Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

logstar

Package Overview
Dependencies
Maintainers
3
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

logstar

Simple, opinionated, isomorphic logging.

  • 3.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
decreased by-91.18%
Maintainers
3
Weekly downloads
 
Created
Source

logstar

Travis Status devDependency Status Dependency Status

Simple, opinionated, isomorphic logging.

It uses winston on the server and console.log on the client. It supports multiple arguments. If you have LOGGLY environment variables set, it will auto-configure the winston loggly transport.

Usage

import * as Logstar from 'logstar';

Logstar.debug('foo');
Logstar.info('bar');
Logstar.fatal('error', new Error('error'));

API

class Logger

import { Logger } from 'logstar';
constructor(options = {})

Configure loggly here. Optionally provide a globalMeta object to be attached to each log request.

{
  logLevel: 'info',
  loggly: {
    token: '',
    subdomain: '',
    tags: '',
  },
  globalMeta: {}
}
For JSON-logging, the following rules apply:
  1. If there are exactly 2 arguments passed to the log function, and the second argument is an object, then that object is used as the meta parameter, and the first argument is used as the log message.
  2. If there is exactly 1 argument passed to the log function, and that argument is an object, then that object is used as the meta parameter, with an empty log message.
  3. In all other cases, the first argument is used as the log message, and the subsequent arguments are added as the context property on the meta object.
debug(...args)
debugf(format, ...args)
info(...args)
infof(format, ...args)
warn(...args)
warnf(format, ...args)
error(...args)
errorf(format, ...args)
fatal(...args)
fatalf(format, ...args)

transactionLogger

Get a logger that adds a transaction_id property to the meta. Useful for tracking related requests.

import { transactionLogger } from 'logstar';
const myLogger = transactionLogger('TRANSACTION-ID');

default

Logger pre-configured with loggly parameters from environment variables. (See below)

import Logstar from 'logstar';

Logstar.info('Hello', 12, { foo: 'bar' }, [1, 2, 3], new Error('Hello'));

// This will end up as:
{"level": "info", "message": "Hello", "context": [12, {"foo": "bar"}, [1, 2, 3], "Hello"]}

Configuration

ENV VARIABLES

LOG_LEVEL="debug" # Defaults to info
LOGGLY_SUBDOMAIN="mysubdomain"
LOGGLY_TAGS="api-server,production"
LOGGLY_TOKEN="secret-loggly-token-here"

Keywords

FAQs

Package last updated on 30 Nov 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc