i3
Macros | Functions | Variables
log.c File Reference
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdlib.h>
#include <sys/time.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <errno.h>
#include <pthread.h>
#include "util.h"
#include "log.h"
#include "i3.h"
#include "libi3.h"
#include "shmlog.h"
Include dependency graph for log.c:

Go to the source code of this file.

Macros

#define I3__FILE__   "log.c"

Functions

static void store_log_markers (void)
void init_logging (void)
 Initializes logging by creating an error logfile in /tmp (or XDG_RUNTIME_DIR, see get_process_filename()).
void set_verbosity (bool _verbose)
 Set verbosity of i3.
void set_debug_logging (const bool _debug_logging)
 Set debug logging.
static void vlog (const bool print, const char *fmt, va_list args)
void verboselog (char *fmt,...)
void errorlog (char *fmt,...)
void debuglog (char *fmt,...)
void purge_zerobyte_logfile (void)
 Deletes the unused log files.

Variables

static bool debug_logging = false
static bool verbose = false
static FILE * errorfile
char * errorfilename
char * shmlogname = ""
int shmlog_size = 0
static char * logbuffer
static char * logwalk
static i3_shmlog_headerheader
static char * loglastwrap
static int logbuffer_size
static int logbuffer_shm

Macro Definition Documentation

#define I3__FILE__   "log.c"

Definition at line 2 of file log.c.

Function Documentation

void debuglog ( char *  fmt,
  ... 
)

Definition at line 279 of file log.c.

References debug_logging, logbuffer, and vlog().

Here is the call graph for this function:

void errorlog ( char *  fmt,
  ... 
)

Definition at line 259 of file log.c.

void init_logging ( void  )

Initializes logging by creating an error logfile in /tmp (or XDG_RUNTIME_DIR, see get_process_filename()).

Definition at line 81 of file log.c.

References i3_shmlog_header::condvar, ELOG, errorfile, errorfilename, get_process_filename(), logbuffer, logbuffer_shm, logbuffer_size, loglastwrap, logwalk, min(), purge_zerobyte_logfile(), sasprintf(), shmlog_size, shmlogname, and store_log_markers().

Referenced by main().

Here is the call graph for this function:

void purge_zerobyte_logfile ( void  )

Deletes the unused log files.

Useful if i3 exits immediately, eg. because –get-socketpath was called. We don't care for syscall failures. This function is invoked automatically when exiting.

Definition at line 295 of file log.c.

References errorfilename.

Referenced by init_logging().

void set_debug_logging ( const bool  _debug_logging)

Set debug logging.

Definition at line 165 of file log.c.

References debug_logging.

Referenced by main().

void set_verbosity ( bool  _verbose)

Set verbosity of i3.

If verbose is set to true, informative messages will be printed to stdout. If verbose is set to false, only errors will be printed.

Definition at line 157 of file log.c.

References verbose.

Referenced by main().

static void store_log_markers ( void  )
static
void verboselog ( char *  fmt,
  ... 
)

Definition at line 244 of file log.c.

static void vlog ( const bool  print,
const char *  fmt,
va_list  args 
)
static

Definition at line 176 of file log.c.

References i3_shmlog_header::condvar, logbuffer, logbuffer_size, loglastwrap, logwalk, store_log_markers(), and i3_shmlog_header::wrap_count.

Referenced by debuglog(), errorlog(), and verboselog().

Here is the call graph for this function:

Variable Documentation

bool debug_logging = false
static

Definition at line 35 of file log.c.

Referenced by debuglog(), and set_debug_logging().

FILE* errorfile
static

Definition at line 37 of file log.c.

Referenced by errorlog(), and init_logging().

char* errorfilename
i3_shmlog_header* header
static

Definition at line 53 of file log.c.

char* logbuffer
static

Definition at line 49 of file log.c.

Referenced by debuglog(), init_logging(), store_log_markers(), verboselog(), and vlog().

int logbuffer_shm
static

Definition at line 60 of file log.c.

Referenced by init_logging().

int logbuffer_size
static

Definition at line 58 of file log.c.

Referenced by init_logging(), store_log_markers(), and vlog().

char* loglastwrap
static

Definition at line 56 of file log.c.

Referenced by init_logging(), store_log_markers(), and vlog().

char* logwalk
static

Definition at line 51 of file log.c.

Referenced by init_logging(), store_log_markers(), and vlog().

int shmlog_size = 0

Definition at line 47 of file log.c.

Referenced by init_logging(), and main().

char* shmlogname = ""

Definition at line 44 of file log.c.

Referenced by handle_signal(), i3_exit(), init_logging(), and x_set_i3_atoms().

bool verbose = false
static

Definition at line 36 of file log.c.

Referenced by set_verbosity(), and verboselog().