Skip to content

Commit 1eb7bf2

Browse files
committed
remove csvformatter
1 parent d68bb19 commit 1eb7bf2

File tree

7 files changed

+16
-92
lines changed

7 files changed

+16
-92
lines changed

cmake/MELSources.cmake

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ list(APPEND MEL_LOGGING_HEADERS
103103
"${MEL_LOGGING_HEADERS_DIR}/Table.hpp"
104104
"${MEL_LOGGING_HEADERS_DIR}/Detail/Csv.inl"
105105
"${MEL_LOGGING_HEADERS_DIR}/Detail/StreamMeta.hpp"
106-
"${MEL_LOGGING_HEADERS_DIR}/Formatters/CsvFormatter.hpp"
107106
"${MEL_LOGGING_HEADERS_DIR}/Formatters/FuncMessageFormatter.hpp"
108107
"${MEL_LOGGING_HEADERS_DIR}/Formatters/MessageOnlyFormatter.hpp"
109108
"${MEL_LOGGING_HEADERS_DIR}/Formatters/TxtFormatter.hpp"

examples/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ mel_example(options)
1010
mel_example(pid)
1111
mel_example(lockables)
1212
mel_example(ring_buffer)
13-
mel_example(logger)
13+
mel_example(log)
1414
mel_example(melscope)
1515
mel_example(math)
1616
mel_example(shared_memory)

examples/ex_logger.cpp renamed to examples/ex_log.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,20 +75,22 @@ int main() {
7575
LOG(Fatal) << "This is a Fatal log"; // goes to MEL.log and console
7676

7777
/// You can change the max severiy of the default logger
78-
MEL_LOGGER->set_max_severity(Debug);
78+
MEL_LOG->set_max_severity(Debug);
7979

8080
LOG(Debug) << "This is another Debug log"; // goes to MEL.log and console
8181
LOG(Verbose) << "This is another Verbose log"; // goes to MEL.log and console
8282

83+
//==========================================================================
84+
8385
// You can create your own loggers too. First you need to choose a
8486
// Formatter. A Formatter is responsible for taking a log record and turning
8587
// it into a string. There are several built-in Formatters, and you can even
86-
// create your own. Here, we will use the built-in CsvFormatter. Once you've
88+
// create your own. Here, we will use the built-in TxtFormatter. Once you've
8789
// chosen a Formatter, you create a Writer. A Writer is responsible for
8890
// taking a formatted string from a Formatter and writing it in some
8991
// prescribed manner, either to the console, a file, memory, etc. Here we
9092
// will choose the built int RollingFileWriter.
91-
RollingFileWriter<CsvFormatter> file_writer("my_log.csv");
93+
RollingFileWriter<TxtFormatter> file_writer("my_log.txt");
9294
// Now, we create the actual Logger. Loggers are paramertized with an
9395
// integer which can be an enum for convienence. The default logger is 0, so
9496
// custom loggers should start at 1 or some other number.

include/MEL/Logging/Formatters/CsvFormatter.hpp

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

include/MEL/Logging/Log.hpp

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
#pragma once
1919

20-
#include <MEL/Logging/Formatters/CsvFormatter.hpp>
2120
#include <MEL/Logging/Formatters/TxtFormatter.hpp>
2221
#include <MEL/Logging/Writers/ColorConsoleWriter.hpp>
2322
#include <MEL/Logging/Writers/RollingFileWriter.hpp>
@@ -26,7 +25,7 @@
2625
#include <cstring>
2726
#include <vector>
2827

29-
#ifndef DEFAULT_MEL_LOGGER
28+
#ifndef DEFAULT_MEL_LOG
3029
#define DEFAULT_LOGGER 0
3130
#endif
3231

@@ -124,31 +123,25 @@ inline Logger<instance>& init_logger(Severity max_severity,
124123
return init_logger<instance>(max_severity, &rollingFilewriter);
125124
}
126125

127-
/// Initializes a logger with RollingFileWriter and Txt/CsvFormatter chosen by
128-
/// file extension (specific logger instance)
126+
/// Initializes a logger with RollingFileWriter and TxtFormatter
129127
template <int instance>
130128
inline Logger<instance>& init_logger(Severity max_severity,
131129
const char* filename,
132130
size_t max_file_size = 0,
133131
int max_files = 0) {
134-
const char* dot = std::strrchr(filename, '.');
135-
if (dot && 0 == std::strcmp(dot, ".csv"))
136-
return init_logger<CsvFormatter, instance>(max_severity, filename,
137-
max_file_size, max_files);
138-
else
139-
return init_logger<TxtFormatter, instance>(max_severity, filename,
140-
max_file_size, max_files);
132+
return init_logger<TxtFormatter, instance>(max_severity, filename,
133+
max_file_size, max_files);
141134
}
142135

143136
//==============================================================================
144137
// DEFAULT MEL LOGGER
145138
//==============================================================================
146139

147-
/// Built in MEL Logger. Contains two writers: (0) a RollingFileWriter with a
140+
/// Built in MEL Log. Contains two writers: (0) a RollingFileWriter with a
148141
/// TxtFormatter and default severity Verbose, and (1) a ColorConsoleWriter with
149142
/// TxtFormatter and default severity Info. Can be disabled by defining
150143
/// MEL_DISABLE_LOG or enabling DISABLE_LOG option in CMakeLists.txt
151-
extern Logger<DEFAULT_LOGGER>* MEL_LOGGER;
144+
extern Logger<DEFAULT_LOGGER>* MEL_LOG;
152145

153146
} // namespace mel
154147

@@ -177,14 +170,14 @@ extern Logger<DEFAULT_LOGGER>* MEL_LOGGER;
177170

178171
/// Log severity level checker for default MEL logger
179172
#define IF_LOG(severity) \
180-
if (!MEL_LOGGER || !MEL_LOGGER->check_severity(severity)) { \
173+
if (!MEL_LOG || !MEL_LOG->check_severity(severity)) { \
181174
; \
182175
} else
183176

184177
/// Main logging macro for defaulter MEL logger
185178
#define LOG(severity) \
186179
IF_LOG(severity) \
187-
*MEL_LOGGER += LogRecord(severity, LOG_GET_FUNC(), __LINE__, LOG_GET_FILE())
180+
*MEL_LOG += LogRecord(severity, LOG_GET_FUNC(), __LINE__, LOG_GET_FILE())
188181

189182
/// Conditional logging macro for default MEL logger
190183
#define LOG_IF(severity, condition) \

include/MEL/Logging/Severity.hpp

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

1818
#pragma once
1919

20-
2120
namespace mel {
2221

2322
/// Represents a logging severity level

src/MEL/Logging/Log.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ namespace mel {
44

55
#ifndef MEL_DISABLE_LOG
66
static ColorConsoleWriter<TxtFormatter> default_console_writer(Info);
7-
Logger<DEFAULT_LOGGER>* MEL_LOGGER = &init_logger<DEFAULT_LOGGER>(Verbose, "MEL.log", 256000, 10).add_writer(&default_console_writer);
7+
Logger<DEFAULT_LOGGER>* MEL_LOG = &init_logger<DEFAULT_LOGGER>(Verbose, "MEL.log", 256000, 10).add_writer(&default_console_writer);
88
#else
9-
Logger<DEFAULT_LOGGER>* MEL_LOGGER = nullptr;
9+
Logger<DEFAULT_LOGGER>* MEL_LOG = nullptr;
1010
#endif
1111

1212
} // namespace mel

0 commit comments

Comments
 (0)