Commit 16a11da 1 parent dc787f3 commit 16a11da Copy full SHA for 16a11da
File tree 1 file changed +9
-0
lines changed
1 file changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -59,7 +59,16 @@ type moduleLogger struct {
59
59
// to start modules with a "log-level" commandline argument. The created logger
60
60
// will send log events back to the module's parent (the RDK) via gRPC when
61
61
// possible and to STDOUT when not possible.
62
+ //
63
+ // `moduleName` will be the name of the created logger. Pass `""` if you wish to
64
+ // use the value specified by the `VIAM_MODULE_NAME` environment variable.
62
65
func NewLoggerFromArgs (moduleName string ) logging.Logger {
66
+ // If no `moduleName` was specified, grab it from the environment (will still be empty
67
+ // string if not specified in environment.)
68
+ if moduleName == "" {
69
+ moduleName , _ = os .LookupEnv ("VIAM_MODULE_NAME" )
70
+ }
71
+
63
72
modAppender := newModuleAppender ()
64
73
baseLogger := logging .NewBlankLogger (moduleName )
65
74
baseLogger .AddAppender (modAppender )
You can’t perform that action at this time.
0 commit comments