diff options
author | wm4 <wm4@nowhere> | 2014-01-16 21:34:58 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2014-01-16 23:06:40 +0100 |
commit | d646d78ccb2fac0ac1a052dc4c9edef3ba734d62 (patch) | |
tree | e5febfc95f0664a514b5f75377a6429ab06ebce1 /player/lua.h | |
parent | 8c5ea38cda7a424d89e080fd16d8902dd7b1d29e (diff) | |
download | mpv-d646d78ccb2fac0ac1a052dc4c9edef3ba734d62.tar.bz2 mpv-d646d78ccb2fac0ac1a052dc4c9edef3ba734d62.tar.xz |
lua: allow scripts to snoop messages
Adds the following Lua function to enable message events:
mp.enable_messages(size, level)
size is the maximum number of messages the ringbuffer consists of. level
is the minimum log level for a message to be added to the ringbuffer,
and uses the same values as the mp.log() function. (Actually not yet,
but this will be fixed in the following commit.)
The messages will be delivered via the mp_event() in the user script,
using "message" as event name. The event argument is a table with the
following fields:
level: log level of the message (string as in mp.log())
prefix: string identifying the module of origin
text: contents of the message
As of currently, the message text will contain newline characters. A
message can consist of several lines. It is also possible that a
message doesn't end with a newline, and a caller can use multiple
messages to "build" a line. Most messages will contain exactly 1 line
ending with a single newline character, though.
If the message buffer overflows (messages are not read quickly enough),
new messages are lost until the queued up messages are read. At the
point of the overflow, a special overflow message is inserted. It will
have prefix set to "overflow", and the message text is set to "".
Care should be taken not to print any messages from the message event
handler. This would lead to an infinite loop (the event handler would be
called again after returning, because a new message is available). This
includes mp.log() and all mp.msg.* functions. Keep in mind that the Lua
print() function is mapped to mp.msg.info().
Diffstat (limited to 'player/lua.h')
0 files changed, 0 insertions, 0 deletions