{"id":27399635,"url":"https://github.com/march-mitsuki/white-logger","last_synced_at":"2026-04-29T22:34:05.114Z","repository":{"id":64779706,"uuid":"577523892","full_name":"March-mitsuki/white-logger","owner":"March-mitsuki","description":"a very simple node and browser logger with only one dependency","archived":false,"fork":false,"pushed_at":"2023-08-07T19:51:12.000Z","size":1388,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-14T13:59:21.461Z","etag":null,"topics":["browser","esm","javascript","logger","logging","nodejs","typescript"],"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/March-mitsuki.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2022-12-12T23:34:46.000Z","updated_at":"2023-05-20T22:02:26.000Z","dependencies_parsed_at":"2025-04-15T22:31:11.562Z","dependency_job_id":null,"html_url":"https://github.com/March-mitsuki/white-logger","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/March-mitsuki/white-logger","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/March-mitsuki%2Fwhite-logger","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/March-mitsuki%2Fwhite-logger/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/March-mitsuki%2Fwhite-logger/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/March-mitsuki%2Fwhite-logger/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/March-mitsuki","download_url":"https://codeload.github.com/March-mitsuki/white-logger/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/March-mitsuki%2Fwhite-logger/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271103202,"owners_count":24699646,"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","status":"online","status_checked_at":"2025-08-19T02:00:09.176Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["browser","esm","javascript","logger","logging","nodejs","typescript"],"created_at":"2025-04-14T03:20:09.937Z","updated_at":"2026-04-29T22:34:05.065Z","avatar_url":"https://github.com/March-mitsuki.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# white-logger\n\nA very simple nodejs and browser logger with only one dependency.\n\nwhite-logger is now released in statable version 1.0.0\n\nAnd there is a BREAKING CHANGE, please see [this document](./docs/nodelogger/migrate.md) for details.\n\n# feature\n\n- Only one dependency. Use [Luxon](https://moment.github.io/luxon/#/) for dealing with dates and times.\n- Pretty print.\n- Native TypeScript.\n- Circular safe.\n\n# install\n\n```bash\nnpm i white-logger\n```\n\n# useage\n\n## nodejs\n\n### use typescript or ESM\n\n```typescript\nimport { nodelogger as logger } from \"white-logger/node\";\n\nlogger.normal(\"normal-level\", \"normal reported.\");\nlogger.info(\"info here\", \"something reported.\", {\n  hello: \"world\",\n});\nlogger.warn(\"notice\", \"something warnning.\", [\"foo\", \"baz\"]);\nlogger.err(\"oops!\", \"something error!\");\n```\n\nYou will get like this in your console.\n\n![log preview img](docs/assets/console_preview.png)\n\nBy default, white-logger will automatically tracks all calls and print them. Easy to find out the problem, right?\n\nAnd white-logger can also automatically output logs to a file. If you want to do this, please configure some setting like this.\n\n```typescript\nimport { nodelogger as logger, configLogger } from \"white-logger/node\";\nimport path from \"path\";\n\n// By setting the logPath option, white-logger will write the log to files automatically.\nconfigLogger({\n  logPath: path.resolve(process.cwd(), \"logs\"),\n});\n\n// Will be written to \u003cproject_root\u003e/logs/\u003ctimestamp\u003e_info.log\nlogger.info(\"some-info\", \"something reported.\");\n```\n\n**Depending on the level, the logs will be written to different files.**\n\n- `logger.normal` will write to `\u003ctimestamp\u003e_normal.log`\n- `logger.info` will write to `\u003ctimestamp\u003e_info.log`\n- `logger.warn` will write to `\u003ctimestamp\u003e_warn.log`\n- `logger.err` will write to `\u003ctimestamp\u003e_err.log`\n\nTimestamp will change from day to day. So, the logs are output to a different file each day.\n\nYou can also only pass a relative path, white-logger will resolve it to your project root directory automatically.\n\n```typescript\nconfigNodeLogger({\n  // Same as above, logs will write to \u003cproject_root_dir\u003e/logs\n  logPath: \"logs\",\n});\n```\n\nIf you config a file output, you will get something like this.\n\n![file output preview](./docs/assets/fileoutput_preview.png)\n\nIf you don't want auto-tracking to fill up your entire console, you can also turn it off when in development mode.\n\n```ts\nconfigNodeLogger({\n  // This will only work on development mode.\n  // In production mode, The trace is forced to be output.\n  trace: false,\n});\n```\n\n### use CommonJS\n\n```javascript\nconst { nodelogger } = require(\"white-logger/node\");\n\nnodelogger.normal(\"normal-level\", \"normal reported.\");\n```\n\nYou can also import with a name of your choice.\n\n```javascript\nconst mylogger = require(\"white-logger/node\").nodelogger;\n\nmylogger.normal(\"normal-level\", \"normal reported.\");\n```\n\n---\n\n## browser\n\nYou can use white-logger in any framework. Like vue or react.\n\n```javascript\n// Please note that the esm module is in esm directory.\nimport { browserlogger as logger } from \"white-logger/esm/browser\";\n\nlogger.normal(\"normal-level\", \"normal reported.\");\nlogger.info(\"info here\", \"something reported.\", {\n  hello: \"world\",\n});\nlogger.warn(\"notice\", \"something warnning.\", [\"foo\", \"baz\"]);\nlogger.err(\"oops!\", \"something error!\");\n```\n\nOpen your console and you can see the results.\n\n![browser preview img](docs/assets/browser_preview.png)\n\nYou can use `configBrowserLogger` function to configure your browser logger.\n\n```typescript\nimport { configBrowserLogger } from \"white-logger/esm/browser\";\n\nconfigBrowserLogger({\n  mode: \"production\",\n  targetUrl: undefined,\n  storagePrefix: undefined,\n});\n```\n\nBy default, browser logger running in development mode.\n\n- In development mode, browser logger will print log to console.\n- In production mode, will _NOT_ print to console, but will do diffrently depending on the `targetUrl` or `storage` config.\n  - If targetUrl defined, browser logger will post log to given url by use fetch api.\n  - If storage defined, browser logger will save log into localStorage with given prefix string.\n  - For more information, please see [this document](docs/browserlogger/index.md).\n\n# configuration\n\n## node logger\n\n```typescript\nexport type NodeLoggerConfig = {\n  logPath?: string; // full or relative path to your logs directory\n  logDateFmt: string; // Luxon format string\n  filenameDateFmt: string; // Luxon format string\n  trace?: boolean;\n};\n\n// default value\nlet __config__: NodeLoggerConfig = {\n  logPath: undefined,\n  logDateFmt: \"yyyy'-'LL'-'dd HH':'mm':'ss Z\",\n  filenameDateFmt: \"yyyy'-'LL'-'dd\",\n  trace: true,\n};\n```\n\nAbout Luxon format string, please see [this Luxon document](https://moment.github.io/luxon/#/formatting?id=table-of-tokens)\n\n- `logPath`: The path of directory that white-logger will write log to.\n- `logDateFmt`: The format of the date being printed to the console.\n- `filenameDateFmt`: The format of the date before being inserted into the output file.\n- For more infomation please see [nodelogger document](docs/nodelogger/index.md)\n\n## browser logger\n\n```typescript\nexport type BrowserLoggerConfig = {\n  mode: \"development\" | \"production\"; // browser logger mode\n  logDateFmt: string; // luxon date format string\n  targetUrl?: string; // fetch post url\n  storagePrefix?: string; // localStorage item key prefix\n  trace?: boolean;\n};\n\n// default value\nlet __config__: BrowserLoggerConfig = {\n  mode: \"development\",\n  logDateFmt: \"yyyy'-'LL'-'dd HH':'mm':'ss Z\",\n  targetUrl: undefined,\n  storagePrefix: undefined,\n  trace: true\n};\n```\n\nAbout Luxon format string, please see [this Luxon document](https://moment.github.io/luxon/#/formatting?id=table-of-tokens)\n\n- `mode`: browser logger mode. For more information on the differences between the two modes of blogger please see [this document](docs/browserlogger/index.md#mode).\n- `logDateFmt`: The format of the date being printed to the console.\n- `targetUrl`: Post url in production mode.\n- `storagePrefix`: localStorage prefix in production mode.\n- For more information, please see [this document](docs/browserlogger/index.md)\n\n# Why is it call White logger?\n\n\u003e \"Any color you want, so long as it is Black.\"\n\nSo, White logger.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarch-mitsuki%2Fwhite-logger","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarch-mitsuki%2Fwhite-logger","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarch-mitsuki%2Fwhite-logger/lists"}