Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
csst-dfs
csst-dfs-commons
Commits
9c8446ef
Commit
9c8446ef
authored
Nov 18, 2022
by
Wei Shoulin
Browse files
add default dir
parent
098455c6
Changes
1
Hide whitespace changes
Inline
Side-by-side
csst_dfs_commons/logging/setup.py
View file @
9c8446ef
...
...
@@ -6,6 +6,8 @@
# This file is part of CSST.
# coding: utf-8
import
os
import
path
import
logging
import
logging.handlers
...
...
@@ -23,8 +25,12 @@ def setup_logging():
ch
.
setLevel
(
logging
.
INFO
)
ch
.
setFormatter
(
cfmt
)
logs_dir
=
os
.
getenv
(
"CSST_DFS_LOGS_DIR"
,
"logs"
)
if
not
os
.
path
.
exists
(
logs_dir
):
os
.
makedirs
(
logs_dir
)
# File handler
fh
=
logging
.
handlers
.
RotatingFileHandler
(
'logs/csst
.log'
,
fh
=
logging
.
handlers
.
RotatingFileHandler
(
os
.
path
.
join
(
logs_dir
,
'csst_dfs
.log'
)
,
maxBytes
=
10
*
1024
*
1024
,
backupCount
=
10
)
fh
.
setLevel
(
logging
.
INFO
)
fh
.
setFormatter
(
ffmt
)
...
...
@@ -57,8 +63,12 @@ def setup_test_logging():
ch
.
setLevel
(
logging
.
WARN
)
ch
.
setFormatter
(
cfmt
)
logs_dir
=
os
.
getenv
(
"CSST_DFS_LOGS_DIR"
,
"logs"
)
if
not
os
.
path
.
exists
(
logs_dir
):
os
.
makedirs
(
logs_dir
)
# Outputs DEBUG level logging to file
fh
=
logging
.
FileHandler
(
'logs/csst-
test.log'
)
fh
=
logging
.
FileHandler
(
os
.
path
.
join
(
logs_dir
,
'csst_dfs_
test.log'
)
,
fh
.
setLevel
(
logging
.
DEBUG
)
fh
.
setFormatter
(
ffmt
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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