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

@deinstapel/tldr

Package Overview
Dependencies
Maintainers
2
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@deinstapel/tldr

TypeScript Logging Library

  • 1.1.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
2
Weekly downloads
 
Created
Source

TLDR - Typescript Logging Done Right

Introduction

TLDR is a logging library driven by and designed for TypeScript. It follows the design and functionality of logrus. TLDR implements structured logging, which means that you can pass structured contexts into the library and evaluate them using a LMS lateron.

Usage Example

The example below is intended to be run in node, if you'd like to run it in the browser change NodeConsoleBackend to BrowserConsoleBackend.

/**
 * First of all, import all required classes and variables.
 * You need to import the logger as well as at least one backend.
 */
import { NodeConsoleBackend, Logger } from '@deinstapel/tldr';

/**
 * ConfigureInstance should be called **exactly** once.
 * Without configureInstance, all log messages will be dropped.
 * You might add global metadata here, for example your apps version
 * or a unique session ID for a specific app startup
 */
Logger.configureInstance({
  globalContext: { session: Math.round(Math.random() * 10000000) },
  backends: [new NodeConsoleBackend({
    color: true,
    formatting: 'human', // Can also be JSON
  })],
});

/**
 * Create a child logger with fields and log an info message
 */
Logger.withFields({
  var: 'foo',
  var2: 'bar',
  answer: 42,
}).info('hello, world');

/**
 * Annotate a single field and log a message with custom log level
 */
Logger.withField('answer', 42).log('customlevel', 'custom message')

Keywords

FAQs

Package last updated on 17 Mar 2021

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