Skip to content

Instantly share code, notes, and snippets.

@adam-hert
Last active June 12, 2017 22:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save adam-hert/3be216388577cc4ac253e7af8c968914 to your computer and use it in GitHub Desktop.
Save adam-hert/3be216388577cc4ac253e7af8c968914 to your computer and use it in GitHub Desktop.
winston and buffers
var winston = require('winston');
require('winston-papertrail').Papertrail
const winstonConsole = new winston.transports.Console()
const winstonPapertrail = new winston.transports.Papertrail({
host: 'logs5.papertrailapp.com',
port: xxxx,
flushOnClose: true,
})
const logger = new winston.Logger({
transports: [winstonConsole, winstonPapertrail],
});
function blockCpuFor(ms,callback) {
var start = new Date().getTime();
var result = 0
while(true) {
result += Math.random() * Math.random();
time_so_far = new Date().getTime() - start
if (time_so_far > ms){
callback()
return;
}
}
}
function displayProgress() {
const message = `It's ${new Date()}`
logger.info(message)
}
function test_buffer(i){
blockCpuFor(2000,displayProgress)
return i
};
//create an array of length 30
var foo = [];
for (var i = 1; i <= 5; i++) {
foo.push(i);
}
var bar = foo.map(test_buffer)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment