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
750e9fab
Commit
750e9fab
authored
Sep 21, 2017
by
David Wilson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make log_to_file accept string level rather than logging package constant
Saves an import, pain in the ass to type all the time.
parent
a9387b05
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
4 additions
and
3 deletions
+4
-3
mitogen/utils.py
mitogen/utils.py
+2
-1
tests/data/webproject/serve_django_app.py
tests/data/webproject/serve_django_app.py
+1
-1
tests/proxy_test.py
tests/proxy_test.py
+1
-1
No files found.
mitogen/utils.py
View file @
750e9fab
...
@@ -27,7 +27,7 @@ def log_to_tmp():
...
@@ -27,7 +27,7 @@ def log_to_tmp():
log_to_file
(
path
=
'/tmp/mitogen.%s.log'
%
(
os
.
getpid
(),))
log_to_file
(
path
=
'/tmp/mitogen.%s.log'
%
(
os
.
getpid
(),))
def
log_to_file
(
path
=
None
,
io
=
True
,
level
=
logging
.
INFO
):
def
log_to_file
(
path
=
None
,
io
=
True
,
level
=
'INFO'
):
"""Install a new :py:class:`logging.Handler` writing applications logs to
"""Install a new :py:class:`logging.Handler` writing applications logs to
the filesystem. Useful when debugging slave IO problems."""
the filesystem. Useful when debugging slave IO problems."""
log
=
logging
.
getLogger
(
''
)
log
=
logging
.
getLogger
(
''
)
...
@@ -37,6 +37,7 @@ def log_to_file(path=None, io=True, level=logging.INFO):
...
@@ -37,6 +37,7 @@ def log_to_file(path=None, io=True, level=logging.INFO):
else
:
else
:
fp
=
sys
.
stderr
fp
=
sys
.
stderr
level
=
getattr
(
logging
,
level
,
logging
.
INFO
)
log
.
setLevel
(
level
)
log
.
setLevel
(
level
)
if
io
:
if
io
:
logging
.
getLogger
(
'mitogen.io'
).
setLevel
(
level
)
logging
.
getLogger
(
'mitogen.io'
).
setLevel
(
level
)
...
...
tests/data/webproject/serve_django_app.py
View file @
750e9fab
...
@@ -27,7 +27,7 @@ def serve_django_app(settings_name):
...
@@ -27,7 +27,7 @@ def serve_django_app(settings_name):
def
main
(
broker
):
def
main
(
broker
):
import
logging
import
logging
mitogen
.
utils
.
log_to_file
(
level
=
logging
.
INFO
,
io
=
False
)
mitogen
.
utils
.
log_to_file
(
io
=
False
)
context
=
mitogen
.
master
.
connect
(
broker
)
context
=
mitogen
.
master
.
connect
(
broker
)
context
.
call
(
os
.
chdir
,
'/'
)
context
.
call
(
os
.
chdir
,
'/'
)
#context.call(mitogen.utils.log_to_file, '/tmp/log')
#context.call(mitogen.utils.log_to_file, '/tmp/log')
...
...
tests/proxy_test.py
View file @
750e9fab
...
@@ -7,7 +7,7 @@ import mitogen.utils
...
@@ -7,7 +7,7 @@ import mitogen.utils
@
mitogen
.
utils
.
run_with_router
@
mitogen
.
utils
.
run_with_router
def
main
(
router
):
def
main
(
router
):
mitogen
.
utils
.
log_to_file
(
io
=
False
,
level
=
logging
.
INFO
)
mitogen
.
utils
.
log_to_file
(
io
=
False
)
child1
=
router
.
ssh
(
name
=
'u'
,
hostname
=
'u'
)
child1
=
router
.
ssh
(
name
=
'u'
,
hostname
=
'u'
)
child2
=
router
.
sudo
(
child2
=
router
.
sudo
(
username
=
'sudo_pw_test'
,
username
=
'sudo_pw_test'
,
...
...
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