@navigator.menu/plugin-logger
v2.0.1
Published
Configurable logging plugin for Navigator.menu
Maintainers
Readme
@navigator.menu/plugin-logger
Configurable logging plugin for Navigator.menu with multiple log levels and flexible output.
Installation
pnpm add @navigator.menu/plugin-loggerUsage
import { NavigatorCore } from '@navigator.menu/core';
import { LoggerPlugin, LogLevel } from '@navigator.menu/plugin-logger';
const nav = new NavigatorCore();
const logger = new LoggerPlugin({
level: LogLevel.INFO,
prefix: '[MyApp]',
timestamps: true
});
nav.use(logger);
// Log messages
logger.debug('Debug info'); // Won't show (level is INFO)
logger.info('Operation started');
logger.warn('Potential issue');
logger.error('Critical error');
// Change level dynamically
logger.setLevel(LogLevel.DEBUG);Log Levels
LogLevel.DEBUG(0): Detailed debugging informationLogLevel.INFO(1): General informational messagesLogLevel.WARN(2): Warning messagesLogLevel.ERROR(3): Error messagesLogLevel.NONE(4): Disable all logging
Options
level: Minimum log level to display (default:LogLevel.INFO)prefix: Custom prefix for all messages (default:[Navigator])timestamps: Enable ISO timestamps (default:false)
License
MIT
