Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
lib: graylog: don't create an _id field
_id screws up graylog, don't do it.
  • Loading branch information
Brandon Philips committed Nov 27, 2012
1 parent 06d71f7 commit 58005f1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions lib/graylog.js
Expand Up @@ -83,6 +83,14 @@ exports.logstr = function(module, level, message, obj) {
if (i == 'full_message') { if (i == 'full_message') {
l['full_message'] = obj[i]; l['full_message'] = obj[i];
} }
/* Avoid getting a warning from graylog:
*
* WARN : org.graylog2.messagehandlers.syslog.SyslogEventHandler - \
* Client tried to override _id field! Skipped field, but still storing message.
*/
else if (i == 'id') {
l["_objid"] = obj[i];
}
else { else {
l["_" + i] = obj[i]; l["_" + i] = obj[i];
} }
Expand Down
2 changes: 1 addition & 1 deletion tests/t.js
Expand Up @@ -11,7 +11,7 @@ logmagic.route("__root__", logmagic.TRACE1, "graylog2-stderr");
log.trace("testing trace v1", {slug: 1}); log.trace("testing trace v1", {slug: 1});


log = logmagic.local('mylib.foo.cars'); log = logmagic.local('mylib.foo.cars');
log.trace("hello world", {counter: 33, account_id: 42, txnid: "fxxxxx"}); log.trace("hello world", {counter: 33, account_id: 42, txnid: "fxxxxx", id: "i'm an id, screwing stuff up"});
logmagic.addRewriter(function(modulename, level, msg, extra) { logmagic.addRewriter(function(modulename, level, msg, extra) {
if (extra.request) { if (extra.request) {
extra.accountId = extra.request.account.id; extra.accountId = extra.request.account.id;
Expand Down

0 comments on commit 58005f1

Please sign in to comment.