{"id":23712544,"url":"https://github.com/luckydye/log","last_synced_at":"2026-02-08T08:30:20.293Z","repository":{"id":220813060,"uuid":"752657713","full_name":"luckydye/log","owner":"luckydye","description":"Practical logging for JavaScript applications.","archived":false,"fork":false,"pushed_at":"2024-12-28T14:34:31.000Z","size":72,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-12-28T15:26:06.419Z","etag":null,"topics":[],"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/luckydye.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":"2024-02-04T12:58:01.000Z","updated_at":"2024-12-28T14:34:36.000Z","dependencies_parsed_at":"2024-02-07T20:28:30.868Z","dependency_job_id":"259ff45f-793b-4e1c-9cf7-5ab0a939ab0b","html_url":"https://github.com/luckydye/log","commit_stats":null,"previous_names":["luckydye/logging"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luckydye%2Flog","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luckydye%2Flog/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luckydye%2Flog/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luckydye%2Flog/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/luckydye","download_url":"https://codeload.github.com/luckydye/log/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239800489,"owners_count":19699127,"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":[],"created_at":"2024-12-30T19:59:24.821Z","updated_at":"2026-02-08T08:30:19.308Z","avatar_url":"https://github.com/luckydye.png","language":"JavaScript","readme":"# log\n\nA small (\u003c2KB gzipped minified) JavaScript logging library inspired by charmbracelet/log and docs.rs/env_logger.\n\n## Usage\n\n```bash\nnpm i @luckydye/log\n```\n\n## Examples\n\n### Log levels\n\n```javascript\nimport logger from '@luckydye/log';\n\nconst log = logger().prefix(\"Test\").trace();\n\nlog.info(\"Log info\");\nlog.error(\"This is an error!\");\n```\n\n```bash\n02/06/2024 00:38:05 INFO \u003clog.spec.ts:7:13\u003e Test: Hello, world!!\n02/05/2024 13:32:53 ERROR \u003clog.spec.ts:7:41\u003e Test: This is an error!\n03/01/2024 22:41:53 ERROR \u003clog.spec.ts:43:25\u003e testing err=Test error\nSyntaxError: Test error\n    at \u003cparse\u003e (:0)\n    at \u003canonymous\u003e (/Users/tihav/source/log/log.spec.ts:82:1)\n```\n\n### Log images to supporting terminals\n\n```javascript\nlog.img(path.resolve(\"./success.png\"));\n```\n\n### Formatted arguments\n\n```javascript\nlog.warn('An Object', 'obj', { one: 2 });\n```\n\n```bash\n02/06/2024 00:38:05 WARN \u003clog.spec.ts:17:64\u003e Text here obj=Object{\"one\":2}\n```\n\n### JSON output\n\n```javascript\nconst logJson = logger().prefix('Json').trace().json();\nlogJson.info('Hello, world!');\n```\n\n```bash\n{\"ts\":\"2024-02-05T13:33:05.270Z\",\"level\":\"info\",\"prefix\":\"Json\",\"location\":\"log.spec.ts:9:48\",\"msg\":\"Hello, world!\",\"args\":[\"Hello, world!\"]}\n```\n\n### Deno\n\n```javascript\nimport logger from \"npm:@luckydye/log\";\n\nconst log = logger().prefix(\"Deno\");\nlog.error(\"Test error\");\n```\n\n### InfluxDB\n\nSend logs to a InfluxDB (v2).\n\n```javascript\nimport logger from \"@luckydye/log\";\nimport { InfluxWriteStream } from '@luckydye/log/influx';\n\nconst log = logger()\n  .prefix('Influx')\n  .pipeTo(\n    new InfluxWriteStream({\n      org: 'organisation',\n      bucket: 'bucket_name',\n      db: 'database_name',\n      url: 'https://influxdb.example.com',\n      token: 'ACCESS_TOKEN',\n    })\n  );\n\n// JS_LOG filtering applies here as well\nlog.info('Hello, world!');\n```\n\n## Environment variables\n\n### JS_LOG\n\nSet the log level. Default is `info`.\n\n#### Set log level for specific prefixes.\n\n```bash\nJS_LOG=[prefix][=][level][,...]\n```\n\n```bash\nJS_LOG = \"error,Test=debug\"\n```\n\n## Configuration\n\n### Prefix\n\n```javascript\nconst log = logger().prefix(\"Topic\");\n```\n\n### Enable stack trace\n\nDisplay last frame of stack trace in the output.\n\n```javascript\nconst log = logger().trace();\n```\n\n### Set time format\n\nSet the time format. Default is `local`.\nSet to `false` to disable time.\n\n```javascript\nconst log = logger().time(\"local\" | \"kitchen\" | \"iso\" | \"utc\");\n\n// disable time\nconst log = logger().time(false);\n```\n\n### Enable json output\n\n```javascript\nconst log = logger().json();\n```\n\n### Pipe log messages to arbitrary stream\n\n```javascript\nconst log = logger().pipeTo(WriteableStream);\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluckydye%2Flog","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fluckydye%2Flog","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluckydye%2Flog/lists"}