Skip to content
This repository has been archived by the owner on Apr 23, 2022. It is now read-only.

Current log format is missing a useful date #39

Closed
kadaan opened this issue Feb 26, 2020 · 3 comments
Closed

Current log format is missing a useful date #39

kadaan opened this issue Feb 26, 2020 · 3 comments
Labels
enhancement New feature or request
Milestone

Comments

@kadaan
Copy link

kadaan commented Feb 26, 2020

Is your feature request related to a problem? Please describe.
The current log configuration includes the number of seconds from service start on every log line. This timestamp is not useful because it cannot be easily determined when specific logs occurred.

Describe the solution you'd like
The easy solution is to change from text to logfmt handler type.

Describe alternatives you've considered
The code includes a comment to allow different formats, but supporting this requires a lot more work due to many formats having required configuration.

What version of git2consul-go are you using?

$ git2consul -version
git2consul, version v0.1.2-dev (branch: master, revision: 9f404c06fe43479f3d81f237cee0ae93b3964905)
build date: 20200226-18:56:58
go version: go1.13.3

Additional context
Switching to logfmt would result in more usable logs like:

$ ./git2consul                                                                                                                                                                            
timestamp=2020-02-26T10:57:33.644652-08:00 level=info message="Starting git2consul version: v0.1.2-dev"
timestamp=2020-02-26T10:57:33.64518-08:00 level=error message="No configuration file provided"
@kadaan kadaan added the enhancement New feature or request label Feb 26, 2020
@liafizan
Copy link
Contributor

@kadaan I do not see an option in apex log for setting format and adding appropriate timestamps. Also, this is still open.
Adding an option to switch to structured log formation as a quick fix
flag.StringVar(&logfmt, "logfmt", "text", "specify log format [text | json] ").
Output will look like this
{"fields":{"caller":"main"},"level":"info","timestamp":"2020-05-14T17:05:12.820147-07:00","message":"Starting git2consul version: v0.1.2-dev"}
{"fields":{"caller":"config"},"level":"info","timestamp":"2020-05-14T17:05:12.821287-07:00","message":"Setting configuration with sane defaults"}
{"fields":{"caller":"repository"},"level":"info","timestamp":"2020-05-14T17:05:12.821835-07:00","message":"Loaded repository test-example"}
{"fields":{"error":"reference not found"},"level":"error","timestamp":"2020-05-14T17:05:13.824648-07:00","message":"Runner error"}

@kadaan
Copy link
Author

kadaan commented May 15, 2020

@faizan82 Thanks! Harder to read, but at least all the useful info is there!!!

@seanmalloy seanmalloy added this to the v0.1.2 milestone May 27, 2020
seanmalloy added a commit that referenced this issue May 27, 2020
main: added structured log option [Fixes #39]
@anjo-swe
Copy link

@seanmalloy when are you planning on rolling out 0.1.2?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Development

No branches or pull requests

4 participants