Git Product home page Git Product logo

Comments (7)

okkez avatar okkez commented on August 23, 2024

fluentSender.end() will close socket immediately.
If you want to wait processing the last message, you can use requireAckResponse option and fluentSender.end("label", {"message": "some message"}).

from fluent-logger-node.

okkez avatar okkez commented on August 23, 2024

@nikhilkakade2108 Please read winston section in README.md.

from fluent-logger-node.

nikhilkakade2108 avatar nikhilkakade2108 commented on August 23, 2024

I added requireAckResponse: true in config, but it is not working for me. The problem here is, I cannot use support.winstonTransport() due to some limitations (I need to add lambdaname by default in every log statement). Is there any other way to end the fluentdSender with all logs flushed at back-end and without using setTimeout()?

The question I have is, what is difference between using support.winstonTransport() and createFluentSender(), because former works properly without any setTimeout()?

calling emit() manually for fluentdSender and ending the connection doesn't send a single log in backend.

from fluent-logger-node.

okkez avatar okkez commented on August 23, 2024

Hmm, your code in first comment is not same as sample code in README.md.
It seems that you don't use winston transport for fluent-logger in your code above.

Which do you want to use fluent-logger's winston support or raw FluentSender?

Could you show me minimal reproducible code?
I could not imagine your situation enough.

from fluent-logger-node.

nikhilkakade2108 avatar nikhilkakade2108 commented on August 23, 2024

yes I am using raw FluentSender. Please refer this code.

var winston=require('winston');
var logger = new (winston.Logger)({
  transports: [new (winston.transports.Console)()]
});

var fluentdSender = require('fluent-logger').createFluentSender('myTag', {
   host: 'localhost',
   port: 24224,
   timeout: 3.0,
   reconnectInterval: 600000
});

logger.on('logging', (transport, level, message, meta) => {
  var data={"message":message,"requestId":"21081","environment":environment,"level":level};
    fluentdSender.emit('',data);
    if (meta.end) {
      fluentdSender.end();
    }
 });

 logger.info('start logging');
 logger.info('something something');
 logger.info('end logging',{end:true});

I cannot see any logs at Fluentd end with above code.
If I add setTimeout(()=>{fluentdSender.end()},1000) ; it works.

from fluent-logger-node.

okkez avatar okkez commented on August 23, 2024

fluendSender.end() has same interface with fluentSender.emit().
fluentSender.end() with no arguments will shutdown fluentSender instance immediately.

We can wait ack response from server using following snippet:

fluentSender.end("label", {"message": "Good bye!"});

from fluent-logger-node.

nikhilkakade2108 avatar nikhilkakade2108 commented on August 23, 2024

writting fluentSender.end("label", {"message": "Good bye!"}); worked for me.
Thanks okkez. Closing the issue.

from fluent-logger-node.

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.