Skip to content
Snippets Groups Projects
Commit 05b3179b authored by Eugine Blikh's avatar Eugine Blikh Committed by Konstantin Osipov
Browse files

Multiple logging improvements

* JSON logging fails to encode functions/cdata/udata, it now uses tostring to
  encode some objects

closes gh-2899
closes gh-2900
parent 10e11e9b
No related branches found
No related tags found
No related merge requests found
......@@ -131,7 +131,8 @@ BuildClientError(const char *file, unsigned line, uint32_t errcode, ...)
void
ClientError::log() const
{
_say(S_ERROR, file, line, errmsg, "%s", tnt_errcode_str(m_errcode));
say_file_line(S_ERROR, file, line, errmsg, "%s",
tnt_errcode_str(m_errcode));
}
......
......@@ -126,7 +126,7 @@ Exception::Exception(const struct type_info *type_arg, const char *file,
void
Exception::log() const
{
_say(S_ERROR, file, line, errmsg, "%s", type->name);
say_file_line(S_ERROR, file, line, errmsg, "%s", type->name);
}
static const struct method_info systemerror_methods[] = {
......@@ -159,8 +159,8 @@ SystemError::SystemError(const char *file, unsigned line,
void
SystemError::log() const
{
_say(S_SYSERROR, file, line, strerror(m_errno), "SystemError %s",
errmsg);
say_file_line(S_SYSERROR, file, line, strerror(m_errno),
"SystemError %s", errmsg);
}
const struct type_info type_OutOfMemory =
......
......@@ -39,7 +39,13 @@ local S_VERBOSE = ffi.C.S_VERBOSE
local S_DEBUG = ffi.C.S_DEBUG
local S_ERROR = ffi.C.S_ERROR
local json = require("json")
local json = require("json").new()
json.cfg{
encode_invalid_numbers = true,
encode_load_metatables = true,
encode_use_tostring = true,
encode_invalid_as_nil = true,
}
local special_fields = {
"file",
......
......@@ -123,14 +123,28 @@ CFORMAT(printf, 5, 0) extern sayfunc_t _say;
* Format and print a message to Tarantool log file.
*
* \param level (int) - log level (see enum \link say_level \endlink)
* \param file (const char * ) - file name to print
* \param line (int) - line number to print
* \param format (const char * ) - printf()-like format string
* \param ... - format arguments
* \sa printf()
* \sa enum say_level
*/
#define say(level, format, ...) ({ \
#define say_file_line(level, file, line, format, ...) ({ \
if (say_log_level_is_enabled(level)) \
_say(level, __FILE__, __LINE__, format, ##__VA_ARGS__); })
_say(level, file, line, format, ##__VA_ARGS__); })
/**
* Format and print a message to Tarantool log file.
*
* \param level (int) - log level (see enum \link say_level \endlink)
* \param format (const char * ) - printf()-like format string
* \param ... - format arguments
* \sa printf()
* \sa enum say_level
*/
#define say(level, format, ...) ({ \
say_file_line(level, __FILE__, __LINE__, format, ##__VA_ARGS__); })
/**
* Format and print a message to Tarantool log file.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment