const { GLib, Gst } = imports.gi;
const REQ_GST_VERSION_MINOR = 18;

function debug(msg, levelName)
{
    levelName = levelName || 'LEVEL_DEBUG';

    if(msg.message) {
        levelName = 'LEVEL_CRITICAL';
        msg = msg.message;
    }
    GLib.log_structured(
        'Clapper', GLib.LogLevelFlags[levelName], {
            MESSAGE: msg,
            SYSLOG_IDENTIFIER: 'clapper'
    });
}

function gstVersionCheck()
{
    if(Gst.VERSION_MINOR >= REQ_GST_VERSION_MINOR)
        return;

    debug(
        'Clapper was designed to' +
        ` work with GStreamer 1.${REQ_GST_VERSION_MINOR} or later.` +
        ` Your version is ${Gst.VERSION_MAJOR}.${Gst.VERSION_MINOR}.` +
        ' Please update GStreamer or expect some things to be broken.',
        'LEVEL_WARNING'
    );
}
