NetSurf
Macros | Typedefs | Enumerations | Functions | Variables
log.h File Reference
#include <stdio.h>
#include <stdbool.h>
#include "utils/errors.h"
Include dependency graph for log.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define NETSURF_LOG_LEVEL   INFO
 
#define NSLOG_LVL(level)   NSLOG_LEVEL_ ## level
 
#define NSLOG_EVL(level)   NSLOG_LVL(level)
 
#define NSLOG_COMPILED_MIN_LEVEL   NSLOG_EVL(NETSURF_LOG_LEVEL)
 
#define LOG_FN   ""
 
#define LOG_LN   __LINE__
 
#define NSLOG(catname, level, logmsg, args...)
 

Typedefs

typedef bool() nslog_ensure_t(FILE *fptr)
 Ensures the FILE handle is available to write logging to. More...
 

Enumerations

enum  nslog_level {
  NSLOG_LEVEL_DEEPDEBUG = 0 , NSLOG_LEVEL_DEBUG = 1 , NSLOG_LEVEL_VERBOSE = 2 , NSLOG_LEVEL_INFO = 3 ,
  NSLOG_LEVEL_WARNING = 4 , NSLOG_LEVEL_ERROR = 5 , NSLOG_LEVEL_CRITICAL = 6
}
 

Functions

nserror nslog_init (nslog_ensure_t *ensure, int *pargc, char **argv)
 Initialise the logging system. More...
 
void nslog_finalise (void)
 Shut down the logging system. More...
 
nserror nslog_set_filter (const char *filter)
 Set the logging filter. More...
 
nserror nslog_set_filter_by_options (void)
 Set the logging filter according to the options. More...
 
void nslog_log (const char *file, const char *func, int ln, const char *format,...) __attribute__((format(printf
 

Variables

bool verbose_log
 flag to enable verbose logging More...
 

Macro Definition Documentation

◆ LOG_FN

#define LOG_FN   ""

Definition at line 112 of file log.h.

◆ LOG_LN

#define LOG_LN   __LINE__

Definition at line 113 of file log.h.

◆ NETSURF_LOG_LEVEL

#define NETSURF_LOG_LEVEL   INFO

Definition at line 69 of file log.h.

◆ NSLOG

#define NSLOG (   catname,
  level,
  logmsg,
  args... 
)
Value:
do { \
if (NSLOG_LEVEL_##level >= NSLOG_COMPILED_MIN_LEVEL) { \
nslog_log(__FILE__, LOG_FN, LOG_LN, logmsg , ##args); \
} \
} while(0)
#define LOG_FN
Definition: log.h:112
#define NSLOG_COMPILED_MIN_LEVEL
Definition: log.h:74
#define LOG_LN
Definition: log.h:113

Definition at line 116 of file log.h.

◆ NSLOG_COMPILED_MIN_LEVEL

#define NSLOG_COMPILED_MIN_LEVEL   NSLOG_EVL(NETSURF_LOG_LEVEL)

Definition at line 74 of file log.h.

◆ NSLOG_EVL

#define NSLOG_EVL (   level)    NSLOG_LVL(level)

Definition at line 73 of file log.h.

◆ NSLOG_LVL

#define NSLOG_LVL (   level)    NSLOG_LEVEL_ ## level

Definition at line 72 of file log.h.

Typedef Documentation

◆ nslog_ensure_t

typedef bool() nslog_ensure_t(FILE *fptr)

Ensures the FILE handle is available to write logging to.

This is provided by the frontends if required

Definition at line 35 of file log.h.

Enumeration Type Documentation

◆ nslog_level

Enumerator
NSLOG_LEVEL_DEEPDEBUG 
NSLOG_LEVEL_DEBUG 
NSLOG_LEVEL_VERBOSE 
NSLOG_LEVEL_INFO 
NSLOG_LEVEL_WARNING 
NSLOG_LEVEL_ERROR 
NSLOG_LEVEL_CRITICAL 

Definition at line 93 of file log.h.

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_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,
  ... 
)

◆ 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:

Variable Documentation

◆ verbose_log

bool verbose_log
extern

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