{"id":15979143,"url":"https://github.com/perry-mitchell/gle","last_synced_at":"2025-06-12T17:08:00.036Z","repository":{"id":42370172,"uuid":"369244643","full_name":"perry-mitchell/gle","owner":"perry-mitchell","description":"Global Log Engine: Environment-agnostic debugging \u0026 logging utility","archived":false,"fork":false,"pushed_at":"2022-07-05T09:40:14.000Z","size":789,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-05-30T00:48:22.647Z","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/perry-mitchell.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":"2021-05-20T14:54:47.000Z","updated_at":"2022-04-08T12:23:57.000Z","dependencies_parsed_at":"2022-09-21T18:02:27.195Z","dependency_job_id":null,"html_url":"https://github.com/perry-mitchell/gle","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"purl":"pkg:github/perry-mitchell/gle","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/perry-mitchell%2Fgle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/perry-mitchell%2Fgle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/perry-mitchell%2Fgle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/perry-mitchell%2Fgle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/perry-mitchell","download_url":"https://codeload.github.com/perry-mitchell/gle/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/perry-mitchell%2Fgle/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259509429,"owners_count":22868834,"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-10-07T23:41:23.623Z","updated_at":"2025-06-12T17:08:00.017Z","avatar_url":"https://github.com/perry-mitchell.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# GLE\n\u003e Global Log Engine: Environment-agnostic debugging \u0026 logging utility\n\nGLE is a logging and debugging utility which allows for easy application/library debug log output when flagged by environment variables.\n\nInspired by `debug`, but with additional support for more environments like:\n * NodeJS\n * Browsers\n * React-Native\n\n## Installation\n\nRun the following to install: `npm install gle --save`.\n\n## Usage\n\nImport one of the two following functions to start logging:\n\n```typescript\nimport { createLog, log } from \"gle\";\n\nconst logContext = createLog(\"my-app:core\");\nlogContext(\"test log\", \"some info\");\n\n// Or\n\nlog(\"my-app:core\", \"test log:\", \"some info\");\n```\n\n`createLog` builds a log function with the **context** already defined. It is generally better for performance, as well. `log` does everything on the fly, and requires a **context** in every call.\n\n\u003e A _context_ is a way to group logs together into some kind of logical \"area\" of your application or library.\n\nTo be able to _view_ these logs, the correct environment variable must be specified.\n\n### Displaying logs in the browser\n\nTo enable logging for a context in the browser, you can use something like the following:\n\n```typescript\nlocalStorage.debug = \"app:*\";\n```\n\n_Later:_\n\n```typescript\nimport { createLog, log } from \"gle\";\n\nconst logContext = createLog(\"app:websocket\");\nlogContext(\"connecting socket\");\n```\n\nWhich will display a log like the following in the browser's console:\n\n```\napp:websocket connecting socket +0ms\n```\n\n### Displaying logs in NodeJS\n\nTo enable logging for a context in a NodeJS app, set the `DEBUG` environment variable:\n\n```bash\nDEBUG=app:* node index.js\n```\n\n_Later, after building:_\n\n```typescript\nimport { createLog, log } from \"gle\";\n\nconst logContext = createLog(\"app:db\");\nlogContext(\"connecting database\");\n```\n\n### Log flags\n\nThe debug environment value can be made up of several different types of patterns:\n\n * A single context: `my-app:some:context`\n * Multiple contexts: `app:core,app:net`\n * A Negated context: `-app:test`\n * A combination: `-app:test,app:init`\n * Wild cards: `app:*`\n   * Multiple: `app:*,system:*`\n   * Anywhere: `app:test,system:*:core`\n   * Negated: `-system:*`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fperry-mitchell%2Fgle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fperry-mitchell%2Fgle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fperry-mitchell%2Fgle/lists"}