@jalik/logger
Advanced tools
Comparing version 2.0.0 to 2.0.1
# Changelog | ||
## v2.0.1 | ||
- Fixes example of `Logger.on(String, Function)` in README | ||
## v2.0.0 | ||
@@ -4,0 +7,0 @@ - **BREAKING:** Method `Logger.on(String, Function)` has changed to improve ease of use. Before you had to pass |
{ | ||
"name": "@jalik/logger", | ||
"version": "2.0.0", | ||
"version": "2.0.1", | ||
"description": "A logging utility to log messages to anywhere.", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -78,14 +78,18 @@ # Logger | ||
logger.error('Forbidden', {error: new Error('forbidden')}); | ||
// You can directly pass an Error object | ||
logger.error(new Error('forbidden')); | ||
// Logs an info message | ||
logger.info('Application started', {date: new Date()}); | ||
logger.info('Application started', { | ||
date: new Date() | ||
}); | ||
// Logs a warning message | ||
logger.warn('Disk usage is above 90%', {diskUsage: 92.6}); | ||
logger.warn('Disk usage is above 90%', { | ||
diskUsage: 92.6 | ||
}); | ||
// Logs a custom type message | ||
const ipAddress = '6.6.6.6'; | ||
logger.log(`The IP address ${ipAddress} has failed to login 3 times in one minute`, 'suspicious', | ||
{ipAddress}); | ||
logger.log(`The IP address ${ipAddress} has failed to login 3 times`, 'suspicious', {ipAddress}); | ||
``` | ||
@@ -120,9 +124,13 @@ | ||
// With this event listener, you can do something when an error happens | ||
logger.on(Types.error, (message, context) => { | ||
logger.on('log', (message, type, context) => { | ||
if (type === Types.error) { | ||
// do whatever you want here... | ||
// save error to database, send an email... | ||
} | ||
}); | ||
// This will trigger the listener defined above | ||
logger.error('Cannot contact DNS server', {ipAddress: '8.8.8.8'}); | ||
logger.error('Cannot contact DNS server', { | ||
ipAddress: '8.8.8.8' | ||
}); | ||
``` | ||
@@ -129,0 +137,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
33755
147