asynclog

logging made easy, useful and scalable

asynclog

Logging made easy, useful and scalable

Build Status NPM Version NPM Download Greenkeeper badge

Features

How to use

npm install --save asynclog
# or, if you are using yarn
yarn add asynclog
const log = require('asynclog')('myApp')

function hello () {
  log('Logging made', 'easy,', 'useful', 'and scalable.')
  log.warn('Not all problems are solved.')
  log.info('And we are actively working to solve them.')
  log.error('Issues:', 'https://github.com/VikramTiwari/asynclog/issues')
  log.trace('Include stacktraces, they make it easier to debug.')
  log.event(0, 'Category', 'Action', 'Label', 0)
}

hello()
ASYNCLOG_NAMESPACE=* node example.js

[Logs Image]

External log providers

# Set ENV variables before running project
LOG_TRANSPORT=google-cloud
GCLOUD_PROJECT=ivikramtiwari # use your project id

Event Tracking

# Set ENV variables before running project
EVENT_TRACKING=google-analytics
GA_TRACKING_ID=UA-20640332-8 # use your tracking id

Error Reporting

# Set ENV variables before running project
ERROR_TRANSPORT=google-cloud
ERROR_TRANSPORT_CONFIG={"projectId":"ivikramtiwari","ignoreEnvironmentCheck":false,"logLevel":2} # replace with your own config

Environment Variables

ENV Variable Possible Value Usage
ASYNCLOG_NAMESPACE * see all logs
  myNamespace log for myNamespace
  -myNamespace don’t log myNamespace
LOG_TRANSPORT google-cloud stream logs to google cloud logging
GCLOUD_PROJECT your-project-id required if google-cloud was selected as LGO_TRANSPORT
EVENT_TRACKING google-analytics stream event to google analytics
GA_TRACKING_ID UA-12345678-9 required if google-analytics was selected as EVENT_TRACKING
ERROR_TRANSPORT google-cloud stream errors to google cloud’s stackdriver error logging
ERROR_TRANSPORT_CONFIG {"projectId":"ivikramtiwari","ignoreEnvironmentCheck":false,"logLevel":2} required if google-cloud was selected as ERROR_TRANSPORT

Credits

Developer: 👨‍💻 Vikram Tiwari

If you found this library helpful, or learned something from it and want to thank me, consider buying me a cup of ☕️.