{"id":22914453,"url":"https://github.com/communitysolidserver/global-logger-factory","last_synced_at":"2026-02-12T15:34:05.203Z","repository":{"id":255486999,"uuid":"852743946","full_name":"CommunitySolidServer/global-logger-factory","owner":"CommunitySolidServer","description":null,"archived":false,"fork":false,"pushed_at":"2026-01-26T07:27:57.000Z","size":446,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2026-01-26T21:44:00.770Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/CommunitySolidServer.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-09-05T10:51:51.000Z","updated_at":"2026-01-26T07:27:59.000Z","dependencies_parsed_at":"2025-10-15T19:02:50.038Z","dependency_job_id":"799c755c-5376-43bb-95ff-8c2aeb5a4fab","html_url":"https://github.com/CommunitySolidServer/global-logger-factory","commit_stats":null,"previous_names":["communitysolidserver/global-logger-factory"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/CommunitySolidServer/global-logger-factory","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CommunitySolidServer%2Fglobal-logger-factory","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CommunitySolidServer%2Fglobal-logger-factory/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CommunitySolidServer%2Fglobal-logger-factory/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CommunitySolidServer%2Fglobal-logger-factory/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CommunitySolidServer","download_url":"https://codeload.github.com/CommunitySolidServer/global-logger-factory/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CommunitySolidServer%2Fglobal-logger-factory/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29370548,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-12T08:51:36.827Z","status":"ssl_error","status_checked_at":"2026-02-12T08:51:26.849Z","response_time":55,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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-12-14T05:14:58.658Z","updated_at":"2026-02-12T15:34:05.178Z","avatar_url":"https://github.com/CommunitySolidServer.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Global logger factory\n\n[![npm version](https://badge.fury.io/js/global-logger-factory.svg)](https://www.npmjs.com/package/global-logger-factory)\n\nProvides utility functions to easily set up logging.\nDue to the nature of this library,\nany configuration changes you make have an effect on any library that makes use of it.\n\n## Creating a new logger\n\nThe `getLoggerFor` can be used inside a class as follows:\n\n```ts\nimport { getLoggerFor } from 'global-logger-factory';\n\nclass MyClass {\n  protected readonly logger = getLoggerFor(this);\n\n  public myFunction(): void {\n    this.logger.info('Something is happening');\n  }\n}\n```\n\nBy referencing the class itself in the `getLoggerFor` call, the class name can be used in the log messages.\nInstead of using `this`, a string can also be used.\n\n## Setting the logger factory\n\nTo define which kind of logger will be created when `getLoggerFor` is called,\n`setGlobalLoggerFactory` needs to be called with an instance of a `LoggerFactory`.\nThis library comes with a `WinstonLoggerFactory` that can be used.\n\n```ts\nimport { setGlobalLoggerFactory, WinstonLoggerFactory } from 'global-logger-factory';\n\nsetGlobalLoggerFactory(new WinstonLoggerFactory('info'));\n```\n\nAfter calling this, all calls to `getLoggerFor` will return a logger created by that factory.\nCalls to `getLoggerFor`, and calls to the resulting loggers,\nwill be buffered until `setGlobalLoggerFactory` is called,\nafter which all messages will be emitted through the logger created by the new factory.\n\nIn case `setGlobalLoggerFactory` is not called before the buffer is full,\nit is assumed a factory will not be set and the buffer is cleared and all following log messages will be ignored.\n\nThere is also a `VoidLoggerFactory` which simply disables logging.\n\n## Setting the log level\n\nThe `WinstonLoggerFactory` takes as input the level of logged messages that should be emitted.\n`new WinstonLoggerFactory('error')` will only emit error messages,\nwhile `new WinstonLoggerFactory('info')` will emit error, warning, and info messages.\n\n## Components.js\n\nComponent.js components are generated for each of the classes.\n`config/logger.json` shows an example of how to set up a `WinstonLoggerFactory`,\nusing a Components.js variable to set the log level.\n\nThis exact configuration can be used directly into your own Components.js configuration by importing\n`glf:config/logger.json`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcommunitysolidserver%2Fglobal-logger-factory","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcommunitysolidserver%2Fglobal-logger-factory","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcommunitysolidserver%2Fglobal-logger-factory/lists"}