yast2-core
Macros | Functions | Variables
y2changes.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 <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_syslog (const char *logmessage)
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()

Macro Definition Documentation

#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().


Function Documentation

static void do_log_syslog ( const char *  logmessage)
static
static void do_log_yast ( const char *  logmessage)
static
static int dup_stderr ( )
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 string old ( const string &  filename,
int  i,
const char *  suffix 
)
static
static FILE* open_logfile ( )
static
static void set_log_filename ( string  fname)
static
static void shift_log_files ( string  filename)
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)
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.


Variable Documentation

bool did_set_logname = false
static

Referenced by do_log_yast(), and set_log_filename().

const char* log_messages[]
static
Initial value:
{
"item",
"note",
}

Referenced by y2_changesfmt_prefix().

bool log_to_file = true
static
bool log_to_syslog = false
static
const char* logname
static
int maxlognum
static
off_t maxlogsize
static
int variable_not_used = dup_stderr()
static
FILE* Y2CHANGES_STDERR = stderr
static

Generated on a sunny day for yast2-core by doxygen 1.8.1