@@ -262,10 +262,36 @@ the command‑specific help for details.
262262 return errors .New ("Cannot use both command file and a command string" )
263263 }
264264
265+ if os .Getenv ("DD_MASK" ) == "" {
266+ os .Setenv ("DD_MASK" , "mgmt,epc,csum,md,df,io,trace" )
267+ }
265268 if opts .Debug {
266- log .WithLogLevel (logging .LogLevelDebug )
267- log .Debug ("debug output enabled" )
269+ log .WithLogLevel (logging .LogLevelTrace )
270+ if os .Getenv ("D_LOG_MASK" ) == "" {
271+ os .Setenv ("D_LOG_MASK" , "INFO,DDB=DEBUG" )
272+ }
273+ // Show debug output and above on stderr to not pollute stdout
274+ // NOTE: DD_STDERR can only be used with INFO and above.
275+ if os .Getenv ("DD_STDERR" ) == "" {
276+ os .Setenv ("DD_STDERR" , "EMIT" )
277+ }
278+ if os .Getenv ("D_LOG_FILE" ) == "" {
279+ os .Setenv ("D_LOG_FILE" , "/dev/stderr" )
280+ }
281+ } else {
282+ log .WithLogLevel (logging .LogLevelError )
283+ if os .Getenv ("D_LOG_MASK" ) == "" {
284+ os .Setenv ("D_LOG_MASK" , "ERR,DDB=WARN" )
285+ }
286+ // Only show warnings and above on stderr to not pollute stdout
287+ if os .Getenv ("DD_STDERR" ) == "" {
288+ os .Setenv ("DD_STDERR" , "WARN" )
289+ }
290+ if os .Getenv ("D_LOG_FILE" ) == "" {
291+ os .Setenv ("D_LOG_FILE" , "/dev/null" )
292+ }
268293 }
294+ log .Debug ("debug output enabled" )
269295
270296 ctx , cleanup , err := InitDdb (log )
271297 if err != nil {
0 commit comments