diff options
author | LaG1924 <12997935+LaG1924@users.noreply.github.com> | 2017-05-12 15:49:50 +0200 |
---|---|---|
committer | LaG1924 <12997935+LaG1924@users.noreply.github.com> | 2017-05-12 15:49:50 +0200 |
commit | e62817b8252974b8a98393275874ee303840bf13 (patch) | |
tree | 4565935f06e369f4a84410b0c098958e07a750c7 /Debug.cpp | |
parent | 2017-05-10 (diff) | |
download | AltCraft-e62817b8252974b8a98393275874ee303840bf13.tar AltCraft-e62817b8252974b8a98393275874ee303840bf13.tar.gz AltCraft-e62817b8252974b8a98393275874ee303840bf13.tar.bz2 AltCraft-e62817b8252974b8a98393275874ee303840bf13.tar.lz AltCraft-e62817b8252974b8a98393275874ee303840bf13.tar.xz AltCraft-e62817b8252974b8a98393275874ee303840bf13.tar.zst AltCraft-e62817b8252974b8a98393275874ee303840bf13.zip |
Diffstat (limited to 'Debug.cpp')
-rw-r--r-- | Debug.cpp | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/Debug.cpp b/Debug.cpp new file mode 100644 index 0000000..eb8b2d2 --- /dev/null +++ b/Debug.cpp @@ -0,0 +1,39 @@ +#include "Debug.hpp" + +const bool isPrintSourceFile = false; +const debug::LogLevel debugPrintLevel = debug::LogLevel::INFO; + +void ::debug::WriteLog(std::string message, debug::LogLevel level, debug::LogSource source, std::string sourceFile, + int lineInFile) { + if (debugPrintLevel > level) + return; + std::string levelText; + switch (level) { + case FATAL: + levelText = "FATAL"; + break; + case ERROR: + levelText = "ERROR"; + break; + case WARNING: + levelText = "WARNING"; + break; + case INFO: + levelText = "INFO"; + break; + case DEBUG: + levelText = "DEBUG"; + break; + } + std::string file = " " + sourceFile + ":" + std::to_string(lineInFile); + std::cout << "[" << levelText << "]: " << message << (isPrintSourceFile ? file : "") << std::endl; + if (level <= LogLevel::ERROR) { + if (level <= LogLevel::FATAL) + exit(-1); + Exception exception; + exception.message = message; + exception.level = level; + exception.source = source; + throw exception; + } +}
\ No newline at end of file |