VOL-1848 API for setting and querying loglevel of api-server;
Add source-router to support routing UpdateLogLevel to cores;
Add logging endpoints to rocore
Change-Id: I89eea3599ea3006fe92e6917221cd1fd235ec5e4
diff --git a/common/log/log.go b/common/log/log.go
index 33100dc..fe3a4e0 100644
--- a/common/log/log.go
+++ b/common/log/log.go
@@ -286,6 +286,17 @@
return nil
}
+// Return a list of all packages that have individually-configured loggers
+func GetPackageNames() []string {
+ i := 0
+ keys := make([]string, len(loggers))
+ for k := range loggers {
+ keys[i] = k
+ i++
+ }
+ return keys
+}
+
// UpdateLogger deletes the logger associated with a caller's package and creates a new logger with the
// defaultFields. If a calling package is holding on to a Logger reference obtained from AddPackage invocation, then
// that package needs to invoke UpdateLogger if it needs to make changes to the default fields and obtain a new logger
@@ -371,6 +382,11 @@
return 0, errors.New(fmt.Sprintf("unknown-package-%s", name))
}
+//GetDefaultLogLevel gets the log level used for packages that don't have specific loggers
+func GetDefaultLogLevel() int {
+ return levelToInt(cfg.Level.Level())
+}
+
//SetLogLevel sets the log level for the logger corresponding to the caller's package
func SetLogLevel(level int) error {
pkgName, _, _, _ := getCallerInfo()
@@ -382,6 +398,11 @@
return nil
}
+//SetDefaultLogLevel sets the log level used for packages that don't have specific loggers
+func SetDefaultLogLevel(level int) {
+ setLevel(cfg, level)
+}
+
// CleanUp flushed any buffered log entries. Applications should take care to call
// CleanUp before exiting.
func CleanUp() error {