Elaboradar  0.1
logging.cpp
1 #include "logging.h"
2 #include <cstdio>
3 #include <stdexcept>
4 
5 using namespace std;
6 
7 namespace {
8 static bool initialized = false;
9 }
10 
11 /*
12  * log4c is currently causing "double free or corruption" if log4c_init is
13  * called twice (even with a log4c_fini inbetween).
14  *
15  * Working around this by calling init just once, and never calling fini
16  */
17 
18 Logging::Logging()
19 {
20  if (!initialized)
21  {
22  // Initialize logging
23  if (log4c_init() != 0)
24  throw runtime_error("failed to set up logging");
25  initialized = true;
26  }
27 }
28 
29 Logging::~Logging()
30 {
31  // if (log4c_fini() != 0)
32  // fprintf(stderr, "failed to shut down logging.\n");
33 }