This plugins can be used to create in-memory logs which can be used by items or other plugins.
No special requirements.
Use the plugin configuration to configure the in-memory logs.
memlog:
class_name: MemLog
class_path: plugins.memlog
name: alert
mappings:
- time
- thread
- level
- message
# maxlen: 50
# items
# - first.item.now
# - second.item.thread.info
# - third.item.level
# - fourth.item.msg
This will register a in-memory log with the name "alert". This can be used to attach to items.
This will give the in-memory log a name which can be used when accessing them.
This configures the list of values which are logged for each log message. The following internal mappings can be used and will be automatically set - if not given explicitely when logging data:
time
- the timestamp of logthread
- the thread logging datalevel
- the log level (defaults to INFO)
Defines the maximum amount of log entries in the in-memory log.
Each time an item is updated using the memlog
configuration setting, a log entry will
be written using the list of items configured in this attribute as log values.
When this is not configured, the default mapping values will be used the associated item's value will be logged.
The following attributes can be used.
Defines the name of in-memory log which should be used to log the item's content to the log. Everything is logged with 'INFO' level.
Simple item logging:
some:
item:
type: str
memlog: alert
Configures that a message should be logged whenever the logic was triggered. It logs a
default message which can be overwritten by the memlog_message
attribute.
Defines the message to be logged. It configures a string which may contain placeholders
which got replaced by using the format()
function.
The following placeholders or object can be used in the message string:
logic
- the logic object, e.g. logic.name for the logic's nameplugin
- the memlog plugin instance objectby
- the string containing the origin of logic triggersource
- the sourcedest
- the destination
The logic
and plugin
placeholders are always available, the rest depends on the
logic invocation/trigger.
Example:
memlog_message: The logic {logic.name} was triggered!
The memlog()
method name is the plugin name which is used in the plugin configuration.
If you use another name, you need to use this name as method name too.
This log the given list of elements of entry
parameter. The list should have the same amount
of items you used in the mapping parameter (see also the default for this value).
sh.memlog((self._sh.now(), threading.current_thread().name, 'INFO', 'Some information'))
This log the given message in msg
parameter with the default log level.
This logs the message in msg
parameter with the given log level specified in lvl
parameter.