New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

node-diagnostics

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-diagnostics

Logging and Timer to perform some basic profiling and diagnostics

  • 0.0.3
  • Source
  • npm
  • Socket score

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

Diagnostic logging and basic profiling using Timers

This module wrap the node.js util.log funciton with some basic level filtering and prefix the message with the process.pid and module name provided.

It also has a Timer functionnality to profile/measure the elapsed time in certain part of your code.

#LICENSE:

This module is licensed under the Apache License v2.0

Installation

npm install node-diagnostics

Include this as a module in your own project

// All diagnostics logs will be prefixed with 'MyModuleName|42|'
var diag = require('node-diagnostics').setPrefix(['MyModuleName',42]).setLevel(3); // info = 3

// Start a timer to display the elapsed time of this section of code.
var timer = diag.startTimer();

// Set the diagnostic level to INFO. Make sure that you reassign the diag
// object with the result of setLevel if you want to be able to use the
// 'diag.level' in you if condition, otherwise it will have the default
// value of 'error'!
diag = diag.setLevel(diag.info);

diag.log(diag.finest, 'Will not be shown, but the string concatenation'
                      + ' will still be done and the method called, it is'
                      + ' slower than the next invocation.');
if (diag.level >= diag.finest) diag.log(diag.finest, 'Will not be shown'
                      + ' but no method invocation and no string concatenation.'
                      + ' this is the prefered way');

if (diag.level >= diag.info)   diag.log(diag.info, 'Will be shown!');
diag.log(diag.info, 'Will be shown!');


diag.log(diag.info, 'test ran in ' + timer.stop().format());

Keywords

FAQs

Package last updated on 28 Apr 2013

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