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

@amazebot/logger

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@amazebot/logger

Basic log handling with overrides for use within other modules.

  • 0.1.1
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
3
increased by200%
Maintainers
1
Weekly downloads
 
Created
Source

📓 Logger

Basic log handling with overrides for use within other modules.

When building dependencies of more complex apps, you don't want to be too opinionated about how logs are written, nor add more dependencies that might not play with choices made in the app. However, you also don't want to hard code console.log and end up with multiple output streams.

This package provides standard logging methods for packages requiring it. They route to console.log by default, but apps requiring those packages can pass in their own log utility, to overwrite the default methods (as long as the logger instance is exported).


Import logger in package

import { logger } from '@amazebot/logger'

Provides standard debug/info/warning/error methods

Package re-exports logger

export const pkgLogger = logger

Write your logs in packages

pkgLogger.info(`That's pretty much it.`)

Outputs to console by default, but allows override.

Replace with external logger in app

import { logger } from 'amazing-logger'
import * as myPackage from 'my-package'
myPackage.logger.replace(logger)

Routes to debug/info/warning/error of new interface.

Silence/restore logs before/after tests

import { silence } from '@amazebot/logger'
describe('test methods that log', () => {
  before(() => silence())
  after(() => silence(false))
})

Routes debug/info/warning/error to null output.

Keywords

FAQs

Package last updated on 11 Dec 2018

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