/* eslint-disable no-console */
import chalk from 'chalk';
export function createLogger(options = {}) {
    const { verbose = false, silent = false, json = false } = options;
    const shouldLog = !silent && !json;
    const shouldDebug = verbose && !silent && !json;
    return {
        log: (color, ...args) => {
            if (shouldLog) {
                const message = args.map((arg) => String(arg)).join(' ');
                // Map color names to chalk functions
                const colorMap = {
                    red: chalk.red,
                    green: chalk.green,
                    blue: chalk.blue,
                    yellow: chalk.yellow,
                    gray: chalk.gray,
                    grey: chalk.gray,
                    cyan: chalk.cyan,
                    magenta: chalk.magenta,
                    white: chalk.white,
                    black: chalk.black,
                };
                const colorFn = colorMap[color];
                const coloredMessage = colorFn ? colorFn(message) : message;
                console.log(coloredMessage);
            }
        },
        info: (...args) => {
            if (shouldLog) {
                const message = args.map((arg) => String(arg)).join(' ');
                console.log(chalk.blue(message));
            }
        },
        success: (...args) => {
            if (shouldLog) {
                const message = args.map((arg) => String(arg)).join(' ');
                console.log(chalk.green(message));
            }
        },
        warning: (...args) => {
            if (shouldLog) {
                const message = args.map((arg) => String(arg)).join(' ');
                console.log(chalk.yellow(message));
            }
        },
        warn: (...args) => {
            // Alias for warning
            if (shouldLog) {
                const message = args.map((arg) => String(arg)).join(' ');
                console.log(chalk.yellow(message));
            }
        },
        error: (...args) => {
            if (!json) {
                const message = args.map((arg) => String(arg)).join(' ');
                console.error(chalk.red(message));
            }
        },
        debug: (...args) => {
            if (shouldDebug) {
                const message = args.map((arg) => String(arg)).join(' ');
                console.log(chalk.gray(message));
            }
        },
        gray: (...args) => {
            if (shouldLog) {
                const message = args.map((arg) => String(arg)).join(' ');
                console.log(chalk.gray(message));
            }
        },
    };
}
/**
 * Create logger from command options
 * Factory function that standardizes logger creation across commands
 *
 * @param options - Command options containing verbose, silent, and json flags
 * @returns Configured logger instance
 */
export function createCommandLogger(options) {
    return createLogger({
        verbose: options.verbose,
        silent: options.silent ?? false,
        json: options.json,
    });
}
//# sourceMappingURL=logger.js.map