@atp-autoteile/logger
v0.0.15
Published
Library, created for logging errors using Sentry
Downloads
5,230
Keywords
Readme
ATP_Logger
Library, created for logging errors using Sentry
! IMPORTANT !
Library requires ATP_LOGGER_DSN env variable to log Sentry errors
ATP_LOGGER_ENV is required for specific Sentry environment ('production' by default)
APPLICATIONINSIGHTS_CONNECTION_STRING is required for Azure Application Insights service
run
npm version <version_name>
after every update
USAGE
Logger has 4 levels of logging
debug
info
warn
error
Simply import the Logger and call info
method to log a message:
import { Logger } from '@atp-autoteile/logger'
const logger = new Logger('service name')
logger.info<string>('Info message')
// loggig errors
try {
throw new Error('Your custom message...');
}
catch (err) {
logger.error(err);
}
For CommonJS module:
const { Logger } = require('@atp-autoteile/logger')
const logger = new Logger('service name')
logger.info('Info message')
Set a service name as a parameter for constructor when creating new Logger instance if you want to use custom log message prefix. Default value is 'ATP_Logger'
env parameters example:
ATP_LOGGER_DSN='https://******@sentry.io/12345'
ATP_LOGGER_ENV='staging'
APPLICATIONINSIGHTS_CONNECTION_STRING='InstrumentationKey=******;IngestionEndpoint=https://******.in.applicationinsights.azure.com/;LiveEndpoint=https://eastus.livediagnostics.monitor.azure.com/'