{"id":14971236,"url":"https://github.com/toreda/log","last_synced_at":"2025-05-13T10:46:11.188Z","repository":{"id":45166746,"uuid":"252853168","full_name":"toreda/log","owner":"toreda","description":"Lightweight TypeScript logger with flexible custom transports.","archived":false,"fork":false,"pushed_at":"2022-03-15T19:46:40.000Z","size":1605,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-16T07:07:15.885Z","etag":null,"topics":["debugging","library","log","logger","loggers","logging","toreda","typed","typescript","yarn"],"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/toreda.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2020-04-03T22:11:51.000Z","updated_at":"2022-04-28T15:28:04.000Z","dependencies_parsed_at":"2022-09-26T22:30:36.071Z","dependency_job_id":null,"html_url":"https://github.com/toreda/log","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toreda%2Flog","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toreda%2Flog/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toreda%2Flog/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toreda%2Flog/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/toreda","download_url":"https://codeload.github.com/toreda/log/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253927852,"owners_count":21985747,"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":["debugging","library","log","logger","loggers","logging","toreda","typed","typescript","yarn"],"created_at":"2024-09-24T13:44:54.254Z","updated_at":"2025-05-13T10:46:11.155Z","avatar_url":"https://github.com/toreda.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"![Toreda](https://content.toreda.com/logo/toreda-logo.png)\n\n[![CI](https://img.shields.io/github/workflow/status/toreda/log/CI?style=for-the-badge)](https://github.com/toreda/log/actions) [![Coverage](https://img.shields.io/sonar/coverage/toreda_log?server=https%3A%2F%2Fsonarcloud.io\u0026style=for-the-badge)](https://sonarcloud.io/dashboard?id=toreda_log) ![Sonar Quality Gate](https://img.shields.io/sonar/quality_gate/toreda_log?server=https%3A%2F%2Fsonarcloud.io\u0026style=for-the-badge)\n\n![GitHub package.json version (branch)](https://img.shields.io/github/package-json/v/toreda/log/master?style=for-the-badge) ![GitHub Release Date](https://img.shields.io/github/release-date/toreda/log?style=for-the-badge) [![GitHub issues](https://img.shields.io/github/issues/toreda/log?style=for-the-badge)](https://github.com/toreda/log/issues)\n\n ![license](https://img.shields.io/github/license/toreda/log?style=for-the-badge)\n\n\n# `@toreda/log` - Dynamic Logger\n\nLight TypeScript logger for node, web, and serverless environments.\n\nFeatures:\n* Small footprint\n* Simple to use\n* Fully supports TypeScript\n* Custom Transport support\n* Works in Browser, Serverless, and Node environments.\n\n\u0026nbsp;\n\n# Contents\n* [**Use Cases**](#use-cases)\n\n* [**What does it do?**](#what-does-it-do)\n* [**Usage**](#usage)\n\n* [**Package**](#Package)\n\t-\t[Install](#Install)\n\t-\t[Run Tests](#run-tests)\n\t-\t[Build](#build-from-source)\n\t-   [License](#license)\n\n\u0026nbsp;\n\n# Use Cases\n\n## Custom Transports\n* Configure transports to receive all log events, or only a filtered subset based on class, group, and log level.\n* Custom transports can filter and receive structured log data for specific events you care about. Get the exact functionality you need without writing a whole library.\n\n## Granular Control\n* Leave disabled log messages in prod environments which can be turned on later for debugging without a code push.\n* Set log levels for individual functions, classes, and groups. See debug output from the system you're debugging without seeing app-wide debug spam.\n\n\u0026nbsp;\n\n# Usage\n`@toreda/log` provides simple and straight forward logging for common use cases, and advanced functionality for use in more complicated situations like server-side and remote debugging.\n\n\n**Create Logger**\n```typescript\nimport {Log} from '@toreda/log';\nconst log = new Log();\n```\n\n\n**Log Levels**\n```typescript\nimport {Log, Levels} from '@toreda/log';\nconst log = new Log({globalLevel: Levels.DEBUG});\n// Change log level:\nlog.setGlobalLevel(Levels.ALL);\n// Disable a specific log level only\nlog.disableGlobalLevel(Levels.TRACE)\n// Disable specific log levels only\nlog.disableGlobalLevels([Levels.DEBUG, Levels.INFO])\n// Enable a specific log level only\nlog.enableGlobalLevel(Levels.DEBUG)\n// Enable specific log levels only\nlog.enableGlobalLevels([Levels.TRACE, Levels.INFO])\n// Trace\nlog.trace('Trace message here');\n// Debug\nlog.debug('Debug message here');\n// Info\nlog.info('Info message here');\n// Warn\nlog.warn('Warn message here');\n// Error\nlog.error('my', 'message', 'here');\n// Multple\nlog.log(Levels.ERROR \u0026 Levels.TRACE, 'trace and error message here');\n// Custom\nconst customLevel =\nlog.log(0b0010_0000_0000, 'custom logging level');\n```\n\n**Groups**\nNew logs can be created from existing logs. The new logs share a state with\nthe log that created them and have an id that tracks the origin of of the log.\n```typescript\nimport {Log} from '@toreda/log';\nconst log = new Log({id: 'ClassLog'});\nconst subLog = log.makeLog('FunctionLog');\n\n// Message has id 'ClassLog'\nlog.info('Class constructor started.');\n// Message has id 'ClassLog.FunctionLog'\nsubLog.info('Function call started.');\n\nlog.globalState === subLog.globalState; // returns true\n```\n\n\n**Transports**\nTransports attach to logs and handle the messages.\n\nA default transport that logs to console can be actived when creating the log.\n```typescript\nimport {Log} from '@toreda/log';\nconst log = new Log({consoleEnabled: true});\nconst sublog = log.makeLog('sublog');\n\n// Logs to the console\nlog.info('Info Message');\n// Logs to the console\nsublog.info('Info Message');\n```\n\nIt can also be activated later\n```typescript\nimport {Log} from '@toreda/log';\nconst log = new Log();\nlog.activateDefaultConsole();\nconst sublog = log.makeLog('sublog');\n\n// Logs to the console\nlog.info('Info Message');\n// Does not log to the console\nsublog.info('Info Message');\n```\n\nCustom transports can also be created\n```typescript\nimport {Log, LogMessage, Transport} from '@toreda/log';\nconst log = new Log();\n// Example dummy example.\n// Custom actions can perform any async activity.\nconst action = async (msg: LogMessage): Promise\u003cboolean\u003e =\u003e {\n   return true;\n}\n// Transports take a string ID, initial log level,\n// and async action function.\nconst transport = new Transport('tid1', LogLevels.ALL, action);\n\n// Add transport to global listeners.\nlog.addTransport(transport);\n```\n\n**Removing Transports**\n```typescript\n// Remove the same transport\n// NOTE: Requires access to original transport object\n// now being removed.\nlog.removeTransport(transport);\n\n// Remove global transport by ID.\n// Use ID to remove global transports if you no\n// longer have a reference to target transport.\nlog.removeTransportById('tid1');\n```\n\n\u0026nbsp;\n\n# Install\nInstall `@toreda/log` directly from NPM.\n\n## Install with Yarn (preferred)\n```bash\nyarn add @toreda/log --dev\n```\n\n## Install using NPM\n```bash\nnpm install @toreda/log --save-dev\n```\n\n\n## Run Tests\nInstall or clone `@toreda/log` [(see above)](#install).\n\nToreda Unit Tests use [Jest](https://jestjs.io/).\n\nInstalling jest is not required after project dependencies are installed ([see above](#install)).\n```bash\nyarn test\n```\n\n\u0026nbsp;\n\n# Build from source\n\nThe next steps are the same whether you installed the package using NPM or cloned the repo from Github.\n\n### Build with Yarn\n Enter the following commands in order from the log project root.\n```bash\nyarn build\n```\n\n### Build with NPM\n Enter the following commands in order from the log project root.\n```bash\nnpm run-script build\n```\n\n\u0026nbsp;\n# Legal\n\n## License\n[MIT](LICENSE) \u0026copy; Toreda, Inc.\n\n\n## Copyright\nCopyright \u0026copy; 2019 - 2022 Toreda, Inc. All Rights Reserved.\n\nhttps://www.toreda.com\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftoreda%2Flog","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftoreda%2Flog","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftoreda%2Flog/lists"}