Module: Lich::Common::ShutdownLog Private
- Defined in:
- documented/common/shutdown_log.rb
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Centralizes shutdown-specific log formatting and diagnostic gating.
Default shutdown logs should answer "why did Lich exit?" without requiring debug mode. Diagnostic logs are reserved for timing/backtrace detail that is useful during investigation but too noisy for routine shutdowns.
Class Method Summary collapse
-
.begin_user_exit_summary! ⇒ void
private
Starts buffering routine info logs for a possible clean user exit.
-
.complete_user_exit_summary(message) ⇒ Boolean
private
Emits a clean user-exit summary or flushes buffered info logs.
-
.debug(message) ⇒ void
private
Logs diagnostic shutdown detail only when diagnostics are enabled.
-
.diagnostics_enabled? ⇒ Boolean
private
Whether shutdown diagnostics should be verbose.
- .error(message) ⇒ void private
-
.flush_user_exit_summary! ⇒ void
private
Flushes any buffered info logs and disables user-exit summarization.
- .info(message) ⇒ void private
- .warning(message) ⇒ void private
Class Method Details
.begin_user_exit_summary! ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
Starts buffering routine info logs for a possible clean user exit.
Warnings and errors still emit immediately and disqualify the compact summary, allowing the caller to flush buffered info lines later.
62 63 64 65 66 67 68 |
# File 'documented/common/shutdown_log.rb', line 62 def begin_user_exit_summary! mutex.synchronize do @user_exit_summary_active = true @user_exit_summary_disqualified = false @buffered_info = [] end end |
.complete_user_exit_summary(message) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Emits a clean user-exit summary or flushes buffered info logs.
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'documented/common/shutdown_log.rb', line 74 def complete_user_exit_summary() buffered_info = nil should_summarize = false mutex.synchronize do if @user_exit_summary_active && !@user_exit_summary_disqualified should_summarize = true else buffered_info = @buffered_info.dup end reset_user_exit_summary_state end if should_summarize write(:info, ) true else buffered_info&.each { || write(:info, ) } false end end |
.debug(message) ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
Logs diagnostic shutdown detail only when diagnostics are enabled.
47 48 49 |
# File 'documented/common/shutdown_log.rb', line 47 def debug() write(:debug, ) if diagnostics_enabled? end |
.diagnostics_enabled? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns whether shutdown diagnostics should be verbose.
52 53 54 |
# File 'documented/common/shutdown_log.rb', line 52 def diagnostics_enabled? defined?(ARGV) && ARGV.include?('--debug') end |
.error(message) ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
38 39 40 41 |
# File 'documented/common/shutdown_log.rb', line 38 def error() flush_disqualified_user_exit_summary! write(:error, ) end |
.flush_user_exit_summary! ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
Flushes any buffered info logs and disables user-exit summarization.
99 100 101 102 103 104 105 106 |
# File 'documented/common/shutdown_log.rb', line 99 def flush_user_exit_summary! buffered_info = nil mutex.synchronize do buffered_info = @buffered_info.dup reset_user_exit_summary_state end buffered_info.each { || write(:info, ) } end |
.info(message) ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
23 24 25 26 27 |
# File 'documented/common/shutdown_log.rb', line 23 def info() return if buffer_info() write(:info, ) end |
.warning(message) ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
31 32 33 34 |
# File 'documented/common/shutdown_log.rb', line 31 def warning() flush_disqualified_user_exit_summary! write(:warning, ) end |