API Reference
core
logged_property
Bases: property
Marks a property to be logged.
Thin wrapper around a standard property. Used in a logger class when the property is to be logged each time the wrapped function is called.
Source code in /opt/hostedtoolcache/Python/3.11.2/x64/lib/python3.11/site-packages/declog/core.py
7 8 9 10 11 |
|
log(value, key=None)
Log value
with the closest Logger.
This function takes a value and optionally a key to call it. If no key is provided, the name of the variable that the value is assigned to is used.
The closest logger is determined by stepping backwards through the call stack until
a __call__
method of a class subclassing BaseLogger
is reached.
Source code in /opt/hostedtoolcache/Python/3.11.2/x64/lib/python3.11/site-packages/declog/core.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
|
database
BaseDatabase
Bases: UserDict
Base class for Databases to be used with declog Loggers.
When a key which does not yet exist is accessed, an empty database is created as the value for that key. This enables a nested keys to be used. All Database types must have this functionality in order for them to be used by a declog Logger.
Source code in /opt/hostedtoolcache/Python/3.11.2/x64/lib/python3.11/site-packages/declog/database.py
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
|
PickleDatabase
Bases: PersistentDatabase
BaseDatabase which gets written to a pickle file.
Drawback of pickle is the whole thing must be read from path so for a big database this will be slow.
Upside is native python objects can be stored so absolutely anything can be logged, while for others it is more limited.
Source code in /opt/hostedtoolcache/Python/3.11.2/x64/lib/python3.11/site-packages/declog/database.py
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
|
StdOutDatabase
Bases: BaseDatabase
Database which prints itself every time a value gets logged.
Source code in /opt/hostedtoolcache/Python/3.11.2/x64/lib/python3.11/site-packages/declog/database.py
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
|
logger
Loggers are classes which are applied to functions as decorators.
When the function is called, the __call__
method of the Logger is
executed, which allows it to log the arguments supplied to the function,
in addition to other marked properties.
The Logger is separated from the database backends, allowing one logger to be used with multiple backends and vice versa.
BaseLogger
Base Logger to be subclassed by the user.
The class attributes db
and unique_keys
should be set by
subclasses.
Source code in /opt/hostedtoolcache/Python/3.11.2/x64/lib/python3.11/site-packages/declog/logger/__init__.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
|
__call__(*args, **kwargs)
Evaluate wrapped function and log variables.
Collates all the arguments and any logged properties in a dictionary.
Saves all items in the dictionary to the database db
under a key specified
by the class' unique_keys
attribute.
Source code in /opt/hostedtoolcache/Python/3.11.2/x64/lib/python3.11/site-packages/declog/logger/__init__.py
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
|
log(key, value)
Log the key and value to db
under the current entry.
Source code in /opt/hostedtoolcache/Python/3.11.2/x64/lib/python3.11/site-packages/declog/logger/__init__.py
53 54 55 |
|
set(**kwargs)
classmethod
Set kwargs as logged properties.
Source code in /opt/hostedtoolcache/Python/3.11.2/x64/lib/python3.11/site-packages/declog/logger/__init__.py
57 58 59 60 61 62 63 64 65 66 67 |
|
DefaultLogger
Bases: BaseLogger
, FunctionNameMixin
, DateTimeMixin
Logger to capture function name, arguments and call time.
A basic 'batteries included' logger. For use as a quick way to go from zero to logging and demonstrating how easy it is to write a custom Logger using mixins.
Source code in /opt/hostedtoolcache/Python/3.11.2/x64/lib/python3.11/site-packages/declog/logger/__init__.py
108 109 110 111 112 113 114 115 116 |
|
mixins
Collection of classes containing commonly used logged properties.
These are used as mixins to save time making custom loggers. For an example of this in action, take a look at the DefaultLogger.
DateTimeMixin
Source code in /opt/hostedtoolcache/Python/3.11.2/x64/lib/python3.11/site-packages/declog/logger/mixins.py
20 21 22 23 24 |
|
datetime()
The time and date.
Source code in /opt/hostedtoolcache/Python/3.11.2/x64/lib/python3.11/site-packages/declog/logger/mixins.py
21 22 23 24 |
|
FunctionNameMixin
Source code in /opt/hostedtoolcache/Python/3.11.2/x64/lib/python3.11/site-packages/declog/logger/mixins.py
13 14 15 16 17 |
|
function_name()
Name of the wrapped function.
Source code in /opt/hostedtoolcache/Python/3.11.2/x64/lib/python3.11/site-packages/declog/logger/mixins.py
14 15 16 17 |
|
UserMixin
Source code in /opt/hostedtoolcache/Python/3.11.2/x64/lib/python3.11/site-packages/declog/logger/mixins.py
27 28 29 30 31 |
|
user()
The current user.
Source code in /opt/hostedtoolcache/Python/3.11.2/x64/lib/python3.11/site-packages/declog/logger/mixins.py
28 29 30 31 |
|