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 🙏

© 2025 – Pkg Stats / Ryan Hefner

rocon-logging-tools

v0.1.0

Published

logging toolkit for rocon project

Downloads

0

Readme

Introduction

This logging helpers make it easy to implement the logging required when developing concert software.
The main features are express middleware which generates transactionID, and customized(our flavor) winston transports, and alias functions to use it.

please use exact fixed version before we release v1.0 to prevent unwanted upgrade by npm up command

How to Use (Basic)

installation

# prerequisites
npm install config-extra --save
npm install winston --save
  
# install rocon_logging_tools
npm install rocon-logging-tools --save

Prepare to use

Configuration

Your configuration file should have following fields

# CWD/default.yaml
log:
  file_level: info
  file_options: {} # see options in https://github.com/winstonjs/winston-daily-rotate-file#options
  file_path: ./log

Import into your project

// setting up config-extra may needs
// see www.npmjs.com/package/config-extra
const config = require('config-extra');
const winston = require('winston');
  
const rocon_logging_tools = require('rocon_logging_tools')(winston, config);

functions for logging

Functions for logging

log(level:string, message: string, ?extra: object)
alias(message: string, ?extra: object)
?extra means it's optional field

quick example

const l = rocon_logging_tools.logger;
  
// You can use log() function for 
l.log('debug', 'debug logging message');
  
// If you want, put extra JSON data as third parameter
l.log('error', 'error logging message', {foo: 'bar'});
  
// You can also use alias functions
l.error('failed something', {details: 'i do not know why'});
l.warning('it is a warning message');
  
// In more shorter form
l.w('warning message', {foo: 'bar'});
l.i('informational message');

Log Levels

we are using syslog severity levels
see : RFC 5424

  • debug - for debug
    • alias: d()
  • info - informational
    • alias: i()
  • notice - notification
    • alias: n()
  • warning - warning
    • alias: w()
  • error - error
    • alias: e()
  • crit - critical
    • alias: c()
  • alert - alert
    • alias: a()
  • emerg - emergency
    • alias: em()

Log File Sample

{"level":"info","message":"debug test","timestamp":"2018-02-27T00:52:56.128Z"}
{"foo":"bar","level":"warning","message":"debug test","timestamp":"2018-02-27T00:52:56.126Z"}

express middleware

Warning: Test was poorly done.

  1. parse txid from req header and req.rocon (if not exist, generate)
  2. put txid to res header and res.rocon (if not exist, generate)
const app = require('express');
app.use(rocon_logging_tools.express.gtxid);
app.use(rocon_logging_tools.express.customTxid('mytxid'));

gtxid will saved on req.rocon.gtxid and http header named X-ROCON-gtxid
ltxid will saved on req.rocon.gtxid and http header named X-ROCON-ltxid
blabla will saved on req.rocon.gtxid and http header named X-ROCON-blabla

Utilities

objectId()

create objectId like a MongoDB's

let id = rocon_logging_tools.helper.objectId();

For Advanced User

using options to override configurations

When initialize rocon_logging_tools, there is optional 3rd field

const rocon_logging_tools = require('rocon_logging_tools')(winston, config, options);

options contains following field

  • consoleLevel - overwrite logging.console_level, default is 'debug'
  • fileLevel - overwrite logging.file_level, default is 'info'
  • filePath - overwrite logging.file_path, there is no default, Program will crash
  • transports - overwrite winston transports

Guide For Contributors

How to build

npm run build