Ticketing Support¶
This documents the support classes for ticketing. With ticketing handlers log records are categorized by location and for every emitted log record a count is added. That way you know how often certain messages are triggered, at what times and when the last occurrence was.
-
class
logbook.ticketing.
TicketingBaseHandler
(hash_salt, level=0, filter=None, bubble=False)[source]¶ Baseclass for ticketing handlers. This can be used to interface ticketing systems that do not necessarily provide an interface that would be compatible with the
BackendBase
interface.
-
class
logbook.ticketing.
TicketingHandler
(uri, app_id='generic', level=0, filter=None, bubble=False, hash_salt=None, backend=None, **db_options)[source]¶ A handler that writes log records into a remote database. This database can be connected to from different dispatchers which makes this a nice setup for web applications:
from logbook.ticketing import TicketingHandler handler = TicketingHandler('sqlite:////tmp/myapp-logs.db')
Parameters: - uri – a backend specific string or object to decide where to log to.
- app_id – a string with an optional ID for an application. Can be used to keep multiple application setups apart when logging into the same database.
- hash_salt – an optional salt (binary string) for the hashes.
- backend – A backend class that implements the proper database handling.
Backends available are:
SQLAlchemyBackend
,MongoDBBackend
.
-
default_backend
¶ The default backend that is being used when no backend is specified. Unless overriden by a subclass this will be the
SQLAlchemyBackend
.alias of
SQLAlchemyBackend
-
class
logbook.ticketing.
BackendBase
(**options)[source]¶ Provides an abstract interface to various databases.
-
get_occurrences
(ticket, order_by='-time', limit=50, offset=0)[source]¶ Selects occurrences from the database for a ticket.
-
-
class
logbook.ticketing.
SQLAlchemyBackend
(**options)[source]¶ Implements a backend that is writing into a database SQLAlchemy can interface.
This backend takes some additional options:
- table_prefix
- an optional table prefix for all tables created by the logbook ticketing handler.
- metadata
- an optional SQLAlchemy metadata object for the table creation.
- autocreate_tables
- can be set to False to disable the automatic creation of the logbook tables.