-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow Python Handling of log messages
This change lets Python LogHandlers handle the log messages produced by nmslib. This lets python control the behaviour of the log messages at run time, meaning that the loglevel can be adjusted and that the output of the messages can be handled any python loghandler. This basically involves transforming the existing logger class into an abstract base, and then creating a python version that adapts the nmslib log system to the python version.
- Loading branch information
Ben Frederickson
committed
Sep 2, 2017
1 parent
bd33311
commit 809507a
Showing
11 changed files
with
202 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ Contents: | |
|
||
Quickstart <quickstart> | ||
API Reference <api> | ||
Logging <logging> | ||
|
||
|
||
Indices and tables | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
Configuring Logging for NMSLIB | ||
============================== | ||
|
||
This library logs to a Python logger named ``nmslib``. This lets | ||
you fully control the log messages produced by nmslib in Python. | ||
|
||
For instance, to log everything produced by nmslib to a default | ||
python logger: | ||
|
||
.. code-block:: python | ||
# setup basic python logging | ||
import logging | ||
logging.basicConfig(level=logging.DEBUG) | ||
# importing nmslib logs some debug messages on startup, that | ||
# that will be output to the python log handler created above | ||
import nmslib | ||
To quiet these messages you can just set the level for nmslib | ||
as appropiate: | ||
|
||
.. code-block:: python | ||
# setup basic python logging | ||
import logging | ||
logging.basicConfig(level=logging.DEBUG) | ||
# Only log WARNING messages and above from nmslib | ||
logging.getLogger('nmslib').setLevel(logging.WARNING) | ||
import nmslib |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,5 +35,4 @@ void initLibrary(LogChoice choice, const char* pLogFile) { | |
initSpaces(); | ||
initMethods(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters