MCPcopy Create free account
hub / github.com/SNAS/openbmp / Logger

Method Logger

Server/src/Logger.cpp:29–69  ·  view source on GitHub ↗

/ * Constructor for class * * \param [in] log_filename log file name or NULL to use stdout * \param [in] debug_filename = debug log filename or NULL to use stdout * * \throws const char * with the error message ***********************************************************************/

Source from the content-addressed store, hash-verified

27 * \throws const char * with the error message
28 ***********************************************************************/
29Logger::Logger(const char *log_filename, const char *debug_filename) {
30
31 /*
32 * Initialize defaults
33 */
34 debugEnabled = false;
35 logFile_REALFILE = false;
36 debugFile_REALFILE = false;
37 width_filename = 20;
38 width_function = 20;
39
40 /*
41 * Open log file
42 */
43 if (log_filename == NULL)
44 logFile = stdout;
45
46 else if ( (logFile=fopen(log_filename, "a+")) == NULL)
47 throw strerror(errno);
48 else
49 // Indicate this is a real file so that we can close it when needed.
50 logFile_REALFILE = true;
51
52 /*
53 * Open the debug log file
54 */
55 if (debug_filename == NULL)
56 debugFile = logFile;
57
58 else {
59 // Check if debug file is the same as the log_filename
60 if (log_filename != NULL and strcmp(log_filename, debug_filename) == 0)
61 debugFile = logFile;
62
63 else if ( (debugFile=fopen(debug_filename, "w")) == NULL)
64 throw strerror(errno);
65 else
66 // Indicate this is a real file so that we can close it when needed.
67 debugFile_REALFILE = true;
68 }
69}
70
71/*********************************************************************//**
72 * Destructor for class

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected