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

logolite

v0.4.0

Published

Lite Virtual Logger and Writer

Downloads

242

Readme

logolite

Lite Virtual Logger and Writer

How to use it?

Create a logger object:

var LogAdapter = require('logolite').LogAdapter;

// connect to a logger instance (winston)
var winston = require('winston');
LogAdapter.connectTo(new winston.Logger({
	transports: [
		new winston.transports.Console({
			level: 'debug',
			json: false,
			timestamp: true,
			colorize: true
		})
	]
}));

/*
// or a bunyan logger instance instead
var bunyan = require('bunyan');
LogAdapter.connectTo(bunyan.createLogger({
	name: 'myApplication',
	level: 'debug'
}));
*/

/*
// or a log4js logger instance
var log4js = require('log4js');
var log4jsLogger = log4js.getLogger();
log4jsLogger.level = 'debug';
LogAdapter.connectTo(log4jsLogger);
*/

// create a logger
var logger = LogAdapter.getLogger();

Create a LogTracer object and put message and loginfo into it:

var LogTracer = require('logolite').LogTracer;

var appTracer = LogTracer.ROOT.branch({
	key: 'appId',
	value: LogTracer.getLogID()
});

// ... your code here ...

// .has() is an alias of .isEnabledFor() method;
// .add() a map (key/value), .put() a single field (key, value)
logger.has('info') && logger.log('info', appTracer
	.add({
		message: 'app level logging message',
		intValue: 123,
		boolValue: true,
		objectData: { key1: 'value 1', key2: 'value 2' },
		strValue: 'simple string'
	})
	.put('singleField', 'put a single key/value')
	.put('anotherField', 1024)
	.toMessage({
		tags: ['FOR_TRACKING_ONLY', 'END_OF_FUNCTION'],
		text: 'Message - integer ${intValue}, str: ${strValue}!'
	}));

// ... your code here ...

// create a child tracer object
var subLevel = appTracer.branch({
	key: 'subLevel',
	value: LogTracer.getLogID()
});

logger.has('debug') && logger.log('debug', subLevel
	.add({
		name: 'Foo',
		percent: 51
	})
	.toMessage({
		text: '${percent}% completed...'
	}));

logger.has('debug') && logger.log('debug', subLevel
	.add({
		name: 'Foo',
		percent: 100
	})
	.toMessage({
		text: '${percent}% completed. The task "${name}" has done.'
	}));

// ... your code here ...

Environment variables

  • LOGOLITE_INSTANCE_ID: (UUID string) predefined instance ID;
  • LOGOLITE_INFO_MESSAGE: (string) Value of message field in libraryInfo logging object (default: "Application Information");
  • LOGOLITE_DEFAULT_SECTOR: (string) default sector name for debug module (default: logolite-default, to display this sector: DEBUG=logolite*,other*);
  • LOGOLITE_ALWAYS_ENABLED: (string) the list of levels that are always enabled (default: none, "all" for all);
  • LOGOLITE_AUTO_DETECT_FOR: ("bunyan"|"winston") detects for default bunyan or winston logging engine (default: none);
  • LOGOLITE_DEBUGLOG_ENABLED: (true/false) forces using debug module to render logging message (default: false);
  • LOGOLITE_DEBUGLOG_GREEDY: (string) the name for debug logging levels is forwarded to console (default: conlog);
  • LOGOLITE_TAGS_EMBEDDABLE: (true/false) enable/disable to embed tags array to output message (default: true);
  • LOGOLITE_TAGS_FIELD_NAME: (string) field name of embedded tags array in output log object (default: "tags");
  • LOGOLITE_TEXT_EMBEDDABLE: (true/false) enable/disable to embed formatted message to output log object (default: true);
  • LOGOLITE_TEXT_FIELD_NAME: (string) field name of formatted message string in output log object (default: "text");
  • LOGOLITE_TEMPLATE_APPLIED: (true/false) enable/disable format logging object by template string (default: true);
  • LOGOLITE_FORMAT_NOT_FOUND_VALUE: (string) value returned when a placeholder in template is not found (default: not_found_value);
  • LOGOLITE_INTERCEPTOR_ENABLED: (true/false) enable/disable interception mode (default: true);
  • LOGOLITE_STRINGIFY_DISABLED: (true/false) turns off stringify logging message when call toMessage() method (default: false);
  • LOGOLITE_STRINGIFY_FAILED_VALUE: (string) value returned when stringify() is failed (default: stringify_failed);
  • LOGOLITE_STRINGIFY_PROTECTED: (true/false) run JSON.stringify() inside try...catch block (default: true);
  • LOGOLITE_BASE64_UUID: (true/false) enable/disable base64 UUID format (default: false);