Banana (Logger) is a fun and advanced TypeScript logger with formatting, callback, timing, and highlighting capabilities. Inspired by the simplicity of logging but with a twist of humor, Banana Logger ensures your logging experience is both efficient and enjoyable.
- Formatted Logging: Customizable log messages with tags, details, metadata, and highlights.
- Callbacks: Define custom log handlers to extend functionality.
- Timing: Measure and log the duration of operations.
- Group Logging: Organize logs into groups for better readability.
- Tabular Data Logging: Easily log data in table format.
- Highlighting Keywords: Highlight specific keywords in log messages for better visibility.
- Environment-Specific Logging: Automatically adjust logging levels based on environment (development, staging, production).
npm install banana-logger
import Banana from 'banana-logger';
// Basic configuration
Banana.configure({ tag: 'APP' });
// Simple logging
Banana.info('Application started');
Banana.warn('Warning!', { details: 'Low memory', metadata: 'RAM: 80%' });
Banana.time('operation');
// ... perform operation ...
Banana.timeEnd('operation');
Banana.setLogCallback((level, message, options) => {
// Send log to external service
});
Banana.groupStart('Initialization');
Banana.debug('Loading modules...');
Banana.groupEnd();
Banana.tab([{ name: 'Alice', age: 30 }, { name: 'Bob', age: 25 }]);
Banana.addBlankLine();
Banana.info('This message is after a blank line');
Banana.configure({ highlights: [{ keyword: 'error', style: '31' }] });
Banana.info('This is an error message that should be highlighted');
Banana.configure({ metadata: 'https://example.com' });
Banana.info('This log entry includes clickable metadata');
Banana.reset();
Banana.info('This log entry should not include any global configuration');
configure(options: { tag?: string; details?: string; metadata?: string; highlights?: HighlightConfig[] })
Configure global options for all logs.
Set a callback function for all log messages.
Log a debug message.
Log an info message.
Log a warning message.
Log an error message.
Start a timer with the specified label.
End a timer and log the elapsed time.
Measure the execution time of a function or promise.
Start a new log group.
End the current log group.
Display data in a tabular format.
Add a blank line to the logs.
Apply highlights to specific keywords in the log message.
Check if a given string is a valid URL.
Reset global configurations to their default state.
Contributions are welcome! Please submit a pull request or open an issue on GitHub.
This project is licensed under the MIT License.
Made with β€οΈ by trevonerd and a touch of π.