{"id":19206893,"url":"https://github.com/pkoretic/polog","last_synced_at":"2026-04-13T17:32:58.112Z","repository":{"id":144904960,"uuid":"90193365","full_name":"pkoretic/polog","owner":"pkoretic","description":"very fast and simple stdout/stderr logging library","archived":false,"fork":false,"pushed_at":"2018-04-17T07:56:00.000Z","size":32,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-09T04:14:04.801Z","etag":null,"topics":["fast","json","log","nodejs"],"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/pkoretic.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}},"created_at":"2017-05-03T21:05:22.000Z","updated_at":"2022-04-30T10:39:37.000Z","dependencies_parsed_at":null,"dependency_job_id":"6e38a690-fda6-41c6-98bf-47048b0ebfe2","html_url":"https://github.com/pkoretic/polog","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/pkoretic/polog","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pkoretic%2Fpolog","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pkoretic%2Fpolog/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pkoretic%2Fpolog/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pkoretic%2Fpolog/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pkoretic","download_url":"https://codeload.github.com/pkoretic/polog/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pkoretic%2Fpolog/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31762549,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-13T15:25:13.801Z","status":"ssl_error","status_checked_at":"2026-04-13T15:25:09.162Z","response_time":93,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["fast","json","log","nodejs"],"created_at":"2024-11-09T13:17:22.039Z","updated_at":"2026-04-13T17:32:58.097Z","avatar_url":"https://github.com/pkoretic.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\u003cimg src=\"https://github.com/pkoretic/polog/blob/misc/polog.png?raw=true\"/\u003e\u003c/div\u003e\n\n[![GitHub license](https://img.shields.io/github/license/mashape/apistatus.svg)](https://github.com/pkoretic/polog/blob/master/LICENSE)\u003cbr/\u003e\n[![NPM](https://nodei.co/npm/polog.png?downloads=true\u0026downloadRank=true\u0026stars=true)](https://www.npmjs.com/package/polog)\n\n`polog` is one of the [fastest](benchmarks) and simplest Node.js logging libraries that behaves as the\nstandard `console` command. It has no dependencies and adds minor features as timestamp, log levels\nand json as opt-in. This library uses as little processing power as possible to avoid affecting\nNode.js event loop.\n\nLogging (in Node.js) should always use stdout/stderr and leave advanced logging manipulation to the\nrest of the stack. For best performance and asynchronous operation you should use pipes on Linux as\nmentioned in [official docs](https://nodejs.org/api/process.html#process_a_note_on_process_i_o).\nThis also enables you to do file logging as efficiently as possible.\n\n`console` uses process.stdout.write which has the same behaviour as this library.\n\n## Installation\n\n```\nnpm install polog\n```\n\n## Options\n\nOptions can be passed as object before creation.\n\n**debug** - `true/false` - enable output of `.debug` function, if set to `false` (default) it won't print anything\n\n```\nconst log = require(\"polog\")({ debug: true })\nlog.debug(\"will be shown\")\n```\n\n**format** - `true/false` - enable usage of util.format, ie:\n\n```\nconst log = require(\"polog\")({ format: true })\nlog.info(\"test: %d\", Math.random())\n```\n\nif set to `false` (default), which is faster, use ES6 template strings\n\n```\nlog.info(`test: ${Math.random()}`)\n```\n\n**prefix** - `function` - prefix messages with custom output, default is `Date.now`\n```\nconst log = require(\"../index.js\")({ prefix: () =\u003e { return (new Date).toISOString() }})\n```\n\nKeep in mind that this is also called on every message output, so you want to keep it as simple as\npossible.\n\n**json** - `true/false` - use json array format, defaults to `false`\n```\nconst log = require(\"polog\")({ json: true })\nlog.info(\"json\")\n```\n\n## Levels and properties\n\nThere are four standard levels:\n\n**info** `I` - standard `stdout` output\n\n**debug** `D` - debug `stdout` output, depens on `debug` options, useful for (NON)PRODUCTION\nenvironment switching\n\n**warn** `W` - `stderr` warnings output\n\n**error** `E` - `stderr` error output\n\nCurrently there is no way to add new levels, if that is wanted, please open an issue.\n\n**debugMode** - `true/false` contains information if debug level is enabled or not\n\n**enableDebug()** - enable debug - same as `debug: true` option at creation time\n\n**disableDebug()** - disable debug - same as `debug: false (default)` option at creation time\n\n## Standard logging\n\n```\nconst log = require(\"polog\")({ debug: true })\n\nlog.debug(\"debug mode\") // shown only when debug is set to true above\nlog.info(\"hello there!\")\nlog.warn(\"be careful\")\nlog.error(\"not good\")\n```\n\nThis will output:\n\n```\n1494005876469 D debug mode\n1494005876469 I hello there!\n1494005876470 W be careful\n1494005876470 E not good\n```\n\nUsing `format` option:\n\n```\nconst log = require(\"polog\")({ format: true })\n\nlog.info(\"test message: %d\", Math.random())\n```\noutputs:\n\n```\n// # 1494006079148 I test message: 0.17100814691155053\n```\nThis calls [util.format](https://nodejs.org/api/util.html#util_util_format_format_args) that is also\nused by `console.*` functions. It is slower since every message has to be processed first. It is\nrecommended to use ES6 template string instead:\n\n```\nconst log = require(\"polog\")()\n\nlog.info(`test message: ${Math.random()}`)\n````\n\nChanging `prefix`:\n\n```\nconst log = require(\"../index.js\")({ prefix: () =\u003e { return (new Date).toISOString() }})\n\nlog.info(\"test message\")\n```\n\noutputs:\n```\n2017-05-05T17:53:05.702Z I test message\n```\n\nThis is probably more user friendly, although default `Date.now` is faster since Date object doesn't\nhave to be created for every function call.\n\nUsing `json`:\n\n```\nconst log = require(\"../index.js\")({ json: true })\n\nlog.info(\"test message\")\n```\n\noutputs:\n```\n[1494153657008,\"I\",\"json!\"]\n```\n\n## Fast file logging on Linux\n\nRedirect (pipe) all logs to a file [asynchronously](https://nodejs.org/api/process.html#process_a_note_on_process_i_o)\n\n```\nnode app.js \u003e app.log 2\u003e\u00261\n```\n\nSplit standard and error logs\n\n```\nnode app.js \u003e access.log 2\u003eerror.log\n```\n\n## Disabling logs\n\nSometimes it might be useful to disable logging library from the outside, like when testing. This\ncan be done setting `NOLOG` env variable to `true`.\n\n```\nNOLOG=true node examples/format.js\n```\n\nIn this case no logs are shown.\n\n## [Benchmarks](benchmarks)\n\nThis should be the fastest logging library for Node.js as far as we know. [Test](benchmarks) it\nyourself and provide feedback.\n\n## Support\n\n * Issues - [open new issue](https://github.com/pkoretic/polog/issues)\n * mail - petar.koretic@gmail.com\n * IRC - `pkoretic` on freenode\n\n## Changelog\n\n**1.1.0** Adds `json` support.\n\n**1.0.0** Initial release\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpkoretic%2Fpolog","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpkoretic%2Fpolog","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpkoretic%2Fpolog/lists"}