diff --git a/docs/usage.md b/docs/usage.md index efdd8c00..e6bc521d 100644 --- a/docs/usage.md +++ b/docs/usage.md @@ -10,6 +10,7 @@ - [`LEFTHOOK`](#lefthook) - [`LEFTHOOK_EXCLUDE`](#lefthook_exclude) - [`LEFTHOOK_QUIET`](#lefthook_quiet) + - [`LEFTHOOK_VERBOSE`](#lefthook_verbose) - [Features and tips](#features-and-tips) - [Disable lefthook in CI](#disable-lefthook-in-ci) - [Local config](#local-config) @@ -163,6 +164,10 @@ SUMMARY: (done in 0.01 seconds) 🥊 lint ``` +### `LEFTHOOK_VERBOSE` + +Set `LEFTHOOK_VERBOSE=1` or `LEFTHOOK_VERBOSE=true` to enable verbose printing. + ## Features and tips ### Disable lefthook in CI diff --git a/internal/lefthook/run.go b/internal/lefthook/run.go index 8c7a8701..f7f97d2c 100644 --- a/internal/lefthook/run.go +++ b/internal/lefthook/run.go @@ -14,8 +14,9 @@ import ( ) const ( - envEnabled = "LEFTHOOK" // "0", "false" - envSkipOutput = "LEFTHOOK_QUIET" // "meta,success,failure,summary,execution" + envEnabled = "LEFTHOOK" // "0", "false" + envSkipOutput = "LEFTHOOK_QUIET" // "meta,success,failure,summary,execution" + envVerbose = "LEFTHOOK_VERBOSE" // keep all output ) func Run(opts *Options, hookName string, gitArgs []string) error { @@ -32,8 +33,12 @@ func (l *Lefthook) Run(hookName string, gitArgs []string) error { return nil } - if hookName == config.GhostHookName { - log.SetLevel(log.WarnLevel) + if l.Verbose || os.Getenv(envVerbose) == "1" || os.Getenv(envVerbose) == "true" { + log.SetLevel(log.DebugLevel) + } else { + if hookName == config.GhostHookName { + log.SetLevel(log.WarnLevel) + } } // Load config