-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/add thread #11
base: master
Are you sure you want to change the base?
Feature/add thread #11
Conversation
if lineData[timeField] == nil { | ||
timeField = "timestamp" | ||
timeValue = lineData[timeField] | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok what's that change exactly? Tests are probably failing straight with this change.
The zapdriver had it's own format, I don't think we should change it. I see two options, those changes are reverted or you add a new method maybePrettyPrintGCPCloudLoggingLine(...)
that deals with correct format.
@@ -269,13 +302,10 @@ func tsFieldToTimestamp(input interface{}) (*time.Time, error) { | |||
return &zeroTime, fmt.Errorf("don't know how to turn %T (value %s) into a time.Time object", input, input) | |||
} | |||
|
|||
// Using the log fields of stack driver: https://cloud.google.com/logging/docs/structured-logging |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is sadly not totally true. StackDriver had its own format and was acquired by Google at some point. They are now using the new format for which you added the log line but this function was seems it's not fully dealing with old logging.
I prefer that we keep backward compatibility, tests should sufficient to ensure nothing is broken.
delete(lineData, "msg") | ||
delete(lineData, "message") | ||
|
||
if os.Getenv("ZAP_PRETTY_PRINT_THREADS") != "" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if os.Getenv("ZAP_PRETTY_PRINT_THREADS") != "" { | |
if os.Getenv("ZAP_PRETTY_THREAD_ON_HEADER") != "" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And create a function that will check this so the environment name is specified at a single place.
var threadId *string | ||
var thread *string | ||
if os.Getenv("ZAP_PRETTY_PRINT_THREADS") != "" { | ||
if v := lineData["thread_id"]; v != nil { | ||
threadIdF64 := v.(float64) | ||
threadIdStr := strconv.FormatFloat(threadIdF64, 'f', -1, 64) | ||
threadId = &threadIdStr | ||
} | ||
|
||
if v := lineData["thread"]; v != nil { | ||
threadStr := v.(string) | ||
thread = &threadStr | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Totally duplicated logic, please refactor.
@@ -194,19 +195,20 @@ func (p *processor) processLine(line string) { | |||
} | |||
|
|||
func (p *processor) maybePrettyPrintLine(line string, lineData map[string]interface{}) (string, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please keep backward compatibility.
Parse the below keys, if they are present:
timestamp
process_id
thread_id
thread