X-Git-Url: http://www.git.cypherpunks.ru/?a=blobdiff_plain;f=log.go;h=703f198368d7b9886c91029962c58a4f3b40dead;hb=7eabb39c54b96fca347a0576f501239d89bd8ec6;hp=1a804355dafe689f140724786f17663606e32d51;hpb=d5a14112bd34676379cd624868717148d93070a1;p=goredo.git diff --git a/log.go b/log.go index 1a80435..703f198 100644 --- a/log.go +++ b/log.go @@ -1,6 +1,6 @@ /* -goredo -- redo implementation on pure Go -Copyright (C) 2020 Sergey Matveev +goredo -- djb's redo implementation on pure Go +Copyright (C) 2020-2021 Sergey Matveev This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -31,23 +31,25 @@ import ( ) const ( - EnvLevel = "REDO_LEVEL" - EnvDebug = "REDO_DEBUG" - EnvLogWait = "REDO_LOG_WAIT" - EnvLogLock = "REDO_LOG_LOCK" - EnvLogPid = "REDO_LOG_PID" - EnvLogJS = "REDO_LOG_JS" - EnvNoColor = "NO_COLOR" + EnvLevel = "REDO_LEVEL" + EnvNoProgress = "REDO_NO_PROGRESS" + EnvDebug = "REDO_DEBUG" + EnvLogWait = "REDO_LOG_WAIT" + EnvLogLock = "REDO_LOG_LOCK" + EnvLogPid = "REDO_LOG_PID" + EnvLogJS = "REDO_LOG_JS" + EnvNoColor = "NO_COLOR" ) var ( - Level = 0 - NoColor bool - Debug bool - LogWait bool - LogLock bool - LogJS bool - MyPid int + Level = 0 + NoColor bool + NoProgress bool + Debug bool + LogWait bool + LogLock bool + LogJS bool + MyPid int CDebug string CRedo string @@ -59,11 +61,12 @@ var ( CReset string CNone string = "NONE" - flagDebug = flag.Bool("debug", 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 = 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)) LogMutex sync.Mutex LogLenPrev int @@ -117,6 +120,9 @@ func trace(level, format string, args ...interface{}) { } p += "wait " case CRedo: + if NoProgress { + return + } p += "redo " case CLock: if !(LogLock || Debug) {