added: allow setting a subdirectory for the logfile from an argument
This commit is contained in:
parent
070cb8da18
commit
2b8a68b83f
3 changed files with 7 additions and 7 deletions
|
@ -86,7 +86,7 @@ CBitVis::~CBitVis()
|
||||||
void CBitVis::Setup()
|
void CBitVis::Setup()
|
||||||
{
|
{
|
||||||
//init the logfile
|
//init the logfile
|
||||||
SetLogFile("bitvis.log");
|
SetLogFile(".bitvis", "bitvis.log");
|
||||||
|
|
||||||
SetupSignals();
|
SetupSignals();
|
||||||
|
|
||||||
|
|
|
@ -66,7 +66,7 @@ string GetStrTime()
|
||||||
return buff;
|
return buff;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool InitLog(string filename, ofstream& logfile)
|
bool InitLog(string directory, string filename, ofstream& logfile)
|
||||||
{
|
{
|
||||||
string homepath;
|
string homepath;
|
||||||
if (!GetHomePath(homepath))
|
if (!GetHomePath(homepath))
|
||||||
|
@ -75,8 +75,8 @@ bool InitLog(string filename, ofstream& logfile)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
string directory = homepath + ".bitvis/";
|
directory = homepath + directory;
|
||||||
string fullpath = directory + filename;
|
string fullpath = directory + "/" + filename;
|
||||||
|
|
||||||
//try to make the directory the log goes in
|
//try to make the directory the log goes in
|
||||||
if (mkdir(directory.c_str(), S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH) == -1)
|
if (mkdir(directory.c_str(), S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH) == -1)
|
||||||
|
@ -124,7 +124,7 @@ string PruneFunction(string function)
|
||||||
return function.substr(spacepos + 1, parenpos - spacepos - 1);
|
return function.substr(spacepos + 1, parenpos - spacepos - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetLogFile(std::string filename)
|
void SetLogFile(const char* directory, const char* filename)
|
||||||
{
|
{
|
||||||
if (!g_logmutex)
|
if (!g_logmutex)
|
||||||
g_logmutex = new CMutex;
|
g_logmutex = new CMutex;
|
||||||
|
@ -139,7 +139,7 @@ void SetLogFile(std::string filename)
|
||||||
g_logbuff = NULL;
|
g_logbuff = NULL;
|
||||||
g_logbuffsize = 0;
|
g_logbuffsize = 0;
|
||||||
|
|
||||||
if (!InitLog(filename, *g_logfile))
|
if (!InitLog(directory, filename, *g_logfile))
|
||||||
g_printlogtofile = false;
|
g_printlogtofile = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@ enum LogLevel
|
||||||
#define LogDebug(fmt, ...) g_printdebuglevel ? PrintLog(fmt, __PRETTY_FUNCTION__, LogLevelDebug, ##__VA_ARGS__) : (void)0
|
#define LogDebug(fmt, ...) g_printdebuglevel ? PrintLog(fmt, __PRETTY_FUNCTION__, LogLevelDebug, ##__VA_ARGS__) : (void)0
|
||||||
|
|
||||||
void PrintLog (const char* fmt, const char* function, LogLevel loglevel, ...) __attribute__ ((format (printf, 1, 4)));
|
void PrintLog (const char* fmt, const char* function, LogLevel loglevel, ...) __attribute__ ((format (printf, 1, 4)));
|
||||||
void SetLogFile(std::string logfile);
|
void SetLogFile(const char* directory, const char* filename);
|
||||||
|
|
||||||
extern bool g_logtostderr;
|
extern bool g_logtostderr;
|
||||||
extern bool g_printlogtofile;
|
extern bool g_printlogtofile;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue