Esempio n. 1
0
log_monitor = file_monitor.getAzureFileMonitor("log_monitor")
log_monitor.configure(settings["azaccount"], settings["azkey"], "logs")
if "proxy_host" in settings:
    log_monitor.set_proxy(settings["proxy_host"], settings["proxy_port"])
if "WeAreInTheCloud" in os.environ:
    log_monitor.add_directory(os.path.join(root_path, settings["logs_path"]))

# ================================================================
# azure log handler

from utils import azure_logging
azure_logging.configure(settings["azaccount"], settings["azkey"])
if "proxy_host" in settings:
    azure_logging.set_proxy(settings["proxy_host"], settings["proxy_port"])
if "WeAreInTheCloud" in os.environ:
    azure_logging.init_storage()
azure_log_handler = azure_logging.get_handler()
azure_log_handler.setLevel(logging.WARN)

# ================================================================
# file log handler

logs_path = os.path.join(root_path, settings["logs_path"])

# ensure logs dir exists

if not os.path.exists(logs_path):
    os.makedirs(logs_path)

file_log_handler = TimedRotatingFileHandler(filename=path.join(logs_path,"site.log"), when="midnight", interval=1, backupCount=2, encoding=None, delay=False, utc=False)
file_log_handler.setFormatter(logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s"))
Esempio n. 2
0
def logs_init():
    if is_admin():
        azure_logging.init_storage()
        return flask.redirect('/logs')
    else:
        return "Not authorized", 401