Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do Winston's log streams work?
    primarykey
    data
    text
    <p>The <a href="https://github.com/flatiron/winston" rel="noreferrer">Winston</a> documentation has a section on <a href="https://github.com/flatiron/winston#streaming-logs" rel="noreferrer">streaming logs</a> which says:</p> <blockquote> <p>Streaming allows you to stream your logs back from your chosen transport.</p> </blockquote> <p>and gives the following code example:</p> <pre><code>// // Start at the end. // winston.stream({ start: -1 }).on('log', function(log) { console.log(log); }); </code></pre> <p>My reading of this is that each new log message added would be output to the console. The <code>{start: -1}</code> config tells the stream to start at the end of the file, so only new log entries are output. I expect the following Node script would result in each existing line of the <code>test.log</code> file being output to the console, and then a new object to be output every 500ms thereafter.</p> <pre><code>var winston = require('winston'); winston.add(winston.transports.File, { filename: 'test.log' }); winston.remove(winston.transports.Console); winston.stream().on('log', function(log) { console.log(log); }); setInterval(function(){ winston.log('info', 'help'); }, 500); </code></pre> <p>I would expect to see something like the following output:</p> <pre><code>{"level":"info","message":"help","timestamp":"2013-12-10T05:55:15.806Z"} {"level":"info","message":"help","timestamp":"2013-12-10T05:55:16.307Z"} {"level":"info","message":"help","timestamp":"2013-12-10T05:55:16.809Z"} {"level":"info","message":"help","timestamp":"2013-12-10T05:55:17.309Z"} {"level":"info","message":"help","timestamp":"2013-12-10T05:56:48.316Z"} </code></pre> <p>What actually occurs is that the logging works as expected with the File transport (the file gets a new log entry every 500ms) but there is no output to the console. The <code>console.log(log)</code> line is never called. </p> <p>Have I missed something obvious, or misunderstood the purpose of Winston's log streams? </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload