~loggerhead-team/loggerhead/trunk-rich

« back to all changes in this revision

Viewing changes to start-loggerhead

  • Committer: Jelmer Vernooij
  • Date: 2008-08-06 18:33:20 UTC
  • mto: (197.1.9 pathargs)
  • mto: This revision was merged to the branch mainline in revision 202.
  • Revision ID: jelmer@samba.org-20080806183320-6llann0k480dlb9y
add --log-folder option.

Show diffs side-by-side

added added

removed removed

Lines of Context:
44
44
    return h
45
45
 
46
46
 
47
 
def setup_logging(home, config, foreground):
 
47
def setup_logging(logdir, config, foreground):
48
48
    # i hate that stupid logging config format, so just set up logging here.
49
49
 
50
 
    log_folder = os.path.join(home, 'logs')
51
50
    if not os.path.exists(log_folder):
52
51
        os.mkdir(log_folder)
53
52
 
79
78
    home = os.path.realpath(os.path.dirname(__file__))
80
79
    default_pidfile = os.path.join(home, 'loggerhead.pid')
81
80
    default_configfile = os.path.join(home, 'loggerhead.conf')
 
81
    default_log_folder = os.path.join(home, 'logs')
82
82
    parser = OptionParser(usage='usage: %prog [options]', version='%prog ' + release.version)
83
83
    parser.add_option('-f', '--foreground', action='store_true', dest='foreground', default=False,
84
84
                      help="run in the foreground; don't daemonize")
86
86
                      help="only start if not already running (useful for cron jobs)")
87
87
    parser.add_option('-p', '--pidfile', dest="pidfile", default=default_pidfile,
88
88
                      help="override pidfile location")
89
 
    parser.add_option('-c', '--configfile', dest="configfile", default=default_configfile,
 
89
    parser.add_option('-c', '--config-file', dest="configfile", default=default_configfile,
90
90
                      help="override configuration file location")
 
91
    parser.add_option('-L', '--log-folder', dest="log-folder", default=default_log_folder,
 
92
                      help="override log file directory")
91
93
    options, args = parser.parse_args()
92
94
    if len(args) > 0:
93
95
        parser.error('No filename arguments are used, only options.')
129
131
 
130
132
        daemon.daemonize(options.pidfile, home)
131
133
 
132
 
    setup_logging(home, config, foreground=options.foreground)
 
134
    setup_logging(options.log_folder, config, foreground=options.foreground)
133
135
 
134
136
    log = logging.getLogger('loggerhead')
135
137
    log.info('Starting up...')