{"id":26339657,"url":"https://github.com/sramam/winston-cfg","last_synced_at":"2026-02-17T17:31:38.660Z","repository":{"id":57398012,"uuid":"84475470","full_name":"sramam/winston-cfg","owner":"sramam","description":"Enables winston configuration via node-config","archived":false,"fork":false,"pushed_at":"2023-06-22T02:28:52.000Z","size":275,"stargazers_count":2,"open_issues_count":6,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-08T06:34:13.463Z","etag":null,"topics":["config","node-config","npm","winston"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sramam.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"code-of-conduct.md","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":"2017-03-09T18:30:35.000Z","updated_at":"2021-05-07T23:25:24.000Z","dependencies_parsed_at":"2024-11-10T00:02:11.521Z","dependency_job_id":"c91d0392-3de8-474e-a7ee-11cb0a90dc6e","html_url":"https://github.com/sramam/winston-cfg","commit_stats":{"total_commits":35,"total_committers":1,"mean_commits":35.0,"dds":0.0,"last_synced_commit":"ed207662f34ad9ffc304df1e1b202e04259dcd19"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sramam%2Fwinston-cfg","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sramam%2Fwinston-cfg/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sramam%2Fwinston-cfg/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sramam%2Fwinston-cfg/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sramam","download_url":"https://codeload.github.com/sramam/winston-cfg/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243818406,"owners_count":20352665,"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":["config","node-config","npm","winston"],"created_at":"2025-03-16T03:18:45.509Z","updated_at":"2026-02-17T17:31:38.642Z","avatar_url":"https://github.com/sramam.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# winston-cfg\n\nTHIS MODULE IS NO LONGER ACTIVELY MAINTAINED.\n\n\u003c!-- badge --\u003e\n[![npm license](https://img.shields.io/npm/l/winston-cfg.svg)](https://www.npmjs.com/package/winston-cfg)\n[![travis status](https://img.shields.io/travis/sramam/winston-cfg.svg)](https://travis-ci.org/sramam/winston-cfg)\n[![Build status](https://ci.appveyor.com/api/projects/status/g7ev07vefgqxl70x?svg=true)](https://ci.appveyor.com/project/sramam/winston-cfg)\n[![Coverage Status](https://coveralls.io/repos/github/sramam/winston-cfg/badge.svg?branch=master)](https://coveralls.io/github/sramam/winston-cfg?branch=master)\n[![David](https://david-dm.org/sramam/winston-cfg/status.svg)](https://david-dm.org/sramam/winston-cfg)\n[![David](https://david-dm.org/sramam/winston-cfg/dev-status.svg)](https://david-dm.org/sramam/winston-cfg?type=dev)\n\u003cbr/\u003e\n[![NPM](https://nodei.co/npm/winston-cfg.png?downloads=true\u0026downloadRank=true\u0026stars=true)](https://nodei.co/npm/winston-cfg/)\n\u003c!-- endbadge --\u003e\n\nA simple utility that enables [winston](https://github.com/winstonjs/winston) configuration via [node-config](https://github.com/lorenwest/node-config)\n\n## Usage\n\n### A brief introduction to winston internals\n\nFor most common use cases, there are three things that one needs to configure with winston:\n\n1. _transports_: the destination(s) for the logs. Winston provides a few out of the box. Transports with external dependencies,  with external dependencies are supported as 3rd party modules. Depending on the actual transport, some have pretty involved configuration.\n1. _loggers_: an ability to segment logging capability, for example by application layer (app, http, db etc). Each logger can have multiple transports - either the global or a custom set.\n1. _default logger_: `winston` instantiate a default logger that is configured with a 'Console' transport and set to 'info' level. This can be configured in exactly the same manner as any logger.\n\n```bash\n                 +-------------------------------------------+\n                 |            winston configuration          |\n+-------------+  |                                           |\n| APPLICATION    |       +----------+                        |\n|             |  |  +--\u003e | Default  +--+                     |\n|             |  |  |    +----------+  |                     |\n| +---------+ |  |  |    +----------+  |   +-------------+   |\n| | Layer 1 +----------\u003e | Logger 1 +-+--\u003e | Transport A +---------\u003e\n| +---------+ |  |       +----------+ |    +-------------+   |\n|     ...     |  |                    |                      |\n| +---------+ |  |       +----------+ +--\u003e +-------------+   |\n| | Layer N +----------\u003e | Logger 1 +----\u003e | Transport B +---------\u003e\n| +---------+ |  |       +----------+      +-------------+   |\n+-------------+  |                                           |\n                 |                                           |\n                 +-------------------------------------------+\n\n```\n\n### Simple Configuraton\n\nPlease see the interface definition in [src/index.ts:Config](https://github.com/sramam/winston-cfg/blob/master/src/index.ts#L10) for details\non valid config settings.\n\nAnd [node-config](https://github.com/lorenwest/node-config) for use of the config module.\n\n```json\n// in config/defaults.json\n{\n  \"winston\": {\n    \"level\": \"info\",\n    \"transports\": [{\n      \"type\": \"Console\"\n    }]\n  }\n}\n```\n\n```javascript\nconst log = require('winston-cfg').winstonCfg();\n```\n\n```typescript\nimport { winstonCfg } from 'winston-cfg';\nconst log = winstongCfg();\n```\n\n### Advanced Configuration\n\n#### transportMap\n\nSince transports may be external modules, `winston` expects to be provided\ninstances of transports associated with a logger - global or custom.\n\nWe are however attempting to expose only the config capability. As a compromise, `winston-cfg` adds a 'type' property to the config. The application also has to instantiate a `transportMap`, which allows the `winston-cfg` to create\nappropriate transports before instantiating loggers.\n\nBy default, `winston-core` supports four transports: `Console`, `File`, `Http` \u0026 `Memory`. Additionally, [3rd-party transports](https://github.com/winstonjs/winston/blob/master/docs/transports.md)\nextend support for other storage mechanisms.\n\n##### Config file\n\nPlease see the interface definition in [src/index.ts:Config](https://github.com/sramam/winston-cfg/blob/master/src/index.ts#L10) for details\non valid config settings.\n\nAnd [node-config](https://github.com/lorenwest/node-config) for use of the config module.\n\n```json\n{\n  \"winston\": {\n    \"level\": \"info\",\n    \"transports\": [\n      {\n        \"type\": \"Console\"\n      },\n      {\n        \"type\": \"File\",\n        \"filename\": \"./winston.log\"\n      },\n      {\n        \"type\": \"CouchDB\",\n        // ... CouchDb Config.\n      }\n    ],\n    \"loggers\": [{\n      \"id\": \"app\",\n      \"level\": \"info\",\n      \"transports\": [{\n        \"type\": \"SimpleDB\",\n        // ...\n      }],\n    }, {\n      \"id\": \"http\"\n    }]\n  }\n}\n```\n\n##### TypeScript boilerplate\n\n```typescript\n\n// do this in your application startup\n\nimport { winstonCfg } from 'winston-cfg';\n\n// import custom transports\nimport { Couchdb as CouchDB } from 'winston-couchdb';\nimport { SimpleDB } from 'winston-simpledb';\n\n// prepare a transport map for initialization\nconst transportMap = {\n  'CouchDB': CouchDB,\n  'SimpleDB': SimpleDB\n};\n\n// read config and initialize winston appropriately.\n// See [node-config](https://github.com/lorenwest/node-config) for details.\nconst winston = winstonCfg(transportMap);\n\n// get handles to individual loggers\nconst log = winston; // default logger\nconst app_log = winston.loggers.get('app');\nconst http_log = winston.loggers.get('http');\n\n// use log, app_log \u0026 http_log as needed.\n```\n\n##### JavaScript boilerplate\n\n```js\nconst logger = 'winston-cfg';\n\n// import custom transports\nconst CouchDB = require('winston-couchdb').CouchDb;\nconst SimpleDB = require('winston-simpledb').SimpleDB;\n\n// prepare a transport map for initialization\nconst transportMap = {\n  'CouchDB': CouchDB,\n  'SimpleDB': SimpleDB\n};\n\n// read config and initialize winston appropriately.\n// See [node-config](https://github.com/lorenwest/node-config) for details.\nconst winston = winstonCfg(transportMap);\n\n// get handles to individual loggers\nconst log = winston; // default logger\nconst app_log = winston.loggers.get('app');\nconst http_log = winston.loggers.get('http');\n\n// use log, app_log \u0026 http_log as needed.\n```\n\n## License\n\nApache 2.0\n\n## Code of Conduct\n\nPlease note that this project is released with a [Contributor Code of Conduct](code-of-conduct.md).\nBy participating in this project you agree to abide by its terms.\n\n## Support\n\nBugs, PRs, comments, suggestions are all welcomed!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsramam%2Fwinston-cfg","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsramam%2Fwinston-cfg","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsramam%2Fwinston-cfg/lists"}