i3
Functions | Variables
log.c File Reference
#include <config.h>
#include "all.h"
#include "shmlog.h"
#include <errno.h>
#include <fcntl.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <unistd.h>
#include <pthread.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 open_logbuffer (void)
 Opens the logbuffer. More...
 
void close_logbuffer (void)
 Closes the logbuffer. More...
 
void set_verbosity (bool _verbose)
 Set verbosity of i3. More...
 
bool get_debug_logging (void)
 Checks if debug logging is active. More...
 
void set_debug_logging (const bool _debug_logging)
 Set debug logging. More...
 
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. More...
 

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
 
static long long physical_mem_bytes
 

Function Documentation

◆ close_logbuffer()

void close_logbuffer ( void  )

Closes the logbuffer.

Definition at line 181 of file log.c.

References logbuffer, logbuffer_shm, and shmlogname.

Referenced by init_logging(), and open_logbuffer().

◆ debuglog()

void debuglog ( char *  fmt,
  ... 
)

Definition at line 336 of file log.c.

References debug_logging, logbuffer, and vlog().

Here is the call graph for this function:

◆ errorlog()

void errorlog ( char *  fmt,
  ... 
)

Definition at line 316 of file log.c.

References errorfile, and vlog().

Here is the call graph for this function:

◆ get_debug_logging()

bool get_debug_logging ( void  )

Checks if debug logging is active.

Definition at line 203 of file log.c.

References debug_logging.

Referenced by cmd_debuglog(), and i3_restart().

◆ init_logging()

void init_logging ( void  )

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

Definition at line 82 of file log.c.

References close_logbuffer(), errorfile, errorfilename, get_process_filename(), logbuffer, open_logbuffer(), physical_mem_bytes, purge_zerobyte_logfile(), and shmlog_size.

Referenced by cmd_shmlog(), and main().

Here is the call graph for this function:

◆ open_logbuffer()

void open_logbuffer ( void  )

Opens the logbuffer.

Definition at line 122 of file log.c.

References close_logbuffer(), i3_shmlog_header::condvar, header, logbuffer, logbuffer_shm, logbuffer_size, loglastwrap, logwalk, min(), physical_mem_bytes, sasprintf(), shmlog_size, shmlogname, and store_log_markers().

Referenced by init_logging().

Here is the call graph for this function:

◆ purge_zerobyte_logfile()

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

References errorfilename.

Referenced by cmd_restart(), and init_logging().

◆ set_debug_logging()

void set_debug_logging ( const bool  _debug_logging)

Set debug logging.

Definition at line 211 of file log.c.

References debug_logging.

Referenced by cmd_debuglog(), and main().

◆ set_verbosity()

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

References verbose.

Referenced by main().

◆ store_log_markers()

static void store_log_markers ( void  )
static

◆ verboselog()

void verboselog ( char *  fmt,
  ... 
)

Definition at line 301 of file log.c.

References logbuffer, verbose, and vlog().

Here is the call graph for this function:

◆ vlog()

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

Definition at line 222 of file log.c.

References i3_shmlog_header::condvar, header, 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

◆ debug_logging

bool debug_logging = false
static

Definition at line 34 of file log.c.

Referenced by debuglog(), get_debug_logging(), and set_debug_logging().

◆ errorfile

FILE* errorfile
static

Definition at line 36 of file log.c.

Referenced by errorlog(), and init_logging().

◆ errorfilename

char* errorfilename

Definition at line 37 of file log.c.

Referenced by init_logging(), purge_zerobyte_logfile(), run_binding(), and start_config_error_nagbar().

◆ header

i3_shmlog_header* header
static

Definition at line 52 of file log.c.

Referenced by ipc_send_client_message(), open_logbuffer(), store_log_markers(), and vlog().

◆ logbuffer

char* logbuffer
static

◆ logbuffer_shm

int logbuffer_shm
static

Definition at line 59 of file log.c.

Referenced by close_logbuffer(), and open_logbuffer().

◆ logbuffer_size

int logbuffer_size
static

Definition at line 57 of file log.c.

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

◆ loglastwrap

char* loglastwrap
static

Definition at line 55 of file log.c.

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

◆ logwalk

char* logwalk
static

Definition at line 50 of file log.c.

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

◆ physical_mem_bytes

long long physical_mem_bytes
static

Definition at line 61 of file log.c.

Referenced by init_logging(), and open_logbuffer().

◆ shmlog_size

int shmlog_size = 0

Definition at line 46 of file log.c.

Referenced by cmd_shmlog(), init_logging(), main(), and open_logbuffer().

◆ shmlogname

char* shmlogname = ""

◆ verbose

bool verbose = false
static

Definition at line 35 of file log.c.

Referenced by CFGFUN(), set_verbosity(), and verboselog().