Skip to content

Commit c399358

Browse files
committed
fix: use dlog directly for TRACE
Signed-off-by: Daeyeon Jeong <daeyeon.jeong@samsung.com>
1 parent 4eebc36 commit c399358

File tree

4 files changed

+34
-44
lines changed

4 files changed

+34
-44
lines changed

deps/message-port/async-uv.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ size_t AsyncUV::EnqueueTask(Task task) {
6363
bool AsyncUV::DrainPendingTasks(uv_loop_t* loop) {
6464
TRACE(MSGPORT, "DrainPendingTasks");
6565
std::lock_guard<std::mutex> lock(queue_mutex_);
66-
TRACE(MSGPORT, "drain pending tasks", queue_.size());
66+
TRACE(MSGPORT, "drain pending tasks %zu", queue_.size());
6767

6868
if (loop == nullptr) {
6969
TRACE(MSGPORT, "invalid loop");
@@ -81,7 +81,7 @@ bool AsyncUV::DrainPendingTasks(uv_loop_t* loop) {
8181
void AsyncUV::DeletePendingTasks() {
8282
TRACE(MSGPORT, "DeletePendingTasks");
8383
std::lock_guard<std::mutex> lock(queue_mutex_);
84-
TRACE(MSGPORT, "delete pending tasks", queue_.size());
84+
TRACE(MSGPORT, "delete pending tasks %zu", queue_.size());
8585
if (!queue_.empty()) {
8686
std::queue<Task> empty;
8787
std::swap(queue_, empty);

deps/message-port/nd/es-helper.cc

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ OptionalRef<StringRef> BuiltinHelperFileRead(
138138
state.get(), StringRef::createFromASCII("invalid file name")));
139139
}
140140
} else {
141-
TRACE(ESCARGOT, "File Not Found:", file_name);
141+
TRACE(ESCARGOT, "File Not Found: %s", file_name);
142142
}
143143
return nullptr;
144144
}
@@ -161,7 +161,7 @@ ValueRef* BuiltinLoad(ExecutionStateRef* state,
161161
// path
162162
CHECK(argv[0]->isString());
163163
file_name = argv[0]->toString(state)->toStdUTF8String();
164-
TRACE(LOADER, KV(file_name));
164+
TRACE(LOADER, "file_name: %s", file_name.c_str());
165165

166166
// useEmptyContext
167167
if (argc > 1) {
@@ -528,19 +528,19 @@ ExecResult CompileAndExecution(ContextRef* context,
528528
break;
529529
}
530530

531-
TRACEF(ESCARGOT,
532-
"Compile: %s",
533-
compile_result.parseErrorMessage->toStdUTF8String());
531+
TRACE(ESCARGOT,
532+
"Compile: %s",
533+
compile_result.parseErrorMessage->toStdUTF8String().c_str());
534534

535535
Evaluator::EvaluatorResult result;
536536
result.error =
537537
ExceptionHelper::CreateErrorObject(context,
538538
compile_result.parseErrorCode,
539539
compile_result.parseErrorMessage);
540540

541-
TRACEF(ESCARGOT,
542-
"Compile: %s",
543-
result.resultOrErrorToString(context)->toStdUTF8String().c_str());
541+
TRACE(ESCARGOT,
542+
"Compile: %s",
543+
result.resultOrErrorToString(context)->toStdUTF8String().c_str());
544544
return result;
545545
}
546546

@@ -552,9 +552,9 @@ ExecResult CompileAndExecution(ContextRef* context,
552552
},
553553
compile_result.script.get());
554554
if (execute_result.isSuccessful() == false) {
555-
TRACEF(ESCARGOT,
556-
"\nExecute:\n%s",
557-
ExecResultHelper::GetErrorString(context, execute_result).c_str());
555+
TRACE(ESCARGOT,
556+
"\nExecute:\n%s",
557+
ExecResultHelper::GetErrorString(context, execute_result).c_str());
558558
}
559559
return execute_result;
560560
}
@@ -592,7 +592,6 @@ std::string ExecResultHelper::GetStackTraceString(
592592
const GCManagedVector<Evaluator::StackTraceData>& traceData,
593593
const std::string& reasonString,
594594
size_t max_stack_size) {
595-
TRACE(ERROR, KV(traceData.size()));
596595
const std::string separator = " ";
597596
std::ostringstream oss;
598597

deps/message-port/nd/nd-logger.h

Lines changed: 19 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -58,47 +58,38 @@ enum LOG_PRIORITY {
5858
#if !defined(ENABLE_TRACE)
5959

6060
#define TRACE(id, ...)
61-
#define TRACE0(id, ...)
62-
#define TRACEF(id, ...)
63-
#define TRACEF0(id, ...)
6461
#define S0(x)
6562
#define KV(x)
6663

6764
#else
68-
69-
#define TRACE(id, ...) \
65+
#if defined(HOST_TIZEN)
66+
#include <dlog.h>
67+
#define TRACE(id, fmt, ...) \
7068
do { \
7169
if (IsTraceEnabled(#id)) { \
72-
Print(LOG_PRIO_DEBUG, \
73-
#id, \
74-
CreateCodeLocation(__PRETTY_FUNCTION__, __FILE_NAME__, __LINE__), \
75-
##__VA_ARGS__); \
70+
dlog_print(DLOG_INFO, \
71+
"LWNODE", \
72+
"%s: (%s:%d) > [MessagePort] " fmt, \
73+
__FUNCTION__, \
74+
__FILE_NAME__, \
75+
__LINE__, \
76+
##__VA_ARGS__); \
7677
} \
7778
} while (0)
78-
79-
#define TRACEF(id, ...) \
79+
#else
80+
#define TRACE(id, fmt, ...) \
8081
do { \
8182
if (IsTraceEnabled(#id)) { \
82-
PrintF(LOG_PRIO_DEBUG, \
83-
#id, \
84-
CreateCodeLocation(__PRETTY_FUNCTION__, __FILE_NAME__, __LINE__), \
83+
printf(DLOG_INFO, \
84+
"LWNODE", \
85+
" %s: (%s:%d) > [MessagePort] " fmt, \
86+
__FUNCTION__, \
87+
__FILE_NAME__, \
88+
__LINE__, \
8589
##__VA_ARGS__); \
8690
} \
8791
} while (0)
88-
89-
#define TRACE0(id, ...) \
90-
do { \
91-
if (IsTraceEnabled(#id)) { \
92-
Print(LOG_PRIO_DEBUG, #id, "", ##__VA_ARGS__); \
93-
} \
94-
} while (0)
95-
96-
#define TRACEF0(id, ...) \
97-
do { \
98-
if (IsTraceEnabled(#id)) { \
99-
PrintF(LOG_PRIO_DEBUG, #id, "", ##__VA_ARGS__); \
100-
} \
101-
} while (0)
92+
#endif
10293

10394
#define S0(x) #x ":"
10495
#define KV(x) S0(x), x

src/lwnode/nd-mod-message-port.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ class MessagePortWrap : public BaseObject {
139139
MessagePortWrap(ObjectRef* object) : BaseObject(object) {
140140
onmessage_ = ValueRef::createUndefined();
141141
}
142-
~MessagePortWrap() { TRACE(MSGPORT_JS, "DELETE", this); }
142+
~MessagePortWrap() { TRACE(MSGPORT_JS, "DELETE %p", this); }
143143

144144
static ValueRef* New(ExecutionStateRef* state,
145145
ValueRef* this_value,
@@ -218,7 +218,7 @@ class MessagePortWrap : public BaseObject {
218218

219219
// Start listening messages
220220
port->OnMessage([this, context](const MessageEvent* event) {
221-
TRACEF(MSGPORT_JS, "OnMessage: %s\n", event->data());
221+
TRACE(MSGPORT_JS, "OnMessage: %s\n", event->data().c_str());
222222

223223
if (!onmessage_->isFunctionObject()) {
224224
return;

0 commit comments

Comments
 (0)