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
39c1e47e
Commit
39c1e47e
authored
Sep 19, 2019
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use 3 decimal places at most for logged startup time
Fixes gh-18278
parent
7d3e53c9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
2 deletions
+17
-2
StartupInfoLogger.java
...main/java/org/springframework/boot/StartupInfoLogger.java
+1
-1
StartupInfoLoggerTests.java
...java/org/springframework/boot/StartupInfoLoggerTests.java
+16
-1
No files found.
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/StartupInfoLogger.java
View file @
39c1e47e
...
@@ -87,7 +87,7 @@ class StartupInfoLogger {
...
@@ -87,7 +87,7 @@ class StartupInfoLogger {
message
.
append
(
"Started "
);
message
.
append
(
"Started "
);
appendApplicationName
(
message
);
appendApplicationName
(
message
);
message
.
append
(
" in "
);
message
.
append
(
" in "
);
message
.
append
(
stopWatch
.
getTotalTime
Seconds
()
);
message
.
append
(
stopWatch
.
getTotalTime
Millis
()
/
1000.0
);
message
.
append
(
" seconds"
);
message
.
append
(
" seconds"
);
try
{
try
{
double
uptime
=
ManagementFactory
.
getRuntimeMXBean
().
getUptime
()
/
1000.0
;
double
uptime
=
ManagementFactory
.
getRuntimeMXBean
().
getUptime
()
/
1000.0
;
...
...
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/Start
Up
LoggerTests.java
→
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/Start
upInfo
LoggerTests.java
View file @
39c1e47e
...
@@ -20,6 +20,8 @@ import org.apache.commons.logging.Log;
...
@@ -20,6 +20,8 @@ import org.apache.commons.logging.Log;
import
org.junit.jupiter.api.Test
;
import
org.junit.jupiter.api.Test
;
import
org.mockito.ArgumentCaptor
;
import
org.mockito.ArgumentCaptor
;
import
org.springframework.util.StopWatch
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
import
static
org
.
mockito
.
BDDMockito
.
given
;
import
static
org
.
mockito
.
BDDMockito
.
given
;
import
static
org
.
mockito
.
Mockito
.
mock
;
import
static
org
.
mockito
.
Mockito
.
mock
;
...
@@ -31,7 +33,7 @@ import static org.mockito.Mockito.verify;
...
@@ -31,7 +33,7 @@ import static org.mockito.Mockito.verify;
* @author Dave Syer
* @author Dave Syer
* @author Andy Wilkinson
* @author Andy Wilkinson
*/
*/
class
Start
Up
LoggerTests
{
class
Start
upInfo
LoggerTests
{
private
final
Log
log
=
mock
(
Log
.
class
);
private
final
Log
log
=
mock
(
Log
.
class
);
...
@@ -44,4 +46,17 @@ class StartUpLoggerTests {
...
@@ -44,4 +46,17 @@ class StartUpLoggerTests {
assertThat
(
captor
.
getValue
().
toString
()).
startsWith
(
"Starting "
+
getClass
().
getSimpleName
());
assertThat
(
captor
.
getValue
().
toString
()).
startsWith
(
"Starting "
+
getClass
().
getSimpleName
());
}
}
@Test
void
startedFormat
()
{
StopWatch
stopWatch
=
new
StopWatch
();
stopWatch
.
start
();
given
(
this
.
log
.
isInfoEnabled
()).
willReturn
(
true
);
stopWatch
.
stop
();
new
StartupInfoLogger
(
getClass
()).
logStarted
(
this
.
log
,
stopWatch
);
ArgumentCaptor
<
Object
>
captor
=
ArgumentCaptor
.
forClass
(
Object
.
class
);
verify
(
this
.
log
).
info
(
captor
.
capture
());
assertThat
(
captor
.
getValue
().
toString
()).
matches
(
"Started "
+
getClass
().
getSimpleName
()
+
" in \\d+\\.\\d{1,3} seconds \\(JVM running for \\d+\\.\\d{1,3}\\)"
);
}
}
}
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