{"id":35026915,"url":"https://github.com/bodrovis/kliedz","last_synced_at":"2026-01-20T16:31:18.775Z","repository":{"id":292379371,"uuid":"980738289","full_name":"bodrovis/kliedz","owner":"bodrovis","description":"Dead-simple, stateless logging utility for JavaScript and TypeScript. Pure functions. No dependencies. Just log.","archived":false,"fork":false,"pushed_at":"2025-12-01T14:13:48.000Z","size":425,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-12-15T19:39:58.641Z","etag":null,"topics":["console","functional","logger","logging","minimal","no-dependencies","typescript"],"latest_commit_sha":null,"homepage":"","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/bodrovis.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","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,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-05-09T16:18:44.000Z","updated_at":"2025-12-01T14:13:49.000Z","dependencies_parsed_at":"2025-05-09T16:45:14.954Z","dependency_job_id":"abb57ce5-f15d-48b8-a3b3-8efabf2d26a9","html_url":"https://github.com/bodrovis/kliedz","commit_stats":null,"previous_names":["bodrovis/kliedz"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/bodrovis/kliedz","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bodrovis%2Fkliedz","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bodrovis%2Fkliedz/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bodrovis%2Fkliedz/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bodrovis%2Fkliedz/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bodrovis","download_url":"https://codeload.github.com/bodrovis/kliedz/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bodrovis%2Fkliedz/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28607190,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-20T16:10:39.856Z","status":"ssl_error","status_checked_at":"2026-01-20T16:10:39.493Z","response_time":117,"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":["console","functional","logger","logging","minimal","no-dependencies","typescript"],"created_at":"2025-12-27T06:27:20.334Z","updated_at":"2026-01-20T16:31:18.770Z","avatar_url":"https://github.com/bodrovis.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Kliedz\n\n![npm](https://img.shields.io/npm/v/kliedz)\n![CI](https://github.com/bodrovis/kliedz/actions/workflows/ci.yml/badge.svg)\n[![NPM Downloads][npm-downloads-image]][npm-downloads-url]\n[![Code Coverage][coverage-image]][coverage-url]\n[![Maintainability][maintainability-image]][maintainability-url]\n\n**Kliedz** is a stateless logging utility for JavaScript and TypeScript written with functional approach.\n\n## Installation\n\n```\nnpm install kliedz\n```\n\n## What is this?\n\nThis is a simple logging system for JS/TS. It lets you conditionally log messages based on a configured log level — without storing state, mutating anything, or pulling in extra dependencies.\n\nIt works around two main concepts: **level** and **threshold**.\n\n### `level`\n\nThe severity of the message you're logging that also determines how the message is printed (which `console` method is used):\n\n- `debug` → `console.log()`\n- `info`  → `console.info()`\n- `warn`  → `console.warn()`\n- `error` → `console.error()`\n\n### `threshold`\n\nA cutoff filter: only messages with `level \u003e= threshold` will be printed. Think of `threshold` as the minimum severity required to be shown. This is useful when log visibility is controlled by a user or environment (e.g. `--verbose`).\n\nSupported values:\n\n- `debug` → everything logs\n- `info` → skips only `debug` (default)\n- `warn` → logs only `warn` and `error`\n- `error` → logs only `error`\n- `silent` → disables all logging\n\n## Usage\n\n```js\nimport { logWithColor, logWithLevel } from \"kliedz\";\n\n// Quick start\nlogWithColor(\"Hey!\");\nlogWithLevel({ level: \"warn\" }, \"Something feels off\");\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Basic \"just log it\" call (uses default level = \"info\", threshold = \"info\")\n// ─────────────────────────────────────────────────────────────────────────────\n\nlogWithColor(\"Hello from the default logger\");\n// [INFO] Hello from the default logger\n// printed in cyan color\n\nlogWithLevel(\"Just a plain info message\", 42);\n// [INFO] Just a plain info message 42\n// printed without color\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Fully configured log call\n// ─────────────────────────────────────────────────────────────────────────────\n\nlogWithColor(\n  {\n    level: \"warn\", // threshold, is optional, defaults to \"info\"\n  },\n  \"This is a warning with color\"\n);\n// [WARN] This is a warning with color\n// printed in orange\n\nlogWithLevel(\n  {\n    level: \"debug\",\n    threshold: \"debug\",\n  },\n  \"Low-level debug info\"\n);\n// [DEBUG] Low-level debug info\n// printed without color\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Including a timestamp in the prefix\n// ─────────────────────────────────────────────────────────────────────────────\n\nlogWithColor(\n  {\n    level: \"error\",\n    threshold: \"debug\",\n    withTimestamp: true,\n  },\n  \"Error occurred!\",\n);\n// 2025-05-10T13:52:59.845Z [ERROR] Error occurred!\n\nlogWithLevel(\n  {\n    level: \"info\",\n    threshold: \"debug\",\n    withTimestamp: true,\n  },\n  \"Startup complete\"\n);\n// 2025-05-10T13:53:15.240Z [INFO] Startup complete\n\n// ─────────────────────────────────────────────────────────────────────────────\n// With a custom prefixBuilder\n// ─────────────────────────────────────────────────────────────────────────────\n\nlogWithLevel(\n  {\n    level: \"info\",\n    threshold: \"debug\",\n    prefixBuilder: () =\u003e \"\u003e\u003e\u003e INFO \u003c\u003c\u003c\",\n  },\n  \"Using a custom prefix builder\"\n);\n// \u003e\u003e\u003e INFO \u003c\u003c\u003c Using a custom prefix builder\n\nlogWithColor(\n  {\n    level: \"warn\",\n    prefixBuilder: () =\u003e {\n      const ts = new Date().toISOString();\n      return `!!${ts}[WARNING]!!`;\n    },\n  },\n  \"Custom warning with timestamped prefix\"\n);\n// !!2025-05-10T14:03:32.302Z[WARNING]!! Custom warning with timestamped prefix\n```\n\n## How it works\n\nThis package provides two main logging functions:\n\n- **`logWithLevel()`** – logs plain messages (no colors)\n- **`logWithColor()`** – logs messages with ANSI-colored `[LEVEL]` prefixes\n\nBoth functions use the same core logic under the hood. You can call them in two ways:\n\n### Option 1: Just log something (default config)\n\nIf you just want to log without caring about configuration:\n\n```ts\nlogWithColor(\"hello world\");\nlogWithLevel(\"something happened\", { id: 123 });\n```\n\nThis uses default settings:\n\n- `level`: `\"info\"`\n- `threshold`: `\"info\"` (so messages with level `\"info\"`, `\"warn\"`, or `\"error\"` will be printed)\n\n### Option 2: Log with full control\n\nIf you need to configure how a message is treated, pass a `LogParams` object as the first argument:\n\n```ts\nlogWithColor(\n  { level: \"warn\", threshold: \"debug\", withTimestamp: true },\n  \"warning issued\"\n);\n\nlogWithLevel(\n  { level: \"debug\", threshold: \"warn\" },\n  \"this will be filtered out\"\n);\n```\n\nYou can control:\n\n- `level`: The severity of the current message (`\"debug\"`, `\"info\"`, `\"warn\"`, `\"error\"`)\n- `threshold`: The cutoff level. Only messages with `level \u003e= threshold` are printed.\n- `withTimestamp`: If true, includes an ISO timestamp in the prefix.\n- `prefixBuilder`: Optional function to fully customize the prefix format.\n\n## Creating custom logger\n\nIt's possible to create a new logger with a custom formatting logic. For example:\n\n```js\nimport { createLogger, getPrefix, formatArg } from \"kliedz\";\nimport type { Formatter, FormatterConfig } from \"kliedz\";\n\n// Define a custom formatter\nconst jsonFormatter: Formatter = (config: FormatterConfig): string =\u003e {\n  const prefix = getPrefix(config); // builds [LEVEL] or timestamped prefix\n\n  // config.args contains one or multiple values to log\n  // Create your message, optionally use formatArg to format these arguments\n  const message = config.args.map(formatArg).join(\" \"); \n\n  // Return final string to log\n  return JSON.stringify({\n    timestamp: new Date().toISOString(),\n    level: config.level,\n    prefix,\n    message,\n  });\n};\n\n// Create logger with formatter\nconst logJson = createLogger(jsonFormatter);\n\n// Use it, optionally providing level and threshold\nlogJson(\"This is a default info log\");\nlogJson({ level: \"warn\" }, \"Something might be wrong\", { id: 123 });\nlogJson({ level: \"error\", withTimestamp: true }, new Error(\"kaboom\"));\n```\n\n## License\n\nLicensed under MIT.\n\n(c) [Ilya Krukowski](https://bodrovis.tech/)\n\n[npm-downloads-image]: https://img.shields.io/npm/dm/kliedz\n[npm-downloads-url]: https://npmcharts.com/compare/kliedz?minimal=true\n[coverage-image]: https://qlty.sh/gh/bodrovis/projects/kliedz/coverage.svg\n[coverage-url]: https://qlty.sh/gh/bodrovis/projects/kliedz\n[maintainability-image]: https://qlty.sh/gh/bodrovis/projects/kliedz/maintainability.svg\n[maintainability-url]: https://qlty.sh/gh/bodrovis/projects/kliedz\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbodrovis%2Fkliedz","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbodrovis%2Fkliedz","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbodrovis%2Fkliedz/lists"}