Skip to content
GitLab
Menu
Why GitLab
Pricing
Contact Sales
Explore
Why GitLab
Pricing
Contact Sales
Explore
Sign in
Get free trial
Changes
Page history
Update Rust
authored
Nov 07, 2023
by
Miki, Hiromitsu
Show whitespace changes
Inline
Side-by-side
Rust.md
View page @
006ea3d9
...
...
@@ -98,6 +98,7 @@ strip = true
#[macro_use]
extern
crate
log
;
use
chrono
::{
DateTime
,
Local
};
use
env_logger
::{
fmt
::
Color
,
Env
};
use
log
::
Level
;
use
std
::
io
::
Write
;
...
...
@@ -114,12 +115,17 @@ fn main() {
Level
::
Warn
=>
Color
::
Yellow
,
Level
::
Error
=>
Color
::
Red
,
});
let
timestamp
=
DateTime
::
parse_from_rfc3339
(
buf
.timestamp_millis
()
.to_string
()
.as_str
())
.unwrap
()
.with_timezone
(
&
Local
)
.format
(
"%Y/%m/%d %H:%M:%S.%3f"
)
.to_string
();
return
match
record
.level
()
{
Level
::
Trace
|
Level
::
Debug
|
Level
::
Info
=>
writeln!
(
buf
,
"{} {:.<5} {}: {}"
,
chrono
::
Local
::
now
()
.format
(
"%Y/%m/%d %H:%M:%S"
)
,
timestamp
,
level_style
.value
(
record
.level
()),
record
.target
(),
record
.args
()
...
...
@@ -127,7 +133,7 @@ fn main() {
Level
::
Error
|
Level
::
Warn
=>
writeln!
(
buf
,
"{} {:.<5} {}: {} ({}:{})"
,
chrono
::
Local
::
now
()
.format
(
"%Y/%m/%d %H:%M:%S"
)
,
timestamp
,
level_style
.value
(
record
.level
()),
record
.target
(),
record
.args
(),
...
...
...
...