cargomedia / cm-janus

UNMAINTAINED. cm/janus bridge
MIT License
2 stars 6 forks source link

Log JSON #213

Closed njam closed 8 years ago

njam commented 8 years ago

Each document should have:

vogdb commented 8 years ago

Currently time contains datetime in the format: 2016-03-18T14:52:24.922Z. Should it be changed to 2016-03-18 14:52:24? @njam @tomaszdurka

tomaszdurka commented 8 years ago

What should be our logger interface?

vogdb commented 8 years ago

It's about sprintf. Log4js supports sprtinf. That is why we are doing this magic. I just took it from https://github.com/gabe0x02/log4js-json-layout. Reworking it now.

So, what about date? You didn't answer.

vogdb commented 8 years ago

What should be our logger interface?

I'm afraid I didn't understand your question. We have log4js interface. https://github.com/nomiddlename/log4js-node#usage

tomaszdurka commented 8 years ago

Yes, we use log4js interface, but as you can see log4js accepts data which can be either string or anything else. I think in case of simple string we should push it into to_json's message field, and in case of object we should probably merge it to top to_json level. Makes sense?

vogdb commented 8 years ago

ok

vogdb commented 8 years ago

@tomaszdurka Will be this fine?

log.info('meet me at %s', 'hello', {foo: 'bar'});

=>

{"time":"2016-03-18T18:01:00.799Z","level":"INFO","message":"meet me at hello","extra":{"foo":"bar"}}
vogdb commented 8 years ago

@tomaszdurka please share your adjustments!

njam commented 8 years ago

Let's use ISO 8601 datetime formatting:

2016-03-18T22:00:00+01:00

I guess it should be easy to obtain in JS!

vogdb commented 8 years ago

Well. toISOString claims to use ISO 8601 but it looks different than yours.

The toISOString() method returns a string in simplified extended ISO format (ISO 8601)

var today = new Date('05 October 2011 14:48 UTC');
console.log(today.toISOString()); // Returns 2011-10-05T14:48:00.000Z

from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString

Should I implement your format?

vogdb commented 8 years ago

Honestly I don't insist on any method. Just want to clarify. You can easily say that you want some format and I will implement it :)

njam commented 8 years ago

2016-03-18T22:00:00Z works fine too!

vogdb commented 8 years ago

done! Please look

njam commented 8 years ago

Ok, here's some final details about how the JSON should look:

{
  "timestamp": "2016-03-23T07:40:01Z",
  "message": "my msg",
  "level": "warning",
  "tags": {
    "tag1": "v1",
    "tag2": "v2"
  },
  "extra1": "v3",
  "extra2": "v3"
}

Anything that we want to segment by should go to tags (all the context info!). Additional information that's useful to understand what a record is about should be on the top level (in the example called extra{1,2}).

tomaszdurka commented 8 years ago

Paired with @vogdb, @vogdb please confirm