gr1c  0.10.2
 All Data Structures Files Functions Variables Typedefs Groups Pages
Macros | Functions
logging.h File Reference

A simple logging mechanism for gr1c. More...

#include <stdio.h>
#include "common.h"

Macros

#define LOGOPT_NOTIME   1
 
#define LOGOPT_TIME   0
 

Functions

int closelogfile ()
 
int getlogopt ()
 
FILE * getlogstream ()
 
void logprint (char *fmt,...)
 
void logprint_endline ()
 
void logprint_raw (char *fmt,...)
 
void logprint_startline ()
 
FILE * openlogfile (char *prefix)
 
void setlogopt (int options)
 
void setlogstream (FILE *fp)
 

Detailed Description

A simple logging mechanism for gr1c.

SCL; 2012, 2013.

Function Documentation

int closelogfile ( )

Manually close the current log stream, unless it is stdout. Return 0 on success, -1 on error.

int getlogopt ( )

Get current log output configuration

void logprint ( char *  fmt,
  ... 
)

Rudimentary printing routine. Supports d, f, and s flags.

void logprint_endline ( )

End line and flush log stream. Intended for use with logprint_raw() and logprint_startline().

void logprint_raw ( char *  fmt,
  ... 
)

Write to log stream. Do not automatically end line, do not flush, etc.

void logprint_startline ( )

Start a new line. Intended for use with logprint_raw() and logprint_endline().

FILE* openlogfile ( char *  prefix)

Open a new log file, automatically name it with the current date and given prefix, and return the resulting stream, or NULL if error. If the file already exists, then it is appended to. If prefix=NULL, then use "gr1c-" and the PID of the calling process. Name ends with ".log"

void setlogopt ( int  options)

Configure format of log entries.

Combine non-conflicting options with or. Options can be

LOGOPT_TIME : Show timestamp (default).

LOGOPT_NOTIME : Do not show timestamp.  
void setlogstream ( FILE *  fp)

Use given stream for logging. If NULL, then use stdout.