Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vmj-qt
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kulya
vmj-qt
Commits
b703b4f6
Commit
b703b4f6
authored
Aug 29, 2022
by
Tijmen de Mes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added message trace/logging
parent
3fd96387
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
129 additions
and
61 deletions
+129
-61
settings.py
blink/configuration/settings.py
+1
-0
logging.py
blink/logging.py
+60
-4
preferences.py
blink/preferences.py
+7
-0
preferences.ui
resources/preferences.ui
+61
-57
No files found.
blink/configuration/settings.py
View file @
b703b4f6
...
...
@@ -53,6 +53,7 @@ class GoogleContactsSettings(SettingsGroup):
class
LogsSettingsExtension
(
LogsSettings
):
trace_sip
=
Setting
(
type
=
bool
,
default
=
False
)
trace_pjsip
=
Setting
(
type
=
bool
,
default
=
False
)
trace_messaging
=
Setting
(
type
=
bool
,
default
=
False
)
trace_msrp
=
Setting
(
type
=
bool
,
default
=
False
)
trace_xcap
=
Setting
(
type
=
bool
,
default
=
False
)
trace_notifications
=
Setting
(
type
=
bool
,
default
=
False
)
...
...
blink/logging.py
View file @
b703b4f6
...
...
@@ -7,7 +7,7 @@ from datetime import datetime
from
pprint
import
pformat
from
application
import
log
from
application.notification
import
IObserver
,
NotificationCenter
,
ObserverWeakrefProxy
from
application.notification
import
IObserver
,
NotificationCenter
,
NotificationData
,
ObserverWeakrefProxy
from
application.python.queue
import
EventQueue
from
application.python
import
Null
from
application.python.types
import
Singleton
...
...
@@ -19,7 +19,7 @@ from sipsimple.configuration.settings import SIPSimpleSettings
from
blink.resources
import
ApplicationData
__all__
=
[
'LogManager'
]
__all__
=
[
'LogManager'
,
'MessagingTrace'
]
@
implementer
(
IObserver
)
...
...
@@ -78,6 +78,7 @@ class LogManager(object, metaclass=Singleton):
self
.
pid
=
os
.
getpid
()
self
.
msrp_level
=
log
.
level
.
INFO
self
.
siptrace_file
=
Null
self
.
massagestrace_file
=
Null
self
.
msrptrace_file
=
Null
self
.
pjsiptrace_file
=
Null
self
.
notifications_file
=
Null
...
...
@@ -93,6 +94,8 @@ class LogManager(object, metaclass=Singleton):
notification_center
.
add_observer
(
self
)
if
settings
.
logs
.
trace_sip
:
self
.
siptrace_file
=
LogFile
(
os
.
path
.
join
(
ApplicationData
.
directory
,
'logs'
,
'sip_trace.txt'
))
if
settings
.
logs
.
trace_messaging
:
self
.
messagingtrace_file
=
LogFile
(
os
.
path
.
join
(
ApplicationData
.
directory
,
'logs'
,
'messaging_trace.txt'
))
if
settings
.
logs
.
trace_msrp
:
self
.
msrptrace_file
=
LogFile
(
os
.
path
.
join
(
ApplicationData
.
directory
,
'logs'
,
'msrp_trace.txt'
))
if
settings
.
logs
.
trace_pjsip
:
...
...
@@ -119,6 +122,7 @@ class LogManager(object, metaclass=Singleton):
self
.
event_queue
=
Null
self
.
siptrace_file
=
Null
self
.
massagestrace_file
=
Null
self
.
msrptrace_file
=
Null
self
.
pjsiptrace_file
=
Null
self
.
notifications_file
=
Null
...
...
@@ -135,7 +139,7 @@ class LogManager(object, metaclass=Singleton):
handler
(
notification
)
settings
=
SIPSimpleSettings
()
if
notification
.
name
not
in
(
'SIPEngineLog'
,
'SIPEngineSIPTrace'
)
and
settings
.
logs
.
trace_notifications
:
if
notification
.
name
not
in
(
'SIPEngineLog'
,
'SIPEngineSIPTrace'
,
'MessagingLog'
)
and
settings
.
logs
.
trace_notifications
:
message
=
'Notification name=
%
s sender=
%
s data=
%
s'
%
(
notification
.
name
,
notification
.
sender
,
pformat
(
notification
.
data
))
try
:
self
.
notifications_file
.
write
(
'
%
s [
%
s
%
d]:
%
s
\n
'
%
(
datetime
.
now
(),
self
.
name
,
self
.
pid
,
message
))
...
...
@@ -148,6 +152,8 @@ class LogManager(object, metaclass=Singleton):
if
notification
.
sender
is
settings
:
if
'logs.trace_sip'
in
notification
.
data
.
modified
:
self
.
siptrace_file
=
LogFile
(
os
.
path
.
join
(
ApplicationData
.
directory
,
'logs'
,
'sip_trace.txt'
))
if
settings
.
logs
.
trace_sip
else
Null
if
'logs.trace_messaging'
in
notification
.
data
.
modified
:
self
.
messagingtrace_file
=
LogFile
(
os
.
path
.
join
(
ApplicationData
.
directory
,
'logs'
,
'messaging_trace.txt'
))
if
settings
.
logs
.
trace_messaging
else
Null
if
'logs.trace_msrp'
in
notification
.
data
.
modified
:
self
.
msrptrace_file
=
LogFile
(
os
.
path
.
join
(
ApplicationData
.
directory
,
'logs'
,
'msrp_trace.txt'
))
if
settings
.
logs
.
trace_msrp
else
Null
if
'logs.trace_pjsip'
in
notification
.
data
.
modified
:
...
...
@@ -215,6 +221,17 @@ class LogManager(object, metaclass=Singleton):
except
Exception
:
pass
def
_LH_MessagingTrace
(
self
,
notification
):
settings
=
SIPSimpleSettings
()
if
not
settings
.
logs
.
trace_messaging
:
return
message
=
"(
%(level)
s)
%(message)
s"
%
notification
.
data
.
__dict__
try
:
self
.
messagingtrace_file
.
write
(
'
%
s [
%
s
%
d]
%
s
\n
'
%
(
notification
.
datetime
,
self
.
name
,
self
.
pid
,
message
))
self
.
messagingtrace_file
.
flush
()
except
Exception
:
pass
def
_LH_MSRPTransportTrace
(
self
,
notification
):
settings
=
SIPSimpleSettings
()
if
not
settings
.
logs
.
trace_msrp
:
...
...
@@ -412,3 +429,42 @@ class LogManager(object, metaclass=Singleton):
message
=
(
"
%
s XCAP manager client did not initialize:
%
s"
%
(
notification
.
datetime
,
notification
.
data
.
error
))
self
.
log_xcap
(
notification
,
message
)
class
MessagingTrace
(
object
,
metaclass
=
Singleton
):
@
classmethod
def
debug
(
cls
,
message
,
*
args
,
**
kw
):
cls
.
_log
(
'DEBUG'
,
message
,
*
args
,
**
kw
)
@
classmethod
def
info
(
cls
,
message
,
*
args
,
**
kw
):
cls
.
_log
(
'INFO'
,
message
,
*
args
,
**
kw
)
@
classmethod
def
warning
(
cls
,
message
,
*
args
,
**
kw
):
cls
.
_log
(
'WARNING'
,
message
,
*
args
,
**
kw
)
warn
=
warning
@
classmethod
def
error
(
cls
,
message
,
*
args
,
**
kw
):
cls
.
_log
(
'ERROR'
,
message
,
*
args
,
**
kw
)
@
classmethod
def
exception
(
cls
,
message
=
''
,
*
args
,
**
kw
):
cls
.
_log
(
'EXCEPTION'
,
message
,
*
args
,
**
kw
)
@
classmethod
def
critical
(
cls
,
message
,
*
args
,
**
kw
):
cls
.
_log
(
'CRITICAL'
,
message
,
*
args
,
**
kw
)
fatal
=
critical
@
classmethod
def
_log
(
cls
,
level
,
message
):
try
:
level
=
getattr
(
log
.
level
,
level
)
except
AttributeError
:
return
data
=
NotificationData
(
level
=
level
,
message
=
message
)
notification_center
=
NotificationCenter
()
notification_center
.
post_notification
(
'MessagingTrace'
,
data
=
data
)
blink/preferences.py
View file @
b703b4f6
...
...
@@ -317,6 +317,7 @@ class PreferencesWindow(base_class, ui_class, metaclass=QSingleton):
# File logging
self
.
trace_sip_button
.
clicked
.
connect
(
self
.
_SH_TraceSIPButtonClicked
)
self
.
trace_messaging_button
.
clicked
.
connect
(
self
.
_SH_TraceMessagingButtonClicked
)
self
.
trace_msrp_button
.
clicked
.
connect
(
self
.
_SH_TraceMSRPButtonClicked
)
self
.
trace_xcap_button
.
clicked
.
connect
(
self
.
_SH_TraceXCAPButtonClicked
)
self
.
trace_notifications_button
.
clicked
.
connect
(
self
.
_SH_TraceNotificationsButtonClicked
)
...
...
@@ -736,6 +737,7 @@ class PreferencesWindow(base_class, ui_class, metaclass=QSingleton):
# File logging settings
self
.
trace_sip_button
.
setChecked
(
settings
.
logs
.
trace_sip
)
self
.
trace_messaging_button
.
setChecked
(
settings
.
logs
.
trace_messaging
)
self
.
trace_msrp_button
.
setChecked
(
settings
.
logs
.
trace_msrp
)
self
.
trace_xcap_button
.
setChecked
(
settings
.
logs
.
trace_xcap
)
self
.
trace_notifications_button
.
setChecked
(
settings
.
logs
.
trace_notifications
)
...
...
@@ -1695,6 +1697,11 @@ class PreferencesWindow(base_class, ui_class, metaclass=QSingleton):
settings
.
logs
.
trace_sip
=
checked
settings
.
save
()
def
_SH_TraceMessagingButtonClicked
(
self
,
checked
):
settings
=
SIPSimpleSettings
()
settings
.
logs
.
trace_messaging
=
checked
settings
.
save
()
def
_SH_TraceMSRPButtonClicked
(
self
,
checked
):
settings
=
SIPSimpleSettings
()
settings
.
logs
.
trace_msrp
=
checked
...
...
resources/preferences.ui
View file @
b703b4f6
...
...
@@ -2980,68 +2980,42 @@
</property>
</widget>
</item>
<item
row=
"1"
column=
"0"
colspan=
"5"
>
<item
row=
"1"
column=
"0"
>
<widget
class=
"QCheckBox"
name=
"trace_messaging_button"
>
<property
name=
"text"
>
<string>
Trace SIP Messaging and PGP Encryption
</string>
</property>
</widget>
</item>
<item
row=
"2"
column=
"0"
colspan=
"5"
>
<widget
class=
"QCheckBox"
name=
"trace_msrp_button"
>
<property
name=
"text"
>
<string>
Trace MSRP (used for chat, file transfer and screen sharing)
</string>
</property>
</widget>
</item>
<item
row=
"
2
"
column=
"0"
colspan=
"5"
>
<item
row=
"
3
"
column=
"0"
colspan=
"5"
>
<widget
class=
"QCheckBox"
name=
"trace_xcap_button"
>
<property
name=
"text"
>
<string>
Trace XCAP (used by presence and for storing contacts)
</string>
</property>
</widget>
</item>
<item
row=
"
3"
column=
"0"
colspan=
"5
"
>
<item
row=
"
4"
column=
"0
"
>
<widget
class=
"QCheckBox"
name=
"trace_notifications_button"
>
<property
name=
"text"
>
<string>
Trace Notifications
</string>
</property>
</widget>
</item>
<item
row=
"9"
column=
"0"
colspan=
"5"
>
<spacer
name=
"file_logging_spacer_2"
>
<property
name=
"orientation"
>
<enum>
Qt::Vertical
</enum>
</property>
<property
name=
"sizeHint"
stdset=
"0"
>
<size>
<width>
20
</width>
<height>
40
</height>
</size>
</property>
</spacer>
</item>
<item
row=
"4"
column=
"4"
>
<spacer
name=
"trace_library_spacer_2"
>
<property
name=
"orientation"
>
<enum>
Qt::Horizontal
</enum>
</property>
<property
name=
"sizeHint"
stdset=
"0"
>
<size>
<width>
40
</width>
<height>
20
</height>
</size>
</property>
</spacer>
</item>
<item
row=
"4"
column=
"3"
>
<widget
class=
"QSpinBox"
name=
"pjsip_trace_level"
>
<property
name=
"maximum"
>
<number>
5
</number>
</property>
</widget>
</item>
<item
row=
"4"
column=
"2"
>
<widget
class=
"QLabel"
name=
"level_label"
>
<item
row=
"5"
column=
"0"
>
<widget
class=
"QCheckBox"
name=
"trace_pjsip_button"
>
<property
name=
"text"
>
<string>
Level:
</string>
<string>
Trace Core Library
</string>
</property>
</widget>
</item>
<item
row=
"
4
"
column=
"1"
>
<item
row=
"
5
"
column=
"1"
>
<spacer
name=
"trace_library_spacer_1"
>
<property
name=
"orientation"
>
<enum>
Qt::Horizontal
</enum>
...
...
@@ -3057,28 +3031,34 @@
</property>
</spacer>
</item>
<item
row=
"
4"
column=
"0
"
>
<widget
class=
"Q
CheckBox"
name=
"trace_pjsip_button
"
>
<item
row=
"
5"
column=
"2
"
>
<widget
class=
"Q
Label"
name=
"level_label
"
>
<property
name=
"text"
>
<string>
Trace Core Library
</string>
<string>
Level:
</string>
</property>
</widget>
</item>
<item
row=
"
6"
column=
"0
"
>
<widget
class=
"Q
PushButton"
name=
"clear_log_files_button
"
>
<property
name=
"
text
"
>
<
string>
Clear log files
</string
>
<item
row=
"
5"
column=
"3
"
>
<widget
class=
"Q
SpinBox"
name=
"pjsip_trace_level
"
>
<property
name=
"
maximum
"
>
<
number>
5
</number
>
</property>
</widget>
</item>
<item
row=
"
6"
column=
"2"
colspan=
"3
"
>
<
widget
class=
"QLabel"
name=
"log_files_size_label
"
>
<property
name=
"
text
"
>
<
string>
There are currently 0Mb of log files
</string
>
<item
row=
"
5"
column=
"4
"
>
<
spacer
name=
"trace_library_spacer_2
"
>
<property
name=
"
orientation
"
>
<
enum>
Qt::Horizontal
</enum
>
</property>
</widget>
<property
name=
"sizeHint"
stdset=
"0"
>
<size>
<width>
40
</width>
<height>
20
</height>
</size>
</property>
</spacer>
</item>
<item
row=
"
5"
column=
"0"
colspan=
"5
"
>
<item
row=
"
6"
column=
"0
"
>
<spacer
name=
"file_logging_spacer_1"
>
<property
name=
"orientation"
>
<enum>
Qt::Vertical
</enum>
...
...
@@ -3094,7 +3074,14 @@
</property>
</spacer>
</item>
<item
row=
"6"
column=
"1"
>
<item
row=
"7"
column=
"0"
>
<widget
class=
"QPushButton"
name=
"clear_log_files_button"
>
<property
name=
"text"
>
<string>
Clear log files
</string>
</property>
</widget>
</item>
<item
row=
"7"
column=
"1"
>
<spacer
name=
"clear_log_files_spacer"
>
<property
name=
"orientation"
>
<enum>
Qt::Horizontal
</enum>
...
...
@@ -3110,6 +3097,26 @@
</property>
</spacer>
</item>
<item
row=
"7"
column=
"2"
colspan=
"3"
>
<widget
class=
"QLabel"
name=
"log_files_size_label"
>
<property
name=
"text"
>
<string>
There are currently 0Mb of log files
</string>
</property>
</widget>
</item>
<item
row=
"8"
column=
"0"
>
<spacer
name=
"file_logging_spacer_2"
>
<property
name=
"orientation"
>
<enum>
Qt::Vertical
</enum>
</property>
<property
name=
"sizeHint"
stdset=
"0"
>
<size>
<width>
20
</width>
<height>
40
</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
...
...
@@ -3961,10 +3968,7 @@
<tabstop>
trace_sip_button
</tabstop>
<tabstop>
trace_msrp_button
</tabstop>
<tabstop>
trace_xcap_button
</tabstop>
<tabstop>
trace_notifications_button
</tabstop>
<tabstop>
trace_pjsip_button
</tabstop>
<tabstop>
pjsip_trace_level
</tabstop>
<tabstop>
clear_log_files_button
</tabstop>
<tabstop>
enable_udp_button
</tabstop>
<tabstop>
enable_tcp_button
</tabstop>
<tabstop>
enable_tls_button
</tabstop>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment