Fork me on GitHub
Data Structures | Macros | Typedefs | Functions
log.c File Reference

Buffered logging. More...

#include <errno.h>
#include <string.h>
#include <unistd.h>
#include "log.h"
#include "utils.h"
#include "loggers/logger.h"
Include dependency graph for log.c:

Data Structures

struct  janus_log_buffer
 

Macros

#define THREAD_NAME   "log"
 
#define INITIAL_BUFSZ   2000
 

Typedefs

typedef struct janus_log_buffer janus_log_buffer
 

Functions

gboolean janus_log_is_stdout_enabled (void)
 Method to check whether stdout logging is enabled. More...
 
gboolean janus_log_is_logfile_enabled (void)
 Method to check whether file-based logging is enabled. More...
 
char * janus_log_get_logfile_path (void)
 Method to get the path to the log file. More...
 
void janus_vprintf (const char *format,...)
 
int janus_log_init (gboolean daemon, gboolean console, const char *logfile)
 Log initialization. More...
 
void janus_log_set_loggers (GHashTable *loggers)
 Method to add a list of external loggers to the log management. More...
 
void janus_log_destroy (void)
 Log destruction. More...
 

Detailed Description

Buffered logging.

Author
Jay Ridgeway jayri.nosp@m.dge@.nosp@m.gmail.nosp@m..com

Implementation of a simple buffered logger designed to remove I/O wait from threads that may be sensitive to such delays. Buffers are saved and reused to reduce allocation calls. The logger output can then be printed to stdout and/or a log file. If external loggers are added to the core, the logger output is passed to those as well.

Core

Macro Definition Documentation

#define INITIAL_BUFSZ   2000
#define THREAD_NAME   "log"

Typedef Documentation

Function Documentation

void janus_log_destroy ( void  )

Log destruction.

char* janus_log_get_logfile_path ( void  )

Method to get the path to the log file.

Returns
The full path to the log file, or NULL otherwise
int janus_log_init ( gboolean  daemon,
gboolean  console,
const char *  logfile 
)

Log initialization.

Note
This should be called before attempting to use the logger. A buffer pool and processing thread are created.
Parameters
daemonWhether the Janus is running as a daemon or not
consoleWhether the output should be printed on stdout or not
logfileLog file to save the output to, if any
Returns
0 in case of success, a negative integer otherwise
gboolean janus_log_is_logfile_enabled ( void  )

Method to check whether file-based logging is enabled.

Returns
TRUE if file-based logging is enabled, FALSE otherwise
gboolean janus_log_is_stdout_enabled ( void  )

Method to check whether stdout logging is enabled.

Returns
TRUE if stdout logging is enabled, FALSE otherwise
void janus_log_set_loggers ( GHashTable *  loggers)

Method to add a list of external loggers to the log management.

Parameters
loggersHash table of external loggers registered in the core
void janus_vprintf ( const char *  format,
  ... 
)