{"id":16224037,"url":"https://github.com/vladmandic/pilogger","last_synced_at":"2025-03-19T12:30:39.863Z","repository":{"id":53151130,"uuid":"260818687","full_name":"vladmandic/pilogger","owner":"vladmandic","description":"Simple Logger for NodeJS","archived":false,"fork":false,"pushed_at":"2024-09-10T14:58:34.000Z","size":158,"stargazers_count":6,"open_issues_count":0,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-07T19:40:47.687Z","etag":null,"topics":["access-log","color-logger","log","logger","logging","nodejs","ring-buffer"],"latest_commit_sha":null,"homepage":"https://github.com/vladmandic/pilogger","language":"TypeScript","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/vladmandic.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-05-03T03:07:43.000Z","updated_at":"2024-09-13T22:10:14.000Z","dependencies_parsed_at":"2024-10-12T00:16:31.604Z","dependency_job_id":null,"html_url":"https://github.com/vladmandic/pilogger","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vladmandic%2Fpilogger","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vladmandic%2Fpilogger/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vladmandic%2Fpilogger/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vladmandic%2Fpilogger/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vladmandic","download_url":"https://codeload.github.com/vladmandic/pilogger/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243989576,"owners_count":20379648,"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":["access-log","color-logger","log","logger","logging","nodejs","ring-buffer"],"created_at":"2024-10-10T12:21:45.746Z","updated_at":"2025-03-19T12:30:39.612Z","avatar_url":"https://github.com/vladmandic.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PiLogger: Simple Logger for NodeJS\n\n## Why\n\nBecause out of all of the existing modules, I couldn't find one that does what I needed and doesn't carry large number of unnecessary dependencies. There are far more complex loggers available, but sometimes all you need is simplicity with specific feature-set.  \nThis module is written in pure ES6 with minimal dependencies.\n\n## Features\n\n- Extremely lightweight\n- Color coding of different log levels for console output\n- Support for console and file logging\n- Prefix messages with timestamp\n- Maintening configurable ring buffer of past messages\n- Automatic expansion of object parameters\n- Automatic concating of multiple parameters\n- All logging functions are asynchronous for non-blocking operations\n\n## Configuration\n\nConfiguration is optional.  \nIf not configured, logging will be to console only and with default format  \nConfiguring inspect options controls how object output is handled  \n\n```js\nconst log = require('pilogger');\nconst options = {\n  options.dateFormat: 'YYYY-MM-DD HH:mm:ss',\n  ringLength: 100,\n  logFile: './application.log',\n  accessFile: './accesss.log',\n  clientFile: './client.log',\n  inspect: {\n    showHidden: true,\n    depth: 5,\n    colors: true,\n    showProxy: true,\n    maxArrayLength: 1024,\n    maxStringLength: 10240,\n    breakLength: 200,\n    compact: 64,\n    sorted: false,\n    getters: true,\n  }\n}\nlog.configure(options);\n```\n\n## Usage\n\nMessages that are printed to console only, useful for debugging\n\n```js\n  log.print(...msg);\n```\n\nMessages that are mirrored to console and `logFile` (if set), each one prefixed and color coded\n\n```js\n  log.blank(...msg);\n  log.data(...msg);\n  log.state(...msg);\n  log.info(...msg);\n  log.warn(...msg);\n  log.error(...msg);\n```\n\nExample output (note that markdown rules strip colored output):\n\n```json\n  2020-08-08 10:36:55 INFO:  piscan version 0.0.1\n  2020-08-08 10:36:55 INFO:  User: root Platform: linux Arch: x64 Node: v14.4.0\n  2020-08-08 10:36:55 STATE: Running as root with full capabilities\n  2020-08-08 10:37:08 DATA:  host: pi ip: 192.168.0.100 time: 12,210\n  2020-08-08 10:37:10 DATA:  mac: DC:A6:32:1B:74:D5 vendor: Raspberry Pi os: Linux 5.4\n  2020-08-08 10:37:12 DATA:  ports: 22,139,445,514,873\n```\n\nMessages that are mirrored to console and `logFile` (if set), each one prefixed and color coded and with time measurement\n\n```js\n  const t0 = process.hrtime.bigint();\n  // do your stuff here\n  log.timed(t0, ...msg);\n```\n\nExample output:\n\n```json\n  2020-08-08 10:39:59 TIMED:  1,004 ms Test function execution\n```\n\nMessages that are output to `accessFile` (if set) only  \nUseful for detailed application access log that you don't want printed to console\n\n```js\n  log.access(...msg);\n```\n\nMessages that are output to `clientFile` (if set) only  \nUseful for logging of any other messages that you don't want printed to console\n\n```js\n  log.client(...msg);\n```\n\nAccess to history ring buffer.  \n`obj.time` is message timestamp, `obj.tag` is message type (info, state, data, warn, error), `obj.msg` is parsed \u0026 concatened message string\n\n```js\n  for (const line in log.ring) {\n    console.log(log.ring[line].time, log.ring[line].tag), log.ring[line].msg);\n  }\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvladmandic%2Fpilogger","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvladmandic%2Fpilogger","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvladmandic%2Fpilogger/lists"}