An open source method of characteristics neutron transport code.
log.h
Go to the documentation of this file.
1 
11 #ifndef LOG_H_
12 #define LOG_H_
13 
14 #ifdef __cplusplus
15 #ifdef SWIG
16 #include "Python.h"
17 #endif
18 #include <stdio.h>
19 #include <stdarg.h>
20 #include <stdlib.h>
21 #include <sstream>
22 #include <iostream>
23 #include <fstream>
24 #include <iomanip>
25 #include <string.h>
26 #include <stdexcept>
27 #include <time.h>
28 #include <math.h>
29 #include <sys/types.h>
30 #include <sys/stat.h>
31 #include <omp.h>
32 #endif
33 
34 #ifdef MPIx
35 #include <mpi.h>
36 #endif
37 
38 #ifdef SWIG
39 #define printf PySys_WriteStdout
40 #endif
41 
47 typedef enum logLevels{
50 
53 
56 
59 
62 
65 
68 
71 
74 
77 
80 
83 
86 
89 } logLevel;
90 
91 
99 extern void set_err(const char *msg);
100 
101 void initialize_logger();
102 void set_output_directory(char* directory);
103 const char* get_output_directory();
104 void set_log_filename(char* filename);
105 const char* get_log_filename();
106 
107 void set_separator_character(char c);
109 void set_header_character(char c);
110 char get_header_character();
111 void set_title_character(char c);
112 char get_title_character();
113 void set_line_length(int length);
114 void set_log_level(const char* new_level);
115 void set_log_level(int new_level);
116 int get_log_level();
117 
118 void log_printf(logLevel level, const char *format, ...);
119 std::string create_multiline_msg(std::string level, std::string message);
120 #ifdef MPIx
121 void log_set_ranks(MPI_Comm comm);
122 #endif
123 
124 #endif /* LOG_H_ */
char get_header_character()
Returns the character used to format HEADER type log messages.
Definition: log.cpp:185
int get_log_level()
Return the minimum level for log messages printed to the screen.
Definition: log.cpp:288
Definition: log.h:49
Definition: log.h:55
void set_output_directory(char *directory)
Sets the output directory for log files.
Definition: log.cpp:113
char get_separator_character()
Returns the character used to format SEPARATOR log messages.
Definition: log.cpp:167
void set_log_filename(char *filename)
Sets the name for the log file.
Definition: log.cpp:140
logLevels
Logging levels characterize an ordered set of message types which may be printed to the screen...
Definition: log.h:47
Definition: log.h:88
Definition: log.h:67
void set_separator_character(char c)
Sets the character to be used when printing SEPARATOR log messages.
Definition: log.cpp:158
void set_line_length(int length)
Sets the maximum line length for log messages.
Definition: log.cpp:214
Definition: log.h:52
Definition: log.h:82
char get_title_character()
Returns the character used to format TITLE log messages.
Definition: log.cpp:203
Definition: log.h:70
void set_title_character(char c)
Sets the character to be used when printing TITLE log messages.
Definition: log.cpp:194
Definition: log.h:61
void set_header_character(char c)
Sets the character to be used when printing HEADER log messages.
Definition: log.cpp:176
void log_printf(logLevel level, const char *format,...)
Print a formatted message to the console.
Definition: log.cpp:300
const char * get_log_filename()
Returns the log filename.
Definition: log.cpp:149
void initialize_logger()
Initializes the logger for use.
Definition: log.cpp:101
const char * get_output_directory()
Returns the output directory for log files.
Definition: log.cpp:131
Definition: log.h:85
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. ...
Definition: log.cpp:621
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...
Definition: log.cpp:224
Definition: log.h:73
Definition: log.h:76
Definition: log.h:79
Definition: log.h:64
Definition: log.h:58
void set_err(const char *msg)
A function stub used to convert C++ exceptions into Python exceptions through SWIG.