Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mitogen
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
mitogen
Commits
b221eaaa
Commit
b221eaaa
authored
Feb 18, 2018
by
David Wilson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ansible: log call timings
parent
1e9fd633
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
3 deletions
+16
-3
ansible_mitogen/connection/mitogen.py
ansible_mitogen/connection/mitogen.py
+11
-1
docs/api.rst
docs/api.rst
+4
-1
mitogen/utils.py
mitogen/utils.py
+1
-1
No files found.
ansible_mitogen/connection/mitogen.py
View file @
b221eaaa
...
...
@@ -26,7 +26,9 @@
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
from
__future__
import
absolute_import
import
logging
import
os
import
time
import
ansible.errors
import
ansible.plugins.connection
...
...
@@ -38,6 +40,9 @@ import ansible_mitogen.helpers
from
ansible_mitogen.strategy.mitogen
import
ContextService
LOG
=
logging
.
getLogger
(
__name__
)
class
Connection
(
ansible
.
plugins
.
connection
.
ConnectionBase
):
#: mitogen.master.Router for this worker.
router
=
None
...
...
@@ -174,7 +179,12 @@ class Connection(ansible.plugins.connection.ConnectionBase):
:returns:
Function return value.
"""
return
self
.
call_async
(
func
,
*
args
,
**
kwargs
).
get
().
unpickle
()
t0
=
time
.
time
()
try
:
return
self
.
call_async
(
func
,
*
args
,
**
kwargs
).
get
().
unpickle
()
finally
:
LOG
.
debug
(
'Call %s%r took %d ms'
,
func
.
func_name
,
args
,
1000
*
(
time
.
time
()
-
t0
))
def
exec_command
(
self
,
cmd
,
in_data
=
''
,
sudoable
=
True
):
"""
...
...
docs/api.rst
View file @
b221eaaa
...
...
@@ -1000,11 +1000,14 @@ A random assortment of utility functions useful on masters and children.
OS X bundles some ancient version of the :py:mod:`six` module.
.. currentmodule:: mitogen.utils
.. function:: log_to_file (path=None, io=
Tru
e, usec=False, level='INFO')
.. function:: log_to_file (path=None, io=
Fals
e, usec=False, level='INFO')
Install a new :py:class:`logging.Handler` writing applications logs to the
filesystem. Useful when debugging slave IO problems.
Parameters to this function may be overridden at runtime using environment
variables. See :ref:`logging-env-vars`.
:param str path:
If not ``None``, a filesystem path to write logs to. Otherwise, logs
are written to :py:data:`sys.stderr`.
...
...
mitogen/utils.py
View file @
b221eaaa
...
...
@@ -49,7 +49,7 @@ def _formatTime(record, datefmt=None):
return
dt
.
strftime
(
datefmt
)
def
log_to_file
(
path
=
None
,
io
=
Tru
e
,
usec
=
False
,
level
=
'INFO'
):
def
log_to_file
(
path
=
None
,
io
=
Fals
e
,
usec
=
False
,
level
=
'INFO'
):
io
=
(
'MITOGEN_LOG_IO'
in
os
.
environ
)
or
io
usec
=
(
'MITOGEN_LOG_USEC'
in
os
.
environ
)
or
usec
level
=
os
.
environ
.
get
(
'MITOGEN_LOG_LEVEL'
,
level
).
upper
()
...
...
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