~loggerhead-team/loggerhead/trunk-rich

« back to all changes in this revision

Viewing changes to __init__.py

  • Committer: geoffreyfishing at gmail
  • Date: 2011-06-03 22:22:39 UTC
  • mto: (431.2.18 loggerhead) (459.2.1 trunk)
  • mto: This revision was merged to the branch mainline in revision 461.
  • Revision ID: geoffreyfishing@gmail.com-20110603222239-3yoy4aohclstugz2
Updated exporter to use bzr patch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
starts a web server to browse the contents of a branch.
31
31
"""
32
32
 
33
 
import sys
34
 
 
35
33
from info import (
36
34
    bzr_plugin_version as version_info,
37
35
    bzr_compatible_versions,
51
49
    HELP = ('Loggerhead, a web-based code viewer and server. (default port: %d)' %
52
50
            (DEFAULT_PORT,))
53
51
 
 
52
    def setup_logging(config):
 
53
        import logging
 
54
        import sys
 
55
 
 
56
        logger = logging.getLogger('loggerhead')
 
57
        handler = logging.StreamHandler(sys.stderr)
 
58
        handler.setLevel(logging.DEBUG)
 
59
        logger.addHandler(handler)
 
60
        logging.getLogger('simpleTAL').addHandler(handler)
 
61
        logging.getLogger('simpleTALES').addHandler(handler)
 
62
 
54
63
    def _ensure_loggerhead_path():
55
64
        """Ensure that you can 'import loggerhead' and get the root."""
56
65
        # loggerhead internal code will try to 'import loggerhead', so
69
78
 
70
79
        from loggerhead.apps.transport import BranchesFromTransportRoot
71
80
        from loggerhead.config import LoggerheadConfig
72
 
        from loggerhead.main import setup_logging
73
81
 
74
82
        if host is None:
75
83
            host = DEFAULT_HOST
79
87
        if not transport.is_readonly():
80
88
            argv.insert(0, '--allow-writes')
81
89
        config = LoggerheadConfig(argv)
82
 
        setup_logging(config, init_logging=False, log_file=sys.stderr)
 
90
        setup_logging(config)
83
91
        app = BranchesFromTransportRoot(transport.base, config)
84
92
        app = HTTPExceptionHandler(app)
85
93
        serve(app, host=host, port=port)