Wave Arts VQE  1.00
Voice Quality Enhancement
Defines | Typedefs | Enumerations | Functions | Variables
WaLog.h File Reference

Logging functions. More...

#include <stdio.h>
#include <stdarg.h>

Go to the source code of this file.

Defines

#define WA_LOG(level, arg)   if (level <= gWaLogLevel) { WaLogMacro_##level(arg); }
 level must be 0...3 or expect errors.
#define WaLogMacro_0(arg)   WaLog0 arg
#define WaLogMacro_1(arg)   WaLog1 arg
#define WaLogMacro_2(arg)   WaLog2 arg
#define WaLogMacro_3(arg)   WaLog3 arg

Typedefs

typedef void WaLogFn (void *arg, int level, char *buf)
 Prototype logging function, to redirect logging.

Enumerations

enum  {
  WA_LOG_DATE = 1, WA_LOG_TIME = 2, WA_LOG_SOURCE = 4, WA_LOG_NEWLINE = 8,
  WA_LOG_INITSPACE = 16
}
 Log decoration flags. More...

Functions

void WaLog (char *source, int level, char *fmt, va_list args)
 Generate log message and pass to WaLogMessage.
void WaLog0 (char *source, char *fmt,...)
 Log level 0.
void WaLog1 (char *source, char *fmt,...)
 Log level 1.
void WaLog2 (char *source, char *fmt,...)
 Log level 2.
void WaLog3 (char *source, char *fmt,...)
 Log level 3.
void WaLogSetDecor (int flags)
 Set the decoration flags.
int WaLogGetDecor ()
 Get the decoration flags.
void WaLogSetLogFn (WaLogFn *fn, void *arg)
 Set function to receive log messages.
void WaLogMessage (int level, char *buf)
 All log messages flow through this function.
int WaLogGetLevel ()
 Get logging level.
void WaLogSetLevel (int level)
 Set logging level.
int WaLogOpen (char *file)
 Log to specified file.
void WaLogClose ()
 Close log file.
void WaLogOpenStdout ()
 Log to stdout.

Variables

int gWaLogLevel
FILE * gWaLogFp

Detailed Description

Logging functions.

Simple log functions accessed via macro, e.g.:

WA_LOG(2, (__FILE__, "got value %d and value %d", a, b));

First argument is level:
0 = critical error
1 = error or important message
2 = moderate detail
3 = fine detail, e.g., inside loops, for debugging only

Second argument is (source, fmt, args...) in printf style, and MUST be enclosed in parentheses to be treated as a single macro argument.

To disable log compilation in an individual module:
#define WA_LOG(level, arg)

Note that there is no thread synchronization, and it might not work as expected for DLLs or plugins where globals are shared between instances. It's a good idea to enclose WA_LOG in curly braces if used as clause of an if statement, otherwise any else clause will generate compile error.


Define Documentation

#define WA_LOG (   level,
  arg 
)    if (level <= gWaLogLevel) { WaLogMacro_##level(arg); }

level must be 0...3 or expect errors.

The semicolon after WA_LOG is not necessary, leads to null statement.


Enumeration Type Documentation

anonymous enum

Log decoration flags.

Enumerator:
WA_LOG_DATE 

output date

WA_LOG_TIME 

output time

WA_LOG_SOURCE 

output source

WA_LOG_NEWLINE 

output newline automatically

WA_LOG_INITSPACE 

output leading space (to match pjsip)

 All Classes Files Functions Variables Typedefs Enumerations Enumerator Defines