NetSurf
Functions | Variables
log.c File Reference
#include <stdarg.h>
#include <stdio.h>
#include "utils/config.h"
#include "utils/nsoption.h"
#include "utils/sys_time.h"
#include "utils/utsname.h"
#include "desktop/version.h"
#include "utils/log.h"
Include dependency graph for log.c:

Go to the source code of this file.

Functions

static int timeval_subtract (struct timeval *result, struct timeval *x, struct timeval *y)
 Subtract the ‘struct timeval’ values X and Y. More...
 
static const char * nslog_gettime (void)
 Obtain a formatted string suitable for prepending to a log message. More...
 
void nslog_log (const char *file, const char *func, int ln, const char *format,...)
 
nserror nslog_set_filter (const char *filter)
 Set the logging filter. More...
 
nserror nslog_init (nslog_ensure_t *ensure, int *pargc, char **argv)
 Initialise the logging system. More...
 
nserror nslog_set_filter_by_options (void)
 Set the logging filter according to the options. More...
 
void nslog_finalise (void)
 Shut down the logging system. More...
 

Variables

bool verbose_log = false
 flag to enable verbose logging More...
 
static FILE * logfile
 The stream to which logging is sent. More...
 

Function Documentation

◆ nslog_finalise()

void nslog_finalise ( void  )

Shut down the logging system.

Shuts down the logging subsystem, resetting to verbose logging and output to stderr. Note, if logging is done after calling this, it will be sent to stderr without filtering.

Definition at line 299 of file log.c.

References logfile, NSLOG, and verbose_log.

Referenced by main(), nsgtk_finalise(), and WinMain().

Here is the caller graph for this function:

◆ nslog_gettime()

static const char * nslog_gettime ( void  )
static

Obtain a formatted string suitable for prepending to a log message.

Returns
formatted string of the time since first log call

Definition at line 72 of file log.c.

References timerisset, and timeval_subtract().

Referenced by nslog_log().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ nslog_init()

nserror nslog_init ( nslog_ensure_t ensure,
int *  pargc,
char **  argv 
)

Initialise the logging system.

Sets up everything required for logging. Processes the argv passed to remove the -v switch for verbose logging. If necessary ensures the output file handle is available.

Definition at line 190 of file log.c.

References logfile, utsname::machine, netsurf_version, utsname::nodename, NSERROR_INIT_FAILED, NSERROR_NOT_FOUND, NSERROR_OK, NSLOG, nslog_set_filter(), utsname::release, utsname::sysname, uname(), verbose_log, and utsname::version.

Referenced by gui_init_replicant(), main(), nsgtk_init(), and WinMain().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ nslog_log()

void nslog_log ( const char *  file,
const char *  func,
int  ln,
const char *  format,
  ... 
)

Definition at line 157 of file log.c.

References logfile, nslog_gettime(), and verbose_log.

Here is the call graph for this function:

◆ nslog_set_filter()

nserror nslog_set_filter ( const char *  filter)

Set the logging filter.

Compiles and enables the given logging filter.

Definition at line 181 of file log.c.

References NSERROR_OK.

Referenced by nslog_init(), and nslog_set_filter_by_options().

Here is the caller graph for this function:

◆ nslog_set_filter_by_options()

nserror nslog_set_filter_by_options ( void  )

Set the logging filter according to the options.

Definition at line 289 of file log.c.

References nslog_set_filter(), nsoption_charp, and verbose_log.

Referenced by nsoption_validate().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ timeval_subtract()

static int timeval_subtract ( struct timeval *  result,
struct timeval *  x,
struct timeval *  y 
)
static

Subtract the ‘struct timeval’ values X and Y.

Parameters
resultThe timeval structure to store the result in
xThe first value
yThe second value
Returns
1 if the difference is negative, otherwise 0.

Definition at line 44 of file log.c.

References result.

Referenced by nslog_gettime().

Here is the caller graph for this function:

Variable Documentation

◆ logfile

FILE* logfile
static

The stream to which logging is sent.

Definition at line 34 of file log.c.

Referenced by nslog_finalise(), nslog_init(), and nslog_log().

◆ verbose_log

bool verbose_log = false

flag to enable verbose logging

Definition at line 31 of file log.c.

Referenced by deskmenu_update(), main(), menu_vlog(), nslog_finalise(), nslog_init(), nslog_log(), nslog_set_filter_by_options(), and plot_init().