LoggerInstance.setTimestamps
Enable or disable timestamps for this specific logger instance.
Syntax​
setTimestamps(enabled: boolean): void
Parameters​
enabled (required)​
Whether to include timestamps in log entries for this instance.
true: Include ISO timestamps in log entriesfalse: Exclude timestamps from log entries
Type: boolean
Examples​
Basic Usage​
const appLogger = logger.createInstance('app');
// Enable timestamps for this instance
appLogger.setTimestamps(true);
// Disable timestamps for this instance
appLogger.setTimestamps(false);
Per-Instance Configuration​
const logger = InteractiveLogger({
timestamps: false // Global setting: no timestamps
});
// Override for specific instances
const appLogger = logger.createInstance('app');
appLogger.setTimestamps(true); // This instance will have timestamps
const apiLogger = logger.createInstance('api');
// This instance will not have timestamps (uses global setting)
Notes​
- This setting overrides the global timestamp setting for this instance
- Timestamps are in ISO format:
2024-01-15T10:30:00.000Z - This is instance-specific and doesn't affect other logger instances
- Timestamps are added when the log is written, not when the method is called
See Also​
- setTimestamps - Set timestamps globally
- LoggerInstance.writeLog - Write logs to this instance