Added logger cligen integration

This commit is contained in:
Tristan Ancelet
2026-02-23 16:11:18 -06:00
parent 7081115b27
commit 5d5f3760ab

View File

@@ -3,6 +3,22 @@ require "colorize"
module Logger module Logger
macro finished
{% if @top_level.has_constant?("CliGen") %}
{% levels = LOG_LEVELS.map{|level| [level.stringify.downcase,level]}.to_h %}
{% for level in %w[ max min ] %}
CliGen.add_default_flag(long: "--{{level}} {{level.upcase}}", "Configure the {{level}}imum log level (default is: #{@@{{level}}_level)})"){|level|
levels = {{levels}}.to_h
abort "ERROR : --{{level}}_level : Level(#{level}) is not valid. (valid: #{labels.keys.join(", ")})" unless levels.has_key?(level)
@@{{level}}_level = LOG_LEVELS[lables[level]]
}
{% end %}
CliGen.add_default_flag(short: "-d", long: "--debug", "Tell the logger that we should enable full debug logging"){
Logger.debug = true
}
{% end %}
end
annotation LoggerWatcher annotation LoggerWatcher
end end