+-------------------------------------------------------------------
+Tue Aug 14 12:03:50 CEST 2012 - aschnell@suse.de
+
+- fixed logging during program termination
+
-------------------------------------------------------------------
Wed Jul 25 10:44:38 CEST 2012 - aschnell@suse.de
using namespace std;
- string filename = "/var/log/snapper.log";
+ // Use a pointer to avoid a global destructor. Otherwise the Snapper
+ // destructor in Factory.cc can be called after when logging does not work
+ // anymore. TODO: nicer solution.
+ string* filename = new string("/var/log/snapper.log");
LogDo log_do = NULL;
LogQuery log_query = NULL;
string prefix = sformat("%s %s libsnapper(%d) %s(%s):%d", datetime(time(0), false, true).c_str(),
ln[level], getpid(), file, func, line);
- FILE* f = fopen(filename.c_str(), "a");
+ FILE* f = fopen(filename->c_str(), "a");
if (f)
{
string tmp = text;
void
initDefaultLogger()
{
- filename = "/var/log/snapper.log";
+ delete filename;
+ filename = new string("/var/log/snapper.log");
if (geteuid())
{
struct passwd* pw = getpwuid(geteuid());
if (pw)
{
- filename = string(pw->pw_dir) + "/.snapper.log";
+ delete filename;
+ filename = new string(string(pw->pw_dir) + "/.snapper.log");
}
}