Skip to content

Commit 50f0e43

Browse files
committed
Add log options: log_print_output and log_print_stack
1 parent c43017d commit 50f0e43

File tree

5 files changed

+20
-3
lines changed

5 files changed

+20
-3
lines changed

io.github.mightycreak.Diffuse.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,18 @@ runtime-version: '3.38'
44
sdk: org.gnome.Sdk
55
command: diffuse
66
finish-args:
7+
- --filesystem=home
8+
- --share=ipc
79
- --socket=wayland
810
- --socket=fallback-x11
9-
- --share=ipc
10-
- --filesystem=home
1111
- --talk-name=org.freedesktop.Flatpak
1212
modules:
1313
- name: diffuse
1414
builddir: true
1515
buildsystem: meson
1616
config-opts:
17+
- -Dlog_print_output=true
18+
- -Dlog_print_stack=true
1719
- -Duse_flatpak=true
1820
sources:
1921
- type: dir

meson_options.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1+
option('log_print_output', type: 'boolean', value: false)
2+
option('log_print_stack', type: 'boolean', value: false)
13
option('use_flatpak', type: 'boolean', value: false)

src/constants.py.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,7 @@ COPYRIGHT = '''{copyright} © 2006-2019 Derrick Moser
2424
WEBSITE = 'https://mightycreak.github.io/diffuse/'
2525

2626
sysconfigdir = '@sysconfigdir@'
27+
2728
use_flatpak = @use_flatpak@
29+
log_print_output = @log_print_output@
30+
log_print_stack = @log_print_stack@

src/meson.build

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ conf.set('VERSION', meson.project_version())
1010
conf.set('localedir', join_paths(get_option('prefix'), get_option('localedir')))
1111
conf.set('pkgdatadir', pkgdatadir)
1212
conf.set('sysconfigdir', sysconfdir)
13+
conf.set('log_print_output', get_option('log_print_output'))
14+
conf.set('log_print_stack', get_option('log_print_stack'))
1315
conf.set('use_flatpak', get_option('use_flatpak'))
1416

1517
configure_file(

src/utils.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import sys
2222
import locale
2323
import subprocess
24+
import traceback
2425

2526
import gi
2627

@@ -43,12 +44,19 @@ def __init__(self, parent, type, s):
4344
def isWindows():
4445
return os.name == 'nt'
4546

47+
def _logPrintOutput(msg):
48+
if constants.log_print_output:
49+
print(msg, file=sys.stderr)
50+
if constants.log_print_stack:
51+
traceback.print_stack()
52+
4653
# convenience function to display debug messages
4754
def logDebug(s):
48-
pass #sys.stderr.write(f'{constants.APP_NAME}: {s}\n')
55+
_logPrintOutput(f'DEBUG: {s}')
4956

5057
# report error messages
5158
def logError(s):
59+
_logPrintOutput(f'ERROR: {s}')
5260
m = MessageDialog(None, Gtk.MessageType.ERROR, s)
5361
m.run()
5462
m.destroy()

0 commit comments

Comments
 (0)