Skip to content
This repository has been archived by the owner on Apr 26, 2022. It is now read-only.

Commit

Permalink
- problem with scoping
Browse files Browse the repository at this point in the history
  • Loading branch information
dennisoelkers committed Dec 8, 2011
1 parent 726145d commit e084b54
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions lib/gelf.js
Expand Up @@ -4,18 +4,9 @@ var zlib = require('zlib');
var Binary = require('binary');

function decode(buf) {
var gelf_header = Binary.parse(buf).word16lu('chunk_magic').vars;
var json;
switch(gelf_header['chunk_magic']) {
case '40056':
json = zlib.inflate(buf);
break;
case '35615':
logger.error('got GZIP message, trying to unzip');
json = zlib.Gunzip(buf);
break;
}
var json = uncompress(buf);

logger.error('got json: '+json);
return JSON.parse(json);
}

Expand All @@ -28,5 +19,18 @@ function encode(struc) {
return comp;
}

function uncompress(buf) {
var gelf_header = Binary.parse(buf).word16lu('chunk_magic').vars;
switch(gelf_header['chunk_magic']) {
case '40056':
return zlib.inflate(buf);
break;
case '35615':
logger.error('got GZIP message, trying to unzip');
return zlib.Gunzip(buf);
break;
}
}

exports.decode = decode;
exports.encode = encode;

0 comments on commit e084b54

Please sign in to comment.