Code Monkey home page Code Monkey logo

Comments (6)

davehorton avatar davehorton commented on August 12, 2024

I could definitely use some advice/help on how to implement/integrate logging into the framework better. You are right, there are spots where I would like to generate a log message from within the framework and right now just using console, which I don't love. Here is another one:

console.error(err.stack) ;

I don't think we can always guarantee that there is a request object in scope, though, so I am not sure about that. Emitting an error on the srf object sounds a bit better, though at lower levels of the stack are not aware of the higher level abstraction that is the srf. Definitely open to suggestions.....

from drachtio-srf.

jonastelzio avatar jonastelzio commented on August 12, 2024

@davehorton so, my immediate reaction would be that any error that's related to code that the implementor (me) has written, should be obtainable through an event on on the SRF instance.

So all errors in middleware, srf.invite and so on, should end up in srf.on('error') - or whatever, I believe that event is already occupied by errors in communication for inbound mode.

Errors that sits at a lower level of abstraction should probably be fine to emit to console.error instead. From my standpoint as an implementor, it should be fine getting caught by whatever logging I've got attached to stderr.

The extensive use of promises can make this a bit annoying to implement though, but with a few strategically placed await statements it'll probably be manageable.

from drachtio-srf.

davehorton avatar davehorton commented on August 12, 2024

that sounds pretty reasonable. One thing I was wondering -- that initial link you gave, an error of that kind should have called your error middleware, if you had any, via this line:

layer.handle(err, req, res, next);

was that not happening?

from drachtio-srf.

jonastelzio avatar jonastelzio commented on August 12, 2024

I'm not sure what error middleware is?

from drachtio-srf.

davehorton avatar davehorton commented on August 12, 2024

it is middleware with 4 args instead of 3, one being an error argument. It is called only when an error is barfed somewhere down the stack:

srf.use((err, req, res, next) => ..

from drachtio-srf.

jonastelzio avatar jonastelzio commented on August 12, 2024

Oh I didn't know that! That takes care of a great deal of the error handling then! I'll just try that out.

from drachtio-srf.

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.