Rename Log package to Trace
This commit is contained in:
parent
fc9726b3ec
commit
e7a396655c
2
deps/ox/src/ox/CMakeLists.txt
vendored
2
deps/ox/src/ox/CMakeLists.txt
vendored
@ -4,6 +4,6 @@ if(OX_USE_STDLIB STREQUAL "ON")
|
|||||||
add_subdirectory(clargs)
|
add_subdirectory(clargs)
|
||||||
endif(OX_USE_STDLIB STREQUAL "ON")
|
endif(OX_USE_STDLIB STREQUAL "ON")
|
||||||
add_subdirectory(fs)
|
add_subdirectory(fs)
|
||||||
add_subdirectory(log)
|
add_subdirectory(trace)
|
||||||
add_subdirectory(mc)
|
add_subdirectory(mc)
|
||||||
add_subdirectory(std)
|
add_subdirectory(std)
|
||||||
|
2
deps/ox/src/ox/fs/CMakeLists.txt
vendored
2
deps/ox/src/ox/fs/CMakeLists.txt
vendored
@ -23,7 +23,7 @@ if(OX_BUILD_EXEC STREQUAL "ON")
|
|||||||
target_link_libraries(
|
target_link_libraries(
|
||||||
oxfstool
|
oxfstool
|
||||||
OxFS
|
OxFS
|
||||||
OxLog
|
OxTrace
|
||||||
OxStd
|
OxStd
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
8
deps/ox/src/ox/fs/test/CMakeLists.txt
vendored
8
deps/ox/src/ox/fs/test/CMakeLists.txt
vendored
@ -24,28 +24,28 @@ target_link_libraries(
|
|||||||
FileStoreFormat
|
FileStoreFormat
|
||||||
OxFS
|
OxFS
|
||||||
OxStd
|
OxStd
|
||||||
OxLog
|
OxTrace
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(
|
target_link_libraries(
|
||||||
FileSystemFormat
|
FileSystemFormat
|
||||||
OxFS
|
OxFS
|
||||||
OxStd
|
OxStd
|
||||||
OxLog
|
OxTrace
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(
|
target_link_libraries(
|
||||||
FileStoreIO
|
FileStoreIO
|
||||||
OxFS
|
OxFS
|
||||||
OxStd
|
OxStd
|
||||||
OxLog
|
OxTrace
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(
|
target_link_libraries(
|
||||||
FSTests
|
FSTests
|
||||||
OxFS
|
OxFS
|
||||||
OxStd
|
OxStd
|
||||||
OxLog
|
OxTrace
|
||||||
)
|
)
|
||||||
|
|
||||||
add_test("FileStoreFormat" FileStoreFormat)
|
add_test("FileStoreFormat" FileStoreFormat)
|
||||||
|
105
deps/ox/src/ox/log/log.cpp
vendored
105
deps/ox/src/ox/log/log.cpp
vendored
@ -1,105 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2015 - 2018 gtalent2@gmail.com
|
|
||||||
*
|
|
||||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdarg.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
#include "log.hpp"
|
|
||||||
|
|
||||||
namespace ox {
|
|
||||||
|
|
||||||
class Logger {
|
|
||||||
|
|
||||||
private:
|
|
||||||
// void* stand-in for FILE*
|
|
||||||
const char *m_path = nullptr;
|
|
||||||
|
|
||||||
public:
|
|
||||||
Logger(const char *path = nullptr);
|
|
||||||
|
|
||||||
~Logger();
|
|
||||||
|
|
||||||
void log(LogLevel_t level, const char *msg, va_list args);
|
|
||||||
|
|
||||||
void info(const char *msg, ...);
|
|
||||||
|
|
||||||
void debug(const char *msg, ...);
|
|
||||||
|
|
||||||
void error(const char *msg, ...);
|
|
||||||
};
|
|
||||||
|
|
||||||
Logger::Logger(const char *path) {
|
|
||||||
m_path = path;
|
|
||||||
}
|
|
||||||
|
|
||||||
Logger::~Logger() {
|
|
||||||
}
|
|
||||||
|
|
||||||
void Logger::log(LogLevel_t level, const char *msg, va_list args) {
|
|
||||||
if (m_path) {
|
|
||||||
auto file = fopen(m_path, "a");
|
|
||||||
vfprintf(file, msg, args);
|
|
||||||
fprintf(file, "\n");
|
|
||||||
fclose(file);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Logger::info(const char *msg, ...) {
|
|
||||||
va_list args;
|
|
||||||
va_start(args, msg);
|
|
||||||
log(LogLevel_t::Info, msg, args);
|
|
||||||
va_end(args);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Logger::debug(const char *msg, ...) {
|
|
||||||
va_list args;
|
|
||||||
va_start(args, msg);
|
|
||||||
log(LogLevel_t::Debug, msg, args);
|
|
||||||
va_end(args);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Logger::error(const char *msg, ...) {
|
|
||||||
va_list args;
|
|
||||||
va_start(args, msg);
|
|
||||||
log(LogLevel_t::Error, msg, args);
|
|
||||||
va_end(args);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static Logger logger;
|
|
||||||
|
|
||||||
void logFile(const char *path) {
|
|
||||||
logger = Logger(path);
|
|
||||||
}
|
|
||||||
|
|
||||||
void log(LogLevel_t level, const char *msg, va_list args) {
|
|
||||||
logger.log(level, msg, args);
|
|
||||||
}
|
|
||||||
|
|
||||||
void info(const char *msg, ...) {
|
|
||||||
va_list args;
|
|
||||||
va_start(args, msg);
|
|
||||||
log(LogLevel_t::Info, msg, args);
|
|
||||||
va_end(args);
|
|
||||||
}
|
|
||||||
|
|
||||||
void debug(const char *msg, ...) {
|
|
||||||
va_list args;
|
|
||||||
va_start(args, msg);
|
|
||||||
log(LogLevel_t::Debug, msg, args);
|
|
||||||
va_end(args);
|
|
||||||
}
|
|
||||||
|
|
||||||
void error(const char *msg, ...) {
|
|
||||||
va_list args;
|
|
||||||
va_start(args, msg);
|
|
||||||
log(LogLevel_t::Error, msg, args);
|
|
||||||
va_end(args);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
2
deps/ox/src/ox/mc/test/CMakeLists.txt
vendored
2
deps/ox/src/ox/mc/test/CMakeLists.txt
vendored
@ -9,7 +9,7 @@ target_link_libraries(
|
|||||||
McTest
|
McTest
|
||||||
OxMetalClaw
|
OxMetalClaw
|
||||||
OxStd
|
OxStd
|
||||||
OxLog
|
OxTrace
|
||||||
)
|
)
|
||||||
|
|
||||||
add_test("Test\\ McTest\\ Writer" McTest MetalClawWriter)
|
add_test("Test\\ McTest\\ Writer" McTest MetalClawWriter)
|
||||||
|
6
deps/ox/src/ox/std/test/CMakeLists.txt
vendored
6
deps/ox/src/ox/std/test/CMakeLists.txt
vendored
@ -5,7 +5,7 @@ add_executable(
|
|||||||
tests.cpp
|
tests.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(StdTest OxLog OxStd)
|
target_link_libraries(StdTest OxTrace OxStd)
|
||||||
|
|
||||||
add_test("Test\\ ox_memcmp\\ ABCDEFG\\ !=\\ HIJKLMN" StdTest "ABCDEFG != HIJKLMN")
|
add_test("Test\\ ox_memcmp\\ ABCDEFG\\ !=\\ HIJKLMN" StdTest "ABCDEFG != HIJKLMN")
|
||||||
add_test("Test\\ ox_memcmp\\ HIJKLMN\\ !=\\ ABCDEFG" StdTest "HIJKLMN != ABCDEFG")
|
add_test("Test\\ ox_memcmp\\ HIJKLMN\\ !=\\ ABCDEFG" StdTest "HIJKLMN != ABCDEFG")
|
||||||
@ -24,7 +24,7 @@ add_executable(
|
|||||||
target_link_libraries(
|
target_link_libraries(
|
||||||
StrOpsTest
|
StrOpsTest
|
||||||
OxStd
|
OxStd
|
||||||
OxLog
|
OxTrace
|
||||||
)
|
)
|
||||||
|
|
||||||
add_test("Test\\ ox_strcmp\\ asdf\\ !=\\ hijk" StrOpsTest "asdf < hijk")
|
add_test("Test\\ ox_strcmp\\ asdf\\ !=\\ hijk" StrOpsTest "asdf < hijk")
|
||||||
@ -48,7 +48,7 @@ add_executable(
|
|||||||
target_link_libraries(
|
target_link_libraries(
|
||||||
ByteSwapTest
|
ByteSwapTest
|
||||||
OxStd
|
OxStd
|
||||||
OxLog
|
OxTrace
|
||||||
)
|
)
|
||||||
|
|
||||||
add_test("Test\\ bigEndianAdapt\\ 0x00ff" ByteSwapTest bigEndianAdapt<uint16_t> 0x00ff)
|
add_test("Test\\ bigEndianAdapt\\ 0x00ff" ByteSwapTest bigEndianAdapt<uint16_t> 0x00ff)
|
||||||
|
@ -1,25 +1,25 @@
|
|||||||
cmake_minimum_required(VERSION 2.8)
|
cmake_minimum_required(VERSION 2.8)
|
||||||
|
|
||||||
add_library(
|
add_library(
|
||||||
OxLog
|
OxTrace
|
||||||
log.cpp
|
trace.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
set_property(
|
set_property(
|
||||||
TARGET
|
TARGET
|
||||||
OxLog
|
OxTrace
|
||||||
PROPERTY
|
PROPERTY
|
||||||
POSITION_INDEPENDENT_CODE ON
|
POSITION_INDEPENDENT_CODE ON
|
||||||
)
|
)
|
||||||
|
|
||||||
install(
|
install(
|
||||||
FILES
|
FILES
|
||||||
log.hpp
|
trace.hpp
|
||||||
DESTINATION
|
DESTINATION
|
||||||
include/ox/mc
|
include/ox/mc
|
||||||
)
|
)
|
||||||
|
|
||||||
install(TARGETS OxLog
|
install(TARGETS OxTrace
|
||||||
LIBRARY DESTINATION lib/ox
|
LIBRARY DESTINATION lib/ox
|
||||||
ARCHIVE DESTINATION lib/ox
|
ARCHIVE DESTINATION lib/ox
|
||||||
)
|
)
|
29
deps/ox/src/ox/trace/trace.cpp
vendored
Normal file
29
deps/ox/src/ox/trace/trace.cpp
vendored
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2015 - 2018 gtalent2@gmail.com
|
||||||
|
*
|
||||||
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include <ox/std/std.hpp>
|
||||||
|
|
||||||
|
#include "trace.hpp"
|
||||||
|
|
||||||
|
namespace ox {
|
||||||
|
|
||||||
|
struct TraceMsg {
|
||||||
|
const char *file;
|
||||||
|
int line;
|
||||||
|
uint64_t time;
|
||||||
|
const char *ch;
|
||||||
|
const char *msg;
|
||||||
|
};
|
||||||
|
|
||||||
|
void trace(const char *file, int line, const char *ch, const char *msg) {
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -10,18 +10,8 @@
|
|||||||
|
|
||||||
namespace ox {
|
namespace ox {
|
||||||
|
|
||||||
enum class LogLevel_t: int {
|
void trace(const char *file, int line, const char *ch, const char *msg);
|
||||||
Info,
|
|
||||||
Debug,
|
|
||||||
Error,
|
|
||||||
};
|
|
||||||
|
|
||||||
void logFile(const char *path);
|
|
||||||
|
|
||||||
void info(const char *msg, ...);
|
|
||||||
|
|
||||||
void debug(const char *msg, ...);
|
|
||||||
|
|
||||||
void error(const char *msg, ...);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define ox_trace(ch, msg) ox::trace(__FILE__, __LINE__, ch, msg)
|
Loading…
x
Reference in New Issue
Block a user