-
Notifications
You must be signed in to change notification settings - Fork 0
/
settings.py
30 lines (24 loc) · 1.14 KB
/
settings.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import logging, logging.handlers, configparser, sys, os
def init(rcfile):
global GANDI_API_KEY, GANDI_ZONE_ID, GANDI_XMLRPC_URL
try:
config = configparser.ConfigParser()
config.read(rcfile)
GANDI_API_KEY = config['gandi']['api_key']
GANDI_ZONE_ID = int(config['gandi']['zone_id'])
GANDI_XMLRPC_URL = config['gandi']['xml_rpc_url']
root = logging.getLogger()
root.setLevel(logging.DEBUG)
formatter = logging.Formatter('%(asctime)s:%(name)s:%(levelname)s:%(message)s')
splat = os.path.splitext(config['log']['path'])
handler = logging.handlers.RotatingFileHandler(splat[0] + ".debug" + splat[1], maxBytes=10*1024, backupCount=10)
handler.setFormatter(formatter)
handler.setLevel(logging.DEBUG)
root.addHandler(handler)
handler = logging.handlers.RotatingFileHandler(config['log']['path'], maxBytes=10*1024, backupCount=1)
handler.setFormatter(formatter)
handler.setLevel(logging.INFO)
root.addHandler(handler)
except:
print('init error:', sys.exc_info()[0])
raise