master - logging: add command[pid] and timestamp to file and verbose output
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=9aea6ae956543995b30282c984af5fdad2347f07 Commit: 9aea6ae956543995b30282c984af5fdad2347f07 Parent: ccfbd505fea2f259f7c89dc23b020b838363a611 Author: David Teigland <[email protected]> AuthorDate: Fri Feb 22 12:01:20 2019 -0600 Committer: David Teigland <[email protected]> CommitterDate: Tue Feb 26 10:03:44 2019 -0600
logging: add command[pid] and timestamp to file and verbose output
Without this, the output from different commands in a single log file could not be separated.
Change the default "indent" setting to 0 so that the default debug output does not include variable spaces in the middle of debug lines.
--- lib/commands/toolcontext.c | 4 +- lib/commands/toolcontext.h | 1 - lib/config/config_settings.h | 2 +- lib/config/defaults.h | 2 +- lib/log/log.c | 66 +++++++++++++++++++++++++++++++++-------- lib/misc/lvm-globals.c | 44 +++++++++++++++++++++++----- lib/misc/lvm-globals.h | 4 ++- tools/lvmcmdline.c | 7 ++-- 8 files changed, 100 insertions(+), 30 deletions(-)
lib/commands/toolcontext.c +2 -2
@@ -320,8 +320,8 @@ static void _init_logging(struct cmd_context *cmd) cmd->default_settings.msg_prefix =find_config_tree_str_allow_empty (cmd, log_prefix_CFG,NULL );init_msg_prefix (cmd->default_settings.msg_prefix); - cmd->default_settings.cmd_name =find_config_tree_bool (cmd, log_command_names_CFG,NULL ); -init_cmd_name (cmd->default_settings.cmd_name); +/* so that file and verbose output have a command prefix */ +init_log_command (0 ,0 );/* Test mode */ cmd->default_settings.test =
lib/commands/toolcontext.h +0 -1
@@ -44,7 +44,6 @@ struct config_info {const char *fmt_name;const char *dmeventd_executable;uint64_t unit_factor; -int cmd_name;/* Show command name? */ mode_t umask;char unit_type;char _padding[1 ];
lib/config/config_settings.h +1 -1
@@ -812,7 +812,7 @@ cfg(log_level_CFG, "level", log_CFG_SECTION, 0, CFG_TYPE_INT, DEFAULT_LOGLEVEL, "There are 6 syslog-like log levels currently in use: 2 to 7 inclusive.\n" "7 is the most verbose (LOG_DEBUG).\n") -cfg(log_indent_CFG, "indent", log_CFG_SECTION, 0, CFG_TYPE_BOOL, DEFAULT_INDENT, vsn(1, 0, 0), NULL, 0, NULL, +cfg(log_indent_CFG, "indent", log_CFG_SECTION, CFG_DEFAULT_COMMENTED, CFG_TYPE_BOOL, DEFAULT_INDENT, vsn(1, 0, 0), NULL, 0, NULL, "Indent messages according to their severity.\n") cfg(log_command_names_CFG, "command_names", log_CFG_SECTION, 0, CFG_TYPE_BOOL, DEFAULT_CMD_NAME, vsn(1, 0, 0), NULL, 0, NULL,
lib/config/defaults.h +1 -1
@@ -221,7 +221,7 @@#define DEFAULT_VERBOSE 0#define DEFAULT_SILENT 0#define DEFAULT_LOGLEVEL 0 -#define DEFAULT_INDENT 1 +#define DEFAULT_INDENT 0#define DEFAULT_ABORT_ON_INTERNAL_ERRORS 0#define DEFAULT_UNITS "r"#define DEFAULT_SUFFIX 1
lib/log/log.c +53 -13
120 lines not on this page · raw message
lib/misc/lvm-globals.c +36 -8
66 lines not on this page · raw message
lib/misc/lvm-globals.h +3 -1
@@ -36,6 +36,7 @@ void init_trust_cache(int trustcache);void init_debug (int level);void init_debug_classes_logged (int classes);void init_cmd_name (int status); +void init_log_command (int log_name,int log_pid);void init_security_level (int level);void init_mirror_in_sync (int in_sync);void init_dmeventd_monitor (int reg);
@@ -73,7 +74,8 @@ int mirror_in_sync(void);int background_polling (void );int ignore_suspended_devices (void );int ignore_lvm_mirrors (void ); -const char *log_command_name (void ); +const char *log_command_info (void ); +const char *log_command_file (void );unsigned is_static (void );int udev_checking (void );const char *sysfs_dir_path (void );
tools/lvmcmdline.c +4 -3
@@ -2492,7 +2492,6 @@ static void _apply_current_settings(struct cmd_context *cmd)init_dmeventd_monitor (DEFAULT_DMEVENTD_MONITOR );init_msg_prefix (cmd->default_settings.msg_prefix); -init_cmd_name (cmd->default_settings.cmd_name);archive_enable (cmd, cmd->current_settings.archive);backup_enable (cmd, cmd->current_settings.backup);
@@ -2788,6 +2787,10 @@ int lvm_run_command(struct cmd_context *cmd, int argc, char **argv)return ECMD_FAILED ; } +set_cmd_name (cmd->name); + +init_log_command (find_config_tree_bool (cmd, log_command_names_CFG,NULL ),0 ); +configure_command_option_values (cmd->name);/* eliminate '-' from all options starting with -- */
@@ -2855,8 +2858,6 @@ int lvm_run_command(struct cmd_context *cmd, int argc, char **argv) cmd->position_argc = argc; cmd->position_argv = argv; -set_cmd_name (cmd->name); -if (arg_is_set (cmd, config_ARG))if (!override_config_tree_from_string (cmd,arg_str_value (cmd, config_ARG,"" ))) { ret =EINVALID_CMD_LINE ;