summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Benjamin Barenblat2015-08-02 12:55:31 -0400
committerGravatar Benjamin Barenblat2015-08-02 12:55:31 -0400
commit9ff23da2550dd159d81933c0236529ececc526b5 (patch)
treea0d000b990dd935986bd41437e51f01b97a086bd /src
parentMerge pull request #999 from LittleWhite-tb/qt-save-location (diff)
downloadyuzu-9ff23da2550dd159d81933c0236529ececc526b5.tar.gz
yuzu-9ff23da2550dd159d81933c0236529ececc526b5.tar.xz
yuzu-9ff23da2550dd159d81933c0236529ececc526b5.zip
Handle invalid `Log::Level::Count`
Add a case of `Log::Level::Count` to all switch statements that dispatch on `Log::Level`. The case simply asserts `false` and notes the invalid log level.
Diffstat (limited to 'src')
-rw-r--r--src/common/logging/backend.cpp5
-rw-r--r--src/common/logging/text_formatter.cpp5
2 files changed, 9 insertions, 1 deletions
diff --git a/src/common/logging/backend.cpp b/src/common/logging/backend.cpp
index d85e58373..68580e1c0 100644
--- a/src/common/logging/backend.cpp
+++ b/src/common/logging/backend.cpp
@@ -6,6 +6,7 @@
6#include <array> 6#include <array>
7#include <cstdio> 7#include <cstdio>
8 8
9#include "common/assert.h"
9#include "common/common_funcs.h" // snprintf compatibility define 10#include "common/common_funcs.h" // snprintf compatibility define
10#include "common/logging/backend.h" 11#include "common/logging/backend.h"
11#include "common/logging/filter.h" 12#include "common/logging/filter.h"
@@ -78,8 +79,10 @@ const char* GetLevelName(Level log_level) {
78 LVL(Warning); 79 LVL(Warning);
79 LVL(Error); 80 LVL(Error);
80 LVL(Critical); 81 LVL(Critical);
82 case Level::Count:
83 ASSERT_MSG(false, "invalid log level");
84 return "Unknown";
81 } 85 }
82 return "Unknown";
83#undef LVL 86#undef LVL
84} 87}
85 88
diff --git a/src/common/logging/text_formatter.cpp b/src/common/logging/text_formatter.cpp
index 94f3dfc1f..e3bb148bb 100644
--- a/src/common/logging/text_formatter.cpp
+++ b/src/common/logging/text_formatter.cpp
@@ -14,6 +14,7 @@
14#include "common/logging/log.h" 14#include "common/logging/log.h"
15#include "common/logging/text_formatter.h" 15#include "common/logging/text_formatter.h"
16 16
17#include "common/assert.h"
17#include "common/common_funcs.h" 18#include "common/common_funcs.h"
18#include "common/string_util.h" 19#include "common/string_util.h"
19 20
@@ -82,6 +83,8 @@ void PrintColoredMessage(const Entry& entry) {
82 color = FOREGROUND_RED | FOREGROUND_INTENSITY; break; 83 color = FOREGROUND_RED | FOREGROUND_INTENSITY; break;
83 case Level::Critical: // Bright magenta 84 case Level::Critical: // Bright magenta
84 color = FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_INTENSITY; break; 85 color = FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_INTENSITY; break;
86 case Level::Count:
87 ASSERT_MSG(false, "invalid log level"); break;
85 } 88 }
86 89
87 SetConsoleTextAttribute(console_handle, color); 90 SetConsoleTextAttribute(console_handle, color);
@@ -101,6 +104,8 @@ void PrintColoredMessage(const Entry& entry) {
101 color = ESC "[1;31m"; break; 104 color = ESC "[1;31m"; break;
102 case Level::Critical: // Bright magenta 105 case Level::Critical: // Bright magenta
103 color = ESC "[1;35m"; break; 106 color = ESC "[1;35m"; break;
107 case Level::Count:
108 ASSERT_MSG(false, "invalid log level"); break;
104 } 109 }
105 110
106 fputs(color, stderr); 111 fputs(color, stderr);