X-Git-Url: http://www.git.cypherpunks.ru/?a=blobdiff_plain;f=log.go;h=c9f9119f1171ece282486d118e1391b1a0241438;hb=34af0e4ad73fb149c9db2c00b0dcc544838a2df2;hp=4d8a982813a1e58a31c43fafbcad3f4d2d4336dd;hpb=b5a5c4fcfcc6fb214136a5cfafaa92d0e50c002a;p=goredo.git diff --git a/log.go b/log.go index 4d8a982..c9f9119 100644 --- a/log.go +++ b/log.go @@ -59,14 +59,14 @@ var ( CWarn string CJS string CReset string - CNone string = "NONE" + CNone = "NONE" - flagNoProgress = flag.Bool("no-progress", false, fmt.Sprintf("no progress printing (%s=1), also implies -no-status", EnvNoProgress)) flagDebug = flag.Bool("d", false, fmt.Sprintf("enable debug logging (%s=1)", EnvDebug)) - flagLogWait = flag.Bool("log-wait", false, fmt.Sprintf("enable wait messages logging (%s=1)", EnvLogWait)) - flagLogLock = flag.Bool("log-lock", false, fmt.Sprintf("enable lock messages logging (%s=1)", EnvLogLock)) - flagLogPid = flag.Bool("log-pid", false, fmt.Sprintf("append PIDs (%s=1)", EnvLogPid)) - flagLogJS = flag.Bool("log-js", false, fmt.Sprintf("enable jobserver messages logging (%s=1)", EnvLogJS)) + flagNoProgress *bool + flagLogWait *bool + flagLogLock *bool + flagLogPid *bool + flagLogJS *bool LogMutex sync.Mutex KeyEraseLine string @@ -84,6 +84,21 @@ func init() { CJS = string(t.Escape.White) CReset = string(t.Escape.Reset) KeyEraseLine = fmt.Sprintf("%s[K", CReset[0:1]) + + cmdName := CmdName() + if !(cmdName == CmdNameRedo || cmdName == CmdNameRedoIfchange) { + return + } + flagNoProgress = flag.Bool("no-progress", false, + fmt.Sprintf("no progress printing (%s=1), also implies -no-status", EnvNoProgress)) + flagLogWait = flag.Bool("log-wait", false, + fmt.Sprintf("enable wait messages logging (%s=1)", EnvLogWait)) + flagLogLock = flag.Bool("log-lock", false, + fmt.Sprintf("enable lock messages logging (%s=1)", EnvLogLock)) + flagLogPid = flag.Bool("log-pid", false, + fmt.Sprintf("append PIDs (%s=1)", EnvLogPid)) + flagLogJS = flag.Bool("log-js", false, + fmt.Sprintf("enable jobserver messages logging (%s=1)", EnvLogJS)) } func erasedStatus(s, end string) string { @@ -93,7 +108,7 @@ func erasedStatus(s, end string) string { return s + KeyEraseLine + end } -func trace(level, format string, args ...interface{}) { +func tracef(level, format string, args ...interface{}) { var p string if MyPid != 0 { p = fmt.Sprintf("[%d] ", MyPid)