Skip to content
This repository was archived by the owner on Jan 14, 2020. It is now read-only.

Step up our logging game#229

Merged
cmcavoy merged 9 commits intov2.0from
217-keep-the-fire
Jun 17, 2013
Merged

Step up our logging game#229
cmcavoy merged 9 commits intov2.0from
217-keep-the-fire

Conversation

@brianloveswords
Copy link
Copy Markdown
Contributor

Fixes #217

* Swap out `winston` for `bunyan`
* Monkey patch `console` so it always outputs to stderr
* Add 'uncaughtException' handler and log exceptions as a fatal event
  before crashing the application.
* Implement custom request logger similar to `connect.logger()`
The way the `console` object is constructed changed between v0.8 and
v0.10. In the latest version of node the object is built from a
constructor and conveniently has _stdout and _stderr properties which
are references to streams which console will treat as stdout and
stderr. In v0.8 the console object is a singleton by virtue of the
methods being directly exported, and worse, the functions write to
process.stdout and process.stderr directly.
And by that I mean I cobbled together a script (bin/messina.js) to
shuttle log events off to a Graylog instance (ours happens to be called
"loggins").

Note: It's mostly cobbled together by tearing apart the source of
bunyan's CLI tool. I'd like to re-write it to be more testable.
* Makefile: `make` now starts the server and pipes stdout through bunyan to get
  readable logs
* readme.md: update with information about the configuration environment
  variables necessary for bin/messina
* [rename] bin/messina.js -> bin/messina
@brianloveswords
Copy link
Copy Markdown
Contributor Author

The Makefile has been updated so the default start server task automatically pipes through a formatter – just running node app.js will spit out raw json for every event.

The raw logs look like this
log

The formatted logs look like this:
log

When piping through bin/messina to send to Graylog, it gets parsed something like this:
log

bin/messina also echos out what's being put in, so it's entirely possible to do node app.js | bin/messina | bunyan to get formatted logs on the console as well as aggregation through graylog.

@brianloveswords
Copy link
Copy Markdown
Contributor Author

Okay, this is pretty much ready I think.

@cmcavoy, @jdotpz to review, @toolness to chastise me for not including tests (I still want modularize & test bin/messina, but I didn't want to have good logs wait on it).

@jdotpz
Copy link
Copy Markdown
Contributor

jdotpz commented Jun 13, 2013

furiousclap

cc @jbuck !

@jdotpz
Copy link
Copy Markdown
Contributor

jdotpz commented Jun 14, 2013

Drats, the one big doh is that using Foreman, it adds about 19 characters to the line, and I have not yet found a good combination of cut, passing variables, and getting gelf working.

foreman start -f Procfile|cut -c19- | GRAYLOG_HOST="loggins.mofoprod.net" GRAYLOG_PORT=12201 GRAYLOG_FACILITY="gelf" ./bin/messina

that works!! Yeah, just not in upstart...yet.

cmcavoy added a commit that referenced this pull request Jun 17, 2013
@cmcavoy cmcavoy merged commit 1d1e2c6 into v2.0 Jun 17, 2013
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Figure out how to get logs in a format for Graylog (loggins)

3 participants