Coder Social home page Coder Social logo

Add logging option about wafer HOT 11 CLOSED

gsquire avatar gsquire commented on September 28, 2024
Add logging option

from wafer.

Comments (11)

 avatar commented on September 28, 2024

Yes! We need logging. We would really welcome your help in implementing it.

from wafer.

gsquire avatar gsquire commented on September 28, 2024

Here is the log format I will use. It will contain as much information that is parsed from the request. I am going to try and finish it this weekend.

from wafer.

 avatar commented on September 28, 2024

Sweet. Let me know if you need any help. Meanwhile, I am trying to improve the throughput of the platform.

from wafer.

gsquire avatar gsquire commented on September 28, 2024

I implemented some very basic logging in my fork. The only problem I had was dealing with statuses other than 200. It looks like the code now sends a 200 and then checks to see if the file or "resource" exists and if it doesn't sends a 404 on top of the existing 200 it sent. Is this a bug?

from wafer.

 avatar commented on September 28, 2024

Good question.

Write now, the status codes are handled entirely by server(). As such, nope.c itself has no idea about the status codes, because server doesn't return anything. One thing we could do is make server() return a status code, which then your logger could use.

What do you think?

from wafer.

gsquire avatar gsquire commented on September 28, 2024

That sounds great. Unless you foresee wanting to return anything form server() in the future, a status code would be really helpful without having to change too much of the code now.

from wafer.

 avatar commented on September 28, 2024

The only problem is, there's no way to enforce return values in C.

from wafer.

gsquire avatar gsquire commented on September 28, 2024

Oh I see, considering that there is a chance that multiple functions may return different values at different times. I will see if I can find an alternative.

from wafer.

gsquire avatar gsquire commented on September 28, 2024

Until there is a way to successfully get return values, I don't know how we can go about logging them. For now all I can log is a request, the ip, and a time stamp.

from wafer.

truongminh avatar truongminh commented on September 28, 2024

I agree with @gsquire. A status code is really helpful and should be compulsory.

One more problem with logging involves the multithreaded model introduced in version 0.0.4 alpha.
Should the logger be run by the main thread (in cleaner() for example) or by worker threads?

from wafer.

 avatar commented on September 28, 2024

If you look at the 0.0.5 branch, I have made some significant changes to support what you are looking for:

the server function now takes the form server(Request * request, Response response )

Response is a struct in the form of

typedef struct struct_response {
    int fd;
    char **headers;
    int flags;
    int apiFlags;
    int status;
} Response;

nopeapi sendHeader family of functions will automatically set the status. Or the users could change it somewhere in the server function. Either way, you can now check the Response.status upon return to get the status.

from wafer.

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.