@bahmutov/all-logs
Capture all console logs
Last updated a year ago by bahmutov .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @bahmutov/all-logs 
SYNC missed versions from official npm registry.

@bahmutov/all-logs renovate-app badge CircleCI

Goal

This module captures:

  • console.{log, warn, error} messages
  • all messages via debug module
  • all messages via util.debuglog

Use

npm install --save @bahmutov/all-logs

Then load this module before your CLI / server code. I suggest just requiring it before your normal module. For example, if normally you start your server like:

{
  "scripts": {
    "start": "node ./lib/server.js"
  }
}

Then you change it to simply be:

{
  "scripts": {
    "start": "node -r @bahmutov/all-logs ./lib/server.js"
  }
}

Note: when debug module is used in dependencies

This module tries to discover debug module in the current module's dependencies, and in all its immediate production dependencies. If it is possible to proxy (older versions of debug module are not compatible), then their logs will be intercepted and you will see debug logs from both your application and its immediate dependencies.

Message format

Each message object has type, namespace and the message text. It also contains a timestamp as ISO string. See src/index.d.ts for the exact interface definition.

Middleware

To expose captured log messages, use the included middleware

if (global.messages) {
  require('@bahmutov/all-logs/middleware/express')(app)
}
const http = require('http')
const logs = require('@bahmutov/all-logs/middleware/http')
http.createServer((req, res) => {
  if (logs(req, res) === true) {
    return
  }
  // your normal handler
})

Which adds GET|POST /__messages__ endpoint

See more

Development

Renovate

We are using RenovateBot to keep dependencies up to date. Find the settings in renovate.json file. Note that we ignore module debug since we are testing this module with older versions in subfolders.

Small print

Author: Gleb Bahmutov <gleb.bahmutov@gmail.com> © 2019

License: MIT - do anything with the code, but don't blame me if it does not work.

Support: if you find any problems with this module, email / tweet / open issue on Github

MIT License

Copyright (c) 2019 Gleb Bahmutov <gleb.bahmutov@gmail.com>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Current Tags

  • 1.8.1                                ...           latest (a year ago)

15 Versions

  • 1.8.1                                ...           a year ago
  • 1.8.0                                ...           a year ago
  • 1.7.1                                ...           a year ago
  • 1.7.0                                ...           a year ago
  • 1.6.0                                ...           a year ago
  • 1.5.2                                ...           a year ago
  • 1.5.1                                ...           a year ago
  • 1.5.0                                ...           2 years ago
  • 1.4.0                                ...           2 years ago
  • 1.3.2                                ...           2 years ago
  • 1.3.1                                ...           2 years ago
  • 1.3.0                                ...           2 years ago
  • 1.2.0                                ...           2 years ago
  • 1.1.0                                ...           2 years ago
  • 1.0.0                                ...           2 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 15
Dependencies (1)
Dev Dependencies (12)
Dependents (1)

Copyright 2014 - 2016 © taobao.org |