SCTC
the soundcloud.com terminal client
Macros | Functions
log.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define _log(...)   __log(__FILE__, __LINE__, __func__, __VA_ARGS__)
 

Functions

bool log_init (char *file)
 
void __log (char *srcfile, int srcline, const char *srcfunc, char *fmt,...)
 
void log_close ()
 

Macro Definition Documentation

#define _log (   ...)    __log(__FILE__, __LINE__, __func__, __VA_ARGS__)

Write a line to the logfile.

A timestamp it prepended to the line and the location of the call to _log is appended.
Format of timestamp: "Wed Jun 30 21:49:08 1993".
Format of the location: "{ in function_name (file_name.c:line_number) }"
Calling _log() prior to log_init() or after log_close() does not have any effect.

Due to the synchronisation of __log(), _log() may be called by several threads 'at once' as well.

Always use _log() instead of __log().

Function Documentation

void __log ( char *  srcfile,
int  srcline,
const char *  srcfunc,
char *  fmt,
  ... 
)

The internal implementation for logging.

Warning
This function is not intended to be called directly by the user. Use _log() instead, as this macro inserts the correct position of the call to __log().

This function is synchronized internally and therefore may be called by several threads 'at once'.

Parameters
srcfileThe file executing the call to __log(); filled by macro _log(), do not use "by hand"
srclineThe line in the file executing the call to __log(); filled by macro _log(), do not use "by hand"
srcfuncThe function callint __log(); filled by macro _log(), do not use "by hand"
fmtThe format used format the line, see man 3 printf for usage.

Here is the caller graph for this function:

void log_close ( )

Finalize logging.

Closes any opened descriptors and frees any remaining memory allocated during usage. Any calls to _log() after call to log_close() do not have any effect.

Typically this function is only called prior to termination.

Here is the caller graph for this function:

bool log_init ( char *  file)

Initialize logging.

Initialize logging and thus allow subsequent calls to _log().

Typically this function is called only once directly after starting up the execution

Parameters
fileThe file to log to, either relative or absolute path.
Returns
true on success, false on error

Here is the caller graph for this function: