Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Benoit Rousselle
bliss
Commits
661d4387
Commit
661d4387
authored
May 17, 2019
by
Piergiorgio Pancino
Browse files
add shared logging initialization function
parent
bae08967
Changes
3
Hide whitespace changes
Inline
Side-by-side
bliss/common/logtools.py
View file @
661d4387
...
...
@@ -17,6 +17,17 @@ from bliss.common.mapping import _BEAMLINE_MAP, BEAMLINE_GRAPH, format_node
__all__
=
[
"log"
,
"lslog"
,
"lsdebug"
]
def
logging_startup
(
log_level
=
logging
.
DEBUG
,
fmt
=
"%(levelname)s %(asctime)-15s %(name)s: %(message)s"
):
"""
Provides basicConfig functionality to bliss activating at proper level the root loggers
"""
logging
.
basicConfig
(
level
=
log_level
,
format
=
fmt
)
logging
.
getLogger
(
"bliss"
).
setLevel
(
log_level
)
logging
.
getLogger
(
"beamline"
).
setLevel
(
log_level
)
class
LogMixin
:
@
autocomplete_property
def
_logger
(
self
,
*
args
,
**
kwargs
):
...
...
bliss/shell/cli/main.py
View file @
661d4387
...
...
@@ -35,11 +35,13 @@ import os
import
sys
import
subprocess
from
docopt
import
docopt
,
DocoptExit
import
logging
from
bliss
import
release
from
bliss.config
import
static
from
bliss.config.static
import
Node
from
bliss.config.conductor
import
client
from
bliss.common.logtools
import
logging_startup
from
.repl
import
embed
from
.
import
session_files_templates
as
sft
...
...
@@ -171,6 +173,10 @@ def main():
print
(
""
)
arguments
=
docopt
(
__doc__
)
# initialize logging
log_level
=
getattr
(
logging
,
arguments
[
"--log-level"
][
0
].
upper
())
logging_startup
(
log_level
)
# Print version
if
arguments
[
"--version"
]:
print
((
"BLISS version %s"
%
release
.
short_version
))
...
...
bliss/shell/cli/start_bliss_repl.py
View file @
661d4387
...
...
@@ -8,19 +8,16 @@
import
sys
from
bliss.shell.cli.repl
import
embed
from
bliss.common.logtools
import
logging_startup
import
logging
fmt
=
"%(levelname)s %(asctime)-15s %(name)s: %(message)s"
def
main
():
session_name
=
sys
.
argv
[
1
]
log_level
=
getattr
(
logging
,
sys
.
argv
[
2
].
upper
())
# activate logging for module-level and session-level loggers
logging
.
basicConfig
(
format
=
fmt
)
logging
.
getLogger
(
"bliss"
).
setLevel
(
log_level
)
logging
.
getLogger
(
"beamline"
).
setLevel
(
log_level
)
# initialize logging
log_level
=
getattr
(
logging
,
sys
.
argv
[
2
].
upper
())
logging_startup
(
log_level
)
embed
(
session_name
=
session_name
,
use_tmux
=
True
)
...
...
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