Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
3dc78d19
Commit
3dc78d19
authored
Sep 21, 2018
by
Johnny Lim
Committed by
Stephane Nicoll
Sep 22, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add log messages to lines only when the destination isn't set
Closes gh-14565
parent
0a310256
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
1 deletion
+19
-1
DeferredLog.java
...in/java/org/springframework/boot/logging/DeferredLog.java
+3
-1
DeferredLogTests.java
...va/org/springframework/boot/logging/DeferredLogTests.java
+16
-0
No files found.
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/DeferredLog.java
View file @
3dc78d19
...
@@ -142,7 +142,9 @@ public class DeferredLog implements Log {
...
@@ -142,7 +142,9 @@ public class DeferredLog implements Log {
if
(
this
.
destination
!=
null
)
{
if
(
this
.
destination
!=
null
)
{
logTo
(
this
.
destination
,
level
,
message
,
t
);
logTo
(
this
.
destination
,
level
,
message
,
t
);
}
}
this
.
lines
.
add
(
new
Line
(
level
,
message
,
t
));
else
{
this
.
lines
.
add
(
new
Line
(
level
,
message
,
t
));
}
}
}
}
}
...
...
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/DeferredLogTests.java
View file @
3dc78d19
...
@@ -16,9 +16,13 @@
...
@@ -16,9 +16,13 @@
package
org
.
springframework
.
boot
.
logging
;
package
org
.
springframework
.
boot
.
logging
;
import
java.util.List
;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.Log
;
import
org.junit.Test
;
import
org.junit.Test
;
import
org.springframework.beans.DirectFieldAccessor
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
import
static
org
.
mockito
.
Mockito
.
mock
;
import
static
org
.
mockito
.
Mockito
.
mock
;
import
static
org
.
mockito
.
Mockito
.
verify
;
import
static
org
.
mockito
.
Mockito
.
verify
;
...
@@ -169,9 +173,21 @@ public class DeferredLogTests {
...
@@ -169,9 +173,21 @@ public class DeferredLogTests {
@Test
@Test
public
void
switchTo
()
{
public
void
switchTo
()
{
DirectFieldAccessor
deferredLogFieldAccessor
=
new
DirectFieldAccessor
(
this
.
deferredLog
);
List
<
String
>
lines
=
(
List
<
String
>)
deferredLogFieldAccessor
.
getPropertyValue
(
"lines"
);
assertThat
(
lines
).
isEmpty
();
this
.
deferredLog
.
error
(
this
.
message
,
this
.
throwable
);
this
.
deferredLog
.
error
(
this
.
message
,
this
.
throwable
);
assertThat
(
lines
).
hasSize
(
1
);
this
.
deferredLog
.
switchTo
(
this
.
log
);
this
.
deferredLog
.
switchTo
(
this
.
log
);
assertThat
(
lines
).
isEmpty
();
this
.
deferredLog
.
info
(
"Message2"
);
this
.
deferredLog
.
info
(
"Message2"
);
assertThat
(
lines
).
isEmpty
();
verify
(
this
.
log
).
error
(
this
.
message
,
this
.
throwable
);
verify
(
this
.
log
).
error
(
this
.
message
,
this
.
throwable
);
verify
(
this
.
log
).
info
(
"Message2"
,
null
);
verify
(
this
.
log
).
info
(
"Message2"
,
null
);
}
}
...
...
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