Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Trevor Cappallo
OperationalLogging
Commits
dcd4d1ad
Commit
dcd4d1ad
authored
Sep 01, 2015
by
Trevor Cappallo
Browse files
replace braces in logging statements
parent
5294a255
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
6 deletions
+7
-6
lib/OperationalLogger.py
lib/OperationalLogger.py
+7
-6
No files found.
lib/OperationalLogger.py
View file @
dcd4d1ad
...
...
@@ -262,9 +262,10 @@ def setup(config_file=None, logger_name=None, log_filename=None, log_root_dir=No
# log_format_console=log_format_console, date_format_console=date_format_console
# )
logger
=
OperationalLogger
(
**
config
)
logging
.
info
(
'Logging output from: {}'
.
format
(
' '
.
join
(
sys
.
argv
)))
logging
.
info
(
'='
*
60
)
logging
.
info
(
'Logging output from: %s'
,
' '
.
join
(
sys
.
argv
))
logging
.
info
(
'Log writing to: %s'
,
config
[
'log_filename'
])
logging
.
info
(
'Process id
{}
, parent process id
{}'
.
format
(
os
.
getpid
(),
os
.
getppid
())
)
logging
.
debug
(
'Process id
%d
, parent process id
%d'
,
os
.
getpid
(),
os
.
getppid
())
logging
.
info
(
'-'
*
60
)
#if notify:
atexit
.
register
(
__exit_handler
,
logger
,
config
[
'notify'
])
...
...
@@ -313,8 +314,8 @@ def log_shell(arg_list, raise_err=False, return_output=False, **kwargs):
return_output: (like subprocess.check_output) returns any output
from shell call instead of the exit code
"""
logging
.
info
(
'Spawning child process from pid=
{}'
.
format
(
os
.
getpid
())
)
logging
.
info
(
'Executing:
{}'
.
format
(
' '
.
join
(
arg_list
))
)
logging
.
info
(
'Spawning child process from pid=
%d'
,
os
.
getpid
())
logging
.
info
(
'Executing:
%s'
,
' '
.
join
(
arg_list
))
try
:
my_name
=
os
.
path
.
basename
(
inspect
.
getfile
(
inspect
.
currentframe
()))
for
f
in
inspect
.
stack
():
...
...
@@ -332,10 +333,10 @@ def log_shell(arg_list, raise_err=False, return_output=False, **kwargs):
return_code
=
proc
.
wait
()
if
return_code
:
if
raise_err
:
logging
.
error
(
'
{}
failed with exit code
{}'
.
format
(
' '
.
join
(
arg_list
),
return_code
)
)
logging
.
error
(
'
%s
failed with exit code
%d'
,
' '
.
join
(
arg_list
),
return_code
)
raise
RuntimeError
(
'{} failed with exit code {}'
.
format
(
' '
.
join
(
arg_list
),
return_code
))
else
:
logging
.
warning
(
'
{}
failed with exit code
{}'
.
format
(
' '
.
join
(
arg_list
),
return_code
)
)
logging
.
warning
(
'
%s
failed with exit code
%d'
,
' '
.
join
(
arg_list
),
return_code
)
return
proc_output
if
return_output
else
return_code
except
OSError
as
err
:
logging
.
error
(
'Error while executing %s: %s'
,
' '
.
join
(
arg_list
),
str
(
err
))
...
...
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