Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
forks
lager
Commits
d416dc0a
Commit
d416dc0a
authored
12 years ago
by
Andrew Thompson
Browse files
Options
Download
Email Patches
Plain Diff
Fix escaped char printing in ~p mode, reported by @etrepum
parent
7815a88c
master
1.2
2.x
basho/fix-async_threshold_test
basho/separate-test-directory
borshop-integration-312-close-file-after-timebased-rotation
borshop-integration-334-issue-332
borshop-integration-335-issue-329
borshop-integration-339-gh334-2x
bugfix/improper-io-list-support
bugfix_jrd_watcher-test
develop-2.2
enable_thumbs
end-to-end/timeseries
feature/rebar3
feature/riak-2903/rebar3
fix_18_tests
fix_otp15_undef
gh286
gh287
gh291
gh334-2x
gh337-2x
killer_poll
mra/gh315
r19-jrd-typed_records
rebar3
upstream-master
3.9.2
3.9.1
3.9.0
3.8.2
3.8.1
3.8.0
3.7.0
3.6.10
3.6.9
3.6.8
3.6.7
3.6.6
3.6.5
3.6.4
3.6.3
3.6.2
3.6.1
3.6.0
3.5.2
3.5.1
3.5.0
3.4.2
3.4.1
3.4.0
3.3.0
3.2.4
3.2.3
3.2.2
3.2.1
3.2.0
3.1.0
3.0.3
3.0.2
3.0.1
3.0.0
3.0.0-RC2
3.0.0-RC1
2.2.3
2.2.2
2.2.1
2.2.0
2.1.1
2.1.0
2.0.3
2.0.2
2.0.1
2.0.0
2.0.0rc2
2.0.0rc1
1.2.2
1.2.1
1.2.0
oktell/3.2.4
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/lager_trunc_io.erl
+23
-6
src/lager_trunc_io.erl
with
23 additions
and
6 deletions
+23
-6
src/lager_trunc_io.erl
View file @
d416dc0a
...
@@ -62,7 +62,7 @@ format(Fmt, Args, Max) ->
...
@@ -62,7 +62,7 @@ format(Fmt, Args, Max) ->
format
(
Fmt
,
Args
,
Max
,
Options
)
->
format
(
Fmt
,
Args
,
Max
,
Options
)
->
try
lager_format
:
format
(
Fmt
,
Args
,
Max
,
Options
)
try
lager_format
:
format
(
Fmt
,
Args
,
Max
,
Options
)
catch
catch
_
:_
->
_
What
:_
Why
->
erlang
:
error
(
badarg
,
[
Fmt
,
Args
])
erlang
:
error
(
badarg
,
[
Fmt
,
Args
])
end
.
end
.
...
@@ -282,7 +282,7 @@ alist_start([H|T], Max, Options) when is_integer(H), H >= 16#20, H =< 16#7e ->
...
@@ -282,7 +282,7 @@ alist_start([H|T], Max, Options) when is_integer(H), H >= 16#20, H =< 16#7e ->
{
R
,
Len
}
=
list_body
([
H
|
T
],
Max
-
2
,
Options
,
false
),
{
R
,
Len
}
=
list_body
([
H
|
T
],
Max
-
2
,
Options
,
false
),
{[
$[
,
R
,
$]
],
Len
+
2
}
{[
$[
,
R
,
$]
],
Len
+
2
}
end
;
end
;
alist_start
([
H
|
T
],
Max
,
Options
)
when
H
=:=
9
;
H
=:=
10
;
H
=:=
13
->
alist_start
([
H
|
T
],
Max
,
Options
)
when
H
=:=
$\t
;
H
=:=
$\n
;
H
=:=
$\r
;
H
=:=
$\v
;
H
=:=
$\e
;
H
=:=
$\f
;
H
=:=
$\b
->
try
alist
([
H
|
T
],
Max
-
1
,
Options
)
of
try
alist
([
H
|
T
],
Max
-
1
,
Options
)
of
{
L
,
Len
}
->
{
L
,
Len
}
->
{[
$"
|
L
],
Len
+
1
}
{[
$"
|
L
],
Len
+
1
}
...
@@ -299,10 +299,14 @@ alist([], _Max, #print_options{force_strings=true}) -> {"", 0};
...
@@ -299,10 +299,14 @@ alist([], _Max, #print_options{force_strings=true}) -> {"", 0};
alist
([],
_
Max
,
_
Options
)
->
{
"
\"
"
,
1
};
alist
([],
_
Max
,
_
Options
)
->
{
"
\"
"
,
1
};
alist
(_,
Max
,
#print_options
{
force_strings
=
true
})
when
Max
<
4
->
{
"..."
,
3
};
alist
(_,
Max
,
#print_options
{
force_strings
=
true
})
when
Max
<
4
->
{
"..."
,
3
};
alist
(_,
Max
,
#print_options
{
force_strings
=
false
})
when
Max
<
5
->
{
"...
\"
"
,
4
};
alist
(_,
Max
,
#print_options
{
force_strings
=
false
})
when
Max
<
5
->
{
"...
\"
"
,
4
};
alist
([
H
|
T
],
Max
,
Options
=
#print_options
{
force_strings
=
false
,
lists_as_strings
=
true
})
when
H
=:=
$"
;
H
=:=
$\\
->
%% preserve escaping around quotes
{
L
,
Len
}
=
alist
(
T
,
Max
-
1
,
Options
),
{[
$\\
,
H
|
L
],
Len
+
2
};
alist
([
H
|
T
],
Max
,
Options
)
when
is_integer
(
H
),
H
>=
16#20
,
H
=<
16#7e
->
% definitely printable
alist
([
H
|
T
],
Max
,
Options
)
when
is_integer
(
H
),
H
>=
16#20
,
H
=<
16#7e
->
% definitely printable
{
L
,
Len
}
=
alist
(
T
,
Max
-
1
,
Options
),
{
L
,
Len
}
=
alist
(
T
,
Max
-
1
,
Options
),
{[
H
|
L
],
Len
+
1
};
{[
H
|
L
],
Len
+
1
};
alist
([
H
|
T
],
Max
,
Options
)
when
H
=:=
9
;
H
=:=
10
;
H
=:=
13
->
alist
([
H
|
T
],
Max
,
Options
)
when
H
=:=
$\t
;
H
=:=
$\n
;
H
=:=
$\r
;
H
=:=
$\v
;
H
=:=
$\e
;
H
=:=
$\f
;
H
=:=
$\b
->
{
L
,
Len
}
=
alist
(
T
,
Max
-
1
,
Options
),
{
L
,
Len
}
=
alist
(
T
,
Max
-
1
,
Options
),
case
Options
#print_options.force_strings
of
case
Options
#print_options.force_strings
of
true
->
true
->
...
@@ -349,9 +353,12 @@ dec_depth(#print_options{depth=Depth} = Options) when Depth > 0 ->
...
@@ -349,9 +353,12 @@ dec_depth(#print_options{depth=Depth} = Options) when Depth > 0 ->
dec_depth
(
Options
)
->
dec_depth
(
Options
)
->
Options
.
Options
.
escape
(
9
)
->
"
\\
t"
;
escape
(
$\t
)
->
"
\\
t"
;
escape
(
10
)
->
"
\\
n"
;
escape
(
$\n
)
->
"
\\
n"
;
escape
(
13
)
->
"
\\
r"
.
escape
(
$\r
)
->
"
\\
r"
;
escape
(
$\e
)
->
"
\\
e"
;
escape
(
$\f
)
->
"
\\
f"
;
escape
(
$\b
)
->
"
\\
b"
.
-
ifdef
(
TEST
).
-
ifdef
(
TEST
).
%%--------------------
%%--------------------
...
@@ -470,6 +477,16 @@ binary_printing_test() ->
...
@@ -470,6 +477,16 @@ binary_printing_test() ->
?
assertEqual
(
"hello"
,
lists
:
flatten
(
format
(
"
~s
"
,
[
<<
"hello"
>>
],
50
))),
?
assertEqual
(
"hello"
,
lists
:
flatten
(
format
(
"
~s
"
,
[
<<
"hello"
>>
],
50
))),
?
assertEqual
(
"hello
\n
world"
,
lists
:
flatten
(
format
(
"
~s
"
,
[
<<
"hello
\n
world"
>>
],
50
))),
?
assertEqual
(
"hello
\n
world"
,
lists
:
flatten
(
format
(
"
~s
"
,
[
<<
"hello
\n
world"
>>
],
50
))),
?
assertEqual
(
"<<
\"
hello
\\
nworld
\"
>>"
,
lists
:
flatten
(
format
(
"
~p
"
,
[
<<
"hello
\n
world"
>>
],
50
))),
?
assertEqual
(
"<<
\"
hello
\\
nworld
\"
>>"
,
lists
:
flatten
(
format
(
"
~p
"
,
[
<<
"hello
\n
world"
>>
],
50
))),
?
assertEqual
(
"<<
\"\\\"
hello world
\\\"\"
>>"
,
lists
:
flatten
(
format
(
"
~p
"
,
[
<<
"
\"
hello world
\"
"
>>
],
50
))),
?
assertEqual
(
"<<
\"
hello
\\\\
world
\"
>>"
,
lists
:
flatten
(
format
(
"
~p
"
,
[
<<
"hello
\\
world"
>>
],
50
))),
?
assertEqual
(
"<<
\"
hello
\\\\
\
world
\"
>>"
,
lists
:
flatten
(
format
(
"
~p
"
,
[
<<
"hello
\\
\
world"
>>
],
50
))),
?
assertEqual
(
"<<
\"
hello
\\\\\\\\
world
\"
>>"
,
lists
:
flatten
(
format
(
"
~p
"
,
[
<<
"hello
\\\\
world"
>>
],
50
))),
?
assertEqual
(
"<<
\"
hello
\\
bworld
\"
>>"
,
lists
:
flatten
(
format
(
"
~p
"
,
[
<<
"hello
\b
world"
>>
],
50
))),
?
assertEqual
(
"<<
\"
hello
\\
tworld
\"
>>"
,
lists
:
flatten
(
format
(
"
~p
"
,
[
<<
"hello
\t
world"
>>
],
50
))),
?
assertEqual
(
"<<
\"
hello
\\
nworld
\"
>>"
,
lists
:
flatten
(
format
(
"
~p
"
,
[
<<
"hello
\n
world"
>>
],
50
))),
?
assertEqual
(
"<<
\"
hello
\\
rworld
\"
>>"
,
lists
:
flatten
(
format
(
"
~p
"
,
[
<<
"hello
\r
world"
>>
],
50
))),
?
assertEqual
(
"<<
\"
hello
\\
eworld
\"
>>"
,
lists
:
flatten
(
format
(
"
~p
"
,
[
<<
"hello
\e
world"
>>
],
50
))),
?
assertEqual
(
"<<
\"
hello
\\
fworld
\"
>>"
,
lists
:
flatten
(
format
(
"
~p
"
,
[
<<
"hello
\f
world"
>>
],
50
))),
?
assertEqual
(
" hello"
,
lists
:
flatten
(
format
(
"
~10s
"
,
[
<<
"hello"
>>
],
50
))),
?
assertEqual
(
" hello"
,
lists
:
flatten
(
format
(
"
~10s
"
,
[
<<
"hello"
>>
],
50
))),
ok
.
ok
.
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help