/*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
import { cyan, gray, green, magenta, red, yellow } from "./colors.js";
import { print } from "./print.js";
import { spinStart, spinStop } from "./spinner.js";
//#region ../css/dist/packages/cli/dist/lib/logger.mjs
/*! © 2026 Yahoo, Inc. UDS CSS v0.0.0-development */
/*! © 2026 Yahoo, Inc. UDS CLI v0.0.0-development */
/**
* Logger utility for CLI commands.
* Centralizes logging behavior with support for silent mode.
*/
/**
* Create a logger instance with optional silent mode.
* When silent, all logging methods become no-ops.
*/
function createLogger(options = {}) {
	const isSilent = options.silent ?? false;
	return {
		/** Whether the logger is in silent mode */
		isSilent,
		/** Print a message (respects silent mode) */
		print: (message) => {
			if (!isSilent) print(message);
		},
		/** Print without silent check (for errors that should always show) */
		printAlways: (message) => {
			print(message);
		},
		/** Start a spinner with message */
		spinStart: (message) => {
			if (!isSilent) spinStart(message);
		},
		/** Stop spinner with icon and message */
		spinStop: (icon, message) => {
			if (!isSilent) spinStop(icon, message);
		},
		/** Log success message */
		success: (message) => {
			if (!isSilent) print(green(`✅ ${message}`));
		},
		/** Log warning message */
		warn: (message) => {
			if (!isSilent) print(yellow(`⚠️  ${message}`));
		},
		/** Log error message (always shows, even in silent mode) */
		error: (message) => {
			print(red(`❌ ${message}`));
		},
		/** Log info message */
		info: (message) => {
			if (!isSilent) print(cyan(message));
		},
		/** Log a labeled value */
		label: (label, value) => {
			if (!isSilent) print(`${magenta(label)} ${cyan(value)}`);
		},
		/** Log a list item */
		listItem: (text) => {
			if (!isSilent) print(`   ${gray("•")} ${text}`);
		},
		/** Log a timestamped message */
		timestamp: (message, color = "green") => {
			if (isSilent) return;
			const time = (/* @__PURE__ */ new Date()).toLocaleTimeString();
			const colorFn = color === "green" ? green : color === "yellow" ? yellow : red;
			print(`${gray(`[${time}]`)} ${colorFn(message)}`);
		},
		/** Log an empty line */
		newline: () => {
			if (!isSilent) print("");
		},
		/** Create a child logger (inherits silent mode) */
		child: (childOptions = {}) => {
			return createLogger({ silent: childOptions.silent ?? isSilent });
		}
	};
}
//#endregion
export { createLogger };
