mirror of
https://github.com/janeczku/calibre-web
synced 2024-11-17 23:34:53 +00:00
Bugfix for logging ldap debug messages with non stream logfile
This commit is contained in:
parent
9646b6e2dd
commit
bde36e3cd4
@ -30,6 +30,14 @@ except ImportError:
|
|||||||
|
|
||||||
log = logger.create()
|
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):
|
class mySimpleLDap(LDAP):
|
||||||
|
|
||||||
@ -38,7 +46,6 @@ class mySimpleLDap(LDAP):
|
|||||||
super(mySimpleLDap, mySimpleLDap).init_app(app)
|
super(mySimpleLDap, mySimpleLDap).init_app(app)
|
||||||
app.config.setdefault('LDAP_LOGLEVEL', 0)
|
app.config.setdefault('LDAP_LOGLEVEL', 0)
|
||||||
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def initialize(self):
|
def initialize(self):
|
||||||
"""Initialize a connection to the LDAP server.
|
"""Initialize a connection to the LDAP server.
|
||||||
@ -50,7 +57,7 @@ class mySimpleLDap(LDAP):
|
|||||||
conn = pyLDAP.initialize('{0}://{1}:{2}'.format(
|
conn = pyLDAP.initialize('{0}://{1}:{2}'.format(
|
||||||
current_app.config['LDAP_SCHEMA'],
|
current_app.config['LDAP_SCHEMA'],
|
||||||
current_app.config['LDAP_HOST'],
|
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,
|
conn.set_option(pyLDAP.OPT_NETWORK_TIMEOUT,
|
||||||
current_app.config['LDAP_TIMEOUT'])
|
current_app.config['LDAP_TIMEOUT'])
|
||||||
conn = self._set_custom_options(conn)
|
conn = self._set_custom_options(conn)
|
||||||
|
Loading…
Reference in New Issue
Block a user