wick icon indicating copy to clipboard operation
wick copied to clipboard

Standardized logging

Open fawadasaurus opened this issue 2 years ago • 3 comments

Is your feature request related to a problem? Please describe.

Different interfaces/logs have different log formats and contents.

Propose a solution

Log formats should be standardized. Ideally they would use json so they can be machine parsed with grok/regex.

Describe alternatives you've considered

None

Additional context

None

fawadasaurus avatar Jan 12 '23 01:01 fawadasaurus

NanoBus already uses uber-go/zap, which is a structured logger. What you are asking for is to be able to change the logger configuration for production instead of only development.

pkedy avatar Jan 12 '23 19:01 pkedy

Different interfaces/logs have different log formats and contents.

Can you list the spots where logging is different? There was an issue with the HTTP static server but that's been fixed AFAIK.

jsoverson avatar Jan 18 '23 20:01 jsoverson

https://github.com/nanobus/nanobus/search?q=println

All of these are effectively log entries that need to be in the standard format.

Again, I believe that all logs should be in JSON format so we can have different message payloads based on the specific use case. For example the HTTP server message can be an access log line where as other service message can have their own types of messages.

{log_level: <INFO>, trace_id: <traceid>, time: <timestamp>, tenant_id: <abc123>, app_name: <myapp>, app_version: <0.0.1>, component: <nanobus.transport.http.static/v1>, message: "'{'
    '"time_local":"$time_local",'
    '"remote_addr":"$remote_addr",'
    '"remote_user":"$remote_user",'
    '"request":"$request",'
    '"status": "$status",'
    '"body_bytes_sent":"$body_bytes_sent",'
    '"request_time":"$request_time",'
    '"http_referrer":"$http_referer",'
    '"http_user_agent":"$http_user_agent"'
  '}'"

This way, a standard NanoBus log has a certain schema that must always include certain information. Each component must define its own log format that can be parsed without regex/pattern matching.

fawadasaurus avatar Jan 19 '23 00:01 fawadasaurus