1
0
mirror of https://github.com/janeczku/calibre-web synced 2024-11-17 15:24:53 +00:00

Bugfix for logging ldap debug messages with non stream logfile

This commit is contained in:
Ozzie Isaacs 2023-03-26 13:17:02 +02:00
parent 9646b6e2dd
commit bde36e3cd4

View File

@ -30,6 +30,14 @@ except ImportError:
log = logger.create()
class LDAPLogger(object):
def write(self, message):
try:
log.debug(message.strip("\n").replace("\n", ""))
except Exception:
log.debug("Logging Error")
class mySimpleLDap(LDAP):
@ -38,7 +46,6 @@ class mySimpleLDap(LDAP):
super(mySimpleLDap, mySimpleLDap).init_app(app)
app.config.setdefault('LDAP_LOGLEVEL', 0)
@property
def initialize(self):
"""Initialize a connection to the LDAP server.
@ -50,7 +57,7 @@ class mySimpleLDap(LDAP):
conn = pyLDAP.initialize('{0}://{1}:{2}'.format(
current_app.config['LDAP_SCHEMA'],
current_app.config['LDAP_HOST'],
current_app.config['LDAP_PORT']), trace_level=log_level)
current_app.config['LDAP_PORT']), trace_level=log_level, trace_file=LDAPLogger())
conn.set_option(pyLDAP.OPT_NETWORK_TIMEOUT,
current_app.config['LDAP_TIMEOUT'])
conn = self._set_custom_options(conn)