{"id":18426152,"url":"https://github.com/wework/we-js-logger","last_synced_at":"2025-04-07T16:32:21.376Z","repository":{"id":12226078,"uuid":"71267313","full_name":"wework/we-js-logger","owner":"wework","description":"Universal logger with transports to Rollbar and Logentries. Uses bunyan under the hood.","archived":false,"fork":false,"pushed_at":"2022-03-30T12:19:18.000Z","size":5934,"stargazers_count":14,"open_issues_count":65,"forks_count":3,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-03-22T21:25:20.052Z","etag":null,"topics":["bunyan","logentries","logging","rollbar","universal","wework"],"latest_commit_sha":null,"homepage":"","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/wework.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":"2016-10-18T16:15:42.000Z","updated_at":"2019-07-10T14:21:15.000Z","dependencies_parsed_at":"2022-08-07T06:16:50.355Z","dependency_job_id":null,"html_url":"https://github.com/wework/we-js-logger","commit_stats":null,"previous_names":[],"tags_count":31,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wework%2Fwe-js-logger","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wework%2Fwe-js-logger/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wework%2Fwe-js-logger/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wework%2Fwe-js-logger/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wework","download_url":"https://codeload.github.com/wework/we-js-logger/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247688109,"owners_count":20979606,"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":["bunyan","logentries","logging","rollbar","universal","wework"],"created_at":"2024-11-06T05:07:01.934Z","updated_at":"2025-04-07T16:32:20.930Z","avatar_url":"https://github.com/wework.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"we-js-logger\n====================\n\n[![Build Status][travis-image]][travis-url]\n[![Coverage Status][coveralls-image]][coveralls-url]\n[![NPM version][npm-version-image]][npm-url]\n[![NPM downloads][npm-downloads-image]][npm-url]\n[![MIT License][license-image]][license-url]\n\n[![Sauce Test Status][saucelabs-image]][saucelabs-url]\n\n\u003eLogger for node processes and browser applications with transports to Rollbar and Logentries\n\n# Introduction\n\nThis is an opinionated logger for JS applications:\n\n- Uses [bunyan](https://github.com/trentm/node-bunyan), a JSON logger, under the hood\n- Transports logs to Logentries and/or Rollbar\n- Universal. Can be used in the browser and Node.js processes\n\n# Usage\n\n```js\nimport Logger from 'we-js-logger';\nconst log = new Logger({\n    name: 'my-logger',\n    environment: 'production',\n    level: 'debug',\n    codeVersion: process.env.SHA_VERSION,\n    logentriesToken: process.env.LOGENTRIES_TOKEN,\n    rollbarToken: process.env.ROLLBAR_TOKEN,\n    scrubFields: ['password'], // blacklist field keys being sent through logger\n});\n```\n\n## Node.js usage\n\nThis package can be used via `npm` and `node` with no special considerations.\n\n## Browser usage\n\nThis package exposes a `client` build for browser usage. It is referenced in the `browser` field of `package.json`, so module loaders that follow this spec will load it easily.\n\nFor example, we commonly use `webpack` to load this module.\n\n### Webpack Considerations\n\n*TODO document webpack setup*\n\n## Configuration\n\nSee https://github.com/wework/we-js-logger/blob/master/API.md#we-js-loggerutillogger for API documentation\n\n## Examples\n\n```js\nlog.fatal({ err }, 'Application crashing because something terrible happened.');\n\nlog.error({ err, req }, 'API request failed');\n\nlog.info({ action }, 'Something relevant happened')\n\nlog.debug({ event, action }, 'Something useful for developers happened');\n\n```\n\nSee https://github.com/trentm/node-bunyan#log-method-api for more detail.\n\n# Logentries Integration\n\n*More docs coming soon.*\n\nProviding the `Logger` constructor a `logentriesToken` option enables this transport.\n\n# Rollbar Integration\n\n## Node\nThis library will initialize Rollbar\nSee https://rollbar.com/docs/notifier/rollbar.js/#quick-start-server for documentation on setting up Rollbar for node processes.\n\n## Browser\nFor browser usage, this library expects Rollbar to be loaded via their quick-start script tag. This also allows Rollbar to capture any errors before the logger's initialization code, if that's important to you.\n\nSee https://rollbar.com/docs/notifier/rollbar.js/#quick-start-browser for documentation on setting up Rollbar for browser applications\n\n# Development\n\nIn lieu of a formal style guide, please ensure PRs follow the conventions present, and have been properly linted and tested. Feel free to open issues to discuss.\n\nBe aware this module is tested in both browser and node runtimes.\n\n## Available tasks\n\n### Build and test\nRuns all tests, static analysis, and bundle for distribution\n```shell\n$ npm start\n```\n\n### Test\nRuns browser and node tests\n```shell\n$ npm test\n```\n\nRuns browser tests via PhantomJS only\n```shell\n$ npm run test:browser\n```\n\nRuns browser tests via SauceLabs only\n```shell\n$ SAUCELABS=true npm run test:browser\n```\n\nRuns node tests only\n```shell\n$ npm run test:node\n```\n\n### TDD\nRuns browser and node tests in watch mode, re-bundles on src file change\n```shell\n$ npm run tdd\n```\n\n### Docs\nRegenerate `API.md` docs from JSDoc comments\n```shell\n$ npm run docs\n```\n\n### Bundle\nPackages client and node bundles for distribution, output to `/dist`\n```shell\n$ npm run bundle\n```\n\n### Distribute\nLints, cleans, bundles, and generates docs for distribution, output to `/dist`\n```shell\n$ npm run dist\n```\n\n### Release\nWe're using `np` to simplify publishing to git + npm. A changelog and docs are generated as part of this script.\n\n```shell\n$ npm run release \u003csemver level/version\u003e\n$ npm run release patch # patch release\n$ npm run release 100.10.1 # release specific version\n```\n\n\n\n[npm-url]: https://npmjs.org/package/we-js-logger\n[npm-version-image]: http://img.shields.io/npm/v/we-js-logger.svg?style=flat-square\n[npm-downloads-image]: http://img.shields.io/npm/dm/we-js-logger.svg?style=flat-square\n\n[coveralls-image]:https://coveralls.io/repos/github/wework/we-js-logger/badge.svg?branch=master\n[coveralls-url]:https://coveralls.io/github/wework/we-js-logger?branch=master\n\n[travis-url]:https://travis-ci.org/wework/we-js-logger\n[travis-image]: https://travis-ci.org/wework/we-js-logger.svg?branch=master\n\n[saucelabs-image]:https://saucelabs.com/browser-matrix/wework-we-js-logger.svg\n[saucelabs-url]:https://saucelabs.com/u/wework-we-js-logger\n\n[license-url]: LICENSE\n[license-image]: http://img.shields.io/badge/license-MIT-000000.svg?style=flat-square\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwework%2Fwe-js-logger","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwework%2Fwe-js-logger","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwework%2Fwe-js-logger/lists"}