summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNagi5Yeq <wu@x-nagi.com>2020-06-01 12:12:59 +0800
committerNagi5Yeq <wu@x-nagi.com>2020-06-01 12:12:59 +0800
commit1e993f800921d2a49ad0c71375512a9209347321 (patch)
tree960893d67f124f5954b365a09805cb9b6ca0e68c
parenta7c22d6229b5072445cb814b43140d8c8cc937a5 (diff)
fix log stuff
-rw-r--r--Log.hh5
-rw-r--r--main.cc2
2 files changed, 6 insertions, 1 deletions
diff --git a/Log.hh b/Log.hh
index 561ccf2..0656fa6 100644
--- a/Log.hh
+++ b/Log.hh
@@ -7,6 +7,8 @@
#include <llvm/Support/FormatVariadic.h>
#include <llvm/Support/WithColor.h>
+#include "Context.hh"
+
namespace pcc {
enum LogLevel { PCC_DEBUG, PCC_INFO, PCC_WARNING, PCC_ERROR };
@@ -18,6 +20,9 @@ const char* GetExecutableName();
template <typename... Args>
void Log(LogLevel level, const char* format, Args&&... args) {
+ if (level < GetLogLevel()) {
+ return;
+ }
auto msg = llvm::formatv(format, std::forward<Args>(args)...);
const char* name = GetExecutableName();
switch (level) {
diff --git a/main.cc b/main.cc
index da938a8..5613a15 100644
--- a/main.cc
+++ b/main.cc
@@ -21,7 +21,7 @@ void compile(llvm::Module* module, llvm::raw_pwrite_stream& output,
int main(int argc, char* argv[]) {
int rv;
- int level = pcc::ToUnderlying(pcc::PCC_WARNING);
+ int level = pcc::PCC_WARNING;
std::string OutputFileName;
enum { IR, ASSEMBLY, OBJECT } CompileType = IR;
int OptLevel = 2;