{"id":15588571,"url":"https://github.com/aturingmachine/trunks","last_synced_at":"2025-04-24T05:18:54.449Z","repository":{"id":57380335,"uuid":"146934370","full_name":"aturingmachine/trunks","owner":"aturingmachine","description":"Simple logging for NodeJS","archived":false,"fork":false,"pushed_at":"2018-11-19T12:14:10.000Z","size":419,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-24T05:18:42.146Z","etag":null,"topics":["javascript","logger","logging","node","nodejs","npm-package"],"latest_commit_sha":null,"homepage":null,"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/aturingmachine.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}},"created_at":"2018-08-31T19:26:36.000Z","updated_at":"2020-01-19T21:39:59.000Z","dependencies_parsed_at":"2022-08-28T22:00:18.322Z","dependency_job_id":null,"html_url":"https://github.com/aturingmachine/trunks","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aturingmachine%2Ftrunks","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aturingmachine%2Ftrunks/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aturingmachine%2Ftrunks/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aturingmachine%2Ftrunks/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aturingmachine","download_url":"https://codeload.github.com/aturingmachine/trunks/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250566700,"owners_count":21451283,"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":["javascript","logger","logging","node","nodejs","npm-package"],"created_at":"2024-10-02T22:40:42.840Z","updated_at":"2025-04-24T05:18:54.433Z","avatar_url":"https://github.com/aturingmachine.png","language":"JavaScript","readme":"# Trunks\n[![npm version](https://badge.fury.io/js/trunks-log.svg)](https://badge.fury.io/js/trunks-log)\n\ntrunks is a simple logger for NodeJS projects. It writes to stdout. I wrote trunks because I couldn't find a lightweight logger that did the bare minimum.\n\n## Installation\n\n```bash\nnpm install --save trunks-log\n```\n\n\n## Usage\n\ntrunks has 5 built in logging levels, `debug, info, success, warn, error` with predefined coloring in their output to make them easier to spot in a slew of logs.\n\n - `debug` prints in yellow\n - `warn` prints in yellow\n - `info` prints in cyan\n - `success` prints in green\n - `error` prints in red (including a passed error's stacktrace)\n\n You can also use the generic `log()` function to print a log with a custom tag in it, this will be printed in magenta.\n\n trunks supports variable replacement, meaning we can pass a template and a list of args to the functions to format the string.\n\n `trunks.info('Hello from {}!', 'trunks')`\n\n Will output: \n `Hello from trunks!` in the message section of the log.\n\n trunks also supports passing objects into the template, they will be output as the result of a `JSON.stringify()` call.\n\n### Logging Levels\n\ntrunks currently supports 2 logging levels, `PROD` and `DEBUG`. \n\n\u003e Any more ideas for further support of logging levels is greatly appreciated\n\n- `DEBUG` will log everything\n- `PROD` will *NOT* log `debug` level logs, or the stacktrace from `error` calls. (This is open to change)\n\nSetting the level to prod should not effect performance as the level check occurs prior to the building of the template.\n\n### Instances\n\nAs of V2.0.0 trunks now supports the ability to namespace an instance of trunks via the constructor. This will change the second section of output in the console. The constructor is as follows:\n\n```\ntrunks (\n  namespace = 'APP',\n  namespaceColor = 'magenta',\n  level = 'DEBUG'\n)\n```\n\nThe trunks instance will default to a `DEBUG` logging level with the namespace `APP` and print the namespace in the color `MAGENTA` (as determined by your terminal).\n\n- `namespace` can be any string\n- `namespaceColor` must be one of: `['yellow', 'red', 'blue', 'green']`, with the default as `magenta`\n- `level` must be one of `['debug', 'prod']`\n\n## Example\n\n```js\nconst trunks = require('../trunks')\n\nconst ex = new trunks()\n\nex.warn('Hello from a trunks {} log!', 'warning')\nex.debug('Hello from a trunks {} log!', 'debug')\nex.log('test', 'Hello from a trunks {} log!', 'custom')\nex.info('Hello from a trunks {} log!', 'info')\nex.success('Hello from a trunks {} log!', 'success')\nex.error(new Error('Test error'), 'Hello from a trunks {} log!', 'error')\n```\n\nWill produce:\n\n![trunks example](https://raw.githubusercontent.com/aturingmachine/trunks/master/examples/trunksExample.png)\n\n## Contributing\n\nPlease feel free to contribute to this project! I am open to any and all suggestions. Simply fork it and make a pr and we can discuss the changes there!\n\n## Roadmap\nIn the future versions of trunks I would like to add:\n- support for use in browsers","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faturingmachine%2Ftrunks","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faturingmachine%2Ftrunks","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faturingmachine%2Ftrunks/lists"}