i3
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 "util.h"
#include "log.h"
#include "i3.h"
#include "libi3.h"
#include "shmlog.h"
#include "loglevels.h"
Include dependency graph for log.c:

Go to the source code of this file.

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()). More...
 
void set_verbosity (bool _verbose)
 Set verbosity of i3. More...
 
void add_loglevel (const char *level)
 Enables the given loglevel. More...
 
static void vlog (const bool print, const char *fmt, va_list args)
 
void verboselog (char *fmt,...)
 Logs the given message to stdout while prefixing the current time to it, but only if verbose mode is activated. More...
 
void errorlog (char *fmt,...)
 Logs the given message to stdout while prefixing the current time to it. More...
 
void debuglog (uint64_t lev, char *fmt,...)
 Logs the given message to stdout while prefixing the current time to it, but only if the corresponding debug loglevel was activated. More...
 

Variables

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

Function Documentation

void add_loglevel ( const char *  level)

Enables the given loglevel.

Definition at line 141 of file log.c.

References loglevel, and loglevels.

Referenced by main().

void debuglog ( uint64_t  lev,
char *  fmt,
  ... 
)

Logs the given message to stdout while prefixing the current time to it, but only if the corresponding debug loglevel was activated.

Definition at line 272 of file log.c.

References logbuffer, loglevel, and vlog().

Here is the call graph for this function:

void errorlog ( char *  fmt,
  ... 
)

Logs the given message to stdout while prefixing the current time to it.

Definition at line 252 of file log.c.

References errorfile, and vlog().

Here is the call graph for this function:

void init_logging ( void  )

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

Definition at line 77 of file log.c.

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

Referenced by main().

Here is the call graph for this function:

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 133 of file log.c.

References verbose.

Referenced by main().

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

Logs the given message to stdout while prefixing the current time to it, but only if verbose mode is activated.

Definition at line 237 of file log.c.

References logbuffer, verbose, and vlog().

Here is the call graph for this function:

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

Definition at line 167 of file log.c.

References logbuffer, logbuffer_size, loglastwrap, logwalk, and store_log_markers().

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

Here is the call graph for this function:

Variable Documentation

FILE* errorfile
static

Definition at line 33 of file log.c.

Referenced by errorlog(), and init_logging().

char* errorfilename

Definition at line 34 of file log.c.

Referenced by init_logging(), and start_configerror_nagbar().

char* logbuffer
static

Definition at line 45 of file log.c.

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

int logbuffer_shm
static

Definition at line 54 of file log.c.

Referenced by init_logging().

int logbuffer_size
static

Definition at line 52 of file log.c.

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

char* loglastwrap
static

Definition at line 50 of file log.c.

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

uint64_t loglevel = 0
static

Definition at line 31 of file log.c.

Referenced by add_loglevel(), and debuglog().

char* logwalk
static

Definition at line 47 of file log.c.

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

int shmlog_size = 0

Definition at line 43 of file log.c.

Referenced by init_logging(), and main().

char* shmlogname = ""

Definition at line 40 of file log.c.

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

bool verbose = false
static

Definition at line 32 of file log.c.

Referenced by set_verbosity(), and verboselog().