I am re-registering our small web application written in golang. Due to external requirements, logging was isolated in one place, so we can turn on the log later. (Not my idea - I promise ....) Nevertheless, we can now register common things, such as date / time, line number, user and message, mainly using parts of the standard library and user / session structure that we pass around.
But - and here the question arises - in lower-level methods, wasting time on a session just to get a username for the sake of logging. So I would like to find something else to use one specific query in the log files. I am sure there is something obvious that I have not thought about.
Ideas so far:
- Java registration frameworks can print a stream identifier, and that would also be nice in this case. Just what is it called something else in golang?
- make the struct user / session structure accessible globally as soon as possible. (You also need to pass the session identifier if there is no stream as the search key. Return to idea number 1.)
- In any case, refuse and pass the user / session structure.
- Do not log errors at the lowest level, but only when the user / session structure is available. The line number will not be good though.
We use gorilla parts for websites and, in addition, it is mainly a standard library.
Suggestions and ideas about this?
logging go
froderik
source share