@@ -21,7 +21,7 @@ local TABLE_TOSTRING_SEP_LEN = string.len(TABLE_TOSTRING_SEP)
21
21
22
22
-- Final function called in format_table() to format the resulting list of
23
23
-- string describing the table.
24
- local function _table_tostring_format_result (tbl , result , indentLevel , printTableRefs , isLogLine )
24
+ local function _table_tostring_format_result (tbl , result , indentLevel , printTableRefs )
25
25
local dispOnMultLines = false
26
26
27
27
-- set dispOnMultLines to true if the maximum LINE_LENGTH would be exceeded with the values
@@ -46,7 +46,7 @@ local function _table_tostring_format_result(tbl, result, indentLevel, printTabl
46
46
end
47
47
48
48
-- now reformat the result table (currently holding element strings)
49
- if dispOnMultLines and not isLogLine then
49
+ if dispOnMultLines then
50
50
local indentString = string.rep (" " , indentLevel - 1 )
51
51
result = {
52
52
" {\n " ,
@@ -77,7 +77,7 @@ function Formatter.mt:initialize(printTableRefs)
77
77
self .recursionTable = {}
78
78
end
79
79
80
- function Formatter .mt :format_table (tbl , indentLevel , isLogLine )
80
+ function Formatter .mt :format_table (tbl , indentLevel )
81
81
indentLevel = indentLevel or 1
82
82
self .recursionTable [tbl ] = true
83
83
@@ -133,16 +133,16 @@ function Formatter.mt:format_table(tbl, indentLevel, isLogLine)
133
133
count = count + 1
134
134
result [count ] = entry
135
135
end
136
- return _table_tostring_format_result (tbl , result , indentLevel , self .printTableRefs , isLogLine )
136
+ return _table_tostring_format_result (tbl , result , indentLevel , self .printTableRefs )
137
137
end
138
138
end
139
139
140
- function Formatter .mt :format (v , indentLevel , isLogLine )
140
+ function Formatter .mt :format (v , indentLevel )
141
141
local type_v = type (v )
142
142
if " string" == type_v then
143
143
return string.format (" %q" , v )
144
144
elseif " table" == type_v then
145
- return self :format_table (v , indentLevel , isLogLine )
145
+ return self :format_table (v , indentLevel )
146
146
elseif " number" == type_v then
147
147
-- eliminate differences in formatting between various Lua versions
148
148
if v ~= v then
@@ -169,24 +169,18 @@ end
169
169
--
170
170
-- * string are enclosed with " by default, or with ' if string contains a "
171
171
-- * tables are expanded to show their full content, with indentation in case of nested tables
172
- function pp .tostring (value , is_logline )
172
+ function pp .tostring (value )
173
173
local formatter = Formatter :new (pp .TABLE_REF_IN_ERROR_MSG )
174
- local result = formatter :format (value , nil , is_logline )
174
+ local result = formatter :format (value )
175
175
if formatter .recursionDetected and not pp .TABLE_REF_IN_ERROR_MSG then
176
176
-- some table contain recursive references,
177
177
-- so we must recompute the value by including all table references
178
178
-- else the result looks like crap
179
- return Formatter :new (true ):format (value , nil , is_logline )
179
+ return Formatter :new (true ):format (value )
180
180
end
181
181
return result
182
182
end
183
183
184
- -- This function helps with displaying `value` of any type without line breaks ('\n')
185
- -- for logging. It is a simple wrapper over the tostring() function.
186
- function pp .tostringlog (value )
187
- return pp .tostring (value , true )
188
- end
189
-
190
184
local function has_new_line (s )
191
185
return (string.find (s , ' \n ' , 1 , true ) ~= nil )
192
186
end
0 commit comments