npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

tektrans-logger

v1.2.8

Published

Tektrans Logger, a wrapper of Winston logger

Downloads

19

Readme

tektrans-logger

License: MIT NodeJS ESLint Winstonjs Tektrans

Version npm Dependency Status

NPM

A wrapper of winstonjs logger, replacing deprecated logger from KOMODO-SDK.

This logger should be used by TEKTRANS projects. But ofcourse you can use it too.

Table of contents

Features

  • Create multiple transports automatically by default:
  • Not creating DailyRotateFile transport if test environment detected. This is the most reason we need a simple wrapper for winstonjs logger.
  • Ability to change log directory.
  • Ability to change log base filename.
  • Ability to publish to redis channel (implemented using winston-redis) - experimental (v1.2.0)

Future features

  • Circular buffer transport.
  • MySQL transport (planned for v1.3.0).
  • MongoDB transport.

Install

npm i tektrans-logger

Usage

Using tektrans-logger is easy. Just include the module and you can use it with default behaviors.

const logger = require('tektrans-logger');

logger.info('User created', {
    username: 'johndoe',
    fullename: 'John Doe',
    comment: 'who is he?',
});

logger.warn('A warn message', {
    eCode: e.code, eMessage: e.message
});

See here for more examples.

Behaviors

You can override behavior by using environment (process.env) or global variable or by specified in config object. Remember to put those override statement before first call of "require('tektrans-logger')" statement.

Here is the list:

  • TEKTRANS_LOGGER_CONFIG: config object
  • TEKTRANS_LOGGER_LEVEL: minimum log level to dump
    • default: "verbose. "
    • alias: LOGLEVEL
    • config property: config.level
  • TEKTRANS_LOGGER_LABEL: log label
    • default: "" (empty string)
    • alias: KOMODO_LOG_LABEL
    • config property: config.label
  • TEKTRANS_LOGGER_DO_NOT_USING_FILE: set it to any value to make logger without using file transport
    • default: null
  • TEKTRANS_LOGGER_USING_FILE: set it to force using file transport even if it was called from test environtment
    • default: null
  • TEKTRANS_LOGGER_DIRECTORY: directory to put log files
    • default: 'logs' directory on working directory
    • config property: config.directory
  • TEKTRANS_LOGGER_FILENAME: base filename for log file
    • default: 'log'
    • alias: KOMODO_LOG_FILENAME
    • config property: config.filename
  • TEKTRANS_LOGGER_CONSOLE_LEVEL: minimum log level to dump using Console transport
    • default: same as TEKTRANS_LOGGER_LEVEL
    • config property: config.console_level
  • TEKTRANS_LOGGER_FILE_LEVEL: minimum log level to dump using file transport
    • default: same as TEKTRANS_LOGGER_LEVEL
    • config property: config.file_level
  • TEKTRANS_LOGGER_MAX_FILES: maximum number of log files to keep. If not set, no logs will be removed. This can be a number of files or number of days. If using days, add 'd' as the suffix. See DailyRotateFile
    • default: null
    • config property: config.max_files

Config default object

{
  level: 'verbose',
  label: null,

  // default is "logs" directory on current workdir
  directory: path.join(process.cwd(), 'logs'),

  filename: 'log',

  // default is using generic level value
  console_level: null,

  // default is using generic level value
  file_level: null,

  // default is no old file removal
  max_files: null,
}

See examples/using-config.js for usage example of using config object.

Experimental Redis transport

Redis transport can be enabled by putting "redis" property on config object.

This config object will use default options for redis transport:

{
  // ...
  redis: true
}

This will specify some property of redis transport:

{
  // ...
  redis: {
    level: 'verbose',
    host: 'localhost',
    port: 6379,
    auth: null,
    channel: null,
  }
}

Default value of Redis transport

  • level: same as general level value
  • host: 'localhost'
  • port: 6379
  • auth: null, no authentication
  • channel: "TEKTRANS-LOGGER_B707E453_<LOG-LABEL-IN-UPPERCASE_IF-SPECIFIED>,". For example if you specify log label as "xyz", channel will be "TEKTRANS-LOGGER_B707E453_XYZ". If you don't specify log label, channel name will be "TEKTRANS-LOGGER_B707E453".

See examples/redis.js for code example.

Caution

Looks like logger.end() will not wait for all logs to be flushed on redis. Expect for missing some of last logs on redis. Or you can put some delay (like 1-2 seconds) before closing the logger with end method.

Changelog

See CHANGELOG.md.

License

Licensed under MIT License (see this file).

Feel free to use or fork it if you think it would be usefull for you.

Copyright PT. TEKNOLOGI TRANSAKSI DIGITAL (TEKTRANS) 2021.

TEKTRANS