Enable/Disable Logging
The ByteHide Logger provides runtime control over logging functionality, allowing you to enable or disable logging dynamically.
Basic Methods
import { Log } from '@bytehide/logger';
// Enable logging
Log.enable();
Log.info('This message will be logged');
// Disable logging
Log.disable();
Log.info('This message will NOT be logged');
// Re-enable logging
Log.enable();
Log.info('This message will be logged again');
Configuration Control
// Start with logging disabled
Log.configure({
enabled: false,
minimumLevel: 'info',
consoleEnabled: true
});
// Enable later
Log.enable();
Status Checking
// Check if logging is currently enabled
if (Log.isEnabled()) {
Log.info('Logging is currently enabled');
}
Environment-Based Control
const loggingEnabled = process.env.NODE_ENV !== 'production';
if (loggingEnabled) {
Log.enable();
} else {
Log.disable();
}