[DEV] change log system

This commit is contained in:
Edouard DUPIN 2014-04-30 22:18:00 +02:00
parent 8854a5a34b
commit 0c6151283b
5 changed files with 75 additions and 15 deletions

View File

@ -44,7 +44,7 @@ void appl::GlyphDecoration::setBold(bool _enable)
}
}
etk::CCout& appl::operator <<(etk::CCout& _os, const appl::GlyphDecoration& _obj)
std::ostream& appl::operator <<(std::ostream& _os, const appl::GlyphDecoration& _obj)
{
_os << "{fg=" << _obj.getForeground();
_os << ",bg=" << _obj.getBackground();

View File

@ -116,7 +116,7 @@ namespace appl {
return m_bold;
};
};
etk::CCout& operator <<(etk::CCout& _os, const appl::GlyphDecoration& _obj);
std::ostream& operator <<(std::ostream& _os, const appl::GlyphDecoration& _obj);
}
#endif

View File

@ -152,6 +152,7 @@ MainWindows::MainWindows(void) {
#else
myTextView = new appl::TextViewer("FreeMono;DejaVuSansMono;FreeSerif", 11);
#endif
myTextView->setName("appl-text-viewer");
myTextView->setExpand(bvec2(true,true));
myTextView->setFill(bvec2(true,true));
mySizerVert2->subWidgetAdd(myTextView);
@ -304,6 +305,37 @@ void MainWindows::onReceiveMessage(const ewol::object::Message& _msg) {
if (NULL == tmpWidget) {
APPL_ERROR("Can not allocate widget == > display might be in error");
} else {
#ifdef SDGSDFGSDFGSDFGSDFGSTERGDHFGHFDS
std::string menuDescription = "<title>Properties</title>\n";
menuDescription += "<group>\n";
menuDescription += " <title>Editor</title>\n";
menuDescription += " <menu>\n";
menuDescription += " <title>Editor Interface</title>\n";
menuDescription += " <short-title>Editor</short-title>\n";
menuDescription += " <widget>appl-text-viewer</widget>\n";
menuDescription += " </menu>\n";
menuDescription += "</group>\n";
menuDescription += "<group>\n";
menuDescription += " <title>Gui</title>\n";
menuDescription += " <menu>\n";
menuDescription += " <title>Font selection</title>\n";
menuDescription += " <short-title>Font</short-title>\n";
menuDescription += " <widget></widget>\n";
menuDescription += " </menu>\n";
menuDescription += " <menu>\n";
menuDescription += " <title>Color selection</title>\n";
menuDescription += " <short-title>Color</short-title>\n";
menuDescription += " <widget></widget>\n";
menuDescription += " </menu>\n";
menuDescription += " <menu>\n";
menuDescription += " <title>Theme selection</title>\n";
menuDescription += " <short-title>Theme</short-title>\n";
menuDescription += " <widget></widget>\n";
menuDescription += " </menu>\n";
menuDescription += "</group>\n";
tmpWidget->setMenu(menuDescription);
#endif
tmpWidget->setTitle("Properties");
popUpWidgetPush(tmpWidget);
tmpWidget->menuAddGroup("Editor");

View File

@ -8,4 +8,8 @@
#include <appl/debug.h>
const char * applLog = "edn ";
int32_t appl::getLogId(void) {
static int32_t g_val = etk::log::registerInstance("edn");
return g_val;
}

View File

@ -9,19 +9,43 @@
#ifndef __APPL_DEBUG_H__
#define __APPL_DEBUG_H__
#include <etk/types.h>
#include <etk/debugGeneric.h>
#include <etk/log.h>
extern const char * applLog;
namespace appl {
int32_t getLogId(void);
};
// TODO : Review this problem of multiple intanciation of "std::stringbuf sb"
#define APPL_BASE(info,data) \
do { \
if (info <= etk::log::getLevel(appl::getLogId())) { \
std::stringbuf sb; \
std::ostream tmpStream(&sb); \
tmpStream << data; \
etk::log::logStream(appl::getLogId(), info, __LINE__, __class__, __func__, tmpStream); \
} \
} while(0)
#define APPL_CRITICAL(data) ETK_CRITICAL(applLog, data)
#define APPL_WARNING(data) ETK_WARNING(applLog, data)
#define APPL_ERROR(data) ETK_ERROR(applLog, data)
#define APPL_INFO(data) ETK_INFO(applLog, data)
#define APPL_DEBUG(data) ETK_DEBUG(applLog, data)
#define APPL_VERBOSE(data) ETK_VERBOSE(applLog, data)
#define APPL_ASSERT(cond, data) ETK_ASSERT(applLog, cond, data)
#define APPL_CHECK_INOUT(cond) ETK_CHECK_INOUT(applLog, cond)
#define APPL_TODO(cond) ETK_TODO(applLog, cond)
#define APPL_CRITICAL(data) APPL_BASE(1, data)
#define APPL_ERROR(data) APPL_BASE(2, data)
#define APPL_WARNING(data) APPL_BASE(3, data)
#ifdef DEBUG
#define APPL_INFO(data) APPL_BASE(4, data)
#define APPL_DEBUG(data) APPL_BASE(5, data)
#define APPL_VERBOSE(data) APPL_BASE(6, data)
#define APPL_TODO(data) APPL_BASE(4, "TODO : " << data)
#else
#define APPL_INFO(data) do { } while(false)
#define APPL_DEBUG(data) do { } while(false)
#define APPL_VERBOSE(data) do { } while(false)
#define APPL_TODO(data) do { } while(false)
#endif
#define APPL_ASSERT(cond,data) \
do { \
if (!(cond)) { \
APPL_CRITICAL(data); \
assert(!#cond); \
} \
} while (0)
#endif