mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Add a basic logging system.
This commit is contained in:
parent
cd9d005c49
commit
2d21ea059b
34
web/config.py
Normal file
34
web/config.py
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
##########################################################################
|
||||||
|
#
|
||||||
|
# pgAdmin 4 - PostgreSQL Tools
|
||||||
|
#
|
||||||
|
# Copyright (C) 2013 - 2014, The pgAdmin Development Team
|
||||||
|
# This software is released under the PostgreSQL Licence
|
||||||
|
#
|
||||||
|
# config.py - Core application configuration settings
|
||||||
|
#
|
||||||
|
##########################################################################
|
||||||
|
|
||||||
|
from logging import *
|
||||||
|
|
||||||
|
# Application log level - one of:
|
||||||
|
# CRITICAL 50
|
||||||
|
# ERROR 40
|
||||||
|
# WARNING 30
|
||||||
|
# SQL 25
|
||||||
|
# INFO 20
|
||||||
|
# DEBUG 10
|
||||||
|
# NOTSET 0
|
||||||
|
PGADMIN_LOG_LEVEL = DEBUG
|
||||||
|
|
||||||
|
# Log file name
|
||||||
|
PGADMIN_LOG_FILE = 'pgadmin4.log'
|
||||||
|
|
||||||
|
# Log format. See
|
||||||
|
PGADMIN_LOG_FORMAT='%(asctime)s: %(levelname)s\t%(name)s:\t%(message)s'
|
||||||
|
|
||||||
|
# Load local config overrides
|
||||||
|
try:
|
||||||
|
from config_local import *
|
||||||
|
except ImportError:
|
||||||
|
pass
|
@ -1,9 +1,35 @@
|
|||||||
import os, sys, inspect
|
##########################################################################
|
||||||
from time import time,ctime
|
#
|
||||||
from flask import Flask
|
# pgAdmin 4 - PostgreSQL Tools
|
||||||
|
#
|
||||||
|
# Copyright (C) 2013 - 2014, The pgAdmin Development Team
|
||||||
|
# This software is released under the PostgreSQL Licence
|
||||||
|
#
|
||||||
|
# pgAdmin4.py - Main application entry point
|
||||||
|
#
|
||||||
|
##########################################################################
|
||||||
|
|
||||||
|
import os, sys, inspect
|
||||||
|
from time import time, ctime
|
||||||
|
from flask import Flask
|
||||||
|
import logging
|
||||||
|
|
||||||
|
# We need to include the root directory in sys.path to ensure that we can
|
||||||
|
# find everything we need when running in the standalone runtime.
|
||||||
|
sys.path.append(os.path.dirname(__file__))
|
||||||
|
|
||||||
|
# Configuration settings
|
||||||
|
from config import *
|
||||||
|
|
||||||
|
# Setup the app object
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
|
|
||||||
|
# Setup logging and log the application startup
|
||||||
|
logging.addLevelName(25, 'SQL')
|
||||||
|
logging.basicConfig(filename=PGADMIN_LOG_FILE, format=PGADMIN_LOG_FORMAT, level=logging.DEBUG)
|
||||||
|
app.logger.setLevel(PGADMIN_LOG_LEVEL)
|
||||||
|
app.logger.debug('Starting pgAdmin 4...')
|
||||||
|
|
||||||
# The main index page
|
# The main index page
|
||||||
@app.route("/")
|
@app.route("/")
|
||||||
def index():
|
def index():
|
||||||
@ -17,7 +43,6 @@ Today is <b>%s</b>
|
|||||||
|
|
||||||
return output
|
return output
|
||||||
|
|
||||||
|
|
||||||
# A special URL used to "ping" the server
|
# A special URL used to "ping" the server
|
||||||
@app.route("/ping")
|
@app.route("/ping")
|
||||||
def ping():
|
def ping():
|
||||||
|
Loading…
Reference in New Issue
Block a user