two-log-min
switch
ora
anddebug
, ifdebug == true
log =>debug
, else log =>ora
install
npm i two-log-min
cli DEMO
npm i -g two-log-min-cli
Usage
1. cli code
// cli.jsconst twoLog = ;let D = cliflags'D' || false;let l = ; let useWhat = !D ? 'ora' : 'log'; const o1 = ora: 'red' log: 'cli'; const backLog = lstart `hello debug: , then use ` o1; ; const o2 = ora: 'green' log: 'cli'; ; const o3 = ora: 'green' log: 'cli' only: 'log'; ; const o4 = ora: 'fail' log: 'cli'; ;
-
l.start === loggerStart
-
l.text === loggerText
-
l.stop === loggerStop
-
l.one === oneOra
logger
***
use for other module withoutl = twoLog(D)
init
2. doc-templite example
code >>
-
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
log
twoLog(debug, userUser):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') |
api examples
let { let createDebug = apilog; createDebugformatters { return v; };}; let l = ; // …elsewhereconst debug = lstart'something str' log: 'foo' ;;// 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 |
strLog
loggerStart(...args):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 |
example: use strLog
const twoLog = ; let l = ; const strLog = lstart'something str' log: 'foo' ; // here set debug namespace;
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