Add log options: log_print_output and log_print_stack
This commit is contained in:
parent
c43017d6db
commit
50f0e431ee
|
@ -4,16 +4,18 @@ runtime-version: '3.38'
|
||||||
sdk: org.gnome.Sdk
|
sdk: org.gnome.Sdk
|
||||||
command: diffuse
|
command: diffuse
|
||||||
finish-args:
|
finish-args:
|
||||||
|
- --filesystem=home
|
||||||
|
- --share=ipc
|
||||||
- --socket=wayland
|
- --socket=wayland
|
||||||
- --socket=fallback-x11
|
- --socket=fallback-x11
|
||||||
- --share=ipc
|
|
||||||
- --filesystem=home
|
|
||||||
- --talk-name=org.freedesktop.Flatpak
|
- --talk-name=org.freedesktop.Flatpak
|
||||||
modules:
|
modules:
|
||||||
- name: diffuse
|
- name: diffuse
|
||||||
builddir: true
|
builddir: true
|
||||||
buildsystem: meson
|
buildsystem: meson
|
||||||
config-opts:
|
config-opts:
|
||||||
|
- -Dlog_print_output=true
|
||||||
|
- -Dlog_print_stack=true
|
||||||
- -Duse_flatpak=true
|
- -Duse_flatpak=true
|
||||||
sources:
|
sources:
|
||||||
- type: dir
|
- type: dir
|
||||||
|
|
|
@ -1 +1,3 @@
|
||||||
|
option('log_print_output', type: 'boolean', value: false)
|
||||||
|
option('log_print_stack', type: 'boolean', value: false)
|
||||||
option('use_flatpak', type: 'boolean', value: false)
|
option('use_flatpak', type: 'boolean', value: false)
|
||||||
|
|
|
@ -24,4 +24,7 @@ COPYRIGHT = '''{copyright} © 2006-2019 Derrick Moser
|
||||||
WEBSITE = 'https://mightycreak.github.io/diffuse/'
|
WEBSITE = 'https://mightycreak.github.io/diffuse/'
|
||||||
|
|
||||||
sysconfigdir = '@sysconfigdir@'
|
sysconfigdir = '@sysconfigdir@'
|
||||||
|
|
||||||
use_flatpak = @use_flatpak@
|
use_flatpak = @use_flatpak@
|
||||||
|
log_print_output = @log_print_output@
|
||||||
|
log_print_stack = @log_print_stack@
|
||||||
|
|
|
@ -10,6 +10,8 @@ conf.set('VERSION', meson.project_version())
|
||||||
conf.set('localedir', join_paths(get_option('prefix'), get_option('localedir')))
|
conf.set('localedir', join_paths(get_option('prefix'), get_option('localedir')))
|
||||||
conf.set('pkgdatadir', pkgdatadir)
|
conf.set('pkgdatadir', pkgdatadir)
|
||||||
conf.set('sysconfigdir', sysconfdir)
|
conf.set('sysconfigdir', sysconfdir)
|
||||||
|
conf.set('log_print_output', get_option('log_print_output'))
|
||||||
|
conf.set('log_print_stack', get_option('log_print_stack'))
|
||||||
conf.set('use_flatpak', get_option('use_flatpak'))
|
conf.set('use_flatpak', get_option('use_flatpak'))
|
||||||
|
|
||||||
configure_file(
|
configure_file(
|
||||||
|
|
10
src/utils.py
10
src/utils.py
|
@ -21,6 +21,7 @@ import os
|
||||||
import sys
|
import sys
|
||||||
import locale
|
import locale
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import traceback
|
||||||
|
|
||||||
import gi
|
import gi
|
||||||
|
|
||||||
|
@ -43,12 +44,19 @@ class MessageDialog(Gtk.MessageDialog):
|
||||||
def isWindows():
|
def isWindows():
|
||||||
return os.name == 'nt'
|
return os.name == 'nt'
|
||||||
|
|
||||||
|
def _logPrintOutput(msg):
|
||||||
|
if constants.log_print_output:
|
||||||
|
print(msg, file=sys.stderr)
|
||||||
|
if constants.log_print_stack:
|
||||||
|
traceback.print_stack()
|
||||||
|
|
||||||
# convenience function to display debug messages
|
# convenience function to display debug messages
|
||||||
def logDebug(s):
|
def logDebug(s):
|
||||||
pass #sys.stderr.write(f'{constants.APP_NAME}: {s}\n')
|
_logPrintOutput(f'DEBUG: {s}')
|
||||||
|
|
||||||
# report error messages
|
# report error messages
|
||||||
def logError(s):
|
def logError(s):
|
||||||
|
_logPrintOutput(f'ERROR: {s}')
|
||||||
m = MessageDialog(None, Gtk.MessageType.ERROR, s)
|
m = MessageDialog(None, Gtk.MessageType.ERROR, s)
|
||||||
m.run()
|
m.run()
|
||||||
m.destroy()
|
m.destroy()
|
||||||
|
|
Loading…
Reference in New Issue