Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
OpenDAS
nni
Commits
862c67df
Unverified
Commit
862c67df
authored
Aug 25, 2021
by
Junwei Sun
Committed by
GitHub
Aug 25, 2021
Browse files
hotfix: fix time format issue (#4108)
parent
a6069165
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
4 deletions
+6
-4
ts/nni_manager/common/log.ts
ts/nni_manager/common/log.ts
+6
-4
No files found.
ts/nni_manager/common/log.ts
View file @
862c67df
...
@@ -75,15 +75,17 @@ export class Logger {
...
@@ -75,15 +75,17 @@ export class Logger {
return
;
return
;
}
}
// `time.toLocaleString('sv')` trick does not work for Windows
const
zeroPad
=
(
num
:
number
):
string
=>
num
.
toString
().
padStart
(
2
,
'
0
'
);
const
isoTime
=
new
Date
(
new
Date
().
toLocaleString
()
+
'
UTC
'
).
toISOString
();
const
now
=
new
Date
();
const
time
=
isoTime
.
slice
(
0
,
10
)
+
'
'
+
isoTime
.
slice
(
11
,
19
);
const
date
=
now
.
getFullYear
()
+
'
-
'
+
zeroPad
(
now
.
getMonth
()
+
1
)
+
'
-
'
+
zeroPad
(
now
.
getDate
());
const
time
=
zeroPad
(
now
.
getHours
())
+
'
:
'
+
zeroPad
(
now
.
getMinutes
())
+
'
:
'
+
zeroPad
(
now
.
getSeconds
());
const
datetime
=
date
+
'
'
+
time
;
const
levelName
=
levelNames
.
has
(
level
)
?
levelNames
.
get
(
level
)
:
level
.
toString
();
const
levelName
=
levelNames
.
has
(
level
)
?
levelNames
.
get
(
level
)
:
level
.
toString
();
const
message
=
args
.
map
(
arg
=>
(
typeof
arg
===
'
string
'
?
arg
:
util
.
inspect
(
arg
))).
join
(
'
'
);
const
message
=
args
.
map
(
arg
=>
(
typeof
arg
===
'
string
'
?
arg
:
util
.
inspect
(
arg
))).
join
(
'
'
);
const
record
=
`[
${
time
}
]
${
levelName
}
(
${
this
.
name
}
)
${
message
}
\n`
;
const
record
=
`[
${
date
time
}
]
${
levelName
}
(
${
this
.
name
}
)
${
message
}
\n`
;
if
(
logFile
===
undefined
)
{
if
(
logFile
===
undefined
)
{
console
.
log
(
record
);
console
.
log
(
record
);
...
...
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