1.1.6 • Published 2 years ago
gudangjs v1.1.6
GudangJS
A simple and lightweight javascript Log service.
How to get started?
Just import Log class, add some appenders at the start of your application, and then use it freely :)
Log.info('Just saying that everything is going well :)');
Log.warn('Something bad happened, but we handled well with that :D');
Log.error('Hey, something bad happened :/');
Set Global LOG Level :
// Set log level to ERROR (only errors will be logged)
Log.level = LogLevel.ERROR;
Log.debug('This will not be logged');
Log.warn('This will not be logged too');
Log.error('This will be.');
Create custom formatters :
class JhonDoeFormatter implements LogFormatter {
format(line: LogLine): string {
return `Jhon Doe said: '${line.text}' When? At ${line.timestamp.toLocaleDateString()}. It was a ${line.level}.`
}
}
// Don't forget to register the appender!
Log.setAppenders(new ConsoleLogAppender(new JhonDoeFormatter()));
Use Filesystem log appenders :
Log.addAppender(new FileSystemLogAppender('/var/log/my_app_log.log'));
// Create a rotating log on the file system
Log.setAppenders([
new RotatingFileSystemLogAppender('/tmp/', 'system_logs')
]);
Log.error('This will be logged on the file system, in a file called system_logs_YYYY-MM-DD.txt');
Create custom appenders:
class JohnDoeAppender extends AbstractLogAppender {
append(line: LogLine): void {
console.log(`Jhon Doe said: '${line.text}'`);
}
}
// Don't forget to add that to the logger!
Log.addAppender(new JohnDoeAppender());
Use multiple appenders :
Log.setAppenders([
new ConsoleLogAppender(),
new FileSystemLogAppender('/tmp/my_log.txt')
]);
Feel free to request for improvements or open issues for bugs :D
1.1.6
2 years ago
1.1.5
2 years ago
1.1.4
2 years ago
1.1.1
2 years ago
1.1.0
2 years ago
1.1.3
2 years ago
1.1.2
2 years ago
1.0.12
2 years ago
1.0.11
5 years ago
1.0.9
5 years ago
1.0.8
5 years ago
1.0.10
5 years ago
1.0.7
5 years ago
1.0.6
5 years ago
1.0.5
5 years ago
1.0.4
5 years ago
1.0.3
5 years ago
1.0.2
5 years ago
1.0.1
5 years ago
1.0.0
5 years ago