mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
Allow syslog facility to be set, or turned off, from the config file.
This commit is contained in:
parent
0e63603659
commit
682c0fef74
@ -61,6 +61,10 @@ log {
|
||||
# LVM2. There are three levels of verbosity, 3 being the most
|
||||
# verbose.
|
||||
verbose = 0
|
||||
|
||||
# Should we send log messages through syslog?
|
||||
# 1 is yes; 0 is no.
|
||||
syslog = 1
|
||||
}
|
||||
|
||||
# Configuration of metadata backups and archiving. In LVM2 when we
|
||||
|
@ -29,7 +29,8 @@ void fin_log() {
|
||||
}
|
||||
|
||||
void fin_syslog() {
|
||||
closelog();
|
||||
if (_syslog)
|
||||
closelog();
|
||||
_syslog = 0;
|
||||
}
|
||||
|
||||
|
@ -105,6 +105,12 @@ is invoked. By default tools append messages to the log file.
|
||||
.IP
|
||||
\fBverbose\fP \(em Default level (0-3) of messages sent to stdout or stderr.
|
||||
3 is the most verbose; 0 should produce the least output.
|
||||
.IP
|
||||
\fBsyslog\fP \(em Set to 1 (the default) to send log messages through syslog.
|
||||
Turn off by setting to 0. If you set to an integer greater than one,
|
||||
this is used - unvalidated - as the facility. The default is LOG_USER.
|
||||
See /usr/include/sys/syslog.h for safe facility values to use.
|
||||
For example, LOG_LOCAL0 might be 128.
|
||||
.TP
|
||||
\fBbackup\fP \(em Configuration for metadata backups.
|
||||
.IP
|
||||
@ -159,3 +165,5 @@ Use 022 to allow other users to read the files by default.
|
||||
.SH SEE ALSO
|
||||
.BR lvm (8)
|
||||
.BR umask (2)
|
||||
.BR syslog (3)
|
||||
.BR syslog.conf (5)
|
||||
|
22
tools/lvm.c
22
tools/lvm.c
@ -72,6 +72,7 @@ struct config_info {
|
||||
int debug;
|
||||
int verbose;
|
||||
int test;
|
||||
int syslog;
|
||||
|
||||
int archive; /* should we archive ? */
|
||||
int backup; /* should we backup ? */
|
||||
@ -710,21 +711,31 @@ static void __init_log(struct config_file *cf)
|
||||
{
|
||||
char *open_mode = "a";
|
||||
|
||||
const char *log_file = find_config_str(cf->root, "log/file", '/', 0);
|
||||
const char *log_file;
|
||||
|
||||
|
||||
_default_settings.syslog =
|
||||
find_config_int(cf->root, "log/syslog", '/', 1);
|
||||
if (_default_settings.syslog != 1)
|
||||
fin_syslog();
|
||||
|
||||
if (_default_settings.syslog > 1)
|
||||
init_syslog(_default_settings.syslog);
|
||||
|
||||
_default_settings.debug =
|
||||
find_config_int(cf->root, "log/level", '/', 0);
|
||||
init_debug(_default_settings.debug);
|
||||
|
||||
_default_settings.verbose =
|
||||
find_config_int(cf->root, "log/verbose", '/', 0);
|
||||
init_verbose(_default_settings.verbose);
|
||||
|
||||
_default_settings.test = find_config_int(cf->root, "global/test",
|
||||
'/', 0);
|
||||
|
||||
if (find_config_int(cf->root, "log/overwrite", '/', 0))
|
||||
open_mode = "w";
|
||||
|
||||
init_debug(_default_settings.debug);
|
||||
init_verbose(_default_settings.verbose);
|
||||
|
||||
log_file = find_config_str(cf->root, "log/file", '/', 0);
|
||||
if (log_file) {
|
||||
/* set up the logging */
|
||||
if (!(_log = fopen(log_file, open_mode)))
|
||||
@ -1078,6 +1089,7 @@ static void fin(void)
|
||||
|
||||
dump_memory();
|
||||
fin_log();
|
||||
fin_syslog();
|
||||
|
||||
if (_log)
|
||||
fclose(_log);
|
||||
|
Loading…
Reference in New Issue
Block a user