Giter Club home page Giter Club logo

minlog's People

Contributors

iansavchenko avatar jobackman avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

minlog's Issues

Column number is sometimes "undefined" in log output

Both Andreas F and I have encountered this problem. Although not a big problem it can be quite confusing the first time seeing it.

So far, we have not seen any clear pattern of what is causing this.

We had a hypothesis that it something to do with deploying a lambda from the terminal (vs deployed from Travis) but when tested it worked also for this case.

MinLog crashes without `serializeTime` serializer

In the minimal setup like

let {
  MinLog,
  logToConsole
} = require('./src/index');

let logger = new MinLog({
  listeners: [
    logToConsole({
      level: 'INFO'
    })
  ],
  serializers: []
});
logger.info('test');

crashes with

(node:75745) UnhandledPromiseRejectionWarning: TypeError: (0 , _moment.default)(
...).utcOffset(...).toISOString is not a function
    at Object.toISOString [as serialize] (/Users/isao/code/github/TobiiPro/minlo
g/src/listeners/log-to-console.js:56:73)
    at /Users/isao/code/github/TobiiPro/minlog/src/listeners/log-to-console.js:2
02:9
    at MinLog.listener [as log] (/Users/isao/code/github/TobiiPro/minlog/src/min
log.js:142:13)
    at apply (/Users/isao/code/github/TobiiPro/minlog/node_modules/lodash/lodash
.js:478:17)
    at MinLog.wrapper [as info] (/Users/isao/code/github/TobiiPro/minlog/node_mo
dules/lodash/lodash.js:5323:16)
    at Object.info (/Users/isao/code/github/TobiiPro/minlog/test.js:16:8)
    at Module._compile (internal/modules/cjs/loader.js:721:30)
    at Module._compile (/Users/isao/code/github/TobiiPro/minlog/node_modules/pir
ates/lib/index.js:99:24)
    at Module._extensions..js (internal/modules/cjs/loader.js:732:10)
    at Object.newLoader [as .js] (/Users/isao/code/github/TobiiPro/minlog/node_m
odules/pirates/lib/index.js:104:7)

fix console formatting

  • indentation
  • references, see [Object]
2019-02-18T15:30:30.204Z        9e0091ed-1e7c-4ad4-a8ea-8681870c616a    2019-02-18T15:30:30.182Z TRACE in the ? context:

Logger started. TRACE
{ _arg0: 'Logger started. TRACE' }
{ _arg1:
{ e:
{ resource: '/sql',
path: '/sql',
httpMethod: 'POST',
headers: [Object],

remove timestamp from console inside aws lambda

aws lambda monkey-patches console functions to add timestamps themselves... so log entries show up as

2019-02-18T15:30:30.203Z 9e0091ed-1e7c-4ad4-a8ea-8681870c616a 2019-02-18T15:30:30.182Z TRACE in the ? context:

MinLog lambda does not log constructed objects (i.e. created with classes)

Repro example:

let {
  MinLog,
  logToConsole,
  serializeTime
} = require('./src/index');

let logger = new MinLog({
  listeners: [
    logToConsole({
      level: 'INFO'
    })
  ],
  serializers: [
    serializeTime
  ]
});

let A = class {
  constructor() {
    this.test = 'test';
  }
};

logger.info('test', new A());

Receiving:

2019-03-01T15:54:36.047Z  INFO
test

Expected: probably, MinLog should call toString of the object.

performance

out of curiousity I just ran the basic benchmarking available at https://github.com/pinojs/pino npm run bench-basic

BASIC benchmark averages
Bunyan average: 680.751ms
Winston average: 496.127ms
Bole average: 375.836ms
Debug average: 328.526ms
LogLevel average: 328.303ms
MinLog average: 474.515ms
Pino average: 240.441ms
PinoExtreme average: 103.965ms
PinoNodeStream average: 219.996ms

I identified some red flags, that when/if removed takes minlog to:

BASIC benchmark averages
Bunyan average: 707.045ms
Winston average: 1885.363ms
Bole average: 627.995ms
Debug average: 416.026ms
LogLevel average: 452.593ms
MinLog average: 196.916ms
Pino average: 287.970ms
PinoExtreme average: 131.185ms
PinoNodeStream average: 283.553ms

red flags:

  • new Date() --- could consider Date.now()
  • getCallerInfo --- could be optional
  • rawEntry --- cloneDeep is expensive, could be optional

console listener mixes object arguments

Minimal reproduce code

let {
  MinLog,
  logToConsole,
  serializeTime
} = require('./src/index');

let logger = new MinLog({
  listeners: [
    logToConsole({
      level: 'INFO'
    })
  ],
  serializers: [
    serializeTime
  ]
});

logger.info('test', {
  obj: 'a'
}, {
  hej: 'b'
}, {
  yo: 'c'
});

Receiving in console:

2019-03-01T14:38:24.860Z  INFO
test
{
  "hej": "b"
}
{
  "obj": "a"
}
{
  "yo": "c"
}

Expected: objects to be in order like a, b, c

Logging large objects messes up AWS CloudWatch console

Logging a return value from a call to axios in an AWS lambda function using minlog messed up the CloudWatch console so that log entries was not shown and the ones that were shown were incomplete and difficult to read. Probably because the stringified version of the object got very long.

Logging it with console.log worked fine and did not have that effect.

Confusing error message when calling with incorrect log level

When calling minlog e.g. like this:

  logger.log('foo');

there will be an error thrown stating:
Error: Unknown level name . Known: time,fatal,verbose,silly,emergency,alert,critical,error,warning,notice,informational,debug,warn,info,trace.

The log level used is not specified in the error message (which seems to be the intention).

image

stringify also in the browser

when logging in the browser, you log references, which in turns means that anything that is folded may not accurate when you unfold. see https://stackoverflow.com/questions/5223513/why-doesnt-console-log-take-a-snapshot-of-the-passed-variables

this is only possible in the browser, and the benefit of logging references versus snapshots are closer to corner cases, as in it happens seldom, and when you do it you do not expect that log entry to ever change

a suggestion would be that minlog could be configurable to log snapshots instead, and MinLog::ref(variable) would be a function that returns a MinLog.Ref instance, that when logged would make MinLog to log the variable instead of the snapshot.

minlog.info(window); // log a snapshot of window, probably not performant at all
minlog.info(minlog.ref(window)); // log a reference of window, just like console.log does

relevant code in minlog/src/listeners/log-to-console.js, line 219 extraArgs.push(value); could be changed to say extraArgs.push(value instanceOf MinLog.Ref ? value : JSON.parse(fastSafeStringify(value)));

feat: allow sampling serializers

basically if a serializer returns undefined, shortcircuit the logging (don't call the rest of the serializers, and don't call the listeners)

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.