Last active
June 12, 2017 22:33
-
-
Save adam-hert/3be216388577cc4ac253e7af8c968914 to your computer and use it in GitHub Desktop.
winston and buffers
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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