trentm / node-bunyan

a simple and fast JSON logging module for node.js services
Other
7.15k stars 514 forks source link

Syntax Error Unexpected Token #358

Open BionanoDev opened 8 years ago

BionanoDev commented 8 years ago

Hello,

Just testing bunyan for the first time. Seeing errors from the CLI. I can see the logs generate properly and they look great, but when I run them through the cli for pretty printing I get an error.

var bunyan = require('bunyan');
var log = bunyan.createLogger({
            name: 'Knickers',
            src: true,
            streams: [{
                type: 'rotating-file',
                path: './Log/Knickers.log',
                period: '1d',   // daily rotation
                count: 3        // keep 3 back copies
            }]
        });
log.info('hello world');

Contents of the file look like this:

{"name":"Knickers","hostname":"BNM-227","pid":10200,"level":30,"msg":"hello world","time":"2016-02-22T22:49:13.318Z","src":{"file":"C:\\Projects\\bnm\\IrysView3\\Server\\Knickers\\App.js","line":26,"func":"App"},"v":0}

If I run this command I get this error:

node Knickers.log | bunyan -l info

SyntaxError: Unexpected token :
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:374:25)
    at Object.Module._extensions..js (module.js:417:10)
    at Module.load (module.js:344:32)
    at Function.Module._load (module.js:301:12)
    at Function.Module.runMain (module.js:442:10)
    at startup (node.js:136:18)
    at node.js:966:3
BionanoDev commented 8 years ago

That was on windows 7 pro.

BionanoDev commented 8 years ago

okay answered my own question. Feeling stupid.... Just needed to issue command like this:

bunyan Knickers.log

michaelnisi commented 8 years ago

No need to feel stupid, in your failed attempt you asked Node to open your log file.

BionanoDev commented 8 years ago

I followed the examples, but the examples were just piping the console output from the running program instead of from a file like I was attempting. Duh. Anyway feels like a nice library thanks.