Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
bfs/bfs/include/Logger.h
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
51 lines (38 sloc)
864 Bytes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef LOGGER_H | |
#define LOGGER_H | |
#include <stdlib.h> | |
#include <iostream> | |
#include <fstream> | |
#include <string> | |
#include <vector> | |
using namespace std; | |
extern class Logger { | |
public: | |
int logging_Level = 1; | |
string filename = "log.txt"; | |
}; | |
void start_log(string filename){ | |
ofstream log_file; | |
log_file.open(filename, std::ios_base::in | std::ios_base::trunc); | |
log_file << "Start log"; | |
log_file.close(); | |
} | |
void write_log(string msg, int msg_level, string filename, Logger* logObject) { | |
string line; | |
ofstream log_file; | |
log_file.open(filename, std::ios_base::app); | |
if (logObject->logging_Level <= msg_level) { | |
//for (int i = 0; i < &msg.size; i++) | |
log_file << msg; | |
} | |
log_file.close(); | |
} | |
Logger* logger = NULL; | |
Logger* getLogger() { | |
if (logger == NULL) { | |
logger = new Logger(); | |
} | |
return logger; | |
} | |
//Logger* logger = getLogger(); | |
#endif |