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