Skip to content

Commit 6e5cb46

Browse files
author
Matthew E Pezent
committed
move files out of main Logging dir
1 parent 1eb7bf2 commit 6e5cb46

File tree

6 files changed

+46
-69
lines changed

6 files changed

+46
-69
lines changed

cmake/MELSources.cmake

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,7 @@ list(APPEND MEL_LOGGING_HEADERS
9898
"${MEL_LOGGING_HEADERS_DIR}/Csv.hpp"
9999
"${MEL_LOGGING_HEADERS_DIR}/File.hpp"
100100
"${MEL_LOGGING_HEADERS_DIR}/Log.hpp"
101-
"${MEL_LOGGING_HEADERS_DIR}/LogRecord.hpp"
102-
"${MEL_LOGGING_HEADERS_DIR}/Severity.hpp"
101+
"${MEL_LOGGING_HEADERS_DIR}/Detail/LogUtil.hpp"
103102
"${MEL_LOGGING_HEADERS_DIR}/Table.hpp"
104103
"${MEL_LOGGING_HEADERS_DIR}/Detail/Csv.inl"
105104
"${MEL_LOGGING_HEADERS_DIR}/Detail/StreamMeta.hpp"
@@ -289,7 +288,7 @@ list(APPEND MEL_LOGGING_SRC
289288
"${MEL_LOGGING_SRC_DIR}/Csv.cpp"
290289
"${MEL_LOGGING_SRC_DIR}/File.cpp"
291290
"${MEL_LOGGING_SRC_DIR}/Log.cpp"
292-
"${MEL_LOGGING_SRC_DIR}/LogRecord.cpp"
291+
"${MEL_LOGGING_SRC_DIR}/LogUtil.cpp"
293292
"${MEL_LOGGING_SRC_DIR}/Table.cpp"
294293
)
295294

include/MEL/Logging/LogRecord.hpp renamed to include/MEL/Logging/Detail/LogUtil.hpp

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,53 @@
1919

2020
#include <MEL/Logging/Detail/StreamMeta.hpp>
2121
#include <sys/stat.h>
22-
#include <MEL/Logging/Severity.hpp>
2322
#include <MEL/Core/Console.hpp>
2423
#include <MEL/Utility/System.hpp>
2524
#include <MEL/Core/Timestamp.hpp>
2625

2726
namespace mel {
2827

28+
/// Represents a logging severity level
29+
enum Severity {
30+
None = 0, ///< always written
31+
Fatal = 1, ///< error that forces application abort
32+
Error = 2, ///< error that is fatal to operation, but not application
33+
Warning = 3, ///< error that may cause issues, but has been accounted for
34+
Info = 4, ///< useful information needed during normal operation
35+
Verbose = 5, ///< useful information not needed during normal operation
36+
Debug = 6, ///< useful information needed for diagnostics
37+
};
38+
39+
inline const char* severity_to_string(Severity severity) {
40+
switch (severity) {
41+
case Fatal:
42+
return "FATAL";
43+
case Error:
44+
return "ERROR";
45+
case Warning:
46+
return "WARN";
47+
case Info:
48+
return "INFO";
49+
case Verbose:
50+
return "VERB";
51+
case Debug:
52+
return "DEBUG";
53+
default:
54+
return "NONE";
55+
}
56+
}
57+
58+
inline Severity string_to_severity(const char* str) {
59+
for (Severity severity = Fatal; severity <= Debug;
60+
severity = static_cast<Severity>(severity + 1)) {
61+
if (severity_to_string(severity)[0] == str[0]) {
62+
return severity;
63+
}
64+
}
65+
66+
return None;
67+
}
68+
2969
/// Encapsulates a Log record
3070
class LogRecord {
3171
public:

include/MEL/Logging/Formatters/TxtFormatter.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
#pragma once
1919

20-
#include <MEL/Logging/LogRecord.hpp>
20+
#include <MEL/Logging/Detail/LogUtil.hpp>
2121
#include <iomanip>
2222

2323
namespace mel {

include/MEL/Logging/Severity.hpp

Lines changed: 0 additions & 62 deletions
This file was deleted.

include/MEL/Logging/Writers/Writer.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
#pragma once
1919

20-
#include <MEL/Logging/LogRecord.hpp>
20+
#include <MEL/Logging/Detail/LogUtil.hpp>
2121

2222
namespace mel {
2323

src/MEL/Logging/LogRecord.cpp renamed to src/MEL/Logging/LogUtil.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include <MEL/Logging/LogRecord.hpp>
1+
#include <MEL/Logging/Detail/LogUtil.hpp>
22
#include <cstring>
33

44
namespace mel {

0 commit comments

Comments
 (0)