An open source method of characteristics neutron transport code.
|
Utility functions for writing log messages to the screen. More...
Go to the source code of this file.
Typedefs | |
typedef enum logLevels | logLevel |
Enumerations | |
enum | logLevels { DEBUG, INFO, INFO_ONCE, NORMAL, NODAL, SEPARATOR, HEADER, TITLE, WARNING, WARNING_ONCE, 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 | initialize_logger () |
Initializes the logger for use. 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... | |
void | set_log_level (int new_level) |
Sets the minimum log message level which will be printed to the console and to the log file. This is an overloaded version to handle a logLevel type input. 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... | |
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.
enum logLevels |
Logging levels characterize an ordered set of message types which may be printed to the screen.
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.
level | a string containing log level prefix |
message | a string containing the log message |
char get_header_character | ( | ) |
Returns the character used to format HEADER type log messages.
const char* get_log_filename | ( | ) |
Returns the log filename.
int get_log_level | ( | ) |
Return the minimum level for log messages printed to the screen.
const char* get_output_directory | ( | ) |
Returns the output directory for log files.
char get_separator_character | ( | ) |
Returns the character used to format SEPARATOR log messages.
char get_title_character | ( | ) |
Returns the character used to format TITLE log messages.
void initialize_logger | ( | ) |
Initializes the logger for use.
This should be immediately called when the logger is imported into Python and before any of its other routines are called. The routine initializes an OpenMP mutual exclusion lock which is used to preclude race conditions from occurring when an ERROR message is reported and program execution is terminated.
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
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)
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.
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.
length | the maximum log message line length in characters |
void set_log_filename | ( | char * | filename | ) |
Sets the name for the log file.
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.
new_level | the minimum logging level as a character array |
void set_log_level | ( | int | new_level | ) |
Sets the minimum log message level which will be printed to the console and to the log file. This is an overloaded version to handle a logLevel type input.
new_level | the minimum logging level as an int(or enum type logLevel) |
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.
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.
c | the character for SEPARATOR log messages |
void set_title_character | ( | char | c | ) |
Sets the character to be used when printing TITLE log messages.
c | the character for TITLE log messages |