-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding initial sinks document, plenty of tweaks all around, a few glo…
…ssary entries
- Loading branch information
Showing
7 changed files
with
135 additions
and
37 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
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 |
---|---|---|
|
@@ -18,6 +18,7 @@ Section Listing | |
overview | ||
logger | ||
record | ||
sinks | ||
sensible | ||
logging_tradition | ||
glossary | ||
|
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
The ``Logger`` | ||
The Logger | ||
============== | ||
|
||
.. automodule:: lithoxyl.logger | ||
|
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
The ``Record`` | ||
The Record | ||
============== | ||
|
||
.. automodule:: lithoxyl.record | ||
|
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 |
---|---|---|
@@ -0,0 +1,77 @@ | ||
The Sink | ||
======== | ||
|
||
In Lithoxyl's system of instrumentation, Records are used to carry | ||
messages, data, and timing metadata through the Loggers to their | ||
destination, the Sinks. This chapter focuses in on this last | ||
step. | ||
|
||
Writing a simple Sink | ||
--------------------- | ||
|
||
Sinks range from very complex to very simple. A useful Sink can be as | ||
simple as:: | ||
|
||
import sys | ||
|
||
class DotSink(object): | ||
def on_end(self, end_event): | ||
sys.stdout.write('.') | ||
sys.stdout.flush() | ||
|
||
|
||
Note that our new Sink does not have to inherit from any special | ||
object. DotSink is a correct and capable Sink, ready to be | ||
instantiated and installed with :meth:`Logger.add_sink`, just like in | ||
the overview. Once added to your Logger, every time a Record ends, a | ||
dot will be written out to your console. | ||
|
||
In this example, ``on_end`` is the handler for just one of Lithoxyl's | ||
events. The next section takes a look at all five of them. | ||
|
||
Events | ||
------ | ||
|
||
Five events can happen in the Lithoxyl system: | ||
|
||
* **begin** - The beginning of a Record, whether manually or through | ||
entering a context-managed block of code. | ||
|
||
The begin event corresponds to the method signature ``on_begin(self, | ||
begin_event)``. Designed to be called once per Record. | ||
* **end** - The completion of a Record, whether manually | ||
(``success()`` and ``failure()``) or through exiting a | ||
context-managed block of code. There are three ways a Record can | ||
end, **success**, **failure**, and **exception**, but all of them | ||
result in an *end* event. | ||
|
||
The end event corresponds to the method signature ``on_end(self, | ||
end_event)``. Designed to be called once per Record. | ||
* **exception** - Called immediately when an exception is raised from | ||
within the context-managed block, or when an exception is manually | ||
handled with Record.exception(). Records ending in exception state | ||
typically fire two events, one for handling the exception, and one | ||
for ending the Record. | ||
|
||
The exception event corresponds to the Sink method signature | ||
``on_exception(self, exc_event, exc_type, exc_obj, exc_tb)``. | ||
Designed to be called up to once. | ||
* **warn** - The registration of a warning within a Record. | ||
|
||
Corresponds to the Sink method signature ``on_warn(self, | ||
warn_event)``. Can be called an arbitrary number of times. | ||
|
||
* **comment** - The registration of a comment from a Logger. Comments | ||
are used for publishing metadata associated with a Logger. | ||
|
||
The comment event corresponds to the Sink method signature | ||
``on_comment(self, comment_event)``. See here for more about | ||
comments. Can be called an arbitrary number of times. | ||
|
||
A Sink handles the event by implementing the respective method. The | ||
event objects that accompany every event are meant to be practically | ||
immutable; their values are set once, at creation. | ||
|
||
|
||
.. Lithoxyl's informal Sink taxonomy ideas: numeric, accumulating, | ||
debug, stream. |