Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
configuration
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
configuration
Commits
75503a29
Commit
75503a29
authored
Jul 22, 2016
by
Calen Pennington
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Extract the python logging into separate methods
parent
fab52f36
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
15 deletions
+20
-15
playbooks/callback_plugins/task_timing.py
+20
-15
No files found.
playbooks/callback_plugins/task_timing.py
View file @
75503a29
...
...
@@ -84,6 +84,24 @@ class CallbackModule(object):
except
Exception
as
ex
:
logger
.
error
(
ex
.
message
)
def
_logger_log_tasks
(
self
,
playbook_name
,
results
):
for
name
,
elapsed
in
results
[:
10
]:
logger
.
info
(
"{0:-<80}{1:->8}"
.
format
(
'{0} '
.
format
(
name
),
' {0:.02f}s'
.
format
(
elapsed
[
1
]),
)
)
def
_logger_log_play
(
self
,
playbook_name
,
duration
,
task_count
):
logger
.
info
(
"
\n
Playbook {0} finished: {1}, {2} total tasks. {3} elapsed.
\n
"
.
format
(
playbook_name
,
time
.
asctime
(),
task_count
,
datetime
.
timedelta
(
seconds
=
(
int
(
duration
)))
)
)
def
playbook_on_stats
(
self
,
stats
):
"""
Prints the timing of each task and total time to
...
...
@@ -106,18 +124,5 @@ class CallbackModule(object):
self
.
_datadog_log_play
(
self
.
playbook_name
,
total_seconds
)
# Log the time of each task
for
name
,
elapsed
in
results
[:
10
]:
logger
.
info
(
"{0:-<80}{1:->8}"
.
format
(
'{0} '
.
format
(
name
),
' {0:.02f}s'
.
format
(
elapsed
[
1
]),
)
)
logger
.
info
(
"
\n
Playbook {0} finished: {1}, {2} total tasks. {3} elapsed.
\n
"
.
format
(
self
.
playbook_name
,
time
.
asctime
(),
len
(
self
.
stats
.
items
()),
datetime
.
timedelta
(
seconds
=
(
int
(
total_seconds
)))
)
)
self
.
_logger_log_tasks
(
self
.
playbook_name
,
results
)
self
.
_logger_log_play
(
self
.
playbook_name
,
total_seconds
,
len
(
self
.
stats
))
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