Ejemplo n.º 1
0
def configure_app (config_file):
    """
    Configures the CherryPy engine with the values given in the 'config_file'.-
    """
    cherrypy.config.update (config_file)
    #
    # start the SQLite-backed logging of the application
    #
    log_db = os.path.join (BASE_PATH,
                           cherrypy.config.get ('log.database'))
    sql_handler = SQLiteHandler (db=log_db)
    sql_handler.setLevel (DEBUG)
    #
    # turn off logging to file ...
    #
    cherrypy.log.error_file = ""
    #
    # ... and activate the SQL-based logging
    #
    cherrypy.log.error_log.addHandler (sql_handler)
    #
    # send Client errors via mail, in case the application is
    # running in production mode
    #
    if cherrypy.config.get ('environment') == 'production':
        from logging.handlers import SMTPHandler
        mail_handler = SMTPHandler (cherrypy.config.get ('log.smtp_server'),
                                    '*****@*****.**',
                                    cherrypy.config.get ('admins'),
                                    'PS Client error')
        mail_handler.setLevel (ERROR)
        cherrypy.log.error_log.addHandler (mail_handler)
    #
    # configuration successful
    #
    cherrypy.log.error_log.info ("Daemon configured correctly")
Ejemplo n.º 2
0
# SMTP server through which mails are sent
#
SMTP_SERVER = '127.0.0.1'

#
# Update URL for newer versions of this client
#
UPDATE_URL = 'http://ps.ijs.si/downloads'

#
# a list of the logging handlers that will be
# attached to the Flask application object
#
LOGGING_HANDLERS = []

sql_handler = SQLiteHandler (db=LOG_DATABASE)
sql_handler.setLevel (DEBUG)
LOGGING_HANDLERS.append (sql_handler)

#if not DEBUG:
if False:
    #
    # setup mail logging in case the application is running in production mode
    #
    from logging.handlers import SMTPHandler
    mail_handler = SMTPHandler (SMTP_SERVER,
                                '*****@*****.**',
                                ADMINS,
                                'PS Client error')
    mail_handler.setLevel (ERROR)
    LOGGING_HANDLERS.append (mail_handler)