{"id":13817191,"url":"https://github.com/chinanf-boy/two-log","last_synced_at":"2025-07-24T23:05:35.965Z","repository":{"id":57383007,"uuid":"134929327","full_name":"chinanf-boy/two-log","owner":"chinanf-boy","description":"ora and winston , just two logger, if debug 我只需要两种信息输出方式✅","archived":false,"fork":false,"pushed_at":"2018-08-24T14:40:26.000Z","size":4475,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-06T12:05:22.299Z","etag":null,"topics":["debug","ora","winston"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/chinanf-boy.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"license","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-05-26T04:32:16.000Z","updated_at":"2018-08-24T14:40:17.000Z","dependencies_parsed_at":"2022-09-11T04:10:46.301Z","dependency_job_id":null,"html_url":"https://github.com/chinanf-boy/two-log","commit_stats":null,"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"purl":"pkg:github/chinanf-boy/two-log","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chinanf-boy%2Ftwo-log","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chinanf-boy%2Ftwo-log/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chinanf-boy%2Ftwo-log/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chinanf-boy%2Ftwo-log/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chinanf-boy","download_url":"https://codeload.github.com/chinanf-boy/two-log/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chinanf-boy%2Ftwo-log/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262470420,"owners_count":23316496,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["debug","ora","winston"],"created_at":"2024-08-04T06:00:36.517Z","updated_at":"2025-06-28T17:36:21.651Z","avatar_url":"https://github.com/chinanf-boy.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# two-log [![Build Status](https://travis-ci.org/chinanf-boy/two-log.svg?branch=master)](https://travis-ci.org/chinanf-boy/two-log) [![codecov](https://codecov.io/gh/chinanf-boy/two-log/badge.svg?branch=master)](https://codecov.io/gh/chinanf-boy/two-log?branch=master) [![explain](http://llever.com/explain.svg)](https://github.com/chinanf-boy/two-log-explain)\n\n\u003e switch `ora` and `winston` , if `debug == true` log =\u003e `winston`, else log =\u003e `ora`\n\n## install\n\n```\nnpm i two-log\n```\n\n## cli demo\n\n```\nnpm i -g two-log-cli\n```\n\n\u003cp\u003e\n\u003cimg src=\"./imgs/demo1.gif\" width=\"40%\"\u003e\n\u003cimg src=\"./imgs/demo2.gif\" width=\"40%\"\u003e\n\u003c/p\u003e\n\n- [two-log-cli](https://github.com/chinanf-boy/two-log-cli)\n\n## Usage\n\n```js\n// cli.js\nconst twoLog = require('two-log');\nlet D = cli.flags['D'] ? true : false;\n\nlet l = twoLog(D);\n\nlet useWhat = !D ? 'ora' : 'winston';\n\nl.start(`hello there debug:${D} , then use ${useWhat}`, {\n\tora: 'red',\n\tlog: 'error',\n});\n\nlet t = 5000;\n\nsetTimeout(() =\u003e {\n\tl.text(`ora:green, log:debug and ${t} i will stop `, {\n\t\tora: 'green',\n\t});\n\n\tl.one('just show one time ora');\n}, t - 3000);\n\nsetTimeout(() =\u003e {\n\tl.text(`ora:green, log:debug and ${t} only show log style `, {\n\t\tora: 'green',\n\t\tonly: 'log',\n\t});\n}, t - 2000);\n\nsetTimeout(() =\u003e {\n\tl.stop(`${t}ms , ok i fail if ora `, { ora: 'fail', log: 'debug' });\n}, t);\n```\n\n### l.start === loggerStart\n\n### l.text === loggerText\n\n### l.stop === loggerStop\n\n### l.one === oneOra\n\n\u003e logger`***` use for other module without `l = twoLog(D)` init\n\n---\n\n## API\n\n### twoLog(debug, userUser):log\n\n#### debug\n\n| name: | debug             |\n| ----- | ----------------- |\n| Type: | `boolean`         |\n| Desc: | debug for two log |\n\n#### userUse(api)\n\n| name:    | userUse                        |\n| -------- | ------------------------------ |\n| Type:    | `function(api)`                |\n| Default: | `undefined`                    |\n| Desc:    | reset winston options for user |\n\n##### api\n\n| name:       | api             |\n| ----------- | --------------- |\n| Type:       | `object`        |\n| Desc:       | api for user    |\n| api.log:    | log === winston |\n| api.setLog: | winston options |\n\n\u003cdetails\u003e\n\n\u003csummary\u003e\napi examples\n\u003c/summary\u003e\n\n```js\nlet userUse = api =\u003e {\n\tlet winston = api.log;\n\tlet wopts = {\n\t\tlevel: 'info',\n\t};\n\tapi.setLog(wopts);\n};\n\nlet l = log(true, userUse);\n// winston level change\n```\n\ntwo-log default winston options\n\n```js\nlet defaultWinston = {\n\tlevel: 'debug',\n\ttransports: [\n\t\tnew winston.transports.Console({\n\t\t\tdatePattern: '.yyyy-MM-ddTHH-mm',\n\t\t\tcolorize: true,\n\t\t}),\n\t\tnew winston.transports.File({\n\t\t\tfilename: `${pkg.name}.log`,\n\t\t\thandleExceptions: true,\n\t\t\tmaxsize: 52000,\n\t\t\tmaxFiles: 1,\n\t\t\tlevel: 'info',\n\t\t\tcolorize: true,\n\t\t}),\n\t],\n};\n```\n\n\u003c/details\u003e\n\n---\n\n### log\n\n| name:    | log                     |\n| -------- | ----------------------- |\n| Type:    | `any`                   |\n| Desc:    | log api                 |\n| Default: | `{ start, text, stop }` |\n| Details: | `start === loggerStart` |\n| Details: | `text === loggerText`   |\n| Details: | `stop === loggerStop`   |\n| Details: | `one === oneOra`        |\n\n---\n\n### loggerStart(str, options)\n\n#### str\n\n| name: | str      |\n| ----- | -------- |\n| Type: | `string` |\n| Desc: | log text |\n\n#### options\n\n| name:         | options                                    |\n| ------------- | ------------------------------------------ |\n| Type:         | `any`                                      |\n| Default:      | `{ ora: 'yellow', log: 'debug', only:\"\" }` |\n| Desc:         | log text                                   |\n| options.ora:  | ora color                                  |\n| options.log:  | winston show log level                     |\n| options.only: | only one {'ora' \\| 'log'} can use          |\n\n### loggerText(str, options)\n\n#### str\n\n| name: | str      |\n| ----- | -------- |\n| Type: | `string` |\n| Desc: | log text |\n\n#### options\n\n| name:         | options                                    |\n| ------------- | ------------------------------------------ |\n| Type:         | `any`                                      |\n| Default:      | `{ ora: 'yellow', log: 'debug', only:\"\" }` |\n| Desc:         | log text                                   |\n| options.ora:  | ora color                                  |\n| options.log:  | winston show log level                     |\n| options.only: | only one {'ora' \\| 'log'} can use          |\n\n### loggerStop(str, options)\n\n#### str\n\n| name: | str      |\n| ----- | -------- |\n| Type: | `string` |\n| Desc: | log text |\n\n#### options\n\n| name:         | options                                                                  |\n| ------------- | ------------------------------------------------------------------------ |\n| Type:         | `any`                                                                    |\n| Default:      | `{ ora: '', log: 'debug', only:\"\" }`                                     |\n| Desc:         | log text                                                                 |\n| options.ora:  | ora {`fail\\|succeed\\|warn`} https://github.com/sindresorhus/ora#instance |\n| options.log:  | winston show log level                                                   |\n| options.only: | only one {'ora' \\| 'log'} can use                                        |\n\n### oneOra(str, options)\n\n#### str\n\n| name: | str      |\n| ----- | -------- |\n| Type: | `string` |\n| Desc: | ora text |\n\n#### options\n\n| name:          | options                                                                  |\n| -------------- | ------------------------------------------------------------------------ |\n| Type:          | `any`                                                                    |\n| Default:       | `{ color: 'yellow', end: 'succeed' }`                                    |\n| Desc:          | log text                                                                 |\n| options.end:   | end {`fail\\|succeed\\|warn`} https://github.com/sindresorhus/ora#instance |\n| options.color: | color                                                                    |\n\n---\n\n## use by\n\n- [node-modules-size](https://github.com/chinanf-boy/node-modules-size) show node_modules hole size\n- [doc-templite](https://github.com/chinanf-boy/doc-templite) multi-md-file with templite tool\n\n## License\n\nMIT © [chinanf-boy](http://llever.com)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchinanf-boy%2Ftwo-log","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchinanf-boy%2Ftwo-log","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchinanf-boy%2Ftwo-log/lists"}