X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=modules%2Flog%2Finclude%2Fdpl%2Flog%2Flog.h;fp=modules_mobile%2Flog%2Finclude%2Fdpl%2Flog%2Flog.h;h=1f6b195837c3eaf5256a0af642abcd2caf97989d;hb=3a034abb4dca58ff0940687d8dd2b829ce2e226f;hp=d4d95ed7f066d735ae2979d04a55db40f09214f6;hpb=58be0971049907f3166ce56a6ad509769565158f;p=framework%2Fweb%2Fwrt-commons.git diff --git a/modules_mobile/log/include/dpl/log/log.h b/modules/log/include/dpl/log/log.h old mode 100644 new mode 100755 similarity index 53% rename from modules_mobile/log/include/dpl/log/log.h rename to modules/log/include/dpl/log/log.h index d4d95ed..1f6b195 --- a/modules_mobile/log/include/dpl/log/log.h +++ b/modules/log/include/dpl/log/log.h @@ -22,33 +22,37 @@ #ifndef DPL_LOG_H #define DPL_LOG_H +#ifndef LOG_TAG +#warning Please define LOG_TAG +#define LOG_TAG "WRT_UNDEFINED" +#endif + +#include +#include +#include #include #include -#include -#include -#include -#include -#include +#include namespace DPL { namespace Log { /** * DPL log system * - * To switch logs into old style, export - * DPL_USE_OLD_STYLE_LOGS before application start + * @deprecated */ +const char *LocateSourceFileName(const char *filename); +std::string FormatMessage(const char *message, + const char *filename, + int line, + const char *function); + class LogSystem : private Noncopyable { private: - typedef std::list AbstractLogProviderPtrList; - AbstractLogProviderPtrList m_providers; - - DLOGLogProvider *m_dlogProvider; - OldStyleLogProvider *m_oldStyleProvider; - bool m_isLoggingEnabled; + std::unique_ptr m_tag; public: bool IsLoggingEnabled() const; @@ -61,7 +65,8 @@ class LogSystem : void Debug(const char *message, const char *filename, int line, - const char *function); + const char *function, + const char *tag = NULL); /** * Log info message @@ -69,7 +74,8 @@ class LogSystem : void Info(const char *message, const char *filename, int line, - const char *function); + const char *function, + const char *tag = NULL); /** * Log warning message @@ -77,7 +83,8 @@ class LogSystem : void Warning(const char *message, const char *filename, int line, - const char *function); + const char *function, + const char *tag = NULL); /** * Log error message @@ -85,7 +92,8 @@ class LogSystem : void Error(const char *message, const char *filename, int line, - const char *function); + const char *function, + const char *tag = NULL); /** * Log pedantic message @@ -93,39 +101,14 @@ class LogSystem : void Pedantic(const char *message, const char *filename, int line, - const char *function); + const char *function, + const char *tag = NULL); /** * Set default's DLOG provider Tag */ void SetTag(const char *tag); - /** - * Add abstract provider to providers list - * - * @notice Ownership is transfered to LogSystem and deleted upon exit - */ - void AddProvider(AbstractLogProvider *provider); - - /** - * Remove abstract provider from providers list - */ - void RemoveProvider(AbstractLogProvider *provider); -}; - -/* - * Replacement low overhead null logging class - */ -class NullStream -{ - public: - NullStream() {} - - template - NullStream& operator<<(const T&) - { - return *this; - } }; /** @@ -135,31 +118,23 @@ typedef Singleton LogSystemSingleton; } } // namespace DPL -// -// Log support -// -// +/** + * Logging API for C++ + * This API print out messages to the main log buffer + */ #ifdef DPL_LOGS_ENABLED - #define DPL_MACRO_FOR_LOGGING(message, function) \ - do \ - { \ - if (DPL::Log::LogSystemSingleton::Instance().IsLoggingEnabled()) \ - { \ +#define DPL_MACRO_FOR_LOGGING(message, function) \ +do { \ std::ostringstream platformLog; \ platformLog << message; \ DPL::Log::LogSystemSingleton::Instance().function( \ platformLog.str().c_str(), \ - __FILE__, __LINE__, __FUNCTION__); \ - } \ - } while (0) + __FILE__, __LINE__, __FUNCTION__, \ + LOG_TAG); \ +} while (0) #else -/* avoid warnings about unused variables */ - #define DPL_MACRO_FOR_LOGGING(message, function) \ - do { \ - DPL::Log::NullStream ns; \ - ns << message; \ - } while (0) +#define DPL_MACRO_FOR_LOGGING(message, function) do { } while (0) #endif #define LogDebug(message) DPL_MACRO_FOR_LOGGING(message, Debug) @@ -168,4 +143,55 @@ typedef Singleton LogSystemSingleton; #define LogError(message) DPL_MACRO_FOR_LOGGING(message, Error) #define LogPedantic(message) DPL_MACRO_FOR_LOGGING(message, Pedantic) + +/** + * Logging API for C + * This API print out messages to the system log buffer + */ +#define INTERNAL_SECURE_LOG __extension__ SECURE_SLOG +#ifdef DPL_LOGS_ENABLED +#define WRT_LOG_(priority, ...) \ +do { \ + INTERNAL_SECURE_LOG(priority, LOG_TAG, __VA_ARGS__); \ +} while(0) +#else +#define WRT_LOG_(priority, ...) do { } while (0) +#endif + +#define WrtLogD(...) WRT_LOG_(LOG_DEBUG, __VA_ARGS__) +#define WrtLogI(...) WRT_LOG_(LOG_INFO, __VA_ARGS__) +#define WrtLogW(...) WRT_LOG_(LOG_WARN, __VA_ARGS__) +#define WrtLogE(...) WRT_LOG_(LOG_ERROR, __VA_ARGS__) + + +/** + * Logging API for C + * This API print out messages to the system log buffer + */ +#ifndef SECURE_SLOGD +#define SECURE_SLOGD(fmt, arg...) SLOGD(fmt,##arg) +#endif + +#ifndef SECURE_SLOGW +#define SECURE_SLOGW(fmt, arg...) SLOGW(fmt,##arg) +#endif + +#ifndef SECURE_SLOGE +#define SECURE_SLOGE(fmt, arg...) SLOGE(fmt,##arg) +#endif + +#undef _D +#undef _W +#undef _E + +#ifdef DPL_LOGS_ENABLED +#define _D(fmt, arg ...) SECURE_SLOGD(fmt, ##arg) +#define _W(fmt, arg ...) SECURE_SLOGW(fmt, ##arg) +#define _E(fmt, arg ...) SECURE_SLOGE(fmt, ##arg) +#else +#define _D(fmt, arg ...) do { } while (0) +#define _W(fmt, arg ...) do { } while (0) +#define _E(fmt, arg ...) do { } while (0) +#endif + #endif // DPL_LOG_H