summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2017-10-16 10:11:28 +0200
committerGitHub <noreply@github.com>2017-10-16 10:11:28 +0200
commite7aa5af9bea7556fa1f841a08479146ac31a2cc7 (patch)
treed257b6269f4b09b392b43ecc3775504ced9a385b
parente43b5244201a4a7d953798dd1b49951cdbe5d6ae (diff)
parent3487eb4c8a99b6b70ac3a32e7a84523f04806f5e (diff)
downloadimag-e7aa5af9bea7556fa1f841a08479146ac31a2cc7.zip
imag-e7aa5af9bea7556fa1f841a08479146ac31a2cc7.tar.gz
Merge pull request #1149 from matthiasbeyer/libimagrt/remove-logging-format-overrides
Remove override functionality for logging formats
-rw-r--r--bin/core/imag/src/main.rs7
-rw-r--r--lib/core/libimagrt/src/logger.rs65
-rw-r--r--lib/core/libimagrt/src/runtime.rs72
3 files changed, 21 insertions, 123 deletions
diff --git a/bin/core/imag/src/main.rs b/bin/core/imag/src/main.rs
index 3cd21ee..8d7da25 100644
--- a/bin/core/imag/src/main.rs
+++ b/bin/core/imag/src/main.rs
@@ -337,13 +337,6 @@ fn forward_commandline_arguments(m: &ArgMatches, scmd: &mut Vec<String>) {
Runtime::arg_generate_compl(), m , scmd);
push(None , Runtime::arg_logdest_name() , m , scmd);
- push(None , Runtime::arg_override_module_logging_setting_name() , m , scmd);
- push(None , Runtime::arg_override_trace_logging_format() , m , scmd);
- push(None , Runtime::arg_override_debug_logging_format() , m , scmd);
- push(None , Runtime::arg_override_info_logging_format() , m , scmd);
- push(None , Runtime::arg_override_warn_logging_format() , m , scmd);
- push(None , Runtime::arg_override_error_logging_format() , m , scmd);
-
}
diff --git a/lib/core/libimagrt/src/logger.rs b/lib/core/libimagrt/src/logger.rs
index a678204..241ff73 100644
--- a/lib/core/libimagrt/src/logger.rs
+++ b/lib/core/libimagrt/src/logger.rs
@@ -86,23 +86,23 @@ impl ImagLogger {
::libimaginteraction::format::register_all_format_helpers(&mut handlebars);
{
- let fmt = try!(aggregate_global_format_trace(matches, config));
+ let fmt = try!(aggregate_global_format_trace(config));
try!(handlebars.register_template_string("TRACE", fmt)); // name must be uppercase
}
{
- let fmt = try!(aggregate_global_format_debug(matches, config));
+ let fmt = try!(aggregate_global_format_debug(config));
try!(handlebars.register_template_string("DEBUG", fmt)); // name must be uppercase
}
{
- let fmt = try!(aggregate_global_format_info(matches, config));
+ let fmt = try!(aggregate_global_format_info(config));
try!(handlebars.register_template_string("INFO", fmt)); // name must be uppercase
}
{
- let fmt = try!(aggregate_global_format_warn(matches, config));
+ let fmt = try!(aggregate_global_format_warn(config));
try!(handlebars.register_template_string("WARN", fmt)); // name must be uppercase
}
{
- let fmt = try!(aggregate_global_format_error(matches, config));
+ let fmt = try!(aggregate_global_format_error(config));
try!(handlebars.register_template_string("ERROR", fmt)); // name must be uppercase
}
@@ -333,77 +333,54 @@ fn aggregate_global_destinations(matches: &ArgMatches, config: Option<&Configura
}
}
-#[inline]
-fn aggregate_global_format(
- read_str: &str,
- cli_match_name: &str,
- error_kind_if_missing: EK,
- matches: &ArgMatches,
- config: Option<&Configuration>
- )
--> Result<String>
-{
- match config {
- Some(cfg) => match cfg.read(read_str) {
+macro_rules! aggregate_global_format {
+ ($read_str:expr, $error_kind_if_missing:expr, $config:expr) => {
+ match try!($config.ok_or(RE::from_kind($error_kind_if_missing))).read($read_str) {
Ok(Some(&Value::String(ref s))) => Ok(s.clone()),
- Ok(Some(_)) => Err(RE::from_kind(EK::ConfigTypeError(read_str.to_owned(), "String"))),
- Ok(None) => Err(RE::from_kind(error_kind_if_missing)),
+ Ok(Some(_)) => Err(RE::from_kind(EK::ConfigTypeError($read_str.to_owned(), "String"))),
+ Ok(None) => Err(RE::from_kind($error_kind_if_missing)),
Err(e) => Err(e).map_err(From::from),
- },
- None => match matches.value_of(cli_match_name).map(String::from) {
- Some(s) => Ok(s),
- None => Err(RE::from_kind(error_kind_if_missing))
}
- }
+ };
}
-fn aggregate_global_format_trace(matches: &ArgMatches, config: Option<&Configuration>)
+fn aggregate_global_format_trace(config: Option<&Configuration>)
-> Result<String>
{
- aggregate_global_format("imag.logging.format.trace",
- Runtime::arg_override_trace_logging_format(),
+ aggregate_global_format!("imag.logging.format.trace",
EK::ConfigMissingLoggingFormatTrace,
- matches,
config)
}
-fn aggregate_global_format_debug(matches: &ArgMatches, config: Option<&Configuration>)
+fn aggregate_global_format_debug(config: Option<&Configuration>)
-> Result<String>
{
- aggregate_global_format("imag.logging.format.debug",
- Runtime::arg_override_debug_logging_format(),
+ aggregate_global_format!("imag.logging.format.debug",
EK::ConfigMissingLoggingFormatDebug,
- matches,
config)
}
-fn aggregate_global_format_info(matches: &ArgMatches, config: Option<&Configuration>)
+fn aggregate_global_format_info(config: Option<&Configuration>)
-> Result<String>
{
- aggregate_global_format("imag.logging.format.info",
- Runtime::arg_override_info_logging_format(),
+ aggregate_global_format!("imag.logging.format.info",
EK::ConfigMissingLoggingFormatInfo,
- matches,
config)
}
-fn aggregate_global_format_warn(matches: &ArgMatches, config: Option<&Configuration>)
+fn aggregate_global_format_warn(config: Option<&Configuration>)
-> Result<String>
{
- aggregate_global_format("imag.logging.format.warn",
- Runtime::arg_override_warn_logging_format(),
+ aggregate_global_format!("imag.logging.format.warn",
EK::ConfigMissingLoggingFormatWarn,
- matches,
config)
}
-fn aggregate_global_format_error(matches: &ArgMatches, config: Option<&Configuration>)
+fn aggregate_global_format_error(config: Option<&Configuration>)
-> Result<String>
{
- aggregate_global_format("imag.logging.format.error",
- Runtime::arg_override_error_logging_format(),
+ aggregate_global_format!("imag.logging.format.error",
EK::ConfigMissingLoggingFormatError,
- matches,
config)
}
diff --git a/lib/core/libimagrt/src/runtime.rs b/lib/core/libimagrt/src/runtime.rs
index ffb27b5..985ff99 100644
--- a/lib/core/libimagrt/src/runtime.rs
+++ b/lib/core/libimagrt/src/runtime.rs
@@ -255,54 +255,6 @@ impl<'a> Runtime<'a> {
.takes_value(true)
.value_name("LOGDESTS"))
- .arg(Arg::with_name(Runtime::arg_override_module_logging_setting_name())
- .long(Runtime::arg_override_module_logging_setting_name())
- .help("Override a module logging setting for one module. Format: <modulename>=<setting>=<value>, whereas <setting> is either 'enabled', 'level' or 'destinations' - This commandline argument is CURRENTLY NOT IMPLEMENTED")
- .multiple(true)
- .required(false)
- .takes_value(true)
- .value_name("SPEC"))
-
- .arg(Arg::with_name(Runtime::arg_override_trace_logging_format())
- .long(Runtime::arg_override_trace_logging_format())
- .help("Override the logging format for the trace logging")
- .multiple(false)
- .required(false)
- .takes_value(true)
- .value_name("FMT"))
-
- .arg(Arg::with_name(Runtime::arg_override_debug_logging_format())
- .long(Runtime::arg_override_debug_logging_format())
- .help("Override the logging format for the debug logging")
- .multiple(false)
- .required(false)
- .takes_value(true)
- .value_name("FMT"))
-
- .arg(Arg::with_name(Runtime::arg_override_info_logging_format())
- .long(Runtime::arg_override_info_logging_format())
- .help("Override the logging format for the info logging")
- .multiple(false)
- .required(false)
- .takes_value(true)
- .value_name("FMT"))
-
- .arg(Arg::with_name(Runtime::arg_override_warn_logging_format())
- .long(Runtime::arg_override_warn_logging_format())
- .help("Override the logging format for the warn logging")
- .multiple(false)
- .required(false)
- .takes_value(true)
- .value_name("FMT"))
-
- .arg(Arg::with_name(Runtime::arg_override_error_logging_format())
- .long(Runtime::arg_override_error_logging_format())
- .help("Override the logging format for the error logging")
- .multiple(false)
- .required(false)
- .takes_value(true)
- .value_name("FMT"))
-
}
/// Get the argument names of the Runtime which are available
@@ -392,30 +344,6 @@ impl<'a> Runtime<'a> {
"logging-destinations"
}
- pub fn arg_override_module_logging_setting_name() -> &'static str {
- "override-module-log-setting"
- }
-
- pub fn arg_override_trace_logging_format() -> &'static str {
- "override-logging-format-trace"
- }
-
- pub fn arg_override_debug_logging_format() -> &'static str {
- "override-logging-format-debug"
- }
-
- pub fn arg_override_info_logging_format() -> &'static str {
- "override-logging-format-info"
- }
-
- pub fn arg_override_warn_logging_format() -> &'static str {
- "override-logging-format-warn"
- }
-
- pub fn arg_override_error_logging_format() -> &'static str {
- "override-logging-format-error"
- }
-
/// Initialize the internal logger
fn init_logger(matches: &ArgMatches, config: Option<&Configuration>) {
use std::env::var as env_var;