Merge #9014 from justinmk/log-more

This commit is contained in:
Justin M. Keyes 2018-09-19 07:55:46 +02:00 committed by GitHub
commit d0401e827b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 25 additions and 12 deletions

View File

@ -190,6 +190,9 @@ for i = 1, #functions do
output:write('Object handle_'..fn.name..'(uint64_t channel_id, Array args, Error *error)') output:write('Object handle_'..fn.name..'(uint64_t channel_id, Array args, Error *error)')
output:write('\n{') output:write('\n{')
output:write('\n#if MIN_LOG_LEVEL <= DEBUG_LOG_LEVEL')
output:write('\n logmsg(DEBUG_LOG_LEVEL, "RPC: ", NULL, -1, true, "invoke '..fn.name..'");')
output:write('\n#endif')
output:write('\n Object ret = NIL;') output:write('\n Object ret = NIL;')
-- Declare/initialize variables that will hold converted arguments -- Declare/initialize variables that will hold converted arguments
for j = 1, #fn.parameters do for j = 1, #fn.parameters do

View File

@ -101,7 +101,7 @@ void log_unlock(void)
/// @param context description of a shared context or subsystem /// @param context description of a shared context or subsystem
/// @param func_name function name, or NULL /// @param func_name function name, or NULL
/// @param line_num source line number, or -1 /// @param line_num source line number, or -1
bool do_log(int log_level, const char *context, const char *func_name, bool logmsg(int log_level, const char *context, const char *func_name,
int line_num, bool eol, const char *fmt, ...) int line_num, bool eol, const char *fmt, ...)
FUNC_ATTR_UNUSED FUNC_ATTR_UNUSED
{ {

View File

@ -22,42 +22,42 @@
# define MIN_LOG_LEVEL INFO_LOG_LEVEL # define MIN_LOG_LEVEL INFO_LOG_LEVEL
#endif #endif
#define LOG(level, ...) do_log((level), NULL, __func__, __LINE__, true, \ #define LOG(level, ...) logmsg((level), NULL, __func__, __LINE__, true, \
__VA_ARGS__) __VA_ARGS__)
#if MIN_LOG_LEVEL <= DEBUG_LOG_LEVEL #if MIN_LOG_LEVEL <= DEBUG_LOG_LEVEL
# undef DLOG # undef DLOG
# undef DLOGN # undef DLOGN
# define DLOG(...) do_log(DEBUG_LOG_LEVEL, NULL, __func__, __LINE__, true, \ # define DLOG(...) logmsg(DEBUG_LOG_LEVEL, NULL, __func__, __LINE__, true, \
__VA_ARGS__) __VA_ARGS__)
# define DLOGN(...) do_log(DEBUG_LOG_LEVEL, NULL, __func__, __LINE__, false, \ # define DLOGN(...) logmsg(DEBUG_LOG_LEVEL, NULL, __func__, __LINE__, false, \
__VA_ARGS__) __VA_ARGS__)
#endif #endif
#if MIN_LOG_LEVEL <= INFO_LOG_LEVEL #if MIN_LOG_LEVEL <= INFO_LOG_LEVEL
# undef ILOG # undef ILOG
# undef ILOGN # undef ILOGN
# define ILOG(...) do_log(INFO_LOG_LEVEL, NULL, __func__, __LINE__, true, \ # define ILOG(...) logmsg(INFO_LOG_LEVEL, NULL, __func__, __LINE__, true, \
__VA_ARGS__) __VA_ARGS__)
# define ILOGN(...) do_log(INFO_LOG_LEVEL, NULL, __func__, __LINE__, false, \ # define ILOGN(...) logmsg(INFO_LOG_LEVEL, NULL, __func__, __LINE__, false, \
__VA_ARGS__) __VA_ARGS__)
#endif #endif
#if MIN_LOG_LEVEL <= WARN_LOG_LEVEL #if MIN_LOG_LEVEL <= WARN_LOG_LEVEL
# undef WLOG # undef WLOG
# undef WLOGN # undef WLOGN
# define WLOG(...) do_log(WARN_LOG_LEVEL, NULL, __func__, __LINE__, true, \ # define WLOG(...) logmsg(WARN_LOG_LEVEL, NULL, __func__, __LINE__, true, \
__VA_ARGS__) __VA_ARGS__)
# define WLOGN(...) do_log(WARN_LOG_LEVEL, NULL, __func__, __LINE__, false, \ # define WLOGN(...) logmsg(WARN_LOG_LEVEL, NULL, __func__, __LINE__, false, \
__VA_ARGS__) __VA_ARGS__)
#endif #endif
#if MIN_LOG_LEVEL <= ERROR_LOG_LEVEL #if MIN_LOG_LEVEL <= ERROR_LOG_LEVEL
# undef ELOG # undef ELOG
# undef ELOGN # undef ELOGN
# define ELOG(...) do_log(ERROR_LOG_LEVEL, NULL, __func__, __LINE__, true, \ # define ELOG(...) logmsg(ERROR_LOG_LEVEL, NULL, __func__, __LINE__, true, \
__VA_ARGS__) __VA_ARGS__)
# define ELOGN(...) do_log(ERROR_LOG_LEVEL, NULL, __func__, __LINE__, false, \ # define ELOGN(...) logmsg(ERROR_LOG_LEVEL, NULL, __func__, __LINE__, false, \
__VA_ARGS__) __VA_ARGS__)
#endif #endif

View File

@ -358,6 +358,7 @@ static void handle_request(Channel *channel, msgpack_object *request)
} }
} else { } else {
multiqueue_put(channel->events, on_request_event, 1, evdata); multiqueue_put(channel->events, on_request_event, 1, evdata);
DLOG("RPC: scheduled %.*s", method->via.bin.size, method->via.bin.ptr);
} }
} }

View File

@ -351,6 +351,8 @@ static bool input_poll(int ms)
blocking = true; blocking = true;
multiqueue_process_events(ch_before_blocking_events); multiqueue_process_events(ch_before_blocking_events);
} }
DLOG("blocking... events_enabled=%d events_pending=%d", events_enabled,
!multiqueue_empty(main_loop.events));
LOOP_PROCESS_EVENTS_UNTIL(&main_loop, NULL, ms, input_ready() || input_eof); LOOP_PROCESS_EVENTS_UNTIL(&main_loop, NULL, ms, input_ready() || input_eof);
blocking = false; blocking = false;

View File

@ -153,6 +153,7 @@ void mch_exit(int r)
free_all_mem(); free_all_mem();
#endif #endif
ILOG("Nvim exit: %d", r);
exit(r); exit(r);
} }

View File

@ -64,6 +64,12 @@ getkey:
may_sync_undo(); may_sync_undo();
} }
#if MIN_LOG_LEVEL <= DEBUG_LOG_LEVEL
char *keyname = key == K_EVENT
? "K_EVENT" : (char *)get_special_key_name(key, mod_mask);
DLOG("input: %s", keyname);
#endif
int execute_result = s->execute(s, key); int execute_result = s->execute(s, key);
if (!execute_result) { if (!execute_result) {
break; break;

View File

@ -69,10 +69,10 @@ static char uilog_last_event[1024] = { 0 };
uilog_seen++; \ uilog_seen++; \
} else { \ } else { \
if (uilog_seen > 0) { \ if (uilog_seen > 0) { \
do_log(DEBUG_LOG_LEVEL, "UI: ", NULL, -1, true, \ logmsg(DEBUG_LOG_LEVEL, "UI: ", NULL, -1, true, \
"%s (+%zu times...)", uilog_last_event, uilog_seen); \ "%s (+%zu times...)", uilog_last_event, uilog_seen); \
} \ } \
do_log(DEBUG_LOG_LEVEL, "UI: ", NULL, -1, true, STR(funname)); \ logmsg(DEBUG_LOG_LEVEL, "UI: ", NULL, -1, true, STR(funname)); \
uilog_seen = 0; \ uilog_seen = 0; \
xstrlcpy(uilog_last_event, STR(funname), sizeof(uilog_last_event)); \ xstrlcpy(uilog_last_event, STR(funname), sizeof(uilog_last_event)); \
} \ } \