{"id":20723976,"url":"https://github.com/nascentdigital/scribe","last_synced_at":"2025-12-12T05:42:01.414Z","repository":{"id":40767432,"uuid":"266180629","full_name":"nascentdigital/scribe","owner":"nascentdigital","description":"A robust and extensible Javascript logging library for the browser.","archived":false,"fork":false,"pushed_at":"2023-05-11T15:59:07.000Z","size":1545,"stargazers_count":1,"open_issues_count":16,"forks_count":0,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-02-24T20:39:40.718Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/nascentdigital.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":"2020-05-22T18:28:05.000Z","updated_at":"2023-05-11T15:52:51.000Z","dependencies_parsed_at":"2024-06-21T04:18:08.466Z","dependency_job_id":"4bc2ad52-202e-407d-a870-6511881bbc1b","html_url":"https://github.com/nascentdigital/scribe","commit_stats":{"total_commits":44,"total_committers":2,"mean_commits":22.0,"dds":"0.022727272727272707","last_synced_commit":"e29528783db373c22cc7347a2596afab881a7cda"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nascentdigital%2Fscribe","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nascentdigital%2Fscribe/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nascentdigital%2Fscribe/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nascentdigital%2Fscribe/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nascentdigital","download_url":"https://codeload.github.com/nascentdigital/scribe/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242998556,"owners_count":20219374,"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":[],"created_at":"2024-11-17T04:11:31.927Z","updated_at":"2025-12-12T05:41:56.235Z","avatar_url":"https://github.com/nascentdigital.png","language":"TypeScript","readme":"# Scribe\n\u003e Finally, a full featured Javascript logging framework for the both browser and Node.\n\n[![NPM version](https://img.shields.io/npm/v/@nascentdigital/scribe.svg)](https://www.npmjs.com/package/@nascentdigital/scribe)\n[![downloads](https://img.shields.io/npm/dm/@nascentdigital/scribe.svg)](http://npm-stat.com/charts.html?package=@nascentdigital/scribe\u0026from=2020-06-05)\n[![Node version](https://img.shields.io/node/v/@nascentdigital/scribe.svg)](http://nodejs.org/download/)\n[![Build Status](https://travis-ci.com/nascentdigital/scribe.svg?branch=master)](https://travis-ci.com/nascentdigital/scribe.svg?branch=master)\n[![Code Coverage](https://img.shields.io/codecov/c/github/nascentdigital/scribe.svg)](https://codecov.io/github/nascentdigital/scribe)\n[![Known Vulnerabilities](https://snyk.io/test/github/nascentdigital/scribe/badge.svg)](https://snyk.io/test/github/nascentdigital/scribe)\n\n\n\n\n## Features\n- Works in the browser and Node.\n- Namespace support for fine-grained logging support at a module, feature, or method level.\n- Log level support to enable prioritized log output.\n- Dynamic configuration of log level mappings based on namespaces patterns.\n- Pluggable middleware transform of log output (e.g. prefixing, colors, custom, etc.)\n- Pluggable writers of log output (e.g. console, null, server-side, custom, etc.)\n- Built in Typescript, compatible with Javascript.\n\n\n## Installation\n\nInstall Scribe using [`npm`](https://www.npmjs.com/):\n\n```bash\nnpm install --save @nascentdigital/scribe\n```\n\nOr [`yarn`](https://yarnpkg.com/en/package/jest):\n\n```bash\nyarn add @nascentdigital/scribe\n```\n\n\n## Usage\n\n### Quick Start\n\nGetting started is really easy.  Simply acquire a `Log` and start logging:\n\n```javascript\nimport {Scribe} from \"@nascentdigtal/scribe\";\n\nScribe.log.debug(\"A debug message\");\n// A debug message\n\nScribe.log.error(\"An error occurred - \", new Error(\"Oops!\"));\n// An error occurred - Error: Oops!\n//   at ...\n```\n\nThis example uses the global log to output a `debug` and `error` [level](#log-levels) log message.  While this is a\nquick way to access and output log messages, the recommended approach is to use [namespaces](#namespaces).\n\n\n### Namespaces\n\nIn modern Javascript we organize our code into [modules](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules)\nwhich build up larger libraries and applications.  Good logging should reflect the [separation of concerns](https://effectivesoftwaredesign.com/2012/02/05/separation-of-concerns/)\nmodelled by the application architecture.\n\n`Scribe` uses namespaces to help developers group and control logging based on related functionality.  The structure of\na namespace is as follows:\n\n|               |                                                  |\n|---------------|--------------------------------------------------|\n|**namespace**  | `\u003cidentifier\u003e`:`\u003cidentifier\u003e`/`\u003cidentifier\u003e`*    |\n|**identifier** | `[a-zA-Z0-9_\\-]`                                   |\n|               |                                                  |\n\n\nSome examples of valid namespaces would be:\n\n- `\"my-app\"`\n- `\"my-app:mymodule\"`\n- `\"my-app:mymodule/foo\"`\n- `\"my-app:mymodule/foo/bar\"`\n- `\"my-app:mymodule/foo/bar/variant_1\"`\n\n### Retrieving a Log\n\nA log can be obtained by accessing the global `Scribe.log` property:\n\n ```javascript\nconst globalLog = Scribe.log;\n```\n\nGenerally you'll want to fetch a log that is dedicated to a specific scope.  You can obtain a specific logger via the\n`Scribe.getLog()` method.  This method creates a log if it doesn't exist or fetches the cached log if it has already\nbeen created.\n\n```javascript\nconst logA = Scribe.getLog(\"moduleA\");\nconst logB = Scribe.getLog(\"moduleB\");\nconst logA2 = Scribe.getLog(\"moduleA\");\n\nlogA.debug(logA === logA2); // true\n```\n\nIn practice, you'll want to dedicate a log per module and scope the namespace to reflect that relationship.\n\n###### mylib/foo.js\n```javascript\nconst log = Scribe.getLog(\"mylib:foo\");\n\nexport function foo(options) {\n\n    if (!options) {\n        log.error(\"foo() invoked without options\");\n        throw new Error(\"Missing 'options' argument.\");\n    }\n\n    log.trace(\"calling foo with options: \", options);\n}\n```\n\n###### mylib/bar.js\n```javascript\nconst log = Scribe.getLog(\"mylib:bar\");\n\nexport function bar(message) {\n    log.debug(\"bar() was invoked with message: \", message);\n}\n```\n\n\n### Log Levels\n\nLog levels provide a way of prioritizing the significance of a log message.  The `Log` interface has log methods the\ncorrespond communicate the following intent around log messages:\n\n| Level         | Method      | Description\n|---------------|-------------|---------------------\n| Trace         | `trace()`   | Used for profiling an application and seeing the details of control flow.  This is a very noisy level that should be reserved for situations that require coding forensics.  Generally trace messages also provide clarity of the stacktrace.\n| Debug         | `debug()`   | This level represents the sweet spot for debugging messages that help developers see the internals of their code when tracking down most bugs.\n| Informational | `info()`    | These usually represent lifecycle events our communicate the result of larger milestones.\n| Warning       | `warn()`    | Warnings are used to communicate anomalies in the code that aren't errors but might be symptoms of underlying issues.  They of show in validation or edge case concerns that the code can handle, but shouldn't really occur.\n| Error         | `error()`   | This is for problems that are almost accompanied with the throwing or catching of `Error`s.  Similar to `trace` messages, this level usually provides a stacktrace when logging.\n| Silent        | *n/a*       | This level doesn't provide a log function because it effectively disables all logging when enabled.\n\nThe levels are cumulative in the sense that they stack.  When `trace` level logging is enabled all other log level are\nautomatically enabled as well, while `debug` enables all levels except `trace`.  Outside of silent, the `error` level is\nthe most strict level and will result in the other messages being suppressed.\n\nHere's an example of how these\n\n\n### Log Filters\n\nMost of the time you'll want to control which of the log levels actually get output to the console.  The\n`Scribe.setLogLevel()` method give precise control of individual log levels by targeting namespaces.  This method\nuses the `*` wildcard to help create glob expressions that can cover many different scenarios.\n\nFilters can be set before or after a log is created, and is guaranteed to take precedence based on the most recently\nset filter that matches a namespace.  The default level for logs is `error` if there is no overridden match.\n\n```javascript\n\n// create a log early\nconst loginLog = Scribe.getLog(\"myapp:onboarding/login\");\n\n// change default level to info, make onboarding debug\nScribe.setLogLevel(\"*\", \"info\");\nScribe.setLogLevel(\"myapp:onboarding*\", \"debug\");\n\n// show some logging\nloginLog.trace(\"suppressed\");\nloginLog.debug(\"OUTPUT\")\nloginLog.error(\"OUTPUT\");\n\n// late binding of another log\nconst homeLog = Scribe.getLog(\"myapp:home\");\n\n// use the new log\nhomeLog.debug(\"suppressed\");\nhomeLog.warn(\"OUTPUT\");\nhomeLog.error(\"OUTPUT\");\n```\n\n#### Dynamically updating LogLevel\n\nWhile debugging in the browser you might want to dynamically set the `LogLevel` to see what's going on.  Scribe exposes\nitself through the globally in the browser through the `window.nascentdigital` namespace.  This allows updates at any\ntime:\n\n```javascript\n\u003e window.nascentdigital.Scribe.setLogLevel(\"*\", \"trace\");\n```\n\n\n### Advanced Configuration\n\n#### Transforms\n\n\n#### Writers\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnascentdigital%2Fscribe","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnascentdigital%2Fscribe","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnascentdigital%2Fscribe/lists"}