You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@htrace.apache.org by cm...@apache.org on 2015/11/02 20:29:39 UTC
incubator-htrace git commit: HTRACE-290. htraced: Fix per-faculty log
level settings and add unit tests for conditional logging (Masatake Iwasaki
via Colin P. McCabe)
Repository: incubator-htrace
Updated Branches:
refs/heads/master 5a6839439 -> de8454f25
HTRACE-290. htraced: Fix per-faculty log level settings and add unit tests for conditional logging (Masatake Iwasaki via Colin P. McCabe)
Project: http://git-wip-us.apache.org/repos/asf/incubator-htrace/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-htrace/commit/de8454f2
Tree: http://git-wip-us.apache.org/repos/asf/incubator-htrace/tree/de8454f2
Diff: http://git-wip-us.apache.org/repos/asf/incubator-htrace/diff/de8454f2
Branch: refs/heads/master
Commit: de8454f2516938e1339a98433ad490b99eedf485
Parents: 5a68394
Author: Colin P. Mccabe <cm...@apache.org>
Authored: Mon Nov 2 11:29:12 2015 -0800
Committer: Colin P. Mccabe <cm...@apache.org>
Committed: Mon Nov 2 11:29:12 2015 -0800
----------------------------------------------------------------------
.../go/src/org/apache/htrace/common/log.go | 2 +-
.../go/src/org/apache/htrace/common/log_test.go | 48 ++++++++++++++++++++
2 files changed, 49 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-htrace/blob/de8454f2/htrace-htraced/go/src/org/apache/htrace/common/log.go
----------------------------------------------------------------------
diff --git a/htrace-htraced/go/src/org/apache/htrace/common/log.go b/htrace-htraced/go/src/org/apache/htrace/common/log.go
index c29195e..2e3e267 100644
--- a/htrace-htraced/go/src/org/apache/htrace/common/log.go
+++ b/htrace-htraced/go/src/org/apache/htrace/common/log.go
@@ -194,7 +194,7 @@ func parseConf(faculty string, cnf *conf.Config) (string, Level) {
} else {
facultyLogPath = cnf.Get(conf.HTRACE_LOG_PATH)
}
- facultyLogLevelKey := faculty + conf.HTRACE_LOG_LEVEL
+ facultyLogLevelKey := faculty + "." + conf.HTRACE_LOG_LEVEL
var facultyLogLevelStr string
if cnf.Contains(facultyLogLevelKey) {
facultyLogLevelStr = cnf.Get(facultyLogLevelKey)
http://git-wip-us.apache.org/repos/asf/incubator-htrace/blob/de8454f2/htrace-htraced/go/src/org/apache/htrace/common/log_test.go
----------------------------------------------------------------------
diff --git a/htrace-htraced/go/src/org/apache/htrace/common/log_test.go b/htrace-htraced/go/src/org/apache/htrace/common/log_test.go
index b415ce2..f0b1cde 100644
--- a/htrace-htraced/go/src/org/apache/htrace/common/log_test.go
+++ b/htrace-htraced/go/src/org/apache/htrace/common/log_test.go
@@ -120,3 +120,51 @@ func TestMultipleFileLogs(t *testing.T) {
fooLg.Close()
barLg.Close()
}
+
+func TestLogLevelEnabled(t *testing.T) {
+ tempDir, err := ioutil.TempDir(os.TempDir(), "TestLogLevelEnabled")
+ if err != nil {
+ panic(fmt.Sprintf("error creating tempdir: %s\n", err.Error()))
+ }
+ defer os.RemoveAll(tempDir)
+ // set log level to DEBUG for facility "foo"
+ logPath := tempDir + conf.PATH_SEP + "log"
+ lg := newLogger("foo", "log.level", "DEBUG",
+ "foo.log.level", "INFO",
+ "log.path", logPath)
+ if lg.TraceEnabled() {
+ t.Fatalf("foo logger has TraceEnabled")
+ }
+ if lg.DebugEnabled() {
+ t.Fatalf("foo logger have DebugEnabled")
+ }
+ if !lg.InfoEnabled() {
+ t.Fatalf("foo logger does not have InfoEnabled")
+ }
+ if !lg.WarnEnabled() {
+ t.Fatalf("foo logger does not have WarnEnabled")
+ }
+ if !lg.ErrorEnabled() {
+ t.Fatalf("foo logger does not have ErrorEnabled")
+ }
+ lg.Close()
+ lg = newLogger("foo", "log.level", "WARN",
+ "foo.log.level", "INFO",
+ "log.path", logPath)
+ if lg.TraceEnabled() {
+ t.Fatalf("foo logger has TraceEnabled")
+ }
+ if lg.DebugEnabled() {
+ t.Fatalf("foo logger has DebugEnabled")
+ }
+ if !lg.InfoEnabled() {
+ t.Fatalf("foo logger does not have InfoEnabled")
+ }
+ if !lg.WarnEnabled() {
+ t.Fatalf("foo logger does not have WarnEnabled")
+ }
+ if !lg.ErrorEnabled() {
+ t.Fatalf("foo logger does not have ErrorEnabled")
+ }
+ lg.Close()
+}