Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F7170793
trafficlog.py
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
trafficlog.py
View Options
# Copyright (C) 2008-2012 AG Projects. See LICENSE for details
import
datetime
# noinspection PyPackageRequirements
from
application
import
log
__all__
=
'Logger'
,
class
Logger
(
log
.
ContextualLogger
):
logger
=
log
.
get_logger
(
'msrplib'
)
def
__init__
(
self
,
prefix
=
None
,
log_traffic
=
False
):
super
(
Logger
,
self
)
.
__init__
(
logger
=
self
.
logger
)
self
.
prefix
=
prefix
or
''
self
.
log_traffic
=
log_traffic
def
apply_context
(
self
,
message
):
return
'{}{}'
.
format
(
self
.
prefix
,
message
)
if
message
!=
''
else
''
def
received_chunk
(
self
,
data
,
transport
):
if
self
.
log_traffic
:
address_line
=
'{local.host}:{local.port} <-- {remote.host}:{remote.port}'
.
format
(
local
=
transport
.
getHost
(),
remote
=
transport
.
getPeer
())
self
.
info
(
'{} {}
\n\n
{}'
.
format
(
datetime
.
datetime
.
now
(),
address_line
,
data
.
chunk_header
+
data
.
data
+
data
.
chunk_footer
))
def
sent_chunk
(
self
,
data
,
transport
):
if
self
.
log_traffic
:
address_line
=
'{local.host}:{local.port} --> {remote.host}:{remote.port}'
.
format
(
local
=
transport
.
getHost
(),
remote
=
transport
.
getPeer
())
self
.
info
(
'{} {}
\n\n
{}'
.
format
(
datetime
.
datetime
.
now
(),
address_line
,
data
.
encoded_header
+
data
.
data
+
data
.
encoded_footer
))
def
received_illegal_data
(
self
,
data
,
transport
):
if
self
.
log_traffic
:
address_line
=
'{local.host}:{local.port} <-- {remote.host}:{remote.port}'
.
format
(
local
=
transport
.
getHost
(),
remote
=
transport
.
getPeer
())
self
.
info
(
'[Bad Message] {} {}
\n\n
{}'
.
format
(
datetime
.
datetime
.
now
(),
address_line
,
data
))
File Metadata
Details
Attached
Mime Type
text/x-python
Expires
Tue, Nov 26, 5:21 AM (1 d, 7 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3413826
Default Alt Text
trafficlog.py (1 KB)
Attached To
Mode
rPYMSRPLIB python3-msrplib
Attached
Detach File
Event Timeline
Log In to Comment