import { run, logger } from 'clide-js';
run({ plugins: [logger()] });
import { run, logger } from 'clide-js';
function timestamp() {
return new Date().toISOString();
}
run({
plugins: [
logger({
prefix: timestamp,
logFile: `logs/${timestamp()}.log`,
enabled: process.env.NODE_ENV === 'development',
})
],
});
import { command, disableLogger, enableLogger } from 'clide-js';
export default command({
options: {
v {
description: 'Enable verbose logging',
type: 'boolean',
default: false,
},
},
handler: async ({ options, context }) => {
const verbose = await options.verbose();
if (verbose) {
enableLogger();
} else {
disableLogger();
}
// rest of the command...
},
});
A minimal logger plugin that logs the result of each execution step. By default, it uses the
Client
fromContext
. If alogFile
is provided, it will log to that file instead.The logger can be enabled or disabled at any time by emitting one of the
LoggerHooks
events:enableLogger
: Turns the logger on.disableLogger
: Turns the logger off.toggleLogger
: Toggles the logger on or off.