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

two-log-min

v1.0.12

Published

ora and debug , just two logger, if debug

Downloads

29

Readme

two-log-min Build Status codecov explain

switch ora and debug , if debug == true log => debug, else log => ora

中文

install

npm i two-log-min

cli DEMO

npm i -g two-log-min-cli

Usage

// cli.js
const twoLog = require('two-log-min');
let D = cli.flags['D'] || false;
let l = twoLog(D);

let useWhat = !D ? 'ora' : 'log';

const o1 = {
	ora: 'red',
	log: 'cli',
};

const backLog = l.start(
	`hello debug:${D} , then use ${c(useWhat)} ${m(toS(o1))}`,
	o1
);

setTimeout(() => {
	backLog(`use backLog ${c('withou log namespace')}`);
}, t - 5000);

const o2 = {
	ora: 'green',
	log: 'cli',
};

setTimeout(() => {
	l.text(`ora:green, log:cli`, o2);

	l.one('one time ora');
}, t - 3000);

const o3 = {
	ora: 'green',
	log: 'cli',
	only: 'log',
};

setTimeout(() => {
	l.text(`ora:green, only show log`, o3);
}, t - 2000);

const o4 = {
	ora: 'fail',
	log: 'cli',
};

setTimeout(() => {
	l.stop(`i fail if ora `, o4);
}, t);
  • l.start === loggerStart

  • l.text === loggerText

  • l.stop === loggerStop

  • l.one === oneOra

logger*** use for other module without l = twoLog(D) init

2. doc-templite example

  • cli log with https://github.com/chinanf-boy/doc-templite/blob/master/cli.js#L51

  • main log with https://github.com/chinanf-boy/doc-templite/blob/master/doc-templite.js#L55

  • more start log 👆, only one stop https://github.com/chinanf-boy/doc-templite/blob/master/cli.js#L112


API

twoLog(debug, userUser):log

debug

| name: | debug | | ----- | ----------------- | | Type: | boolean | | Desc: | debug for two log |

userUse(api)

| name: | userUse | | -------- | ---------------------------- | | Type: | function(api) | | Default: | undefined | | Desc: | reset debug options for user |

api

| name: | api | | -------- | ---------------------- | | Type: | object | | Desc: | api for user | | api.log: | log = require('debug') | | api.ora: | ora = require('ora') |

let userUse = api => {
	let createDebug = api.log;
	createDebug.formatters.h = v => {
		return v.toString('hex');
	};
};

let l = twoLog(true, userUse);

// …elsewhere
const debug = l.start('something str', { log: 'foo' });
debug('this is hex: %h', new Buffer('hello world'));
//   foo this is hex: 68656c6c6f20776f726c6421 +0ms

log

| name: | log | | -------- | -------------------------------------------------- | | Type: | any | | Desc: | log api | | Default: | { start, text, stop, one } | | Details: | start === [loggerStart](#loggerstartstr-options) | | Details: | text === [loggerText](#loggertextstr-options) | | Details: | stop === [loggerStop](#loggerstopstr-options) | | Details: | one === oneOra |


loggerStart(...args):strLog

str

| name: | str | | -------------------- | ------------------------------------------------------------ | | Type: | string | | Desc: | start log | | Expand by ...args: | start('one','two',opts) , one +/% formatter two will log |

options

| name: | options | | ------------- | ------------------------------------------- | | Type: | any | | Default: | { ora: 'yellow', log:pkgName, only:"" } | | Desc: | log text | | options.ora: | ora color | | options.log: | debug show log level | | options.only: | only one {'ora' | 'log'} can use |

pkgName is the most closest package.json name

strLog(...args)

| name: | strLog | | ----- | -------------------------------------------- | | Type: | Function | | Desc: | can use debug without namespace, may ora |

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

let l = twoLog(true);

const strLog = l.start('something str', { log: 'foo' }); // here set debug namespace
strLog('this is just like debug');

code >>>

loggerText(...args)

str

| name: | str | | -------------------- | ----------------------------------------------------------- | | Type: | string | | Desc: | log text | | Expand by ...args: | text('one','two',opts) , one +/% formatter two will log |

options

| name: | options | | ------------- | ------------------------------------------ | | Type: | any | | Default: | { ora: 'yellow', log: pkgName, only:"" } | | Desc: | log text | | options.ora: | ora color | | options.log: | debug show log level | | options.only: | only one {'ora' | 'log'} can use |

pkgName is the most closest package.json name

loggerStop(...args)

str

| name: | str | | -------------------- | ----------------------------------------------------------- | | Type: | string | | Desc: | log text | | Expand by ...args: | stop('one','two',opts) , one +/% formatter two will log |

options

| name: | options | | ------------- | ------------------------------------------------------------------------ | | Type: | any | | Default: | { ora: '', log: pkgName, only:"" } | | Desc: | log text | | options.ora: | ora {fail\|succeed\|warn} https://github.com/sindresorhus/ora#instance | | options.log: | debug show log level | | options.only: | only one {'ora' | 'log'} can use |

oneOra(...args)

str

| name: | str | | -------------------- | ---------------------------------------------------------- | | Type: | string | | Desc: | ora text | | Expand by ...args: | one('one','two',opts) , one +/% formatter two will log |

options

| name: | options | | -------------- | ------------------------------------------------------------------------ | | Type: | any | | Default: | { color: 'yellow', end: 'succeed' } | | Desc: | log text | | options.end: | end {fail\|succeed\|warn} https://github.com/sindresorhus/ora#instance | | options.color: | color for ota |


concat

  • two-log just need two log, ora / winston

License

MIT © chinanf-boy