{"id":22370368,"url":"https://github.com/alpheusday/terminok.js","last_synced_at":"2025-07-30T20:31:41.112Z","repository":{"id":253207100,"uuid":"842821448","full_name":"alpheustangs/terminok.js","owner":"alpheustangs","description":"A terminal logging solution","archived":false,"fork":false,"pushed_at":"2024-10-29T13:00:16.000Z","size":238,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-10-29T14:58:38.062Z","etag":null,"topics":["filesystem","javascript","logging","node","terminal","terminok","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/alpheustangs.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-08-15T06:51:27.000Z","updated_at":"2024-10-29T13:00:13.000Z","dependencies_parsed_at":"2024-09-15T04:38:00.601Z","dependency_job_id":"ac5a08a9-0294-4b15-8d04-6127a94efdd6","html_url":"https://github.com/alpheustangs/terminok.js","commit_stats":null,"previous_names":["alpheustangs/terminok.js"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alpheustangs%2Fterminok.js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alpheustangs%2Fterminok.js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alpheustangs%2Fterminok.js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alpheustangs%2Fterminok.js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alpheustangs","download_url":"https://codeload.github.com/alpheustangs/terminok.js/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228182931,"owners_count":17881594,"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":["filesystem","javascript","logging","node","terminal","terminok","typescript"],"created_at":"2024-12-04T19:45:02.323Z","updated_at":"2025-07-30T20:31:40.683Z","avatar_url":"https://github.com/alpheustangs.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Terminok\n\nA terminal logging solution.\n\nTerminok is a logging solution that outputs colorful logs to the terminal or saves them to a file. It supports both web and Node environments, with additional runtime compatibility based on the configuration.\n\n## Installation\n\nInstall this package as a dependency in the project:\n\n```sh\n# npm\nnpm i terminok\n\n# Yarn\nyarn add terminok\n\n# pnpm\npnpm add terminok\n```\n\n## Quick Start\n\nCreate a client with default schema as follows:\n\n```ts\nimport type { Client } from \"terminok\";\nimport { createClient, SCHEMA_DEFAULT } from \"terminok\";\n\nconst log: Client\u003ctypeof SCHEMA_DEFAULT\u003e = createClient({\n    schema: SCHEMA_DEFAULT,\n});\n\nlog.info(\"Hello\");\n```\n\nOr create a custom schema with the following code:\n\n```ts\nimport type { Client, Schema } from \"terminok\";\nimport { createClient, COLORS } from \"terminok\";\n\nconst customSchema = [\n    {\n        key: \"ping\",\n        color: COLORS.red,\n    }\n] as const satisfies Schema;\n\nconst log: Client\u003ctypeof customSchema\u003e = createClient({\n    schema: customSchema,\n});\n\nlog.ping(\"pong\");\n```\n\n## Documentation\n\nFor more information, please refer to the [documentation](./docs/README.md).\n\n## What If\n\nTerminok provides a highly customizable config and schema, so you can create your own logger easily. But you may meet some problems during the creation.\n\n### What If the Schema Is Empty\n\nIf the schema is empty, it will return nothing as a result. So you should import the default schema or create your own schema.\n\n```ts\nimport { createClient } from \"terminok\";\n\nconst log = createClient();\n\n// Nothing will be inside `log`\n```\n\n### What If I Want to Customize How the Log Will Be Displayed\n\nTo customize how the log will be displayed, you may edit `format` parameter in config to customize the output.\n\n```ts\nimport type { Client, FormatData } from \"terminok\";\nimport { createClient, SCHEMA_DEFAULT } from \"terminok\";\n\nconst log: Client\u003ctypeof SCHEMA_DEFAULT\u003e = createClient({\n    schema: SCHEMA_DEFAULT,\n    config: {\n        format: (data: FormatData) =\u003e {\n            return `- [${data.title}] ${data.content}`;\n        },\n    }\n});\n\nlog.info(\"Hello\");\n```\n\n### What If I Set `onDone`/`onTrigger` Config on Both Config and Schema\n\nIf you set `onDone`/`onTrigger` on both config and schema, both of them will be executed. And the `onDone`/`onTrigger` function in `config` will be executed first.\n\n```ts\nimport type { Client, Schema } from \"terminok\";\nimport { createClient, COLORS } from \"terminok\";\n\nconst customSchema = [\n    {\n        key: \"ping\",\n        color: COLORS.red,\n        onDone: (): void =\u003e {\n            // executed second\n        }\n    },\n] as const satisfies Schema;\n\nconst log: Client\u003ctypeof customSchema\u003e = createClient({\n    schema: customSchema,\n    config: {\n        onDone: (): void =\u003e {\n            // executed first\n        }\n    }\n});\n```\n\n### What If I Set `output` Config on Both `config` and `schema`\n\nIf you set `output` on both config and schema, the `output` config in `config` will be overrided by the `output` config in `schema`.\n\n```ts\nimport type { Client, Schema } from \"terminok\";\nimport { createClient, COLORS } from \"terminok\";\n\nconst customSchema = [\n    {\n        key: \"ping\",\n        color: COLORS.red,\n    },\n    {\n        key: \"ping2\",\n        color: COLORS.red,\n        output: {\n            // ...\n        }\n    }\n] as const satisfies Schema;\n\nconst log: Client\u003ctypeof customSchema\u003e = createClient({\n    schema: customSchema,\n    config: {\n        output: {\n            // ...\n        }\n    }\n});\n\nawait log.ping(\"pong\").toFile(); // run with config `output` settings \nawait log.ping2(\"pong\").toFile(); // run with schema `output` settings\n```\n\n### What If the `toFile()` Function Triggered in Web\n\nWhile Terminok supports both web and Node.js environments, the `toFile()` function is exclusive for Node.js environments by default. Using `toFile()` in web will lead to an error.\n\n```ts\nimport type { Client } from \"terminok\";\nimport { createClient, SCHEMA_DEFAULT } from \"terminok\";\n\nconst log: Client\u003ctypeof SCHEMA_DEFAULT\u003e = createClient({\n    schema: SCHEMA_DEFAULT,\n});\n\nawait log.info(\"Hello\").toFile();\n\n// This will lead to an error in web with default config\n```\n\n## License\n\nThis project is licensed under the terms of the MIT license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falpheusday%2Fterminok.js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falpheusday%2Fterminok.js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falpheusday%2Fterminok.js/lists"}