mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-02-07 11:50:21 +00:00
Merge pull request #559 from tahoe-lafs/2981.send-eliot-logs.somewhere
Send Eliot logs somewhere. Fixes: ticket:2981
This commit is contained in:
commit
95745b9467
@ -12,6 +12,12 @@ import pytest_twisted
|
|||||||
# tests converted from check_magicfolder_smoke.py
|
# tests converted from check_magicfolder_smoke.py
|
||||||
# see "conftest.py" for the fixtures (e.g. "magic_folder")
|
# see "conftest.py" for the fixtures (e.g. "magic_folder")
|
||||||
|
|
||||||
|
def test_eliot_logs_are_written(temp_dir):
|
||||||
|
# The integration test configuration arranges for this logging
|
||||||
|
# configuration. Verify it actually does what we want.
|
||||||
|
assert exists(join(temp_dir, "alice", "logs", "eliot.json"))
|
||||||
|
assert exists(join(temp_dir, "bob", "logs", "eliot.json"))
|
||||||
|
|
||||||
|
|
||||||
def test_alice_writes_bob_receives(magic_folder):
|
def test_alice_writes_bob_receives(magic_folder):
|
||||||
alice_dir, bob_dir = magic_folder
|
alice_dir, bob_dir = magic_folder
|
||||||
|
0
newsfragments/2981.other
Normal file
0
newsfragments/2981.other
Normal file
@ -13,6 +13,7 @@ from allmydata.util.encodingutil import quote_output, quote_local_unicode_path,
|
|||||||
from allmydata.util.eliotutil import (
|
from allmydata.util.eliotutil import (
|
||||||
opt_eliot_destination,
|
opt_eliot_destination,
|
||||||
opt_help_eliot_destinations,
|
opt_help_eliot_destinations,
|
||||||
|
eliot_logging_service,
|
||||||
)
|
)
|
||||||
|
|
||||||
def GROUP(s):
|
def GROUP(s):
|
||||||
@ -183,13 +184,28 @@ def dispatch(config,
|
|||||||
d.addCallback(_raise_sys_exit)
|
d.addCallback(_raise_sys_exit)
|
||||||
return d
|
return d
|
||||||
|
|
||||||
|
def _maybe_enable_eliot_logging(options, reactor):
|
||||||
|
if options.get("destinations"):
|
||||||
|
service = eliot_logging_service(reactor, options["destinations"])
|
||||||
|
# There is no Twisted "Application" around to hang this on so start
|
||||||
|
# and stop it ourselves.
|
||||||
|
service.startService()
|
||||||
|
reactor.addSystemEventTrigger("after", "shutdown", service.stopService)
|
||||||
|
# Pass on the options so we can dispatch the subcommand.
|
||||||
|
return options
|
||||||
|
|
||||||
def run():
|
def run():
|
||||||
assert sys.version_info < (3,), ur"Tahoe-LAFS does not run under Python 3. Please use Python 2.7.x."
|
assert sys.version_info < (3,), ur"Tahoe-LAFS does not run under Python 3. Please use Python 2.7.x."
|
||||||
|
|
||||||
if sys.platform == "win32":
|
if sys.platform == "win32":
|
||||||
from allmydata.windows.fixups import initialize
|
from allmydata.windows.fixups import initialize
|
||||||
initialize()
|
initialize()
|
||||||
|
# doesn't return: calls sys.exit(rc)
|
||||||
|
task.react(_run_with_reactor)
|
||||||
|
|
||||||
|
def _run_with_reactor(reactor):
|
||||||
d = defer.maybeDeferred(parse_or_exit_with_explanation, sys.argv[1:])
|
d = defer.maybeDeferred(parse_or_exit_with_explanation, sys.argv[1:])
|
||||||
|
d.addCallback(_maybe_enable_eliot_logging, reactor)
|
||||||
d.addCallback(dispatch)
|
d.addCallback(dispatch)
|
||||||
def _show_exception(f):
|
def _show_exception(f):
|
||||||
# when task.react() notices a non-SystemExit exception, it does
|
# when task.react() notices a non-SystemExit exception, it does
|
||||||
@ -201,7 +217,7 @@ def run():
|
|||||||
f.printTraceback(file=sys.stderr)
|
f.printTraceback(file=sys.stderr)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
d.addErrback(_show_exception)
|
d.addErrback(_show_exception)
|
||||||
task.react(lambda _reactor: d) # doesn't return: calls sys.exit(rc)
|
return d
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
run()
|
run()
|
||||||
|
@ -458,12 +458,14 @@ class _DestinationParser(object):
|
|||||||
10,
|
10,
|
||||||
arg_list,
|
arg_list,
|
||||||
))
|
))
|
||||||
get_file = lambda: LogFile(
|
def get_file():
|
||||||
path.basename(),
|
path.parent().makedirs(ignoreExistingDirectory=True)
|
||||||
path.dirname(),
|
return LogFile(
|
||||||
rotateLength=rotate_length,
|
path.basename(),
|
||||||
maxRotatedFiles=max_rotated_files,
|
path.dirname(),
|
||||||
)
|
rotateLength=rotate_length,
|
||||||
|
maxRotatedFiles=max_rotated_files,
|
||||||
|
)
|
||||||
return lambda reactor: FileDestination(get_file())
|
return lambda reactor: FileDestination(get_file())
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user