Giter Site home page Giter Site logo

Comments (5)

JaniAnttonen avatar JaniAnttonen commented on June 16, 2024

Nice find. Might want to take a closer look at the events winston listens to. I'll come back at you, but you're welcome to submit a solution if you find one :)

from winston-loki.

JaniAnttonen avatar JaniAnttonen commented on June 16, 2024

It is a bit weird though, if the logged event firing is the culprit. The index.js structure is based on https://github.com/winstonjs/winston/blob/bc6a363ec9164d03f266cab7c918d92208d2ec73/examples/custom-transport.js, that's why the logged event gets fired before the transport. Are you using batching or sending out logs as they come? Does changing that option change things?

from winston-loki.

JaniAnttonen avatar JaniAnttonen commented on June 16, 2024

#51 might have fixed this?

from winston-loki.

zabil avatar zabil commented on June 16, 2024

Hi, We see this issue where the logs are not completely shipped.

For reference here is the setup.

  logger = winston.createLogger({
    level,
    transports: [
      new LokiTransport({
        host: lokiHost,
        batching: false,
        format: json(),
        onConnectionError: (err) => console.error(err),
      }),
    ]
  });

 export default logger;

Usage in lambda

import log from "logger";

export const handler = async (event: S3ObjectEvent) => {
  log.info("Received S3 Notification event");
  // And other log events
}

We have noticed that not all the log statements are being sent, especially the ones at the end. We think this happens because the handler shuts down after the response.

Version info

    "node_modules/winston-loki": {
      "version": "6.0.6",
      "resolved": "https://registry.npmjs.org/winston-loki/-/winston-loki-6.0.6.tgz",
      ...

from winston-loki.

rlfrahm avatar rlfrahm commented on June 16, 2024

I'm encountering this issue as well. I'm using this for scripts run by ts-node, so my workaround has been to wait for 5 seconds at the end of the script before process.exit(0). I'm not sure what to do for an API endpoint for instance yet. I see there are some options to pass in to the LokiTransport constructor like timeout and gracefulShutdown, as well as flush() available from the class, but I've not tested a combo that solves this issue.

from winston-loki.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.