kentonh / gPanel

A web-hosting control panel written in Go.
MIT License
80 stars 25 forks source link

Logging errors within APIs to server_errors.log #71

Closed george-e-shaw-iv closed 6 years ago

george-e-shaw-iv commented 6 years ago

Severity level (1-10):

7

Files/Directories Involved:

pkg/api/* server/logs/server_errors.log <- stored in a constant in pkg/file/file.go

Description:

The handler either has to be passed from pkg/webhost.go into the API handler function, or a new instance of the server_errors.log file has to be generated within the API package.

Personal Comments:

Even if you don't feel like tackling this issue, if you want to offer some advice on what you think the best course of action would be, please do comment on the issue.

aaronarduino commented 6 years ago

What exactly are you wanting to log here? Just err values or more than that?

I'd be willing to implement this.

george-e-shaw-iv commented 6 years ago

@aaronarduino Anything that prevents the API from successfully completing whatever it needs to do should be logged. You can take a look at how I'm dealing with the server/account/public errors, they're by no means anything very amazing as far as content goes quite yet, and if you want to improve on the verboseness (if thats a word) on what all the errors log then by all means go ahead and do that.

Now that I think about it it may be up for discussion to log them within the account and server logs respectively, but if we just started with server that would be an okay entry point and it can always be expanded later. It might be somewhat hard to distinguish between the two at this point, especially because there is as many account logs as there is bundles in the program. So probably just sticking with server at first would be the best bet and I'll think about the best course of distinguishing which error log to place it into at a later time when it becomes more important.

You can create a new bundle within the server and then generate some errors within any of them and view them to see whats going on. Respectively I log errors within pkg/gpserver/gpserver.go, pkg/gpaccount/gpaccount.go, and pkg/public/public.go all within their ServeHTTP functions using the pkg/file/file.go handler.

If you get confused about where anything is coming from or have any questions you can always send me a slack message or just talk back and forth on here. My slack on devICT is just george.shaw