docs
evals
scenario-1
scenario-10
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
Build a command-line logging utility that intelligently formats output based on the terminal environment, supporting multiple output destinations with platform-specific behavior.
Create a logger that:
Auto-detects terminal capabilities - The logger should automatically determine whether the current environment supports colored output and adjust formatting accordingly.
Supports multiple output modes - The logger must support writing to:
Provides configurable color control - Users should be able to:
Handles platform differences - The implementation should properly detect and handle:
The logger should expose:
/**
* Creates a new logger instance with the specified configuration.
*
* @param {Object} options - Configuration options
* @param {boolean} [options.fileOutput=false] - Whether to write to a log file
* @param {string} [options.filePath='./output.log'] - Path to log file if fileOutput is true
* @param {boolean|null} [options.forceColor=null] - Override color detection: true=force on, false=force off, null=auto-detect
* @returns {Logger} A logger instance
*/
function createLogger(options);
/**
* Logger instance methods
*/
class Logger {
/**
* Logs an informational message in cyan
*/
info(message);
/**
* Logs a success message in green
*/
success(message);
/**
* Logs a warning message in yellow
*/
warning(message);
/**
* Logs an error message in red
*/
error(message);
/**
* Returns whether colors are currently enabled
*/
isColorEnabled();
}forceColor: false disables colors even in color-capable terminals @testforceColor: true enables colors even in non-color terminals @testProvides terminal color formatting support with automatic platform detection.