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
f85f4775
Commit
f85f4775
authored
Sep 01, 2015
by
Trevor Cappallo
Browse files
fix bug where critical logs not being sent to debug address
parent
2984a6d4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
2 deletions
+7
-2
lib/OperationalLogger.py
lib/OperationalLogger.py
+6
-1
lib/TestZExit.py
lib/TestZExit.py
+1
-1
No files found.
lib/OperationalLogger.py
View file @
f85f4775
...
...
@@ -24,6 +24,8 @@ def __exit_handler(logger, notify):
for
level
in
'DEBUG'
,
'ERROR'
,
'CRITICAL'
:
if
level
not
in
notify
:
notify
[
level
]
=
[]
elif
type
(
notify
[
level
])
is
str
:
notify
[
level
]
=
[
notify
[
level
]]
# add the last uncaught exception that has occurred as an error, if present
try
:
...
...
@@ -35,15 +37,18 @@ def __exit_handler(logger, notify):
if
logger
.
has_errors
():
addresses
=
notify
[
'ERROR'
]
print
"before addresses:"
,
addresses
if
notify
[
'DEBUG'
]:
addresses
.
extend
(
notify
[
'DEBUG'
])
if
logger
.
has_critical
():
if
logger
.
has_critical
()
and
notify
[
'CRITICAL'
]
:
addresses
=
addresses
.
extend
(
notify
[
'CRITICAL'
])
if
not
addresses
:
logging
.
warning
(
'There were errors, but no recipients specified. No email sent.'
)
else
:
addresses
=
list
(
set
(
addresses
))
logger
.
email_log
(
addresses
)
print
"after addresses"
,
addresses
print
"notify ="
,
notify
elif
notify
[
'DEBUG'
]:
addresses
=
list
(
set
(
notify
[
'DEBUG'
]))
logger
.
email_log
(
addresses
,
level
=
logging
.
DEBUG
)
...
...
lib/TestZExit.py
View file @
f85f4775
...
...
@@ -42,7 +42,7 @@ class TestExit(unittest.TestCase):
temp_buffer
=
logging
.
StreamHandler
(
s
)
h
=
logging
.
getLogger
().
addHandler
(
temp_buffer
)
atexit
.
_run_exitfuncs
()
assert
"
No recipients found. Email not
sent"
in
s
.
getvalue
()
assert
"
no email
sent"
in
s
.
getvalue
()
.
lower
()
logging
.
getLogger
().
removeHandler
(
h
)
...
...
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