~loggerhead-team/loggerhead/trunk-rich

« back to all changes in this revision

Viewing changes to serve-branches

  • Committer: Martin Albisetti
  • Date: 2008-09-10 22:53:39 UTC
  • mfrom: (219.1.3 reloader)
  • Revision ID: argentina@gmail.com-20080910225339-p987y5hgtxrq8p5c
Add --reload option to restart LH automatically when developing. (Guillermo Gonzalez)

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
from loggerhead.apps.filesystem import (
30
30
    BranchesFromFileSystemRoot, UserBranchesFromFileSystemRoot)
31
31
from loggerhead.util import Reloader
32
 
from loggerhead.apps.error import ErrorHandlerApp
33
32
 
34
33
 
35
34
def command_line_parser():
37
36
    parser.set_defaults(
38
37
        user_dirs=False,
39
38
        show_version=False,
40
 
        log_folder=None,
41
39
        )
42
40
    parser.add_option("--user-dirs", action="store_true", dest="user_dirs",
43
41
                      help="Serve user directories as ~user.")
52
50
    parser.add_option("--reload", action="store_true", dest="reload",
53
51
                      help="Restarts the application when changing python"
54
52
                           " files. Only used for development purposes.")
55
 
    parser.add_option('--log-folder', dest="log_folder", 
56
 
                      type=str, help="The directory to place log files")
57
53
    parser.add_option("--version", action="store_true", dest="show_version",
58
54
                      help="Print the software version and exit")
59
55
    return parser
60
56
 
61
57
 
62
58
def main(args):
 
59
    logging.basicConfig()
 
60
    logging.getLogger().setLevel(logging.DEBUG)
 
61
 
63
62
    parser = command_line_parser()
64
63
    (options, args) = parser.parse_args(sys.argv[1:])
65
64
 
96
95
        app = UserBranchesFromFileSystemRoot(path, options.trunk_dir)
97
96
    else:
98
97
        app = BranchesFromFileSystemRoot(path)
99
 
    
100
 
    # setup_logging()
101
 
    logging.basicConfig()
102
 
    logging.getLogger('').setLevel(logging.DEBUG)
103
 
    logger = getattr(app, 'log', logging.getLogger('loggerhead'))
104
 
    if options.log_folder:
105
 
        logfile_path = os.path.join(options.log_folder, 'serve-branches.log')
106
 
    else:
107
 
        logfile_path = 'serve-branches.log'
108
 
    logfile = logging.FileHandler(logfile_path, 'a')
109
 
    formatter = logging.Formatter('%(asctime)s %(levelname)-8s %(name)s:'
110
 
                                  ' %(message)s')
111
 
    logfile.setFormatter(formatter)
112
 
    logfile.setLevel(logging.DEBUG)
113
 
    logger.addHandler(logfile)
114
 
    # setup_logging() #end
115
 
    app = ErrorHandlerApp(app)
116
98
    app = HTTPExceptionHandler(app)
117
 
    app = TransLogger(app, logger=logger)
 
99
    app = TransLogger(app)
118
100
 
119
101
    if not options.user_prefix:
120
102
        prefix = '/'