UNPKG

amaran-light-cli

Version:

Command line tool for controlling Aputure Amaran lights via WebSocket to a local Amaran desktop app.

41 lines 1.3 kB
import chalk from 'chalk'; /** * Returns a formatted ISO timestamp in gray brackets: [2025-10-26T14:30:00.000Z] */ export function getTimestamp() { return chalk.gray(`[${new Date().toISOString()}] `); } let isGlobalTimestampsEnabled = false; /** * Overrides global console.log and console.error to prepend timestamps. */ export function enableGlobalTimestamps() { if (isGlobalTimestampsEnabled) return; const originalLog = console.log; const originalError = console.error; console.log = (...args) => { process.stdout.write(getTimestamp()); originalLog.apply(console, args); }; console.error = (...args) => { process.stderr.write(getTimestamp()); originalError.apply(console, args); }; isGlobalTimestampsEnabled = true; } /** * Logs a message with a timestamp (legacy, now handled by global console). */ export function logWithTimestamp(message, color) { const formattedMsg = color ? color(message) : message; console.log(formattedMsg); } /** * Logs an error message with a timestamp (legacy, now handled by global console). */ export function errorWithTimestamp(message, color) { const formattedMsg = color ? color(message) : message; console.error(formattedMsg); } //# sourceMappingURL=logging.js.map