Add custom debug script with Gst version check

This commit is contained in:
Rafostar
2020-09-03 10:43:07 +02:00
parent 176ddf1cc2
commit 7d2b1f1118
3 changed files with 44 additions and 3 deletions

View File

@@ -1,10 +1,13 @@
const { Gdk, GLib, GObject, Gtk } = imports.gi;
const Debug = imports.clapper_src.debug;
const { Interface } = imports.clapper_src.interface;
const { Player } = imports.clapper_src.player;
const { Window } = imports.clapper_src.window;
const APP_NAME = 'Clapper';
let { debug } = Debug;
var App = GObject.registerClass({
Signals: {
'ready': {
@@ -306,11 +309,11 @@ var App = GObject.registerClass({
_onPlayerWarning(self, error)
{
log(error.message);
debug(error.message, 'LEVEL_WARNING');
}
_onPlayerError(self, error)
{
logError(error);
debug(error);
}
});

33
clapper_src/debug.js Normal file
View File

@@ -0,0 +1,33 @@
const { GLib, Gst } = imports.gi;
const GST_VERSION = Gst.version();
const REQ_GST_VER_MINOR = 16;
function debug(msg, levelName)
{
levelName = levelName || 'LEVEL_DEBUG';
if(msg instanceof Error) {
levelName = 'LEVEL_CRITICAL';
msg = msg.message;
}
GLib.log_structured(
'Clapper', GLib.LogLevelFlags[levelName], {
MESSAGE: msg,
SYSLOG_IDENTIFIER: 'clapper'
});
}
function gstVersionCheck()
{
if(GST_VERSION[1] >= REQ_GST_VER_MINOR)
return;
debug(
'clapper interface was designed to' +
` work with GStreamer 1.${REQ_GST_VER_MINOR} or later.` +
` Your version is ${GST_VERSION[0]}.${GST_VERSION[1]}.` +
' Please update GStreamer or expect some things to be broken.',
'LEVEL_WARNING'
);
}

View File

@@ -1,11 +1,16 @@
const { GObject, Gtk, GstPlayer } = imports.gi;
const { GObject, Gtk, Gst, GstPlayer } = imports.gi;
const { Controls } = imports.clapper_src.controls;
const Debug = imports.clapper_src.debug;
let { debug } = Debug;
var Interface = GObject.registerClass(
class ClapperInterface extends Gtk.Grid
{
_init(opts)
{
Debug.gstVersionCheck();
super._init();
let defaults = {