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/y2changes.h"
#include "y2util/stringutil.h"
#include "y2util/PathInfo.h"
#include <syslog.h>
Macros | |
#define | _GNU_SOURCE 1 /* Needed for vasprintf below */ |
#define | Y2CHANGES_DATE "%Y-%m-%d %H:%M:%S" /* The date format */ |
#define | Y2CHANGES_FORMAT "%s <%s> %s " |
#define | Y2CHANGES_SYSLOG "<%d>%s " |
#define | Y2CHANGES_MAXSIZE 10* 1024 * 1024 /* Maximal logfile size */ |
#define | Y2CHANGES_MAXNUM 10 /* Maximum logfiles number */ |
#define | LOGDIR "/var/log/YaST2" |
#define | Y2CHANGES_ROOT LOGDIR "/y2changes" |
#define | Y2CHANGES_USER "/.y2changes" /* Relative to $HOME */ |
#define | Y2CHANGES_FALLBACK "/y2changes" |
#define | Y2CHANGES_VAR_SIZE "Y2MAXLOGSIZE" |
#define | Y2CHANGES_VAR_NUM "Y2MAXLOGNUM" |
#define | Y2CHANGES_FACILITY "yast2" |
Functions | |
static void | do_log_yast (const char *logmessage) |
static void | shift_log_files (string filename) |
static int | dup_stderr () |
static FILE * | open_logfile () |
string | y2_changesfmt_prefix (logcategory_t category) |
void | y2changes_function (logcategory_t category, const char *format,...) |
static void | set_log_filename (string fname) |
static string | old (const string &filename, int i, const char *suffix) |
Variables | |
static bool | did_set_logname = false |
static const char * | logname |
static off_t | maxlogsize |
static int | maxlognum |
static bool | log_to_file = true |
static bool | log_to_syslog = false |
static FILE * | Y2CHANGES_STDERR = stderr |
static const char * | log_messages [] |
static int | variable_not_used = dup_stderr() |
#define _GNU_SOURCE 1 /* Needed for vasprintf below */ |
#define LOGDIR "/var/log/YaST2" |
#define Y2CHANGES_DATE "%Y-%m-%d %H:%M:%S" /* The date format */ |
Referenced by y2_changesfmt_prefix().
#define Y2CHANGES_FACILITY "yast2" |
#define Y2CHANGES_FALLBACK "/y2changes" |
Referenced by set_log_filename().
#define Y2CHANGES_FORMAT "%s <%s> %s " |
Referenced by y2_changesfmt_prefix().
#define Y2CHANGES_MAXNUM 10 /* Maximum logfiles number */ |
Referenced by set_log_filename().
#define Y2CHANGES_MAXSIZE 10* 1024 * 1024 /* Maximal logfile size */ |
Referenced by set_log_filename().
#define Y2CHANGES_ROOT LOGDIR "/y2changes" |
Referenced by set_log_filename().
#define Y2CHANGES_SYSLOG "<%d>%s " |
Referenced by y2changes_function().
#define Y2CHANGES_USER "/.y2changes" /* Relative to $HOME */ |
Referenced by set_log_filename().
#define Y2CHANGES_VAR_NUM "Y2MAXLOGNUM" |
Referenced by set_log_filename().
#define Y2CHANGES_VAR_SIZE "Y2MAXLOGSIZE" |
Referenced by set_log_filename().
|
static |
References did_set_logname, logname, open_logfile(), set_log_filename(), shift_log_files(), and Y2CHANGES_STDERR.
Referenced by y2changes_function().
|
static |
y2changes 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 Y2CHANGES output done after the redirection would show up in the external programs output file instead of yast2's stderr.
References Y2CHANGES_STDERR.
|
static |
Referenced by shift_log_files(), and YCPElement::writeCopy().
|
static |
References PathInfo::assert_dir(), Pathname::dirname(), logname, and Y2CHANGES_STDERR.
Referenced by do_log_yast().
|
static |
Logfile name initialization
References did_set_logname, log_to_file, log_to_syslog, logname, maxlognum, maxlogsize, stringutil::strtonum(), Y2CHANGES_FALLBACK, Y2CHANGES_MAXNUM, Y2CHANGES_MAXSIZE, Y2CHANGES_ROOT, Y2CHANGES_STDERR, Y2CHANGES_USER, Y2CHANGES_VAR_NUM, and Y2CHANGES_VAR_SIZE.
Referenced by do_log_yast().
|
static |
Maintain logfiles We do all of this ourselves because during the installation logrotate does not run
References maxlognum, maxlogsize, and old().
Referenced by do_log_yast().
string y2_changesfmt_prefix | ( | logcategory_t | category | ) |
References log_messages, Y2CHANGES_DATE, and Y2CHANGES_FORMAT.
Referenced by y2changes_function().
void y2changes_function | ( | logcategory_t | category, |
const char * | format, | ||
... | |||
) |
The universal logger function
References do_log_yast(), log_to_file, log_to_syslog, y2_changesfmt_prefix(), and Y2CHANGES_SYSLOG.
|
static |
Referenced by do_log_yast(), and set_log_filename().
|
static |
Referenced by y2_changesfmt_prefix().
|
static |
Referenced by set_log_filename(), and y2changes_function().
|
static |
Referenced by set_log_filename(), and y2changes_function().
|
static |
Referenced by do_log_yast(), open_logfile(), and set_log_filename().
|
static |
Referenced by set_log_filename(), and shift_log_files().
|
static |
Referenced by set_log_filename(), and shift_log_files().
|
static |
|
static |
Referenced by do_log_yast(), dup_stderr(), open_logfile(), and set_log_filename().