-
-
Notifications
You must be signed in to change notification settings - Fork 222
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Stephen Eckels
committed
Jun 3, 2020
1 parent
0f47489
commit 2a65c07
Showing
7 changed files
with
72 additions
and
60 deletions.
There are no files selected for viewing
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#include "polyhook2/ErrorLog.hpp" | ||
|
||
void PLH::ErrorLog::setLogLevel(PLH::ErrorLevel level) { | ||
m_logLevel = level; | ||
} | ||
|
||
void PLH::ErrorLog::push(std::string msg, PLH::ErrorLevel level) { | ||
push({ std::move(msg), level }); | ||
} | ||
|
||
void PLH::ErrorLog::push(PLH::Error err) { | ||
if (err.lvl >= m_logLevel) { | ||
switch (err.lvl) { | ||
case ErrorLevel::INFO: | ||
std::cout << "[+] Info: " << err.msg << std::endl; | ||
break; | ||
case ErrorLevel::WARN: | ||
std::cout << "[!] Warn: " << err.msg << std::endl; | ||
break; | ||
case ErrorLevel::SEV: | ||
std::cout << "[!] Error: " << err.msg << std::endl; | ||
break; | ||
default: | ||
std::cout << "Unsupported error message logged " << err.msg << std::endl; | ||
} | ||
} | ||
|
||
m_log.push_back(std::move(err)); | ||
} | ||
|
||
PLH::Error PLH::ErrorLog::pop() { | ||
Error err{}; | ||
if (!m_log.empty()) { | ||
err = std::move(m_log.back()); | ||
m_log.pop_back(); | ||
} | ||
return err; | ||
} | ||
|
||
PLH::ErrorLog& PLH::ErrorLog::singleton() { | ||
static ErrorLog log; | ||
return log; | ||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#include "polyhook2/UID.hpp" | ||
|
||
PLH::UID::UID(long val) { | ||
this->val = val; | ||
} | ||
|
||
std::atomic_long& PLH::UID::singleton() { | ||
static std::atomic_long base = { -1 }; | ||
base++; | ||
return base; | ||
} |