{"id":21189050,"url":"https://github.com/tycrek/tlog","last_synced_at":"2025-07-10T02:31:34.447Z","repository":{"id":48057656,"uuid":"384215956","full_name":"tycrek/tlog","owner":"tycrek","description":"tycrek's custom logger library","archived":false,"fork":false,"pushed_at":"2024-03-29T03:23:05.000Z","size":370,"stargazers_count":4,"open_issues_count":1,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-11-05T02:47:29.137Z","etag":null,"topics":["express-middleware","log","logger","logging","logging-library","nodejs","plugins"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/@tycrek/log","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tycrek.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":"2021-07-08T18:29:55.000Z","updated_at":"2023-06-13T01:17:17.000Z","dependencies_parsed_at":"2024-06-21T05:46:51.231Z","dependency_job_id":"219c115e-6256-4b29-bcc4-f76008c4a03b","html_url":"https://github.com/tycrek/tlog","commit_stats":null,"previous_names":[],"tags_count":41,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tycrek%2Ftlog","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tycrek%2Ftlog/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tycrek%2Ftlog/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tycrek%2Ftlog/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tycrek","download_url":"https://codeload.github.com/tycrek/tlog/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225614662,"owners_count":17496938,"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":["express-middleware","log","logger","logging","logging-library","nodejs","plugins"],"created_at":"2024-11-20T18:49:44.562Z","updated_at":"2024-11-20T18:49:45.163Z","avatar_url":"https://github.com/tycrek.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[//]: # (NPM centered badge template START --------------------------------------------------)\n\n\u003cdiv align=\"center\"\u003e\n\ntlog\n===\n\n[![NPMCBT badge]][NPMCBT link]\n\n*My custom logger library*\n\u003c/div\u003e\n\n[NPMCBT badge]: https://img.shields.io/npm/v/@tycrek/log?color=CB3837\u0026label=%20View%20on%20NPM\u0026logo=npm\u0026style=for-the-badge\n[NPMCBT link]: https://www.npmjs.com/package/@tycrek/log\n\n[//]: # (NPM centered badge template END ----------------------------------------------------)\n\n# Features\n\n- 🌈 **Colours, timestamps, \u0026 labels**\n- 🔧 **Easily configurable**\n- 🔗 **Method chaining**\n- ⚙ **Utility logs**\n- 📝 **Comments**\n- 🔌 **Express.js middleware**\n- 🚀 **No `console` wrapping**\n\n# Installation\n\nInstall using **`npm i @tycrek/log`**, then load it into your project:\n\n```js\n// Import TLog\nimport { TLog } from '@tycrek/log';\n// or\nconst TLog = require('@tycrek/log');\n\n// Set up a new instance\nconst logger = new TLog();\n\n// or, set a level\nconst logger = new TLog('info');\n```\n\nPrints an info log:\n\n```js\nlogger.info('Hello, hell!');\n```\n\nMethods return the logger instance, allowing for method chaining:\n\n```js\nlogger\n    .warn('Wait, why are we in hell?')\n    .debug('Because we\\'re not using industry standard logging libs!');\n```\n\nYou can configure TLog options with the following methods:\n\n| Method | Description |\n| --- | --- |\n| **`.setLevel(level)`** | Sets the minimum log level to print. |\n| **`.setTimestamp({})`** | Enables or disables the timestamp, or configures **colour**, **preset**, \u0026 **format**. |\n| **`.setLabel({})`** | Enables or disables the label, or configures **padding**, **case**, \u0026 **alignment**. |\n| **`.setTitle({})`** | Sets the title **delimiter**. |\n| **`.setExtra({})`** | Sets the extra **prefix** \u0026 **suffix**. |\n| **`.setComments({})`** | Sets the comment **character** \u0026 **colour**. |\n\nTimestamps use [Luxon](https://moment.github.io/luxon/). To see what options are available for `timestamp.preset` \u0026 `timestamp.format`, review the Luxon documentation:\n\n- [Luxon presets](https://moment.github.io/luxon/docs/manual/formatting.html#presets)\n- [Luxon formats](https://moment.github.io/luxon/docs/manual/formatting.html#table-of-tokens)\n\n## General log methods\n\n### `logger.[level](title, message?, extra?)`\n\nPrints a log with the specified level. The `title` is printed in bold \u0026 colour, followed by the `message` in normal text. If `extra` is provided, it is printed in italics after the message.\n\nYou may pass **1**, **2**, or **3** parameters to these methods (message; title \u0026 message; title, message, \u0026 extra).\n\nPossible levels are:\n\n| Level | Severity |\n| --- | --- |\n| **`debug`** | `100` |\n| **`info`** | `200` |\n| **`warn`** | `300` |\n| **`error`** | `400` |\n| **`fatal`** | `500` |\n\nAdditional log levels are available for your convenience:\n\n| Level | Severity |\n| --- | --- |\n| **`utils`** | `100` |\n| **`success`** | `200` |\n| **`express`** | `200` |\n\n## Utility logs\n\n| Method | Description |\n| --- | --- |\n| **`.pid()`** | Prints the current process ID. |\n| **`.cwd()`** | Prints the current working directory. |\n| **`.epoch()`** | Prints the current Unix epoch in milliseconds. |\n| **`.uptime()`** | Prints the process uptime in seconds. |\n| **`.comment(message)`** | Prints a comment-like log. Useful for demoing outputs. |\n| **`.basic(message)`** | Prints a basic log with a timestamp (if enabled). |\n\n## Invisible utility logs\n\n| Method | Description |\n| --- | --- |\n| **`.blank()`** | Prints a blank line. |\n| **`.clear()`** | Clears the console using Unicode escape sequences. May behave differently on different platforms. |\n| **`.callback(cb)`** | Calls the provided `cb` function. |\n\n## Express.js middleware\n\nTLog comes with an included Express middleware. To use it, simply import it \u0026 add it to your Express app:\n\n```ts\nimport { TLog } from '@tycrek/log';\nimport express from 'express';\n\nconst logger = new TLog();\nconst app = express();\n\napp.use(logger.express());\napp.get('/', (req, res) =\u003e res.send('Hello, world!'));\napp.listen(3000);\n```\n\nThe middleware is still a bit of a work-in-progress following the TypeScript rewrite, but it should work fine for most use cases.\n\nYou can configure the middleware with the following options:\n\n| Option | Description |\n| --- | --- |\n| **`excludePaths`** | An array of paths to exclude from logging. |\n| **`excludeMethods`** | An array of HTTP methods to exclude from logging. |\n| **`trimPaths`** | Must be either `false` or an Object. |\n| *`trimPaths.maxLength`* | Any paths longer than this will be trimmed. |\n| *`trimPaths.delimiter`* | The character to use to replace trimmed path segments. |\n| **`morganMode`** | Mimics the behaviour of [morgan](https://www.npmjs.com/package/morgan). **Not yet implemented.** |\n\n# 🍁 Colours.\n\n**Colours**. I am **Canadian**. It is **colours**. If you don't like it, go **fork** yourself.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftycrek%2Ftlog","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftycrek%2Ftlog","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftycrek%2Ftlog/lists"}