All Projects → ianstormtaylor → Browser Logger

ianstormtaylor / Browser Logger

Licence: other
A dead simple logger, designed to be perfect for the browser.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Browser Logger

Gf
GoFrame is a modular, powerful, high-performance and enterprise-class application development framework of Golang.
Stars: ✭ 6,501 (+14675%)
Mutual labels:  logging, logger
Simplog
A simple logger. No dependencies, no special features, just logging.
Stars: ✭ 17 (-61.36%)
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 (+1438.64%)
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 (+809.09%)
Mutual labels:  logging, logger
Gollum
An n:m message multiplexer written in Go
Stars: ✭ 883 (+1906.82%)
Mutual labels:  logging, logger
Quill
Asynchronous Low Latency C++ Logging Library
Stars: ✭ 422 (+859.09%)
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 (+1797.73%)
Mutual labels:  logging, logger
Cocoadebug
iOS Debugging Tool 🚀
Stars: ✭ 3,769 (+8465.91%)
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 (-45.45%)
Mutual labels:  logging, logger
Thoth
An Error Logger for Go
Stars: ✭ 22 (-50%)
Mutual labels:  logging, logger
Onelog
Dead simple, super fast, zero allocation and modular logger for Golang
Stars: ✭ 389 (+784.09%)
Mutual labels:  logging, logger
Escriba
📜 Logging on steroids
Stars: ✭ 30 (-31.82%)
Mutual labels:  logging, logger
Monolog
Requirements
Stars: ✭ 19,361 (+43902.27%)
Mutual labels:  logger, logging
Izumi
Productivity-oriented collection of lightweight fancy stuff for Scala toolchain
Stars: ✭ 423 (+861.36%)
Mutual labels:  logging, logger
Laravel Logger
An out the box activity logger for your Laravel or Lumen application. Laravel logger is an activity event logger for your laravel application. It comes out the box with ready to use with dashboard to view your activity. Laravel logger can be added as a middleware or called through a trait. This package is easily configurable and customizable. Supports Laravel 5.3, 5.4, 5.5, 5.6, 5.7, 5.8, 6, and 7+
Stars: ✭ 366 (+731.82%)
Mutual labels:  logging, logger
Logbook
An extensible Java library for HTTP request and response logging
Stars: ✭ 822 (+1768.18%)
Mutual labels:  logging, logger
Caterpillar
Caterpillar is the ultimate logging system for Deno, Node.js, and Web Browsers. Log levels are implemented to the RFC standard. Log entries can be filtered and piped to various streams, including coloured output to the terminal, the browser's console, and debug files. You can even write your own transforms.
Stars: ✭ 330 (+650%)
Mutual labels:  logging, logger
Electron Timber
Pretty logger for Electron apps
Stars: ✭ 337 (+665.91%)
Mutual labels:  logging, logger
Jslogger
Integrate JavaScript Logging with ASP.NET Core Logging APIs
Stars: ✭ 19 (-56.82%)
Mutual labels:  logging, logger
Cartus
A structured logging abstraction with multiple backends.
Stars: ✭ 21 (-52.27%)
Mutual labels:  logging, logger

browser-logger

A dead simple logger, designed to be perfect for the browser.


Features

  • No configuration necessary—with sane defaults based on your NODE_ENV and LOG_LEVEL variables.
  • Makes your logging nice and easy to read in development.
  • Only logs errors by default in production, so user's won't see junk in the console.
  • Leverages the browser's smart, built-in console formatting and stack traces.

Example

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

import logger from 'browser-logger'

logger.info('Websocket connected!', { port: 4000 })
logger.error('Invalid `type` argument', { argument: 'type', value: 'nuber' })

In development, it outputs an easy to read version, using the browser's built-in formatting...

And in production it will only log errors by default, to not confuse users who might open the console.

That's it!


Why?

The default console behavior in most browsers these days has a nice API, with great support for different data types and stack traces. But things get noisey without some control over the "log level".

Unfortunately most of the browser-focused logging libraries aren't great—they're bloated in size, or they use console.log which doesn't add stack traces for errors, or they're overly complex to setup.

I wanted a super-simple logger for the browser, with sane defaults.

That way you can just import 'browser-logger' and not have to worry about configuring things at all.


API

import logger from 'browser-logger'

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

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

LOG_LEVEL

localStorage.setItem('LOG_LEVEL', 'warn')

To change the level of logs that are output, set the Local Storage LOG_LEVEL variable. (Or you can do it via your browser's developer tools UI.)

If you want to completely disable logging, set LOG_LEVEL to 'none'.

new Logger(options)

import { Logger } from 'browser-logger'

const logger = new Logger({
  level: String,     // Defaults to `LOG_LEVEL` if set, or `'info'`.
  prefix: String,    // Defaults to `''`.
})

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:

  • level sets the current log threshold, silencing logs that don't meet it.
  • prefix sets a string that will be prepend to every message.

logger[level](message, data)

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

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

  • trace
  • debug
  • info
  • warn
  • error
  • fatal

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

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

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].