40 const int dir_err = mkdir(
"logs", S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
42 PDB_COUT <<
"logs folder created." << std::endl;
45 outputFile = fopen(std::string(
"logs/" + fName).c_str(),
"a");
47 std::cout <<
"Unable to open logging file.\n";
52 pthread_mutex_init(&
fileLock,
nullptr);
62 outputFile = fopen((std::string(
"logs/") + fName).c_str(),
"a");
64 std::cout <<
"Unable to open logging file.\n";
100 writeLn(std::to_string(writeMe));
123 this->
writeLn(
"[TRACE] " + writeMe);
131 this->
writeLn(
"[DEBUG] " + writeMe);
140 this->
writeLn(
"[INFO] " + writeMe);
149 this->
writeLn(
"[WARN] " + writeMe);
157 this->
writeLn(
"[ERROR] " + writeMe);
165 this->
writeLn(
"[FATAL] " + writeMe);
179 time_t now = time(0);
182 tstruct = *localtime(&now);
183 strftime(buf,
sizeof(buf),
"[%Y-%m-%d-%X] ", &tstruct);
186 writeMe = buf + writeMe;
189 pthread_t threadId = pthread_self();
190 if (writeMe[writeMe.length() - 1] !=
'\n') {
191 fprintf(
outputFile,
"[%lu]%s\n", threadId, writeMe.c_str());
193 fprintf(
outputFile,
"[%lu]%s", threadId, writeMe.c_str());
204 fwrite(data,
sizeof(
char), length,
outputFile);
void writeInt(int writeMe)
void fatal(std::string writeMe)
void setLoglevel(LogLevel loglevel)
void writeLn(std::string writeMe)
void info(std::string writeMe)
void error(std::string writeMe)
void write(char *data, unsigned int length)
PDBLogger(std::string fName)
void debug(std::string writeMe)
void open(std::string fName)
void setEnabled(bool enabled)
void warn(std::string writeMe)
void trace(std::string writeMe)