Skip to content

Instantly share code, notes, and snippets.

@MatinMN
Created October 29, 2017 19:52
Show Gist options
  • Save MatinMN/5c26e0e3d1c1d9acbf4ae1bf4d0de15c to your computer and use it in GitHub Desktop.
Save MatinMN/5c26e0e3d1c1d9acbf4ae1bf4d0de15c to your computer and use it in GitHub Desktop.
#include <iostream>
class Log{
public:
const int LogLevelError = 0;
const int LogLevelWarning = 1;
const int LogLevelInfo = 2;
private:
int LogLevel = LogLevelInfo;
public:
void SetLevel(int level) {
LogLevel = level;
}
void Warn(const char* message) {
if (LogLevel >= LogLevelWarning)
std::cout << "[WARNING]: " << message << std::endl;
}
void Info(const char* message) {
if (LogLevel >= LogLevelInfo)
std::cout << "[WARNING]: " << message << std::endl;
}
void Error(const char* message) {
if (LogLevel >= LogLevelError)
std::cout << "[WARNING]: " << message << std::endl;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment