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
|
# LVM2. There are three levels of verbosity, 3 being the most
|
||||||
# verbose.
|
# verbose.
|
||||||
verbose = 0
|
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
|
# Configuration of metadata backups and archiving. In LVM2 when we
|
||||||
|
@ -29,7 +29,8 @@ void fin_log() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void fin_syslog() {
|
void fin_syslog() {
|
||||||
closelog();
|
if (_syslog)
|
||||||
|
closelog();
|
||||||
_syslog = 0;
|
_syslog = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,6 +105,12 @@ is invoked. By default tools append messages to the log file.
|
|||||||
.IP
|
.IP
|
||||||
\fBverbose\fP \(em Default level (0-3) of messages sent to stdout or stderr.
|
\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.
|
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
|
.TP
|
||||||
\fBbackup\fP \(em Configuration for metadata backups.
|
\fBbackup\fP \(em Configuration for metadata backups.
|
||||||
.IP
|
.IP
|
||||||
@ -159,3 +165,5 @@ Use 022 to allow other users to read the files by default.
|
|||||||
.SH SEE ALSO
|
.SH SEE ALSO
|
||||||
.BR lvm (8)
|
.BR lvm (8)
|
||||||
.BR umask (2)
|
.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 debug;
|
||||||
int verbose;
|
int verbose;
|
||||||
int test;
|
int test;
|
||||||
|
int syslog;
|
||||||
|
|
||||||
int archive; /* should we archive ? */
|
int archive; /* should we archive ? */
|
||||||
int backup; /* should we backup ? */
|
int backup; /* should we backup ? */
|
||||||
@ -710,21 +711,31 @@ static void __init_log(struct config_file *cf)
|
|||||||
{
|
{
|
||||||
char *open_mode = "a";
|
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 =
|
_default_settings.debug =
|
||||||
find_config_int(cf->root, "log/level", '/', 0);
|
find_config_int(cf->root, "log/level", '/', 0);
|
||||||
|
init_debug(_default_settings.debug);
|
||||||
|
|
||||||
_default_settings.verbose =
|
_default_settings.verbose =
|
||||||
find_config_int(cf->root, "log/verbose", '/', 0);
|
find_config_int(cf->root, "log/verbose", '/', 0);
|
||||||
|
init_verbose(_default_settings.verbose);
|
||||||
|
|
||||||
_default_settings.test = find_config_int(cf->root, "global/test",
|
_default_settings.test = find_config_int(cf->root, "global/test",
|
||||||
'/', 0);
|
'/', 0);
|
||||||
|
|
||||||
if (find_config_int(cf->root, "log/overwrite", '/', 0))
|
if (find_config_int(cf->root, "log/overwrite", '/', 0))
|
||||||
open_mode = "w";
|
open_mode = "w";
|
||||||
|
|
||||||
init_debug(_default_settings.debug);
|
log_file = find_config_str(cf->root, "log/file", '/', 0);
|
||||||
init_verbose(_default_settings.verbose);
|
|
||||||
|
|
||||||
if (log_file) {
|
if (log_file) {
|
||||||
/* set up the logging */
|
/* set up the logging */
|
||||||
if (!(_log = fopen(log_file, open_mode)))
|
if (!(_log = fopen(log_file, open_mode)))
|
||||||
@ -1078,6 +1089,7 @@ static void fin(void)
|
|||||||
|
|
||||||
dump_memory();
|
dump_memory();
|
||||||
fin_log();
|
fin_log();
|
||||||
|
fin_syslog();
|
||||||
|
|
||||||
if (_log)
|
if (_log)
|
||||||
fclose(_log);
|
fclose(_log);
|
||||||
|
Loading…
Reference in New Issue
Block a user