Skip to content
Snippets Groups Projects
Commit 04dc46b6 authored by Mark Woolrich's avatar Mark Woolrich
Browse files

*** empty log message ***

parent 22a3e0d7
No related branches found
No related tags found
No related merge requests found
......@@ -82,6 +82,47 @@ namespace Utilities {
logEstablished = true;
}
void Log::setthenmakeDir(const string& pdirname, const string& plogfilename, bool pstream_to_logfile, bool pstream_to_cout)
{
if(logEstablished)
{
logfileout.close();
}
dir = pdirname;
logfilename = plogfilename;
stream_to_logfile = pstream_to_logfile;
stream_to_cout = pstream_to_cout;
ifstream dirif;
dirif.open(dir.c_str(), ios::in);
bool direxists = !logfileout.bad();
cout << "direxists = " << direxists << endl;
if(!direxists)
{
// make directory
int ret = system(("mkdir "+ dir + " 2>/dev/null").c_str());
if(ret == 0)
{
throw Exception(string(string("Unable to make directory ")+dir).c_str());
}
}
// setup logfile
if(stream_to_logfile)
{
logfileout.open((dir + "/" + logfilename).c_str(), ios::out);
if(logfileout.bad())
{
throw Exception(string(string("Unable to setup logfile ")+logfilename+string(" in directory ")+dir).c_str());
}
}
logEstablished = true;
}
}
......
......@@ -90,6 +90,11 @@ namespace Utilities{
/** The stream_to* variables define the streaming behaviour */
void setDir(const string& pdirname, const string& plogfilename = "logfile", bool pstream_to_logfile = true, bool pstream_to_cout = false);
/** Sets an existing directory to place results into. */
/** If does not exist then makes it. */
/** The stream_to* variables define the streaming behaviour */
void setthenmakeDir(const string& pdirname, const string& plogfilename = "logfile", bool pstream_to_logfile = true, bool pstream_to_cout = false);
/** Closes old logfile buffer and attempts to open new one with name specified and sets streaming to logfile on */
void setLogFile(const string& plogfilename);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment