Added mutex lock to log output.
This commit is contained in:
parent
64afc5ab9f
commit
4286a7b449
@ -14,7 +14,5 @@ namespace coreutils {
|
||||
|
||||
Log(LOG_EXCEPT) << text;
|
||||
}
|
||||
|
||||
Exception::~Exception() {}
|
||||
|
||||
}
|
||||
|
@ -9,7 +9,6 @@ namespace coreutils {
|
||||
|
||||
public:
|
||||
Exception(std::string text, std::string file = __FILE__, int line = __LINE__, int errorNumber = -1);
|
||||
~Exception();
|
||||
|
||||
std::string className;
|
||||
std::string file;
|
||||
|
4
Log.cpp
4
Log.cpp
@ -61,6 +61,8 @@ namespace coreutils {
|
||||
Log::~Log() {
|
||||
|
||||
if(output) {
|
||||
|
||||
mtx.lock();
|
||||
|
||||
std::stringstream out;
|
||||
out << seq << "." << this->str() << std::endl;;
|
||||
@ -73,6 +75,8 @@ namespace coreutils {
|
||||
|
||||
std::cout << out.str();
|
||||
++seq;
|
||||
|
||||
mtx.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
|
3
Log.h
3
Log.h
@ -86,6 +86,9 @@ namespace coreutils {
|
||||
///
|
||||
|
||||
static int seq;
|
||||
|
||||
private:
|
||||
std::mutex mtx;
|
||||
|
||||
};
|
||||
|
||||
|
2
compile
2
compile
@ -5,7 +5,7 @@ do
|
||||
filename="${file%.*}"
|
||||
list="$list $filename.o"
|
||||
echo -n "Compiling $filename..."
|
||||
g++ -c $file &
|
||||
g++ -g -c $file
|
||||
if [ $? = '0' ]
|
||||
then
|
||||
echo "OK"
|
||||
|
Loading…
x
Reference in New Issue
Block a user