Enable/Disable Logging
The ByteHide Logger provides runtime control over logging functionality, allowing you to enable or disable logging dynamically.
Basic Methods
JavaScript
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');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
JavaScript
// Start with logging disabled
Log.configure({
enabled: false,
minimumLevel: 'info',
consoleEnabled: true
});
// Enable later
Log.enable();// Start with logging disabled
Log.configure({
enabled: false,
minimumLevel: 'info',
consoleEnabled: true
});
// Enable later
Log.enable();Status Checking
JavaScript
// Check if logging is currently enabled
if (Log.isEnabled()) {
Log.info('Logging is currently enabled');
}// Check if logging is currently enabled
if (Log.isEnabled()) {
Log.info('Logging is currently enabled');
}Environment-Based Control
JavaScript
const loggingEnabled = process.env.NODE_ENV !== 'production';
if (loggingEnabled) {
Log.enable();
} else {
Log.disable();
}const loggingEnabled = process.env.NODE_ENV !== 'production';
if (loggingEnabled) {
Log.enable();
} else {
Log.disable();
}