@@ -179,10 +179,36 @@ Example Paths:
179179 return nil
180180 }
181181
182+ if os .Getenv ("DD_MASK" ) == "" {
183+ os .Setenv ("DD_MASK" , "mgmt,epc,csum,md,df,io,trace" )
184+ }
182185 if opts .Debug {
183- log .WithLogLevel (logging .LogLevelDebug )
184- log .Debug ("debug output enabled" )
186+ log .WithLogLevel (logging .LogLevelTrace )
187+ if os .Getenv ("D_LOG_MASK" ) == "" {
188+ os .Setenv ("D_LOG_MASK" , "INFO,DDB=DEBUG" )
189+ }
190+ // Show debug output and above on stderr to not pollute stdout
191+ // NOTE: DD_STDERR can only be used with INFO and above.
192+ if os .Getenv ("DD_STDERR" ) == "" {
193+ os .Setenv ("DD_STDERR" , "EMIT" )
194+ }
195+ if os .Getenv ("D_LOG_FILE" ) == "" {
196+ os .Setenv ("D_LOG_FILE" , "/dev/stderr" )
197+ }
198+ } else {
199+ log .WithLogLevel (logging .LogLevelError )
200+ if os .Getenv ("D_LOG_MASK" ) == "" {
201+ os .Setenv ("D_LOG_MASK" , "ERR,DDB=WARN" )
202+ }
203+ // Only show warnings and above on stderr to not pollute stdout
204+ if os .Getenv ("DD_STDERR" ) == "" {
205+ os .Setenv ("DD_STDERR" , "WARN" )
206+ }
207+ if os .Getenv ("D_LOG_FILE" ) == "" {
208+ os .Setenv ("D_LOG_FILE" , "/dev/null" )
209+ }
185210 }
211+ log .Debug ("debug output enabled" )
186212
187213 ctx , cleanup , err := InitDdb (log )
188214 if err != nil {
0 commit comments