A monte carlo pin cell spectral code for nuclear engineering applications.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
log.h File Reference

Utility functions for writing log messages to the screen. More...

Go to the source code of this file.

Macros

#define printf   PySys_WriteStdout
 

Typedefs

typedef enum logLevels logLevel
 Logging levels characterize an ordered set of message types which may be printed to the screen.
 

Enumerations

enum  logLevels {
  DEBUG, INFO, NORMAL, SEPARATOR,
  HEADER, TITLE, WARNING, CRITICAL,
  RESULT, UNITTEST, ERROR
}
 Logging levels characterize an ordered set of message types which may be printed to the screen. More...
 

Functions

void set_err (const char *msg)
 A function stub used to convert C++ exceptions into Python exceptions through SWIG. More...
 
void set_output_directory (char *directory)
 Sets the output directory for log files. More...
 
const char * get_output_directory ()
 Returns the output directory for log files. More...
 
void set_log_filename (char *filename)
 Sets the name for the log file. More...
 
const char * get_log_filename ()
 Returns the log filename. More...
 
void set_separator_character (char c)
 Sets the character to be used when printing SEPARATOR log messages. More...
 
char get_separator_character ()
 Returns the character used to format SEPARATOR log messages. More...
 
void set_header_character (char c)
 Sets the character to be used when printing HEADER log messages. More...
 
char get_header_character ()
 Returns the character used to format HEADER type log messages. More...
 
void set_title_character (char c)
 Sets the character to be used when printing TITLE log messages. More...
 
char get_title_character ()
 Returns the character used to format TITLE log messages. More...
 
void set_line_length (int length)
 Sets the maximum line length for log messages. More...
 
void set_log_level (const char *new_level)
 Sets the minimum log message level which will be printed to the console and to the log file. More...
 
int get_log_level ()
 Return the minimum level for log messages printed to the screen. More...
 
void log_printf (logLevel level, const char *format,...)
 Print a formatted message to the console. More...
 
std::string create_multiline_msg (std::string level, std::string message)
 Breaks up a message which is too long for a single line into a multiline message. More...
 

Detailed Description

Utility functions for writing log messages to the screen.

Applies level-based logging to print formatted messages to the screen and to a log file.

Author
William Boyd (wboyd.nosp@m.@mit.nosp@m..edu)
Date
January 22, 2012

Enumeration Type Documentation

enum logLevels

Logging levels characterize an ordered set of message types which may be printed to the screen.

Enumerator
DEBUG 

A debugging message

INFO 

An informational but verbose message

NORMAL 

A brief progress update on run progress

SEPARATOR 

A message of a single line of characters

HEADER 

A message centered within a line of characters

TITLE 

A message sandwiched between two lines of characters

WARNING 

A message for to warn the user

CRITICAL 

A message to warn of critical program conditions

RESULT 

A message containing program results

UNITTEST 

A messsage for unit testing

ERROR 

A message reporting error conditions

Function Documentation

std::string create_multiline_msg ( std::string  level,
std::string  message 
)

Breaks up a message which is too long for a single line into a multiline message.

This is an internal function which is called by log_printf and should not be called directly by the user.

Parameters
levela string containing log level prefix
messagea string containing the log message
Returns
a string with a formatted multiline message
char get_header_character ( )

Returns the character used to format HEADER type log messages.

Returns
the character used for HEADER type log messages
const char* get_log_filename ( )

Returns the log filename.

Returns
a character array for the log filename
int get_log_level ( )

Return the minimum level for log messages printed to the screen.

Returns
the minimum level for log messages
const char* get_output_directory ( )

Returns the output directory for log files.

Returns
a character array for the log file directory
char get_separator_character ( )

Returns the character used to format SEPARATOR log messages.

Returns
the character used for SEPARATOR log messages
char get_title_character ( )

Returns the character used to format TITLE log messages.

Returns
the character used for TITLE log messages
void log_printf ( logLevel  level,
const char *  format,
  ... 
)

Print a formatted message to the console.

If the logging level is ERROR, this function will throw a runtime exception

Parameters
levelthe logging level for this message
formatvariable list of C++ formatted arguments
void set_err ( const char *  msg)

A function stub used to convert C++ exceptions into Python exceptions through SWIG.

This method is not defined in the C++ source. It is defined in the SWIG inteface files (i.e., openmoc/openmoc.i)

Parameters
msga character array for the exception message
void set_header_character ( char  c)

Sets the character to be used when printing HEADER log messages.

Parameters
cthe character for HEADER log messages
void set_line_length ( int  length)

Sets the maximum line length for log messages.

Messages longer than this amount will be broken up into multiline messages.

Parameters
lengththe maximum log message line length in characters
void set_log_filename ( char *  filename)

Sets the name for the log file.

Parameters
filenamea character array for log filename
void set_log_level ( const char *  new_level)

Sets the minimum log message level which will be printed to the console and to the log file.

Parameters
new_levelthe minimum logging level as a character array
void set_output_directory ( char *  directory)

Sets the output directory for log files.

If the directory does not exist, it creates it for the user.

Parameters
directorya character array for the log file directory
void set_separator_character ( char  c)

Sets the character to be used when printing SEPARATOR log messages.

Parameters
cthe character for SEPARATOR log messages
void set_title_character ( char  c)

Sets the character to be used when printing TITLE log messages.

Parameters
cthe character for TITLE log messages