Merge pull request #76 from oatpp/default_logger

Better Logging system
This commit is contained in:
Leonid Stryzhevskyi 2019-05-26 21:00:31 +03:00 committed by GitHub
commit 86c3fd005d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
21 changed files with 259 additions and 103 deletions

View File

@ -32,7 +32,7 @@ namespace oatpp { namespace test {
void UnitTest::run(v_int32 times) {
OATPP_LOGD(TAG, "\033[1mSTART\033[0m...");
OATPP_LOGI(TAG, "\033[1mSTART\033[0m...");
v_counter objectsCount = base::Environment::getObjectsCount();
v_counter objectsCreated = base::Environment::getObjectsCreated();
@ -49,18 +49,18 @@ void UnitTest::run(v_int32 times) {
v_counter objectsCreatedPerTest = base::Environment::getObjectsCreated() - objectsCreated;
if(leakingObjects == 0){
OATPP_LOGD(TAG, "\033[1mFINISHED\033[0m - \033[1;32msuccess!\033[0m");
OATPP_LOGD(TAG, "\033[33m%d(micro), %d(objs)\033[0m\n", millis, objectsCreatedPerTest);
OATPP_LOGI(TAG, "\033[1mFINISHED\033[0m - \033[1;32msuccess!\033[0m");
OATPP_LOGI(TAG, "\033[33m%d(micro), %d(objs)\033[0m\n", millis, objectsCreatedPerTest);
}else{
OATPP_LOGD(TAG, "\033[1mFINISHED\033[0m - \033[1;31mfailed\033[0m, leakingObjects = %d", leakingObjects);
OATPP_LOGE(TAG, "\033[1mFINISHED\033[0m - \033[1;31mfailed\033[0m, leakingObjects = %d", leakingObjects);
auto POOLS = oatpp::base::memory::MemoryPool::POOLS;
auto it = POOLS.begin();
while (it != POOLS.end()) {
auto pool = it->second;
if(pool->getObjectsCount() != 0) {
OATPP_LOGD("Pool", "name: '%s' [%d(objs)]", pool->getName().c_str(), pool->getObjectsCount());
OATPP_LOGV("Pool", "name: '%s' [%d(objs)]", pool->getName().c_str(), pool->getObjectsCount());
}
it ++;
}

View File

@ -42,14 +42,14 @@ void IOEventWorker::initEventQueue() {
m_eventQueueHandle = ::epoll_create1(0);
if(m_eventQueueHandle == -1) {
OATPP_LOGD("[oatpp::async::worker::IOEventWorker::initEventQueue()]", "Error. Call to ::epoll_create1() failed. errno=%d", errno);
OATPP_LOGE("[oatpp::async::worker::IOEventWorker::initEventQueue()]", "Error. Call to ::epoll_create1() failed. errno=%d", errno);
throw std::runtime_error("[oatpp::async::worker::IOEventWorker::initEventQueue()]: Error. Call to ::epoll_create1() failed.");
}
m_outEvents = std::unique_ptr<v_char8[]>(new (std::nothrow) v_char8[MAX_EVENTS * sizeof(struct epoll_event)]);
if(!m_outEvents) {
OATPP_LOGD("[oatpp::async::worker::IOEventWorker::initEventQueue()]",
OATPP_LOGE("[oatpp::async::worker::IOEventWorker::initEventQueue()]",
"Error. Unable to allocate %d bytes for events.", MAX_EVENTS * sizeof(struct epoll_event));
throw std::runtime_error("[oatpp::async::worker::IOEventWorker::initEventQueue()]: Error. Unable to allocate memory for events.");
}
@ -57,7 +57,7 @@ void IOEventWorker::initEventQueue() {
m_wakeupTrigger = ::eventfd(0, EFD_NONBLOCK);
if(m_wakeupTrigger == -1) {
OATPP_LOGD("[oatpp::async::worker::IOEventWorker::initEventQueue()]", "Error. Call to ::eventfd() failed. errno=%d", errno);
OATPP_LOGE("[oatpp::async::worker::IOEventWorker::initEventQueue()]", "Error. Call to ::eventfd() failed. errno=%d", errno);
throw std::runtime_error("[oatpp::async::worker::IOEventWorker::initEventQueue()]: Error. Call to ::eventfd() failed.");
}
@ -74,7 +74,7 @@ void IOEventWorker::initEventQueue() {
auto res = ::epoll_ctl(m_eventQueueHandle, EPOLL_CTL_ADD, m_wakeupTrigger, &event);
if(res == -1) {
OATPP_LOGD("[oatpp::async::worker::IOEventWorker::initEventQueue()]", "Error. Call to ::epoll_ctl failed. errno=%d", errno);
OATPP_LOGE("[oatpp::async::worker::IOEventWorker::initEventQueue()]", "Error. Call to ::epoll_ctl failed. errno=%d", errno);
throw std::runtime_error("[oatpp::async::worker::IOEventWorker::initEventQueue()]: Error. Call to ::epoll_ctl() failed.");
}
@ -98,7 +98,7 @@ void IOEventWorker::setCoroutineEvent(AbstractCoroutine* coroutine, int operatio
case Action::TYPE_IO_REPEAT: break;
default:
OATPP_LOGD("[oatpp::async::worker::IOEventWorker::pushCoroutineToQueue()]", "Error. Unknown Action. action.getType()==%d", action.getType());
OATPP_LOGE("[oatpp::async::worker::IOEventWorker::pushCoroutineToQueue()]", "Error. Unknown Action. action.getType()==%d", action.getType());
throw std::runtime_error("[oatpp::async::worker::IOEventWorker::pushCoroutineToQueue()]: Error. Unknown Action.");
}
@ -125,7 +125,7 @@ void IOEventWorker::setCoroutineEvent(AbstractCoroutine* coroutine, int operatio
auto res = epoll_ctl(m_eventQueueHandle, operation, action.getIOHandle(), &event);
if(res == -1) {
OATPP_LOGD("[oatpp::async::worker::IOEventWorker::setEpollEvent()]", "Error. Call to epoll_ctl failed. operation=%d, errno=%d", operation, errno);
OATPP_LOGE("[oatpp::async::worker::IOEventWorker::setEpollEvent()]", "Error. Call to epoll_ctl failed. operation=%d, errno=%d", operation, errno);
throw std::runtime_error("[oatpp::async::worker::IOEventWorker::setEpollEvent()]: Error. Call to epoll_ctl failed.");
}
@ -153,7 +153,7 @@ void IOEventWorker::waitEvents() {
auto eventsCount = epoll_wait(m_eventQueueHandle, outEvents, MAX_EVENTS, -1);
if(eventsCount < 0) {
OATPP_LOGD("[oatpp::async::worker::IOEventWorker::waitEvents()]", "Error. errno=%d", errno);
OATPP_LOGE("[oatpp::async::worker::IOEventWorker::waitEvents()]", "Error. errno=%d", errno);
throw std::runtime_error("[oatpp::async::worker::IOEventWorker::waitEvents()]: Error. Event loop failed.");
}
@ -204,7 +204,7 @@ void IOEventWorker::waitEvents() {
res = epoll_ctl(m_eventQueueHandle, EPOLL_CTL_DEL, action.getIOHandle(), nullptr);
if(res == -1) {
OATPP_LOGD(
OATPP_LOGE(
"[oatpp::async::worker::IOEventWorker::waitEvents()]",
"Error. Call to epoll_ctl failed. operation=%d, errno=%d. action_code=%d, worker_specialization=%d",
EPOLL_CTL_DEL, errno, action.getIOEventCode(), m_specialization
@ -221,7 +221,7 @@ void IOEventWorker::waitEvents() {
res = epoll_ctl(m_eventQueueHandle, EPOLL_CTL_DEL, action.getIOHandle(), nullptr);
if(res == -1) {
OATPP_LOGD(
OATPP_LOGE(
"[oatpp::async::worker::IOEventWorker::waitEvents()]",
"Error. Call to epoll_ctl failed. operation=%d, errno=%d. action_code=%d, worker_specialization=%d",
EPOLL_CTL_DEL, errno, action.getIOEventCode(), m_specialization
@ -241,7 +241,7 @@ void IOEventWorker::waitEvents() {
res = epoll_ctl(m_eventQueueHandle, EPOLL_CTL_DEL, prevAction.getIOHandle(), nullptr);
if(res == -1) {
OATPP_LOGD("[oatpp::async::worker::IOEventWorker::waitEvents()]", "Error. Call to epoll_ctl failed. operation=%d, errno=%d", EPOLL_CTL_DEL, errno);
OATPP_LOGE("[oatpp::async::worker::IOEventWorker::waitEvents()]", "Error. Call to epoll_ctl failed. operation=%d, errno=%d", EPOLL_CTL_DEL, errno);
throw std::runtime_error("[oatpp::async::worker::IOEventWorker::waitEvents()]: Error. Call to epoll_ctl failed.");
}

View File

@ -45,7 +45,7 @@ void IOEventWorker::initEventQueue() {
m_outEvents = std::unique_ptr<v_char8[]>(new (std::nothrow) v_char8[MAX_EVENTS * sizeof(struct kevent)]);
if(!m_outEvents) {
OATPP_LOGD("[oatpp::async::worker::IOEventWorker::initEventQueue()]",
OATPP_LOGE("[oatpp::async::worker::IOEventWorker::initEventQueue()]",
"Error. Unable to allocate %d bytes for events.", MAX_EVENTS * sizeof(struct kevent));
throw std::runtime_error("[oatpp::async::worker::IOEventWorker::initEventQueue()]: Error. Unable to allocate memory for events.");
}
@ -130,7 +130,7 @@ void IOEventWorker::consumeBacklog() {
m_inEvents = std::unique_ptr<v_char8[]>(new (std::nothrow) v_char8[m_inEventsCapacity * sizeof(struct kevent)]);
if(!m_inEvents) {
OATPP_LOGD("[oatpp::async::worker::IOEventWorker::consumeBacklog()]",
OATPP_LOGE("[oatpp::async::worker::IOEventWorker::consumeBacklog()]",
"Error. Unable to allocate %d bytes for events.", m_inEventsCapacity * sizeof(struct kevent));
throw std::runtime_error("[oatpp::async::worker::IOEventWorker::consumeBacklog()]: Error. Unable to allocate memory for events.");
}

View File

@ -64,17 +64,17 @@
#endif
/**
* DISABLE logs level V
* DISABLE logs priority V
*/
//#define OATPP_DISABLE_LOGV
/**
* DISABLE logs level D
* DISABLE logs priority D
*/
//#define OATPP_DISABLE_LOGD
/**
* DISABLE logs level E
* DISABLE logs priority E
*/
//#define OATPP_DISABLE_LOGE

View File

@ -23,13 +23,17 @@
***************************************************************************/
#include "Environment.hpp"
#include <iomanip>
#include <chrono>
#include <iostream>
#include <cstring>
#include <ctime>
#include <stdarg.h>
namespace oatpp { namespace base {
Logger* Environment::m_logger = nullptr;
std::shared_ptr<Logger> Environment::m_logger;
std::unordered_map<std::string, std::unordered_map<std::string, void*>> Environment::m_components;
v_atomicCounter Environment::m_objectsCount(0);
@ -37,7 +41,76 @@ v_atomicCounter Environment::m_objectsCreated(0);
thread_local v_counter Environment::m_threadLocalObjectsCount = 0;
thread_local v_counter Environment::m_threadLocalObjectsCreated = 0;
void Environment::init(){
DefaultLogger::DefaultLogger(const Config& config)
: m_config(config)
{}
void DefaultLogger::log(v_int32 priority, const std::string& tag, const std::string& message) {
bool indent = false;
auto time = std::chrono::system_clock::now().time_since_epoch();
std::lock_guard<std::mutex> lock(m_lock);
switch (priority) {
case PRIORITY_V:
std::cout << "\033[0;0m V \033[0m|";
break;
case PRIORITY_D:
std::cout << "\033[34;0m D \033[0m|";
break;
case PRIORITY_I:
std::cout << "\033[32;0m I \033[0m|";
break;
case PRIORITY_W:
std::cout << "\033[45;0m W \033[0m|";
break;
case PRIORITY_E:
std::cout << "\033[41;0m E \033[0m|";
break;
default:
std::cout << " " << priority << " |";
}
if(m_config.timeFormat) {
time_t seconds = std::chrono::duration_cast<std::chrono::seconds>(time).count();
struct tm now;
localtime_r(&seconds, &now);
std::cout << std::put_time(&now, m_config.timeFormat);
indent = true;
}
if(m_config.printTicks) {
auto ticks = std::chrono::duration_cast<std::chrono::microseconds>(time).count();
if(indent) {
std::cout << " ";
}
std::cout << ticks;
indent = true;
}
if(indent) {
std::cout << "|";
}
std::cout << " " << tag << ":" << message << "\n";
}
void Environment::init() {
init(std::make_shared<DefaultLogger>());
}
void Environment::init(const std::shared_ptr<Logger>& logger) {
m_logger = logger;
checkTypes();
m_objectsCount = 0;
@ -48,12 +121,14 @@ void Environment::init(){
if(m_components.size() > 0) {
throw std::runtime_error("[oatpp::base::Environment]: Invalid state. Components were created before call to Environment::init()");
}
}
void Environment::destroy(){
if(m_components.size() > 0) {
throw std::runtime_error("[oatpp::base::Environment]: Invalid state. Leaking components");
}
m_logger.reset();
}
void Environment::checkTypes(){
@ -107,13 +182,14 @@ v_counter Environment::getThreadLocalObjectsCreated(){
return m_threadLocalObjectsCreated;
}
void Environment::setLogger(Logger* logger){
delete m_logger;
void Environment::setLogger(const std::shared_ptr<Logger>& logger){
m_logger = logger;
}
void Environment::printCompilationConfig() {
OATPP_LOGD("oatpp-version", OATPP_VERSION);
#ifdef OATPP_DISABLE_ENV_OBJECT_COUNTERS
OATPP_LOGD("oatpp/Config", "OATPP_DISABLE_ENV_OBJECT_COUNTERS");
#endif

View File

@ -32,8 +32,8 @@
#include <mutex>
#include <string>
#include <unordered_map>
#include <memory>
#include <stdexcept>
#include <stdlib.h>
#define OATPP_VERSION "0.19.4"
@ -74,9 +74,34 @@ namespace oatpp { namespace base{
/**
* Interface for system-wide Logger.<br>
* All calls to `OATPP_DISABLE_LOGV`, `OATPP_DISABLE_LOGE`, `OATPP_DISABLE_LOGD` should come here.
* All calls to `OATPP_DISABLE_LOGV`, `OATPP_DISABLE_LOGE`, `OATPP_DISABLE_LOGD` will come here.
*/
class Logger {
public:
/**
* Log priority V-verbouse.
*/
static constexpr v_int32 PRIORITY_V = 0;
/**
* Log priority D-debug.
*/
static constexpr v_int32 PRIORITY_D = 1;
/**
* Log priority I-Info.
*/
static constexpr v_int32 PRIORITY_I = 2;
/**
* Log priority W-Warning.
*/
static constexpr v_int32 PRIORITY_W = 3;
/**
* Log priority E-error.
*/
static constexpr v_int32 PRIORITY_E = 4;
public:
/**
* Virtual Destructor.
@ -92,6 +117,47 @@ public:
virtual void log(v_int32 priority, const std::string& tag, const std::string& message) = 0;
};
/**
* Default Logger implementation.
*/
class DefaultLogger : public Logger {
public:
/**
* Default Logger Config.
*/
struct Config {
/**
* Time format of the log message.
* If nullptr then do not print time.
* Default value - `%Y-%m-%d %H:%M:%S`.
*/
const char* timeFormat;
/**
* Print micro-ticks in the log message.
*/
bool printTicks;
};
private:
Config m_config;
std::mutex m_lock;
public:
/**
* Constructor.
* @param config - Logger config.
*/
DefaultLogger(const Config& config = {"%Y-%m-%d %H:%M:%S", true});
/**
* Log message with priority, tag, message.
* @param priority - log-priority channel of the message.
* @param tag - tag of the log message.
* @param message - message.
*/
void log(v_int32 priority, const std::string& tag, const std::string& message) override;
};
/**
* Class to manage application environment.<br>
* Manage object counters, manage components, and do system health-checks.
@ -103,7 +169,7 @@ private:
static thread_local v_counter m_threadLocalObjectsCount;
static thread_local v_counter m_threadLocalObjectsCreated;
private:
static Logger* m_logger;
static std::shared_ptr<Logger> m_logger;
static void checkTypes();
private:
static std::unordered_map<std::string, std::unordered_map<std::string, void*>> m_components;
@ -169,6 +235,12 @@ public:
*/
static void init();
/**
* Initialize environment and do basic health-checks.
* @param logger - system-wide logger.
*/
static void init(const std::shared_ptr<Logger>& logger);
/**
* De-initialize environment and do basic health-checks.
* Check for memory leaks.
@ -211,9 +283,9 @@ public:
/**
* Set environment logger.
* @param logger - pointer to logger.
* @param logger - system-wide logger.
*/
static void setLogger(Logger* logger);
static void setLogger(const std::shared_ptr<Logger>& logger);
/**
* Print debug information of compilation config.<br>
@ -228,7 +300,7 @@ public:
/**
* Call `Logger::log()`
* @param priority - priority channel of the message.
* @param priority - log-priority channel of the message.
* @param tag - tag of the log message.
* @param message - message.
*/
@ -237,7 +309,7 @@ public:
/**
* Format message and call `Logger::log()`<br>
* Message is formatted using `vsnprintf` method.
* @param priority - priority channel of the message.
* @param priority - log-priority channel of the message.
* @param tag - tag of the log message.
* @param message - message.
* @param ... - format arguments.
@ -274,19 +346,31 @@ if(!(EXP)) { \
}
#ifndef OATPP_DISABLE_LOGV
#define OATPP_LOGV(TAG, ...) oatpp::base::Environment::logFormatted(0, TAG, __VA_ARGS__);
#define OATPP_LOGV(TAG, ...) oatpp::base::Environment::logFormatted(oatpp::base::Logger::PRIORITY_V, TAG, __VA_ARGS__);
#else
#define OATPP_LOGV(TAG, ...)
#endif
#ifndef OATPP_DISABLE_LOGD
#define OATPP_LOGD(TAG, ...) oatpp::base::Environment::logFormatted(1, TAG, __VA_ARGS__);
#define OATPP_LOGD(TAG, ...) oatpp::base::Environment::logFormatted(oatpp::base::Logger::PRIORITY_D, TAG, __VA_ARGS__);
#else
#define OATPP_LOGD(TAG, ...)
#endif
#ifndef OATPP_DISABLE_LOGI
#define OATPP_LOGI(TAG, ...) oatpp::base::Environment::logFormatted(oatpp::base::Logger::PRIORITY_I, TAG, __VA_ARGS__);
#else
#define OATPP_LOGI(TAG, ...)
#endif
#ifndef OATPP_DISABLE_LOGW
#define OATPP_LOGW(TAG, ...) oatpp::base::Environment::logFormatted(oatpp::base::Logger::PRIORITY_W, TAG, __VA_ARGS__);
#else
#define OATPP_LOGW(TAG, ...)
#endif
#ifndef OATPP_DISABLE_LOGE
#define OATPP_LOGE(TAG, ...) oatpp::base::Environment::logFormatted(2, TAG, __VA_ARGS__);
#define OATPP_LOGE(TAG, ...) oatpp::base::Environment::logFormatted(oatpp::base::Logger::PRIORITY_E, TAG, __VA_ARGS__);
#else
#define OATPP_LOGE(TAG, ...)
#endif

View File

@ -120,13 +120,9 @@ void runTests() {
int main() {
oatpp::base::Environment::init();
oatpp::base::Environment::setLogger(new Logger());
runTests();
oatpp::base::Environment::setLogger(nullptr);
oatpp::base::Environment::destroy();
/* Print how much objects were created during app running, and what have left-probably leaked */
/* Disable object counting for release builds using '-D OATPP_DISABLE_ENV_OBJECT_COUNTERS' flag for better performance */
std::cout << "\nEnvironment:\n";

View File

@ -127,7 +127,7 @@ void testPool(v_int32 objectsNumber, v_int32 garbageNumber, v_int32 chunkSize){
OATPP_ASSERT(objects[i]->a == -100);
}
#else
OATPP_LOGV("TEST[base::memory::MemoryPoolTest]", "\033[35mWARNING. 'OATPP_DISABLE_POOL_ALLOCATIONS' flag is ON. Assertions disabled.\033[0m");
OATPP_LOGW("TEST[base::memory::MemoryPoolTest]", "WARNING. 'OATPP_DISABLE_POOL_ALLOCATIONS' flag is ON. Assertions disabled.");
#endif
delete [] objects;

View File

@ -69,52 +69,52 @@ void TypeTest::onRun() {
auto obj = TestDto::createShared();
OATPP_LOGD(TAG, "type: '%s'", obj->_string.valueType->name);
OATPP_LOGV(TAG, "type: '%s'", obj->_string.valueType->name);
OATPP_ASSERT(obj->_string.valueType->name == oatpp::data::mapping::type::__class::String::CLASS_NAME);
OATPP_LOGD(TAG, "type: '%s'", obj->_int8.valueType->name);
OATPP_LOGV(TAG, "type: '%s'", obj->_int8.valueType->name);
OATPP_ASSERT(obj->_int8.valueType->name == oatpp::data::mapping::type::__class::Int8::CLASS_NAME);
OATPP_LOGD(TAG, "type: '%s'", obj->_int16.valueType->name);
OATPP_LOGV(TAG, "type: '%s'", obj->_int16.valueType->name);
OATPP_ASSERT(obj->_int16.valueType->name == oatpp::data::mapping::type::__class::Int16::CLASS_NAME);
OATPP_LOGD(TAG, "type: '%s'", obj->_int32.valueType->name);
OATPP_LOGV(TAG, "type: '%s'", obj->_int32.valueType->name);
OATPP_ASSERT(obj->_int32.valueType->name == oatpp::data::mapping::type::__class::Int32::CLASS_NAME);
OATPP_LOGD(TAG, "type: '%s'", obj->_int64.valueType->name);
OATPP_LOGV(TAG, "type: '%s'", obj->_int64.valueType->name);
OATPP_ASSERT(obj->_int64.valueType->name == oatpp::data::mapping::type::__class::Int64::CLASS_NAME);
OATPP_LOGD(TAG, "type: '%s'", obj->_float32.valueType->name);
OATPP_LOGV(TAG, "type: '%s'", obj->_float32.valueType->name);
OATPP_ASSERT(obj->_float32.valueType->name == oatpp::data::mapping::type::__class::Float32::CLASS_NAME);
OATPP_LOGD(TAG, "type: '%s'", obj->_float64.valueType->name);
OATPP_LOGV(TAG, "type: '%s'", obj->_float64.valueType->name);
OATPP_ASSERT(obj->_float64.valueType->name == oatpp::data::mapping::type::__class::Float64::CLASS_NAME);
OATPP_LOGD(TAG, "type: '%s'", obj->_boolean.valueType->name);
OATPP_LOGV(TAG, "type: '%s'", obj->_boolean.valueType->name);
OATPP_ASSERT(obj->_boolean.valueType->name == oatpp::data::mapping::type::__class::Boolean::CLASS_NAME);
OATPP_LOGD(TAG, "type: '%s'", obj->_list_string.valueType->name);
OATPP_LOGV(TAG, "type: '%s'", obj->_list_string.valueType->name);
OATPP_ASSERT(obj->_list_string.valueType->name == oatpp::data::mapping::type::__class::AbstractList::CLASS_NAME);
OATPP_LOGD(TAG, "type: '%s'", obj->_list_int32.valueType->name);
OATPP_LOGV(TAG, "type: '%s'", obj->_list_int32.valueType->name);
OATPP_ASSERT(obj->_list_int32.valueType->name == oatpp::data::mapping::type::__class::AbstractList::CLASS_NAME);
OATPP_LOGD(TAG, "type: '%s'", obj->_list_int64.valueType->name);
OATPP_LOGV(TAG, "type: '%s'", obj->_list_int64.valueType->name);
OATPP_ASSERT(obj->_list_int64.valueType->name == oatpp::data::mapping::type::__class::AbstractList::CLASS_NAME);
OATPP_LOGD(TAG, "type: '%s'", obj->_list_float32.valueType->name);
OATPP_LOGV(TAG, "type: '%s'", obj->_list_float32.valueType->name);
OATPP_ASSERT(obj->_list_float32.valueType->name == oatpp::data::mapping::type::__class::AbstractList::CLASS_NAME);
OATPP_LOGD(TAG, "type: '%s'", obj->_list_float64.valueType->name);
OATPP_LOGV(TAG, "type: '%s'", obj->_list_float64.valueType->name);
OATPP_ASSERT(obj->_list_float64.valueType->name == oatpp::data::mapping::type::__class::AbstractList::CLASS_NAME);
OATPP_LOGD(TAG, "type: '%s'", obj->_list_boolean.valueType->name);
OATPP_LOGV(TAG, "type: '%s'", obj->_list_boolean.valueType->name);
OATPP_ASSERT(obj->_list_boolean.valueType->name == oatpp::data::mapping::type::__class::AbstractList::CLASS_NAME);
OATPP_LOGD(TAG, "type: '%s'", obj->_map_string_string.valueType->name);
OATPP_LOGV(TAG, "type: '%s'", obj->_map_string_string.valueType->name);
OATPP_ASSERT(obj->_map_string_string.valueType->name == oatpp::data::mapping::type::__class::AbstractListMap::CLASS_NAME);
OATPP_LOGD(TAG, "type: '%s'", obj->obj1.valueType->name);
OATPP_LOGV(TAG, "type: '%s'", obj->obj1.valueType->name);
OATPP_ASSERT(obj->obj1.valueType->name == oatpp::data::mapping::type::__class::AbstractObject::CLASS_NAME);
}

View File

@ -39,7 +39,7 @@ void ChunkedBufferTest::onRun() {
stream << "int=" << 1 << ", float=" << 1.1 << ", "
<< "bool=" << true << " or " << false;
OATPP_LOGD(TAG, "str='%s'", stream.toString()->c_str());
OATPP_LOGV(TAG, "str='%s'", stream.toString()->c_str());
stream.clear();
stream << 101;

View File

@ -35,7 +35,7 @@ void Base64Test::onRun() {
{
oatpp::String encoded = oatpp::encoding::Base64::encode(message);
OATPP_LOGD(TAG, "encoded='%s'", encoded->c_str());
OATPP_LOGV(TAG, "encoded='%s'", encoded->c_str());
OATPP_ASSERT(encoded->equals(messageEncoded.get()));
oatpp::String decoded = oatpp::encoding::Base64::decode(encoded);
OATPP_ASSERT(message->equals(decoded.get()));
@ -43,7 +43,7 @@ void Base64Test::onRun() {
{
oatpp::String encoded = oatpp::encoding::Base64::encode(message, oatpp::encoding::Base64::ALPHABET_BASE64_URL_SAFE);
OATPP_LOGD(TAG, "encoded='%s'", encoded->c_str());
OATPP_LOGV(TAG, "encoded='%s'", encoded->c_str());
oatpp::String decoded = oatpp::encoding::Base64::decode(encoded, oatpp::encoding::Base64::ALPHABET_BASE64_URL_SAFE_AUXILIARY_CHARS);
OATPP_ASSERT(message->equals(decoded.get()));
}

View File

@ -50,7 +50,7 @@ void writeBinaryInt(v_int32 value){
}
}
OATPP_LOGD("bin", "value='%s'", (const char*) &buff);
OATPP_LOGV("bin", "value='%s'", (const char*) &buff);
}

View File

@ -36,7 +36,7 @@ void UrlTest::onRun() {
{
const char* urlText = "http://root@127.0.0.1:8000/path/to/resource/?q1=1&q2=2";
OATPP_LOGD(TAG, "urlText='%s'", urlText);
OATPP_LOGV(TAG, "urlText='%s'", urlText);
auto url = Url::Parser::parseUrl(urlText);
OATPP_ASSERT(url.scheme && url.scheme == "http");
@ -51,7 +51,7 @@ void UrlTest::onRun() {
{
const char* urlText = "ftp://root@oatpp.io:8000/path/to/resource?q1=1&q2=2";
OATPP_LOGD(TAG, "urlText='%s'", urlText);
OATPP_LOGV(TAG, "urlText='%s'", urlText);
auto url = Url::Parser::parseUrl(urlText);
OATPP_ASSERT(url.scheme && url.scheme == "ftp");
@ -66,7 +66,7 @@ void UrlTest::onRun() {
{
const char* urlText = "https://oatpp.io/?q1=1&q2=2";
OATPP_LOGD(TAG, "urlText='%s'", urlText);
OATPP_LOGV(TAG, "urlText='%s'", urlText);
auto url = Url::Parser::parseUrl(urlText);
OATPP_ASSERT(url.scheme && url.scheme == "https");
@ -81,7 +81,7 @@ void UrlTest::onRun() {
{
const char* urlText = "https://oatpp.io/";
OATPP_LOGD(TAG, "urlText='%s'", urlText);
OATPP_LOGV(TAG, "urlText='%s'", urlText);
auto url = Url::Parser::parseUrl(urlText);
OATPP_ASSERT(url.scheme && url.scheme == "https");
@ -94,7 +94,7 @@ void UrlTest::onRun() {
{
const char* urlText = "https://oatpp.io";
OATPP_LOGD(TAG, "urlText='%s'", urlText);
OATPP_LOGV(TAG, "urlText='%s'", urlText);
auto url = Url::Parser::parseUrl(urlText);
OATPP_ASSERT(url.scheme && url.scheme == "https");
@ -107,7 +107,7 @@ void UrlTest::onRun() {
{
const char* urlText = "oatpp.io";
OATPP_LOGD(TAG, "urlText='%s'", urlText);
OATPP_LOGV(TAG, "urlText='%s'", urlText);
auto url = Url::Parser::parseUrl(urlText);
OATPP_ASSERT(url.scheme == nullptr);
@ -120,7 +120,7 @@ void UrlTest::onRun() {
{
const char* urlText = "?key1=value1&key2=value2&key3=value3";
OATPP_LOGD(TAG, "urlText='%s'", urlText);
OATPP_LOGV(TAG, "urlText='%s'", urlText);
auto params = Url::Parser::parseQueryParams(urlText);
OATPP_ASSERT(params.size() == 3);
OATPP_ASSERT(params["key1"] == "value1");
@ -130,7 +130,7 @@ void UrlTest::onRun() {
{
const char *urlText = "?key1=value1&key2&key3=value3";
OATPP_LOGD(TAG, "urlText='%s'", urlText);
OATPP_LOGV(TAG, "urlText='%s'", urlText);
auto params = Url::Parser::parseQueryParams(urlText);
OATPP_ASSERT(params.size() == 3);
OATPP_ASSERT(params["key1"] == "value1");
@ -140,7 +140,7 @@ void UrlTest::onRun() {
{
const char *urlText = "?key1=value1&key2&key3";
OATPP_LOGD(TAG, "urlText='%s'", urlText);
OATPP_LOGV(TAG, "urlText='%s'", urlText);
auto params = Url::Parser::parseQueryParams(urlText);
OATPP_ASSERT(params.size() == 3);
OATPP_ASSERT(params["key1"] == "value1");
@ -150,7 +150,7 @@ void UrlTest::onRun() {
{
const char *urlText = "label?key1=value1&key2=value2&key3=value3";
OATPP_LOGD(TAG, "urlText='%s'", urlText);
OATPP_LOGV(TAG, "urlText='%s'", urlText);
auto params = Url::Parser::labelQueryParams(urlText);
OATPP_ASSERT(params.size() == 3);
OATPP_ASSERT(params["key1"] == "value1");
@ -160,7 +160,7 @@ void UrlTest::onRun() {
{
const char* urlText = "label?key1=value1&key2&key3=value3";
OATPP_LOGD(TAG, "urlText='%s'", urlText);
OATPP_LOGV(TAG, "urlText='%s'", urlText);
auto params = Url::Parser::labelQueryParams(urlText);
OATPP_ASSERT(params.size() == 3);
OATPP_ASSERT(params["key1"] == "value1");
@ -170,7 +170,7 @@ void UrlTest::onRun() {
{
const char* urlText = "label?key1=value1&key2&key3";
OATPP_LOGD(TAG, "urlText='%s'", urlText);
OATPP_LOGV(TAG, "urlText='%s'", urlText);
auto params = Url::Parser::labelQueryParams(urlText);
OATPP_ASSERT(params.size() == 3);
OATPP_ASSERT(params["key1"] == "value1");

View File

@ -66,7 +66,7 @@ namespace {
OATPP_ASSERT(stream->getSize() == res);
OATPP_ASSERT(stream->toString() == "OK");
//OATPP_LOGD("client", "finished - OK");
//OATPP_LOGV("client", "finished - OK");
}

View File

@ -66,7 +66,7 @@ namespace {
}
}
}
OATPP_LOGD("WriterTask", "sent %d bytes", m_transferedBytes);
OATPP_LOGV("WriterTask", "sent %d bytes", m_transferedBytes);
}
};
@ -94,14 +94,14 @@ namespace {
m_buffer->write(readBuffer, res);
}
}
OATPP_LOGD("ReaderTask", "sent %d bytes", m_buffer->getSize());
OATPP_LOGV("ReaderTask", "sent %d bytes", m_buffer->getSize());
}
};
void runTransfer(const std::shared_ptr<Pipe>& pipe, v_int32 chunksToTransfer, bool writeNonBlock, bool readerNonBlock) {
OATPP_LOGD("transfer", "writer-nb: %d, reader-nb: %d", writeNonBlock, readerNonBlock);
OATPP_LOGV("transfer", "writer-nb: %d, reader-nb: %d", writeNonBlock, readerNonBlock);
auto buffer = oatpp::data::stream::ChunkedBuffer::createShared();

View File

@ -159,11 +159,11 @@ void DTOMapperTest::onRun(){
auto result = mapper->writeToString(test1);
OATPP_LOGD(TAG, "json='%s'", (const char*) result->getData());
OATPP_LOGV(TAG, "json='%s'", (const char*) result->getData());
OATPP_LOGD(TAG, "...");
OATPP_LOGD(TAG, "...");
OATPP_LOGD(TAG, "...");
OATPP_LOGV(TAG, "...");
OATPP_LOGV(TAG, "...");
OATPP_LOGV(TAG, "...");
oatpp::parser::Caret caret(result);
auto obj = mapper->readFromCaret<Test>(caret);
@ -188,7 +188,7 @@ void DTOMapperTest::onRun(){
result = mapper->writeToString(obj);
OATPP_LOGD(TAG, "json='%s'", (const char*) result->getData());
OATPP_LOGV(TAG, "json='%s'", (const char*) result->getData());
}

View File

@ -150,9 +150,9 @@ public:
Action handleError(const std::shared_ptr<const Error>& error) override {
if(error->is<oatpp::data::AsyncIOError>()) {
auto e = static_cast<const oatpp::data::AsyncIOError*>(error.get());
OATPP_LOGD("[FullAsyncClientTest::ClientCoroutine_echoBodyAsync::handleError()]", "AsyncIOError. %s, %d", e->what(), e->getCode());
OATPP_LOGE("[FullAsyncClientTest::ClientCoroutine_echoBodyAsync::handleError()]", "AsyncIOError. %s, %d", e->what(), e->getCode());
} else {
OATPP_LOGD("[FullAsyncClientTest::ClientCoroutine_echoBodyAsync::handleError()]", "Error. %s", error->what());
OATPP_LOGE("[FullAsyncClientTest::ClientCoroutine_echoBodyAsync::handleError()]", "Error. %s", error->what());
}
return propagateError();
}
@ -196,9 +196,9 @@ public:
if(error) {
if(error->is<oatpp::data::AsyncIOError>()) {
auto e = static_cast<const oatpp::data::AsyncIOError*>(error.get());
OATPP_LOGD("[FullAsyncClientTest::ClientCoroutine_echoBodyAsync::handleError()]", "AsyncIOError. %s, %d", e->what(), e->getCode());
OATPP_LOGE("[FullAsyncClientTest::ClientCoroutine_echoBodyAsync::handleError()]", "AsyncIOError. %s, %d", e->what(), e->getCode());
} else {
OATPP_LOGD("[FullAsyncClientTest::ClientCoroutine_echoBodyAsync::handleError()]", "Error. %s", error->what());
OATPP_LOGE("[FullAsyncClientTest::ClientCoroutine_echoBodyAsync::handleError()]", "Error. %s", error->what());
}
}
return propagateError();
@ -237,7 +237,7 @@ void FullAsyncClientTest::onRun() {
ClientCoroutine_echoBodyAsync::SUCCESS_COUNTER != -1
) {
OATPP_LOGD("Client", "Root=%d, Body=%d",
OATPP_LOGV("Client", "Root=%d, Body=%d",
ClientCoroutine_getRootAsync::SUCCESS_COUNTER.load(),
ClientCoroutine_echoBodyAsync::SUCCESS_COUNTER.load()
);
@ -245,11 +245,11 @@ void FullAsyncClientTest::onRun() {
std::this_thread::sleep_for(std::chrono::milliseconds(100));
if(ClientCoroutine_getRootAsync::SUCCESS_COUNTER == iterations){
ClientCoroutine_getRootAsync::SUCCESS_COUNTER = -1;
OATPP_LOGD("Client", "getRootAsync - DONE!");
OATPP_LOGV("Client", "getRootAsync - DONE!");
}
if(ClientCoroutine_echoBodyAsync::SUCCESS_COUNTER == iterations){
ClientCoroutine_echoBodyAsync::SUCCESS_COUNTER = -1;
OATPP_LOGD("Client", "echoBodyAsync - DONE!");
OATPP_LOGV("Client", "echoBodyAsync - DONE!");
}
}

View File

@ -140,7 +140,7 @@ void FullAsyncTest::onRun() {
for(v_int32 i = 0; i < iterationsStep * 10; i ++) {
//OATPP_LOGD("i", "%d", i);
//OATPP_LOGV("i", "%d", i);
{ // test simple GET
auto response = client->getRoot(connection);
@ -191,7 +191,7 @@ void FullAsyncTest::onRun() {
if((i + 1) % iterationsStep == 0) {
auto ticks = oatpp::base::Environment::getMicroTickCount() - lastTick;
lastTick = oatpp::base::Environment::getMicroTickCount();
OATPP_LOGD("i", "%d, tick=%d", i + 1, ticks);
OATPP_LOGV("i", "%d, tick=%d", i + 1, ticks);
}
}

View File

@ -207,7 +207,7 @@ void FullTest::onRun() {
if((i + 1) % iterationsStep == 0) {
auto ticks = oatpp::base::Environment::getMicroTickCount() - lastTick;
lastTick = oatpp::base::Environment::getMicroTickCount();
OATPP_LOGD("i", "%d, tick=%d", i + 1, ticks);
OATPP_LOGV("i", "%d, tick=%d", i + 1, ticks);
}
}

View File

@ -52,13 +52,13 @@ public:
#include OATPP_CODEGEN_BEGIN(ApiController)
ENDPOINT("GET", "/", root) {
//OATPP_LOGD(TAG, "GET '/'");
//OATPP_LOGV(TAG, "GET '/'");
return createResponse(Status::CODE_200, "Hello World!!!");
}
ENDPOINT("GET", "params/{param}", getWithParams,
PATH(String, param)) {
//OATPP_LOGD(TAG, "GET params/%s", param->c_str());
//OATPP_LOGV(TAG, "GET params/%s", param->c_str());
auto dto = TestDto::createShared();
dto->testValue = param;
return createDtoResponse(Status::CODE_200, dto);
@ -83,7 +83,7 @@ public:
ENDPOINT("GET", "headers", getWithHeaders,
HEADER(String, param, "X-TEST-HEADER")) {
//OATPP_LOGD(TAG, "GET headers {X-TEST-HEADER: %s}", param->c_str());
//OATPP_LOGV(TAG, "GET headers {X-TEST-HEADER: %s}", param->c_str());
auto dto = TestDto::createShared();
dto->testValue = param;
return createDtoResponse(Status::CODE_200, dto);
@ -91,7 +91,7 @@ public:
ENDPOINT("POST", "body", postBody,
BODY_STRING(String, body)) {
//OATPP_LOGD(TAG, "POST body %s", body->c_str());
//OATPP_LOGV(TAG, "POST body %s", body->c_str());
auto dto = TestDto::createShared();
dto->testValue = body;
return createDtoResponse(Status::CODE_200, dto);
@ -99,7 +99,7 @@ public:
ENDPOINT("POST", "echo", echo,
BODY_STRING(String, body)) {
//OATPP_LOGD(TAG, "POST body(echo) size=%d", body->getSize());
//OATPP_LOGV(TAG, "POST body(echo) size=%d", body->getSize());
return createResponse(Status::CODE_200, body);
}

View File

@ -54,7 +54,7 @@ public:
ENDPOINT_ASYNC_INIT(Root)
Action act() {
//OATPP_LOGD(TAG, "GET '/'");
//OATPP_LOGV(TAG, "GET '/'");
return _return(controller->createResponse(Status::CODE_200, "Hello World Async!!!"));
}
@ -66,7 +66,7 @@ public:
Action act() {
auto param = request->getPathVariable("param");
//OATPP_LOGD(TAG, "GET params/%s", param->c_str());
//OATPP_LOGV(TAG, "GET params/%s", param->c_str());
auto dto = TestDto::createShared();
dto->testValue = param;
return _return(controller->createDtoResponse(Status::CODE_200, dto));
@ -80,7 +80,7 @@ public:
Action act() {
auto param = request->getHeader("X-TEST-HEADER");
//OATPP_LOGD(TAG, "GET headers {X-TEST-HEADER: %s}", param->c_str());
//OATPP_LOGV(TAG, "GET headers {X-TEST-HEADER: %s}", param->c_str());
auto dto = TestDto::createShared();
dto->testValue = param;
return _return(controller->createDtoResponse(Status::CODE_200, dto));
@ -93,12 +93,12 @@ public:
ENDPOINT_ASYNC_INIT(PostBody)
Action act() {
//OATPP_LOGD(TAG, "POST body. Reading body...");
//OATPP_LOGV(TAG, "POST body. Reading body...");
return request->readBodyToStringAsync().callbackTo(&PostBody::onBodyRead);
}
Action onBodyRead(const String& body) {
//OATPP_LOGD(TAG, "POST body %s", body->c_str());
//OATPP_LOGV(TAG, "POST body %s", body->c_str());
auto dto = TestDto::createShared();
dto->testValue = body;
return _return(controller->createDtoResponse(Status::CODE_200, dto));
@ -111,12 +111,12 @@ public:
ENDPOINT_ASYNC_INIT(Echo)
Action act() {
//OATPP_LOGD(TAG, "POST body(echo). Reading body...");
//OATPP_LOGV(TAG, "POST body(echo). Reading body...");
return request->readBodyToStringAsync().callbackTo(&Echo::onBodyRead);
}
Action onBodyRead(const String& body) {
//OATPP_LOGD(TAG, "POST echo size=%d", body->getSize());
//OATPP_LOGV(TAG, "POST echo size=%d", body->getSize());
return _return(controller->createResponse(Status::CODE_200, body));
}