All Projects → ianstormtaylor → Heroku Logger

ianstormtaylor / Heroku Logger

Licence: other
A dead simple logger, designed to be perfect for Heroku apps.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Heroku Logger

Qtwebapp
QtWebApp is a HTTP server like Java servlets, written in C++ with the Qt framework.
Stars: ✭ 50 (-12.28%)
Mutual labels:  logging, logger
Znetcs.aspnetcore.logging.entityframeworkcore
This is Entity Framework Core logger and logger provider. A small package to allow store logs in any data store using Entity Framework Core.
Stars: ✭ 24 (-57.89%)
Mutual labels:  logging, logger
Simplog
A simple logger. No dependencies, no special features, just logging.
Stars: ✭ 17 (-70.18%)
Mutual labels:  logging, logger
G3log
G3log is an asynchronous, "crash safe", logger that is easy to use with default logging sinks or you can add your own. G3log is made with plain C++14 (C++11 support up to release 1.3.2) with no external libraries (except gtest used for unit tests). G3log is made to be cross-platform, currently running on OSX, Windows and several Linux distros. See Readme below for details of usage.
Stars: ✭ 677 (+1087.72%)
Mutual labels:  logging, logger
Loglevelnext
A modern logging library for Node.js that provides log level mapping to the console
Stars: ✭ 33 (-42.11%)
Mutual labels:  logging, logger
Logbook
An extensible Java library for HTTP request and response logging
Stars: ✭ 822 (+1342.11%)
Mutual labels:  logging, logger
Thoth
An Error Logger for Go
Stars: ✭ 22 (-61.4%)
Mutual labels:  logging, logger
Quill
Asynchronous Low Latency C++ Logging Library
Stars: ✭ 422 (+640.35%)
Mutual labels:  logging, logger
Escriba
📜 Logging on steroids
Stars: ✭ 30 (-47.37%)
Mutual labels:  logging, logger
Cartus
A structured logging abstraction with multiple backends.
Stars: ✭ 21 (-63.16%)
Mutual labels:  logging, logger
Serverless Es Logs
A Serverless plugin to transport logs to ElasticSearch
Stars: ✭ 51 (-10.53%)
Mutual labels:  logging, logger
Ios Sdk
AppSpector is a debugging service for mobile apps
Stars: ✭ 56 (-1.75%)
Mutual labels:  logging, logger
Gf
GoFrame is a modular, powerful, high-performance and enterprise-class application development framework of Golang.
Stars: ✭ 6,501 (+11305.26%)
Mutual labels:  logging, logger
Snoopy
Snoopy is a small library that logs all program executions on your Linux/BSD system (a.k.a. Snoopy Logger).
Stars: ✭ 835 (+1364.91%)
Mutual labels:  logging, logger
Izumi
Productivity-oriented collection of lightweight fancy stuff for Scala toolchain
Stars: ✭ 423 (+642.11%)
Mutual labels:  logging, logger
Jslogger
Integrate JavaScript Logging with ASP.NET Core Logging APIs
Stars: ✭ 19 (-66.67%)
Mutual labels:  logging, logger
Onelog
Dead simple, super fast, zero allocation and modular logger for Golang
Stars: ✭ 389 (+582.46%)
Mutual labels:  logging, logger
Concurrency Logger
Log HTTP requests/responses separately, visualize their concurrency and report logs/errors in context of a request.
Stars: ✭ 400 (+601.75%)
Mutual labels:  logging, logger
Gollum
An n:m message multiplexer written in Go
Stars: ✭ 883 (+1449.12%)
Mutual labels:  logging, logger
Browser Logger
A dead simple logger, designed to be perfect for the browser.
Stars: ✭ 44 (-22.81%)
Mutual labels:  logging, logger

heroku-logger

A dead simple logger, designed to be perfect for Heroku apps.


Features

  • No configuration necessary—with sane defaults based on your NODE_ENV and LOG_LEVEL environment variables.
  • Matches Heroku's own logfmt formatting syntax in production.
  • Makes your logging nice and easy to read in development.

Example

Given an API which is what you'd expect...

const logger = require('heroku-logger')

logger.info('Starting server', { port: 4000 })
logger.error('Invalid `type` argument', { argument: 'type', value: 'nuber' })

In development, it outputs an easy to read version...

But in production, it omits the junk, since Heroku handles that for you, and simply outputs the data in logfmt...

In any add-ons attached to your Heroku log drain, the metadata will be picked up automatically...

That's it!


Why?

There are lots of Node.js logging packages—simple ones that basically just print strings to the console, and complex ones like Winston or Bunyan which give you fine-grained control.

But none that were a one-liner for Heroku apps, with sane defaults.

Heroku already handles all of the logging issues that complex libraries solve—timestamping, process-stamping, log draining, performance, etc. So the complex libraries are just extra configuration for no gains.

But the one thing that no logger handled nicely was matching Heroku's logfmt formatting out of the box. By using logfmt for your application logs, you get a consistent output for everything, so any consumers of the Heroku log drains can automatically parse them, because they're in the same format.


API

const logger = require('heroku-logger')

logger.info('message', { key: 'value' })
[info] message key=value level=info message=message

The package exports the one-liner logger singleton as the default, which is already instanciated with sane defaults using the LOG_LEVEL and NODE_ENV environment variables.

new Logger(options)

const Logger = require('heroku-logger').Logger

const logger = new Logger({
  color: Boolean,    // Defaults to `true` only if `NODE=ENV != 'production'`.
  delimiter: String, // Defaults to  `'#'`.
  level: String,     // Defaults to `LOG_LEVEL` if set, or `'info'`.
  prefix: String,    // Defaults to `''`.
  readable: Boolean, // Defaults to `true` only if `NODE=ENV != 'production'`.
})

But if you need to create multiple instances, which can be useful for subclassing loggers based on the parts of your system, the Logger constructor is also exported, which takes the following options:

  • color sets whether to log in colors, for easier scanning.
  • level sets the current log threshold, silencing logs that don't meet it.
  • delimiter sets the delimiter to use for nested data keys.
  • prefix sets a string that will be prepend to every message.
  • readable sets whether to log the message separate from the data.

logger[level](message, data)

logger.info('message', { key: 'value' })
logger.error('error!', { code: 400 })
[info] message key=value level=info message=message
[error] error! code=400 level=error message=error!

Log a message with data to the console at level, where level is one of:

  • debug
  • info
  • warn
  • error

You can also pass an Error object as a message, in which case the logger will automatically convert it into useful message and data with a full stack trace.

logger.log(level, message, data)

logger.log('info', 'message', { key: 'value' })
[info] message key=value level=info message=message

Log a message with data to the console at level.

logger.clone(options)

const other = logger.clone({ prefix: '[package] ' })

other.info('message', { key: 'value' })
[info] [package] message key=value level=info message=message

Create a new Logger instance, copying the existing loggers config, but extending it with optional options.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].