diff options
author | Thiago de Arruda <tpadilha84@gmail.com> | 2014-10-23 22:19:18 -0300 |
---|---|---|
committer | Thiago de Arruda <tpadilha84@gmail.com> | 2014-10-23 22:19:18 -0300 |
commit | 65942d3a8d84510fcee2dd1c6306a5af13296c84 (patch) | |
tree | cbb3ce006567835f4ed64582cfa4c0181bd2d7bb /src/nvim/log.c | |
parent | d1e063a8af57661c37da31954346b2b9f73dd9b5 (diff) | |
parent | d696fa51f8a295942da8952d7f85c44b9afac67e (diff) | |
download | rneovim-65942d3a8d84510fcee2dd1c6306a5af13296c84.tar.gz rneovim-65942d3a8d84510fcee2dd1c6306a5af13296c84.tar.bz2 rneovim-65942d3a8d84510fcee2dd1c6306a5af13296c84.zip |
Merge PR #1331 'Fixes to job and channel modules'
Diffstat (limited to 'src/nvim/log.c')
-rw-r--r-- | src/nvim/log.c | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/src/nvim/log.c b/src/nvim/log.c index da28a18509..e8e0c9bbb9 100644 --- a/src/nvim/log.c +++ b/src/nvim/log.c @@ -20,7 +20,7 @@ # include "log.c.generated.h" #endif -bool do_log(int log_level, const char *func_name, int line_num, +bool do_log(int log_level, const char *func_name, int line_num, bool eol, const char* fmt, ...) FUNC_ATTR_UNUSED { FILE *log_file = open_log_file(); @@ -31,8 +31,8 @@ bool do_log(int log_level, const char *func_name, int line_num, va_list args; va_start(args, fmt); - bool ret = v_do_log_to_file(log_file, log_level, func_name, line_num, fmt, - args); + bool ret = v_do_log_to_file(log_file, log_level, func_name, line_num, eol, + fmt, args); va_end(args); if (log_file != stderr && log_file != stdout) { @@ -45,13 +45,13 @@ bool do_log(int log_level, const char *func_name, int line_num, /// /// @return The FILE* specified by the USR_LOG_FILE path or stderr in case of /// error -static FILE *open_log_file(void) +FILE *open_log_file(void) { static bool opening_log_file = false; // check if it's a recursive call if (opening_log_file) { - do_log_to_file(stderr, ERROR_LOG_LEVEL, __func__, __LINE__, + do_log_to_file(stderr, ERROR_LOG_LEVEL, __func__, __LINE__, true, "Trying to LOG() recursively! Please fix it."); return stderr; } @@ -81,7 +81,7 @@ static FILE *open_log_file(void) open_log_file_error: opening_log_file = false; - do_log_to_file(stderr, ERROR_LOG_LEVEL, __func__, __LINE__, + do_log_to_file(stderr, ERROR_LOG_LEVEL, __func__, __LINE__, true, "Couldn't open USR_LOG_FILE, logging to stderr! This may be " "caused by attempting to LOG() before initialization " "functions are called (e.g. init_homedir())."); @@ -89,20 +89,20 @@ open_log_file_error: } static bool do_log_to_file(FILE *log_file, int log_level, - const char *func_name, int line_num, + const char *func_name, int line_num, bool eol, const char* fmt, ...) { va_list args; va_start(args, fmt); - bool ret = v_do_log_to_file(log_file, log_level, func_name, line_num, fmt, - args); + bool ret = v_do_log_to_file(log_file, log_level, func_name, line_num, eol, + fmt, args); va_end(args); return ret; } static bool v_do_log_to_file(FILE *log_file, int log_level, - const char *func_name, int line_num, + const char *func_name, int line_num, bool eol, const char* fmt, va_list args) { static const char *log_levels[] = { @@ -133,7 +133,9 @@ static bool v_do_log_to_file(FILE *log_file, int log_level, if (vfprintf(log_file, fmt, args) < 0) { return false; } - fputc('\n', log_file); + if (eol) { + fputc('\n', log_file); + } if (fflush(log_file) == EOF) { return false; } |