[
https://issues.apache.org/jira/browse/HTRACE-89?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14294428#comment-14294428
]
Colin Patrick McCabe commented on HTRACE-89:
--------------------------------------------
bq. No line number and no originating class! (smile)
Yeah. We could potentially get the caller's function and line number from Go
(there is a function to get stack traces), but I think it might be too slow...
I'll have to look into it later...
bq. We'll add test for log level later so we don't compose String each time:
lg.Tracef("Shard processor for %s wrote span %s.\n", shd.path, span.ToJson())
One nice thing is that we don't compose the string unless this "if" statement
triggers:
{code}
func (lg *Logger) write(level Level, str string) {
if level >= lg.level {
lg.sink.write(time.Now().Format(time.RFC3339) + " " +
level.LogString() + ": " + str)
}
}
{code}
So we already have the same level of non-composing-ness as {{slf4j}}. We don't
pay the overhead of creating new string objects most of the time (certainly not
for TRACE messages.)
Of course, the parameters that we pass to the log messages will always be
evaluated, so we might still need to add {{if (logging)...}} to a few places,
but hopefully not that much.
bq. I can't change log level dynamically?
Yeah, this is TODO. :) I think it wouldn't be that bad to add a REST call to
do this later.
Another TODO is log rolling... it's not hard, just need to actually do it.
bq. This stuff is related to this patch? store.shards\[idx\] = nil
I noticed that Close was not idempotent, and I wanted it to be... it's a tiny
thing so I guess I'll just leave it.
bq. lg is ugly name... why not just call it logger so plain what it is.
I guess my thinking here was that we'll end up using the logger object a lot,
so it's nice for it to have a short name. Log messages also tend to use up a
lot of horizontal space, so it's nice to shorten the prefix for all of them. I
guess let's try out "lg" for now and we can change it if it gets too annoying.
bq. Otherwise, patch looks good. +1. Lets get it in. We can make it fancier
later.
thanks
> htraced: add log levels, writing to log files
> ---------------------------------------------
>
> Key: HTRACE-89
> URL: https://issues.apache.org/jira/browse/HTRACE-89
> Project: HTrace
> Issue Type: New Feature
> Affects Versions: 3.2.0
> Reporter: Colin Patrick McCabe
> Assignee: Colin Patrick McCabe
> Fix For: 3.2.0
>
> Attachments: HTRACE-89.001.patch
>
>
> htraced should have log levels and the ability to write to log files.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)