diff --git a/config.ini.sample b/config.ini.sample index 50374ea..d032be5 100644 --- a/config.ini.sample +++ b/config.ini.sample @@ -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] diff --git a/seafile-ldap.py b/seafile-ldap.py index 1d54dcd..0b9087d 100644 --- a/seafile-ldap.py +++ b/seafile-ldap.py @@ -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: ".format(bindAccount)) +logger.debug("Finished reading the ini config.") + +break # setup the server server = Server(serverDNS, port=serverPort, use_ssl=serverSSL)