{"id":17497444,"url":"https://github.com/miguelcastillo/loggero","last_synced_at":"2025-09-10T14:23:26.435Z","repository":{"id":143887433,"uuid":"41946971","full_name":"MiguelCastillo/loggero","owner":"MiguelCastillo","description":"Lightweight stream based logger","archived":false,"fork":false,"pushed_at":"2017-09-19T14:38:08.000Z","size":35,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-30T09:04:39.456Z","etag":null,"topics":[],"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/MiguelCastillo.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":"2015-09-05T03:06:23.000Z","updated_at":"2017-04-22T03:40:11.000Z","dependencies_parsed_at":"2023-07-18T13:18:35.456Z","dependency_job_id":null,"html_url":"https://github.com/MiguelCastillo/loggero","commit_stats":{"total_commits":41,"total_committers":2,"mean_commits":20.5,"dds":0.2682926829268293,"last_synced_commit":"3c9795d81a5a563c14cacbd0e7b015d50ae32766"},"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/MiguelCastillo/loggero","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MiguelCastillo%2Floggero","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MiguelCastillo%2Floggero/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MiguelCastillo%2Floggero/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MiguelCastillo%2Floggero/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MiguelCastillo","download_url":"https://codeload.github.com/MiguelCastillo/loggero/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MiguelCastillo%2Floggero/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264086654,"owners_count":23555375,"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-19T15:47:21.097Z","updated_at":"2025-07-07T13:35:43.492Z","avatar_url":"https://github.com/MiguelCastillo.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## loggero\n\n\u003e Lightweight stream based logger\n\n\n## Examples\n\nA few examples can be found [here](https://github.com/MiguelCastillo/loggero/tree/master/examples).\n\n\n## API\n\n\u003e Logger comes with a default logger instance called `global`.\n\n### create(name, options)\n\nFactory method to create loggers with a particular name. Options are\n\n1. **enabled** [boolean] - Flag to create the logger in a enabled/disabled state. *Default - true*.\n2. **stream** [WritableStream] - Stream to write messages to.  If a stream isn't provided, the global logger's stream will be used, which defaults to console. *Default - undefined*.\n3. **level** [levels] - Minimum level for messages to be logged. If a level isn't provided, the global logger's level will be used, which defaults to `info`. *Default - undefined*.\n\n``` javascript\nvar loggero = require('loggero');\n\nvar logger = loggero.create('OhWoW', {\n  enabled: false,\n  level: loggero.levels.warn\n});\n```\n\n### levels\n\n`levels` are enums that represent a threshold for logging messages. Meaning, that only messages of equal or higher level will be logged. The lowest level is `info` and the highest level is `error`. If custom levels are used, they will follow the same processing logic for determing if a particular message should be logged. For custom levels, you will need to specfy values higher than `error` which is 3.\n\nThe different values are\n\n1. `info` - alias `log`.\n2. `warn`.\n3. `error`.\n\nThe following example we configure the `global` logger to log warnings and errors.  Also a few messages are logged to illustrate the logging interface.\n\n```\nvar logger = require('loggero');\n\nlogger\n  .level(logger.levels.warn)\n  .log('Message 1')\n  .warn('Warning 1')\n  .error('Error 1');\n```\n\n### find(name)\n\nMethod to find a logger by name.\n\nIn the example below, we search for the logger called `OhWoW`, configure its logging level, and log a few messages.\n\n```\nvar logger = require('loggero');\n\nlogger\n  .find('OhWoW')\n  .level(logger.levels.info)\n  .log('Message 1')\n  .warn('Warning 1')\n  .error('Error 1');\n```\n\n### pipe(stream)\n\nMethod to setup the stream the logger writes to. Currently, a logger can only have one stream.\n\nThe example below shows how the default `global` logger is piped to `JSONStream`, and then piped to `process.stdout`. The output format is [JSONLines](http://jsonlines.org/).\n\n```\nvar JSONStream = require('JSONStream');\nvar logger = require('loggero');\n\nlogger\n  .pipe(JSONStream.stringify(false))\n  .pipe(process.stdout);\n\nlogger\n  .warn('A warning', 'cup cakes are low')\n  .error('An error', 'cup cakes ran out', 'buy more')\n  .log('message 12');\n```\n\n### write(level, data)\n\nGeneric method to log messages. Call this if you are looking to write messages with a custom level. This method is what logger uses internally to log messages, warnings, and errors.\n\n\n### log(message, ...)\n\nMethod to log `info` messages.\n\n\n### info(message, ...)\n\nAlias for the `log` method.  Use whichever is more suitable for your taste.\n\n\n### warn(message, ...)\n\nMethod to log warnings.\n\n\n### error(message, ...)\n\nMethod to log errors.\n\n\n### enable()\n\nMethod to enable message logging.\n\n\n### disable()\n\nMethod to disable messages logging.\n\n\n### only()\n\nMethod to quickly disable ALL logger but the logger `only()` was called on. Only one logger can be set to `only`.  If one is already set to `only`, the call is a noop.\n\n\n### all()\n\nMethod that removes the `only` filter.\n\n\n### enableAll()\n\nMethod to enable all loggers; global `enable`.  When this is called, all logger will log. `only` and `level` will still determine whether or not a logger instance can actually log a message.\n\n\n### disableAll()\n\nThis disables the global enable flag. If this is called, then no logger will be able to log messages of any kind.\n\n\n### level(level)\n\nMinimum level a message must have in order to be logged.  For example, if the current level is `warn`, the only `warn` and `error` will be logged. Please see [levels](#levels) for the list of values.\n\n\n## Licensed under MIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmiguelcastillo%2Floggero","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmiguelcastillo%2Floggero","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmiguelcastillo%2Floggero/lists"}