Rename Log package to Trace

This commit is contained in:
Gary Talent 2018-02-03 14:26:47 -06:00
parent fc9726b3ec
commit e7a396655c
9 changed files with 47 additions and 133 deletions

View File

@ -4,6 +4,6 @@ if(OX_USE_STDLIB STREQUAL "ON")
add_subdirectory(clargs)
endif(OX_USE_STDLIB STREQUAL "ON")
add_subdirectory(fs)
add_subdirectory(log)
add_subdirectory(trace)
add_subdirectory(mc)
add_subdirectory(std)

View File

@ -23,7 +23,7 @@ if(OX_BUILD_EXEC STREQUAL "ON")
target_link_libraries(
oxfstool
OxFS
OxLog
OxTrace
OxStd
)
endif()

View File

@ -24,28 +24,28 @@ target_link_libraries(
FileStoreFormat
OxFS
OxStd
OxLog
OxTrace
)
target_link_libraries(
FileSystemFormat
OxFS
OxStd
OxLog
OxTrace
)
target_link_libraries(
FileStoreIO
OxFS
OxStd
OxLog
OxTrace
)
target_link_libraries(
FSTests
OxFS
OxStd
OxLog
OxTrace
)
add_test("FileStoreFormat" FileStoreFormat)

View File

@ -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);
}
}

View File

@ -9,7 +9,7 @@ target_link_libraries(
McTest
OxMetalClaw
OxStd
OxLog
OxTrace
)
add_test("Test\\ McTest\\ Writer" McTest MetalClawWriter)

View File

@ -5,7 +5,7 @@ add_executable(
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\\ HIJKLMN\\ !=\\ ABCDEFG" StdTest "HIJKLMN != ABCDEFG")
@ -24,7 +24,7 @@ add_executable(
target_link_libraries(
StrOpsTest
OxStd
OxLog
OxTrace
)
add_test("Test\\ ox_strcmp\\ asdf\\ !=\\ hijk" StrOpsTest "asdf < hijk")
@ -48,7 +48,7 @@ add_executable(
target_link_libraries(
ByteSwapTest
OxStd
OxLog
OxTrace
)
add_test("Test\\ bigEndianAdapt\\ 0x00ff" ByteSwapTest bigEndianAdapt<uint16_t> 0x00ff)

View File

@ -1,25 +1,25 @@
cmake_minimum_required(VERSION 2.8)
add_library(
OxLog
log.cpp
OxTrace
trace.cpp
)
set_property(
TARGET
OxLog
OxTrace
PROPERTY
POSITION_INDEPENDENT_CODE ON
)
install(
FILES
log.hpp
trace.hpp
DESTINATION
include/ox/mc
)
install(TARGETS OxLog
install(TARGETS OxTrace
LIBRARY DESTINATION lib/ox
ARCHIVE DESTINATION lib/ox
)

29
deps/ox/src/ox/trace/trace.cpp vendored Normal file
View 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) {
}
}

View File

@ -10,18 +10,8 @@
namespace ox {
enum class LogLevel_t: int {
Info,
Debug,
Error,
};
void logFile(const char *path);
void info(const char *msg, ...);
void debug(const char *msg, ...);
void error(const char *msg, ...);
void trace(const char *file, int line, const char *ch, const char *msg);
}
#define ox_trace(ch, msg) ox::trace(__FILE__, __LINE__, ch, msg)