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

klg-logger

Package Overview
Dependencies
Maintainers
2
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

klg-logger

log 工具,基于 tracer,简单,可以显示 log 的位置

  • 2.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
35
decreased by-10.26%
Maintainers
2
Weekly downloads
 
Created
Source

klg-logger

log 工具,基于 tracer,简单,可以显示 log 的位置

配置

见 tracer 文档 https://www.npmjs.com/package/tracer

用法

简单版本

默认版本是把 log 输出到 console

import { Logger } from 'klg-logger'

const logger = new Logger({
  level: config.get('log.level'), 
  dateformat: 'yyyy-mm-dd HH:MM:ss.L',
  inspectOpt: {
    showHidden: false, // if true then the object's non-enumerable properties will be shown too. Defaults to false
    depth: 5 // tells inspect how many times to recurse while formatting the object. This is useful for inspecting large complicated objects. Defaults to 2. To make it recurse indefinitely pass null.
  }
})

logger.info('hello world')
logger.debug('hello %s', 'world')
logger.error('hello %s', 'error')

export default logger

自定义 transport

如果你需要把 log 输出到文件或者发送其他地方,可以自定义 transport function

const logger = new Logger({
  level: 'log',
  transport: function (data: Tracer.LogOutput) {
    // 写文件
    fs.write(data)
    // 发送其他地址
    tcp.send(data)

    assert(data)
    assert(data.level === 0)
  }
})
logger.log('hello world')

Keywords

FAQs

Package last updated on 10 Jul 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