@@ -126,6 +126,17 @@ const _debugFunc = function (error, prefix = null) {
126
126
} ) ;
127
127
} ;
128
128
129
+ /**
130
+ * A special debug function for logging packet dumps with
131
+ * their contents omitted.
132
+ * @param {object } packet - A GSConnect packet payload
133
+ * @param {string } [prefix] - An optional prefix for the dump
134
+ */
135
+ // eslint-disable-next-line func-style
136
+ const _packetDebugFunc = function ( packet , prefix = null ) {
137
+ _debugFunc ( packet . type , prefix ) ;
138
+ } ;
139
+
129
140
// Swap the function out for a no-op anonymous function for speed
130
141
const settings = new Gio . Settings ( {
131
142
settings_schema : Config . GSCHEMA . lookup ( Config . APP_ID , true ) ,
@@ -138,16 +149,23 @@ settings.connect('changed::debug', (settings, key) => {
138
149
if ( settings . get_boolean ( 'debug' ) )
139
150
globalThis . debug = _debugFunc ;
140
151
else
141
- globalThis . debug = ( ) => { } ;
152
+ globalThis . debug = ( ) => { } ;
153
+
154
+ // eslint-disable-next-line func-style
155
+ const _getPacketFunc = function ( settings , debugKey , detailKey ) {
156
+ const debugEnabled = settings . get_boolean ( debugKey ) ;
157
+ const debugDetail = settings . get_boolean ( detailKey ) ;
158
+ if ( debugEnabled && ! debugDetail )
159
+ return _packetDebugFunc ;
160
+ else
161
+ return globalThis . debug ;
162
+ } ;
142
163
143
164
settings . connect ( 'changed::debug-detail' , ( settings , key ) => {
144
- globalThis . debugDetail = settings . get_boolean ( key ) ;
165
+ globalThis . debugPacket = _getPacketFunc ( settings , 'debug' , key ) ;
145
166
} ) ;
146
167
147
- if ( settings . get_boolean ( 'debug-detail' ) )
148
- globalThis . debugDetail = true ;
149
- else
150
- globalThis . debugDetail = false ;
168
+ globalThis . debugPacket = _getPacketFunc ( settings , 'debug' , 'debug-detail' ) ;
151
169
152
170
/**
153
171
* A simple (for now) pre-comparison sanitizer for phone numbers
0 commit comments