yast2-core
|
#include <errno.h>
#include <fcntl.h>
#include <malloc.h>
#include <pwd.h>
#include <signal.h>
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/types.h>
#include <unistd.h>
#include <limits>
#include <list>
#include "y2util/y2log.h"
#include "y2util/miniini.h"
#include "y2util/stringutil.h"
#include "y2util/PathInfo.h"
#include <syslog.h>
Classes | |
class | LogTail::Impl |
Macros | |
#define | Y2LOG_DATE "%Y-%m-%d %H:%M:%S" /* The date format */ |
#define | Y2LOG_COMMON "%s %s%s:%d %s%s" |
#define | Y2LOG_SIMPLE "%2$s%3$s:%4$d %1$s %5$s%6$s" /* this is GNU gettext parameter reordering */ |
#define | Y2LOG_FORMAT "%s <%d> %s(%d)" |
#define | Y2LOG_SYSLOG "<%d>%s" |
#define | Y2LOG_MAXSIZE 10* 1024 * 1024 /* Maximal logfile size */ |
#define | Y2LOG_MAXNUM 10 /* Maximum logfiles number */ |
#define | LOGDIR "/var/log/YaST2" |
#define | Y2LOG_ROOT LOGDIR "/y2log" |
#define | Y2LOG_USER "/.y2log" /* Relative to $HOME */ |
#define | Y2LOG_FALLBACK "/y2log" |
#define | Y2LOG_CONF "log.conf" /* Relative to $HOME or /etc/YaST2 */ |
#define | Y2LOG_VAR_DEBUG "Y2DEBUG" |
#define | Y2LOG_VAR_ALL "Y2DEBUGALL" |
#define | Y2LOG_VAR_ONCRASH "Y2DEBUGONCRASH" |
#define | Y2LOG_VAR_SIZE "Y2MAXLOGSIZE" |
#define | Y2LOG_VAR_NUM "Y2MAXLOGNUM" |
#define | Y2LOG_FACILITY "yast2" |
Functions | |
static void | do_log_syslog (const char *logmessage) |
static void | do_log_yast (const char *logmessage) |
static int | dup_stderr () |
static int variable_not_used | __attribute__ ((unused)) |
static FILE * | open_logfile () |
void | y2_logger_function (loglevel_t level, const string &component, const char *file, const int line, const char *func, const char *format,...) |
void | y2_logger_blanik (loglevel_t level, const string &component, const char *file, const int line, const char *func, const char *format,...) |
string | y2_logfmt_common (bool simple, const string &component, const char *file, const int line, const char *function, const char *format, va_list ap) |
string | y2_logfmt_prefix (loglevel_t level) |
void | y2_vlogger_function (loglevel_t level, const string &component, const char *file, const int line, const char *function, const char *format, va_list ap) |
void | y2_vlogger_blanik (loglevel_t level, const string &component, const char *file, const int line, const char *function, const char *format, va_list ap) |
void | y2_logger_raw (const char *logmessage) |
void | set_log_filename (string fname) |
string | get_log_filename () |
static string | old (const string &filename, int i, const char *suffix) |
void | shift_log_files_if_needed (string filename) |
static void | signal_handler (int signum) |
static void | set_signal_handler (int signum) |
void | set_log_conf (string confname) |
bool | should_be_logged (int loglevel, const string &componentname) |
void | set_log_simple_mode (bool simple) |
void | set_log_debug (bool on) |
bool | get_log_debug () |
bool | should_be_buffered () |
Variables | |
inisection | logconf |
static bool | did_set_logname = false |
static sig_atomic_t | did_read_logconf = 0 |
static const char * | logname |
static off_t | maxlogsize |
static int | maxlognum |
static sig_atomic_t | log_debug = false |
static bool | log_to_file = true |
static bool | log_to_syslog = false |
static bool | log_all_variable = false |
static bool | log_simple = false |
static FILE * | Y2LOG_STDERR = stderr |
LogTail | blanik = LogTail () |
#define LOGDIR "/var/log/YaST2" |
#define Y2LOG_COMMON "%s %s%s:%d %s%s" |
Referenced by y2_logfmt_common().
#define Y2LOG_CONF "log.conf" /* Relative to $HOME or /etc/YaST2 */ |
Referenced by set_log_conf().
#define Y2LOG_DATE "%Y-%m-%d %H:%M:%S" /* The date format */ |
Referenced by y2_logfmt_prefix().
#define Y2LOG_FACILITY "yast2" |
#define Y2LOG_FALLBACK "/y2log" |
Referenced by set_log_filename().
#define Y2LOG_FORMAT "%s <%d> %s(%d)" |
Referenced by y2_logfmt_prefix().
#define Y2LOG_MAXNUM 10 /* Maximum logfiles number */ |
Referenced by set_log_filename().
#define Y2LOG_MAXSIZE 10* 1024 * 1024 /* Maximal logfile size */ |
Referenced by set_log_filename().
#define Y2LOG_ROOT LOGDIR "/y2log" |
Referenced by set_log_filename().
#define Y2LOG_SIMPLE "%2$s%3$s:%4$d %1$s %5$s%6$s" /* this is GNU gettext parameter reordering */ |
Referenced by y2_logfmt_common().
#define Y2LOG_SYSLOG "<%d>%s" |
Referenced by y2_vlogger_function().
#define Y2LOG_USER "/.y2log" /* Relative to $HOME */ |
Referenced by set_log_filename().
#define Y2LOG_VAR_ALL "Y2DEBUGALL" |
Referenced by set_log_conf().
#define Y2LOG_VAR_DEBUG "Y2DEBUG" |
Referenced by set_log_conf().
#define Y2LOG_VAR_NUM "Y2MAXLOGNUM" |
Referenced by set_log_filename().
#define Y2LOG_VAR_ONCRASH "Y2DEBUGONCRASH" |
Referenced by should_be_buffered().
#define Y2LOG_VAR_SIZE "Y2MAXLOGSIZE" |
Referenced by set_log_filename().
|
static |
Referenced by shift_log_files_if_needed().
|
static |
Referenced by y2_logger_raw().
|
static |
References did_set_logname, logname, open_logfile(), set_log_filename(), shift_log_files_if_needed(), and Y2LOG_STDERR.
Referenced by y2_logger_raw(), and y2_vlogger_function().
|
static |
y2log must use a private copy of stderr, esp. in case we're always logging to it (option "-l -"). Some classes like liby2(ExternalProgram) redirect stderr in order to redirect an external programs error output. As a side effect y2log output done after the redirection would show up in the external programs output file instead of yast2's stderr.
References Y2LOG_STDERR.
bool get_log_debug | ( | ) |
whether debug logging is enabled
References log_debug.
string get_log_filename | ( | ) |
Logfile name reporting
References did_set_logname, logname, and set_log_filename().
|
static |
Referenced by shift_log_files_if_needed(), and YCPElement::writeCopy().
|
static |
References PathInfo::assert_dir(), Pathname::dirname(), log_simple, logname, and Y2LOG_STDERR.
Referenced by do_log_yast().
void set_log_conf | ( | string | confname | ) |
Parse the log.conf
References did_read_logconf, log_all_variable, log_debug, log_to_file, log_to_syslog, logconf, logname, miniini(), set_signal_handler(), Y2LOG_CONF, Y2LOG_VAR_ALL, and Y2LOG_VAR_DEBUG.
Referenced by main(), process_options(), set_log_filename(), and should_be_logged().
void set_log_debug | ( | bool | on = true | ) |
void set_log_filename | ( | string | fname | ) |
Logfile name initialization
References did_read_logconf, did_set_logname, log_to_file, log_to_syslog, logname, maxlognum, maxlogsize, set_log_conf(), stringutil::strtonum(), Y2LOG_FALLBACK, Y2LOG_MAXNUM, Y2LOG_MAXSIZE, Y2LOG_ROOT, Y2LOG_STDERR, Y2LOG_USER, Y2LOG_VAR_NUM, and Y2LOG_VAR_SIZE.
Referenced by do_log_yast(), get_log_filename(), Y2SLog::init(), main(), process_options(), and should_be_logged().
void set_log_simple_mode | ( | bool | simple | ) |
|
static |
References signal_handler().
Referenced by set_log_conf().
void shift_log_files_if_needed | ( | string | filename | ) |
Maintain logfiles We do all of this ourselves because during the installation logrotate does not run
References __attribute__(), maxlognum, maxlogsize, and old().
Referenced by do_log_yast().
bool should_be_buffered | ( | ) |
Should we bother evaluating the arguments to the buffering function?
References Y2LOG_VAR_ONCRASH.
bool should_be_logged | ( | int | loglevel, |
const string & | componentname | ||
) |
Test if we should create a log entry
References did_read_logconf, did_set_logname, log_all_variable, log_debug, log_simple, logconf, set_log_conf(), and set_log_filename().
|
static |
Signal handler: re-read log configuration The variable is checked in the main logger function
References did_read_logconf, and log_debug.
Referenced by set_signal_handler().
string y2_logfmt_common | ( | bool | simple, |
const string & | component, | ||
const char * | file, | ||
const int | line, | ||
const char * | function, | ||
const char * | format, | ||
va_list | ap | ||
) |
Formats the common part
References stringutil::form(), stringutil::vform(), Y2LOG_COMMON, and Y2LOG_SIMPLE.
Referenced by y2_vlogger_blanik(), and y2_vlogger_function().
string y2_logfmt_prefix | ( | loglevel_t | level | ) |
References stringutil::form(), Y2LOG_DATE, and Y2LOG_FORMAT.
Referenced by y2_vlogger_blanik(), and y2_vlogger_function().
void y2_logger_blanik | ( | loglevel_t | level, |
const string & | component, | ||
const char * | file, | ||
const int | line, | ||
const char * | func, | ||
const char * | format, | ||
... | |||
) |
References y2_vlogger_blanik().
void y2_logger_function | ( | loglevel_t | level, |
const string & | component, | ||
const char * | file, | ||
const int | line, | ||
const char * | func, | ||
const char * | format, | ||
... | |||
) |
The universal logger function
References y2_vlogger_function().
void y2_logger_raw | ( | const char * | logmessage | ) |
References do_log_syslog(), do_log_yast(), log_to_file, and log_to_syslog.
void y2_vlogger_blanik | ( | loglevel_t | level, |
const string & | component, | ||
const char * | file, | ||
const int | line, | ||
const char * | function, | ||
const char * | format, | ||
va_list | ap | ||
) |
References blanik, log_simple, log_to_file, log_to_syslog, LogTail::push_back(), y2_logfmt_common(), and y2_logfmt_prefix().
Referenced by y2_logger_blanik().
void y2_vlogger_function | ( | loglevel_t | level, |
const string & | component, | ||
const char * | file, | ||
const int | line, | ||
const char * | function, | ||
const char * | format, | ||
va_list | ap | ||
) |
References do_log_yast(), log_simple, log_to_file, log_to_syslog, y2_logfmt_common(), y2_logfmt_prefix(), and Y2LOG_SYSLOG.
Referenced by y2_logger_function().
Referenced by signal_log_stored_debug(), and y2_vlogger_blanik().
|
static |
Referenced by set_log_conf(), set_log_filename(), should_be_logged(), and signal_handler().
|
static |
Referenced by do_log_yast(), get_log_filename(), set_log_filename(), and should_be_logged().
|
static |
Referenced by set_log_conf(), and should_be_logged().
|
static |
Referenced by get_log_debug(), set_log_conf(), set_log_debug(), should_be_logged(), and signal_handler().
|
static |
Referenced by open_logfile(), set_log_simple_mode(), should_be_logged(), y2_vlogger_blanik(), and y2_vlogger_function().
|
static |
Referenced by set_log_conf(), set_log_filename(), y2_logger_raw(), y2_vlogger_blanik(), and y2_vlogger_function().
|
static |
Referenced by set_log_conf(), set_log_filename(), y2_logger_raw(), y2_vlogger_blanik(), and y2_vlogger_function().
inisection logconf |
Referenced by set_log_conf(), and should_be_logged().
|
static |
Referenced by do_log_yast(), get_log_filename(), open_logfile(), set_log_conf(), and set_log_filename().
|
static |
Referenced by set_log_filename(), and shift_log_files_if_needed().
|
static |
Referenced by set_log_filename(), and shift_log_files_if_needed().
|
static |
Referenced by do_log_yast(), dup_stderr(), open_logfile(), and set_log_filename().