Skip to content

Logging API for C scripts #16707

@LordMZTE

Description

@LordMZTE

Expected behavior of the wanted feature

Similar to the mp.msg module for Lua scripts which allows sending log messages, we should implement a similar API that can be used by C scripts. I have checked client.h but could not find any function definitions that would allow this.

Alternative behavior of the wanted feature

Manually printing log messages to stderr. This not only looks out-of-line, but will also clobber term-osd.

Log File

No response

Sample Files

The API could perhaps look something like this:

typedef enum mpv_log_level {
    MPV_TRACE,
    MPV_DEBUG,
    MPV_VERBOSE,
    MPV_INFO,
    MPV_WARN,
    MPV_ERROR,
    MPV_FATAL
} mpv_log_level;

// Send a string log message
void mpv_msg_log(mpv_log_level level, const char *msg);

// Use format strings (this could also just be `mpv_msg_log`)
void mpv_msg_logf(mpv_log_level level, const char *fmt, ...);

// Perhaps also shorthands for log levels such as `mpv_msg_info`.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions