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

serverlog

v1.1.1

Published

Log utility for the server

Downloads

3

Readme

serverlog

Server file/console log utility.

Installation

npm install --save serverlog

Description

This logger is 99% compatible with the known console api of chrome and firefox.

Supports timers, counters and groups. Also colors.

Twin brother for the browser - browserlog:

https://www.npmjs.com/package/browserlog

https://github.com/newtoncodes/browserlog

Default logger

'use strict';

const Logger = require('../index');

// All options are optional!

let console = new Logger({
    file: __dirname + '/test.txt', // Save file path
    saveLogger: false,             // Save current log to the main logger too
    style: ['blue'],               // List of all styles
    silent: false,                 // Mute console output
    fileDate: true,                // Display date in saved file
    fileTime: true,                // Display time in saved file
    colors: true,                  // Display colors and styles in console
    colorsFull: false,             // If label is set, only it will be colorful
                                   // To make the whole log colorful, set this to true
    consoleDate: false,            // Display date in console output
    consoleTime: true,             // Display time in console output
    consoleStderr: false,          // Use stderr instead of stdout to print errors in console
    label: ''                      // Label to be displayed next to each message
});

console.log('Test.');

Multiple streams

'use strict';

const Logger = require('../index');

let console = new Logger({
    file: __dirname + '/test.txt',
    label: 'APP'
    consoleStderr: false
});

console.add('stream1', {
    file: __dirname + '/test1.txt',
    style: ['blue'],
    label: 'STREAM 1',
    consoleStderr: false
});

console.log('Test default.');
console.stream1.log('Test stream.');

Multiple streams singleton (IntelliSense support)

'use strict';

const Logger = require('../index');
const Stream = Logger.Stream;

let logger = new Logger({
    file: __dirname + '/test.txt',
    consoleStderr: false
});

logger.test1 = new Stream({
    file: __dirname + '/test1.txt',
    style: ['blue'],
    consoleStderr: false,
    label: 'TEST 2'
});

logger.test2 = new Stream({
    file: __dirname + '/test2.txt',
    style: ['green'],
    consoleStderr: false,
    label: 'TEST 2'
});

module.exports = logger;

// Now we import the logger from other files. It can replace console:
const console = require('./LocalLogger.js');

console.log('Test default.');
console.test1.log('Test stream 1.');
console.test2.log('Test stream 2.');

Examples

console.assert(false, 'Test assert #1');

console.write('Test write on single line', '... ');
console.write('D');
console.write('O');
console.write('N');
console.write('E\n');

console.log('MULTI\nLINE\nTEXT\nLOG');

console.group('Group test #1');
console.log('Normal log behavior:', 2, {test: 1});
console.table({test: 1}, 'Some compatibility fns.');
console.debug({test: 1}, 'Some alias fns.');

console.groupCollapsed('Group test #2');
console.assert(false, 'Test assert #2');
console.log('In-group log...', {test: 2});
console.dir({test: 2}, 'Inspect');

// console.clear();
console.groupEnd();

function someFunction() {
    console.trace();
    throw new Error('Test error');
}

function someFunction2() {
    someFunction();
}

try {
    someFunction();
} catch (e) {
    console.error(e);
    console.warn(e);
}

console.groupEnd();

console.info('Info', {test: 1});
console.debug('Debug', {test: 1});
console.error('Error', {test: 1});

console.count('Counter');
console.count('Counter');
console.count('Counter');

console.time('Timer #1');
console.timeEnd('Timer #1');

console.time('Timer #2');
setTimeout(() => {
    console.timeEnd('Timer #2');
}, 1000);