Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members

y2log.cc File Reference

#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 "y2util/y2log.h"
#include "y2util/miniini.h"
#include <syslog.h>

Defines

#define _GNU_SOURCE   1 /* Needed for vasprintf below */
#define Y2LOG_DATE   "%Y-%m-%d %H:%M:%S" /* The date format */
#define Y2LOG_FORMAT   "%s <%d> %s(%d)%s %s%s:%d %s%s"
#define Y2LOG_SIMPLE   "%2$s%3$s:%4$d %1$s %6$s%7$s" /* this is GNU gettext parameter reordering */
#define Y2LOG_SYSLOG   "<%d>%s %s%s:%d %s%s"
#define Y2LOG_MAXSIZE   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_SIZE   "Y2MAXLOGSIZE"
#define Y2LOG_VAR_NUM   "Y2MAXLOGNUM"
#define Y2LOG_FACILITY   "yast2"

Functions

void shift_log_files (string filename)
int dup_stderr ()
void y2_logger_function (loglevel_t level, const char *component, const char *file, const int line, const char *func, const char *format,...)
void y2_vlogger_function (loglevel_t level, const char *component, const char *file, const int line, const char *function, const char *format, va_list ap)
void set_log_filename (string fname)
string get_log_filename ()
void signal_handler (int signum)
void set_signal_handler (int signum)
void set_log_conf (string confname)
bool should_be_logged (int loglevel, string componentname)
void set_log_simple_mode (bool simple)
void set_log_debug (bool on)
bool get_log_debug ()

Variables

inisection logconf
bool did_set_logname = false
bool did_read_logconf = false
char * logname
int maxlogsize
int maxlognum
bool log_debug = false
bool log_to_file = true
bool log_to_syslog = false
bool log_all_variable = false
bool log_simple = false
FILE * Y2LOG_STDERR = stderr
const char * log_messages []
int variable_not_used = dup_stderr()

Define Documentation

#define _GNU_SOURCE   1 /* Needed for vasprintf below */
 

#define LOGDIR   "/var/log/YaST2"
 

#define Y2LOG_CONF   "log.conf" /* Relative to $HOME or /etc/YaST2 */
 

#define Y2LOG_DATE   "%Y-%m-%d %H:%M:%S" /* The date format */
 

#define Y2LOG_FACILITY   "yast2"
 

#define Y2LOG_FALLBACK   "/y2log"
 

#define Y2LOG_FORMAT   "%s <%d> %s(%d)%s %s%s:%d %s%s"
 

#define Y2LOG_MAXNUM   10 /* Maximum logfiles number */
 

#define Y2LOG_MAXSIZE   1024 * 1024 /* Maximal logfile size */
 

#define Y2LOG_ROOT   LOGDIR "/y2log"
 

#define Y2LOG_SIMPLE   "%2$s%3$s:%4$d %1$s %6$s%7$s" /* this is GNU gettext parameter reordering */
 

#define Y2LOG_SYSLOG   "<%d>%s %s%s:%d %s%s"
 

#define Y2LOG_USER   "/.y2log" /* Relative to $HOME */
 

#define Y2LOG_VAR_ALL   "Y2DEBUGALL"
 

#define Y2LOG_VAR_DEBUG   "Y2DEBUG"
 

#define Y2LOG_VAR_NUM   "Y2MAXLOGNUM"
 

#define Y2LOG_VAR_SIZE   "Y2MAXLOGSIZE"
 


Function Documentation

int dup_stderr  )  [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.

bool get_log_debug  ) 
 

whether debug logging is enabled

string get_log_filename  ) 
 

Logfile name reporting

void set_log_conf string  confname  ) 
 

Parse the log.conf

void set_log_debug bool  on = true  ) 
 

enable or disable debug logging

Parameters:
on true for on

void set_log_filename string  fname  ) 
 

Logfile name initialization

void set_log_simple_mode bool  simple  ) 
 

Set (or reset) the simple mode

void set_signal_handler int  signum  )  [static]
 

void shift_log_files string  filename  )  [static]
 

Maintain logfiles

bool should_be_logged int  loglevel,
string  componentname
 

Test if we should create a log entry

void signal_handler int  signum  )  [static]
 

Signal handler: re-read log configuration The variable is checked in the main logger function

void y2_logger_function loglevel_t  level,
const char *  component,
const char *  file,
const int  line,
const char *  func,
const char *  format,
  ...
 

The universal logger function

void y2_vlogger_function loglevel_t  level,
const char *  component,
const char *  file,
const int  line,
const char *  function,
const char *  format,
va_list  ap
 

The universal logger function


Variable Documentation

bool did_read_logconf = false [static]
 

bool did_set_logname = false [static]
 

bool log_all_variable = false [static]
 

bool log_debug = false [static]
 

const char* log_messages[] [static]
 

Initial value:

 {
    "debug",
    "milestone",
    "warning",
    "error",
    "error",
    "error",
    "error",
}

bool log_simple = false [static]
 

bool log_to_file = true [static]
 

bool log_to_syslog = false [static]
 

inisection logconf
 

char* logname [static]
 

int maxlognum [static]
 

int maxlogsize [static]
 

int variable_not_used = dup_stderr() [static]
 

FILE* Y2LOG_STDERR = stderr [static]
 


Generated on Thu Feb 23 23:56:10 2006 for liby2util by doxygen 1.3.6