-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1335 from spidernet-io/enhance-e2e-for-restart-ap…
…iserver enhance e2e for restart api-server case
- Loading branch information
Showing
7 changed files
with
124 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// Copyright 2022 Authors of spidernet-io | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package common | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
"time" | ||
) | ||
|
||
type Logger struct { | ||
logs []string | ||
startTime time.Time | ||
endTime time.Time | ||
} | ||
|
||
func NewLogger() *Logger { | ||
return &Logger{ | ||
startTime: time.Now(), | ||
} | ||
} | ||
|
||
func (l *Logger) Log(message string) { | ||
l.logs = append(l.logs, message) | ||
} | ||
|
||
func (l *Logger) Save() string { | ||
endTime := time.Now() | ||
duration := endTime.Sub(l.startTime) | ||
|
||
var sb strings.Builder | ||
|
||
// Append all log entries | ||
for _, log := range l.logs { | ||
sb.WriteString(log) | ||
sb.WriteString("\n") | ||
} | ||
|
||
// Append the total time spent in seconds | ||
sb.WriteString(fmt.Sprintf("Total duration: %.2f seconds\n", duration.Seconds())) | ||
|
||
return sb.String() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters