Main Page | Data Structures | File List | Data Fields | Globals | Related Pages

log.c File Reference

Logging functions, with levels, multiple output channels, and syslog. More...

#include "log.h"
#include <sys/types.h>
#include <sys/time.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <syslog.h>
#include <unistd.h>
#include <stdio.h>
#include <assert.h>

Defines

#define debug(prg)   { if (debug_flag) { prg } }
 Run debug code if debugging is enabled.


Functions

void LOGFilename (const char *filename)
 Set the filename to be used by the logger.

int LOGInit (LogTarget lt, LogLevel max, const char *prefix)
 Initialise the log subsystem.

void LOGShutdown ()
 Close down the log subsystem.

void LOGSetLevel (LogLevel max)
 Set the maximum level.

const char * level_name (LogLevel ll)
 Get a string representing the given log level.

void LOGWrite (LogLevel ll, const char *msg)
 Write a message to the log file.


Variables

const int debug_flag = 0
 Control whether debug code is run.

int log_initialised = 0
 Flag indicating whether the log system has been initialised.

LogTarget log_targets = 0
 Bitmask defining which log systems messages should be sent to.

LogLevel log_level = 2
 Level indicating the maximum level of messages that should be logged.

const char * log_fname = NULL
 Filename of the file currently being used for logging.

const char * log_prefix = "Glacsweb"
 Prefix used when writing log messages to indicate their source.

FILE * log_fileptr
 File pointer of the file currently being used for logging.


Detailed Description

Logging functions, with levels, multiple output channels, and syslog.

Copyright (C) 2004 Alistair Riddoch, The University of Southampton


Function Documentation

const char* level_name LogLevel  ll  )  [static]
 

Get a string representing the given log level.

Parameters:
ll log level which this message is at.
Returns:
string representing log level.

void LOGFilename const char *  filename  ) 
 

Set the filename to be used by the logger.

Must be called before LOGInit if file logging is enabled.

Parameters:
filename string containing the name of the file to be as a log.

int LOGInit LogTarget  lt,
LogLevel  max,
const char *  prefix
 

Initialise the log subsystem.

Initialise the log targets indicated, and set the maximum level and log prefix. If logging to file is required then the filename must have already been set using LOGFilename(). If an error occurs, logging is still enabled, but those targets which encountered an error will not be enabled.

Parameters:
lt bitmask defining which targets to set up.
max maximum log level which should be logged.
prefix to be used when writing log messages to indicate their source.
Returns:
zero if initialisation is successful, non-zero otherwise.

void LOGSetLevel LogLevel  max  ) 
 

Set the maximum level.

The maximum level can be changed only after logging has been initialised.

Parameters:
max maximum log level which should be logged.

void LOGShutdown  ) 
 

Close down the log subsystem.

Close any of the log targets which need to be closed.

void LOGWrite LogLevel  ll,
const char *  msg
 

Write a message to the log file.

If the level given is less than or equal to the maximum level, the message will be logged to the enabled log targets.

Parameters:
ll log level which this message is at.
msg contents of log message.


Variable Documentation

const int debug_flag = 0 [static]
 

Control whether debug code is run.

Set to non-zero if debug code should be run.

int log_initialised = 0 [static]
 

Flag indicating whether the log system has been initialised.

Set to non-zero when the log system is successfully started up.

LogLevel log_level = 2 [static]
 

Level indicating the maximum level of messages that should be logged.

Messages above this level (of lower priority) are discarded.


Generated on Mon Aug 9 13:41:45 2004 for Glacsweb by doxygen 1.3.5