Coder Social home page Coder Social logo

all-logs's Introduction

@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 <[email protected]> © 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 <[email protected]>

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.

all-logs's People

Contributors

bahmutov avatar renovate-bot avatar renovate[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

vladimir1412

all-logs's Issues

remove debuglog namespace and PID

When we capture util.debuglog message it contains the namespace and PID like this

VERBOSE 999: this is verbose debug = 42

We should skip the namespace and PID

Organize messages

For each message store:

  • source: console, util, debug that corresponds to the console logs, util.debuglog and debug module source
  • namespace. This is different per source
    • for source: console it will be "log", "warn", "error"
    • for util and debug it will be the namespace
  • message - fully formatted string

Action Required: Fix Renovate Configuration

There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.

Error type: Preset name not found within published preset config (monorepo:babel6). Note: this is a nested preset so please contact the preset author if you are unable to fix it yourself.

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Edited/Blocked

These updates have been manually edited so Renovate will no longer make changes. To discard all commits and start over, click on a checkbox.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

circleci
.circleci/config.yml
  • cypress/base 12.22.8
npm
package.json
  • strip-ansi 5.2.0
  • common-tags 1.8.2
  • execa-wrap 1.4.0
  • husky 3.1.0
  • lint-staged 9.5.0
  • mocha 6.2.3
  • mocha-banner 1.1.2
  • prettier 1.19.1
  • ramda 0.29.0
  • semantic-release 15.14.0
  • snap-shot-it 7.9.10
  • stop-only 3.3.1
test-debug-v2/package.json

  • Check this box to trigger a request for Renovate to run again on this repository

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.