Utility functions for writing log messages to the screen.
More...
Go to the source code of this file.
|
#define | printf PySys_WriteStdout |
|
|
typedef enum logLevels | logLevel |
| Logging levels characterize an ordered set of message types which may be printed to the screen.
|
|
|
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...
|
|
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
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
|
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
-
level | a string containing log level prefix |
message | a 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
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
-
level | the logging level for this message |
format | variable 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
-
msg | a character array for the exception message |
void set_header_character |
( |
char |
c | ) |
|
Sets the character to be used when printing HEADER log messages.
- Parameters
-
c | the 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
-
length | the maximum log message line length in characters |
void set_log_filename |
( |
char * |
filename | ) |
|
Sets the name for the log file.
- Parameters
-
filename | a 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_level | the 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
-
directory | a 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
-
c | the character for SEPARATOR log messages |
void set_title_character |
( |
char |
c | ) |
|
Sets the character to be used when printing TITLE log messages.
- Parameters
-
c | the character for TITLE log messages |