Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Logging from function that is called repeatedly #72

Open
jefffriesen opened this issue Jun 8, 2017 · 1 comment
Open

Logging from function that is called repeatedly #72

jefffriesen opened this issue Jun 8, 2017 · 1 comment

Comments

@jefffriesen
Copy link

I've got a node.js process that repeatedly maps over long-running functions. I'm trying to log that into Papertrail but I only get the first log showing up in Papertrail. It's a brand-new instance of Papertrail and I've checked that there are no log filters applied.

Two scenarios:

  1. If I control-c the process, I only get the first log in Papertrail (but all intermediate logs still go to the console)
  2. If I let the process finish, I get all of the backed-up logs showing up in Papertrail. But that defeats the purpose of seeing what's going one while it's running.

The function called repeatedly is displayProgress() shown below.

import winston from 'winston'
require('winston-papertrail').Papertrail

const winstonConsole = new winston.transports.Console()
const winstonPapertrail = new winston.transports.Papertrail({
  host: 'logsx.papertrailapp.com',
  port: xxxx,
  flushOnClose: true,
})

const logger = new winston.Logger({
  transports: [winstonConsole, winstonPapertrail],
})

export function displayProgress() {
  const message = `It's ${new Date()}`
  logger.info(message)

  // These don't fix the problem:
  // winstonPapertrail.on('connect', (message) => {
  //   logger && logger.info(message)
  // })
  //
  // winstonPapertrail.on('error', (err) => {
  //   logger && logger.error(err)
  // })
}

It's like it's storing it and then flushing it only at the end. I've tried flushOnClose as true and as false but neither solves the problem. Does the library not support this? Or is there a setting that I'm missing?

Thank you

@technoSpino
Copy link

I am also having this issue using the transport in an aws lamda

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants