@atp-autoteile/logger
TypeScript icon, indicating that this package has built-in type declarations

0.0.13 • Public • Published

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/'

Readme

Keywords

none

Package Sidebar

Install

npm i @atp-autoteile/logger

Weekly Downloads

1,386

Version

0.0.13

License

UNLICENSED

Unpacked Size

32.8 kB

Total Files

27

Last publish

Collaborators

  • jannikblume
  • barbara_kellner
  • anehaichik
  • chris.tietz
  • nicolae.visan