add logger for ini parse and break to test
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
[DEFAULT]
|
||||
# debug, info, warning, error, critical
|
||||
logLevel = INFO
|
||||
logFilePath = /tmp/seafile-ldap.log
|
||||
|
||||
# this section contains information related to the server
|
||||
[LDAP SERVER]
|
||||
|
||||
@@ -5,26 +5,34 @@ from getpass import getpass
|
||||
import configparser
|
||||
import logging
|
||||
|
||||
#logger = logging.getLogger(__main__)
|
||||
#logger.setLevel(logging.INFO)
|
||||
logger = logging.getLogger(__main__)
|
||||
logFormatter = logging.Formatter('%(asctime)s - [%(levelname)s] %(message)s', datefmt='%Y-%m-%d %H:%M:%S')
|
||||
logger.setLevel(logging.INFO)
|
||||
|
||||
#logging.basicConfig(level=logging.INFO,format='%(asctime)s - [%(levelname)s] %(message)s', datefmt='%Y-%m-%d %H:%M:%S')
|
||||
#fileHandler = logging.FileHandler("/tmp/seafile-ldap.log")
|
||||
#fileHandler.setFormatter(logFormatter)
|
||||
#logger.addHandler(fileHandler)
|
||||
|
||||
#logLevel = config['DEFAULT']['logLevel']
|
||||
#logLevel = debug
|
||||
|
||||
#logging.basicConfig(level=logging.logLevel,format='%(asctime)s - [%(levelname)s] %(message)s', datefmt='%Y-%m-%d %H:%M:%S')
|
||||
consoleHandler = logging.StreamHandler()
|
||||
consoleHandler.setFormatter(logFormatter)
|
||||
logger.addHandler(consoleHandler)
|
||||
|
||||
# import the config file
|
||||
logger.debug("Starting to read the ini config.")
|
||||
config = configparser.ConfigParser()
|
||||
config.read(cwd + '/config.ini')
|
||||
|
||||
serverDNS = config['LDAP SERVER']['server']
|
||||
serverPort = config['LDAP SERVER']['port']
|
||||
serverSSL = config['LDAP SERVER'].getboolean('ssl')
|
||||
logger.debug("Server: %0, Server Port: %1, Using SSL: %3".format(serverDNS, serverPort, serverSSL))
|
||||
|
||||
bindAccount = config['Bind Account']['username']
|
||||
bindPassword = config['Bind Account']['password']
|
||||
logger.debug("Bind Account: %0, Bind Password: <hidden>".format(bindAccount))
|
||||
logger.debug("Finished reading the ini config.")
|
||||
|
||||
break
|
||||
|
||||
# setup the server
|
||||
server = Server(serverDNS, port=serverPort, use_ssl=serverSSL)
|
||||
|
||||
Reference in New Issue
Block a user