mirror of
https://github.com/Samsung/escargot.git
synced 2026-06-22 10:01:50 +00:00
Update customized logging
* enabled by ESCARGOT_USE_CUSTOM_LOGGING flag * user can registers customized logging through Platform's inherited functions Signed-off-by: HyukWoo Park <hyukwoo.park@samsung.com>
This commit is contained in:
parent
78b1aa7d2e
commit
4366a01196
9 changed files with 64 additions and 6 deletions
2
.github/workflows/es-actions.yml
vendored
2
.github/workflows/es-actions.yml
vendored
|
|
@ -100,7 +100,7 @@ jobs:
|
|||
strategy:
|
||||
matrix:
|
||||
tc: ['octane', 'v8 chakracore spidermonkey']
|
||||
build_opt: ['', '-DESCARGOT_THREADING=ON', '-DESCARGOT_SMALL_CONFIG=ON']
|
||||
build_opt: ['', '-DESCARGOT_THREADING=ON', '-DESCARGOT_SMALL_CONFIG=ON -DESCARGOT_USE_CUSTOM_LOGGING=ON']
|
||||
exclude:
|
||||
# exclude spidermonkey on threading-enabled build (TODO)
|
||||
- tc: 'v8 chakracore spidermonkey'
|
||||
|
|
|
|||
|
|
@ -135,7 +135,9 @@ IF (ESCARGOT_LIBICU_SUPPORT)
|
|||
ENDIF()
|
||||
ENDIF()
|
||||
|
||||
IF (${ESCARGOT_HOST} STREQUAL "tizen_obs")
|
||||
IF (ESCARGOT_USE_CUSTOM_LOGGING)
|
||||
SET (ESCARGOT_DEFINITIONS ${ESCARGOT_DEFINITIONS} -DESCARGOT_USE_CUSTOM_LOGGING)
|
||||
ELSEIF (${ESCARGOT_HOST} STREQUAL "tizen_obs")
|
||||
PKG_CHECK_MODULES (DLOG REQUIRED dlog)
|
||||
SET (ESCARGOT_LIBRARIES ${ESCARGOT_LIBRARIES} ${DLOG_LIBRARIES})
|
||||
SET (ESCARGOT_INCDIRS ${ESCARGOT_INCDIRS} ${DLOG_INCLUDE_DIRS})
|
||||
|
|
|
|||
|
|
@ -317,6 +317,17 @@ typedef int32_t UChar32;
|
|||
#define FALSE 0
|
||||
#endif
|
||||
|
||||
#ifdef ESCARGOT_USE_CUSTOM_LOGGING
|
||||
// use customized logging
|
||||
#include <stdarg.h>
|
||||
namespace Escargot {
|
||||
void customEscargotInfoLogger(const char* format, ...);
|
||||
void customEscargotErrorLogger(const char* format, ...);
|
||||
} // namespace Escargot
|
||||
#define ESCARGOT_LOG_INFO(...) ::Escargot::customEscargotInfoLogger(__VA_ARGS__);
|
||||
#define ESCARGOT_LOG_ERROR(...) ::Escargot::customEscargotErrorLogger(__VA_ARGS__);
|
||||
#else
|
||||
// use default logging
|
||||
#define ESCARGOT_LOG_INFO(...) fprintf(stdout, __VA_ARGS__);
|
||||
#define ESCARGOT_LOG_ERROR(...) fprintf(stderr, __VA_ARGS__);
|
||||
|
||||
|
|
@ -333,6 +344,7 @@ typedef int32_t UChar32;
|
|||
#define ESCARGOT_LOG_INFO(...) dlog_print(DLOG_INFO, "Escargot", __VA_ARGS__);
|
||||
#define ESCARGOT_LOG_ERROR(...) dlog_print(DLOG_ERROR, "Escargot", __VA_ARGS__);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef CRASH
|
||||
#define CRASH ASSERT_NOT_REACHED
|
||||
|
|
|
|||
|
|
@ -183,6 +183,18 @@ public:
|
|||
m_platform->deallocateThreadLocalCustomData();
|
||||
}
|
||||
|
||||
#ifdef ESCARGOT_USE_CUSTOM_LOGGING
|
||||
virtual void customInfoLogger(const char* format, va_list arg) override
|
||||
{
|
||||
m_platform->customInfoLogger(format, arg);
|
||||
}
|
||||
|
||||
virtual void customErrorLogger(const char* format, va_list arg) override
|
||||
{
|
||||
m_platform->customErrorLogger(format, arg);
|
||||
}
|
||||
#endif
|
||||
|
||||
private:
|
||||
PlatformRef* m_platform;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1945,6 +1945,19 @@ public:
|
|||
// do nothing
|
||||
}
|
||||
|
||||
#ifdef ESCARGOT_USE_CUSTOM_LOGGING
|
||||
// default custom logger
|
||||
virtual void customInfoLogger(const char* format, va_list arg)
|
||||
{
|
||||
vfprintf(stdout, format, arg);
|
||||
}
|
||||
|
||||
virtual void customErrorLogger(const char* format, va_list arg)
|
||||
{
|
||||
vfprintf(stderr, format, arg);
|
||||
}
|
||||
#endif
|
||||
|
||||
void* threadLocalCustomData();
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -24,7 +24,6 @@
|
|||
#include "runtime/GlobalObject.h"
|
||||
#include "runtime/RegExpObject.h"
|
||||
#include "runtime/StaticStrings.h"
|
||||
#include "runtime/String.h"
|
||||
|
||||
namespace Escargot {
|
||||
|
||||
|
|
|
|||
|
|
@ -100,4 +100,21 @@ Global::Waiter* Global::waiter(void* blockAddress)
|
|||
}
|
||||
#endif
|
||||
|
||||
#ifdef ESCARGOT_USE_CUSTOM_LOGGING
|
||||
void customEscargotInfoLogger(const char* format, ...)
|
||||
{
|
||||
va_list arg;
|
||||
va_start(arg, format);
|
||||
Global::platform()->customInfoLogger(format, arg);
|
||||
va_end(arg);
|
||||
}
|
||||
|
||||
void customEscargotErrorLogger(const char* format, ...)
|
||||
{
|
||||
va_list arg;
|
||||
va_start(arg, format);
|
||||
Global::platform()->customErrorLogger(format, arg);
|
||||
va_end(arg);
|
||||
}
|
||||
#endif
|
||||
} // namespace Escargot
|
||||
|
|
|
|||
|
|
@ -53,6 +53,12 @@ public:
|
|||
// ThreadLocal custom data (g_customData)
|
||||
virtual void* allocateThreadLocalCustomData() = 0;
|
||||
virtual void deallocateThreadLocalCustomData() = 0;
|
||||
|
||||
#ifdef ESCARGOT_USE_CUSTOM_LOGGING
|
||||
// customized logging
|
||||
virtual void customInfoLogger(const char* format, va_list arg) = 0;
|
||||
virtual void customErrorLogger(const char* format, va_list arg) = 0;
|
||||
#endif
|
||||
};
|
||||
} // namespace Escargot
|
||||
|
||||
|
|
|
|||
|
|
@ -115,9 +115,6 @@ private:
|
|||
uint64_t m_start;
|
||||
const char* m_msg;
|
||||
};
|
||||
} // namespace Escargot
|
||||
|
||||
namespace Escargot {
|
||||
|
||||
namespace detail {
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue