Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neoppod
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ivan Tyagov
neoppod
Commits
24b1d024
Commit
24b1d024
authored
Jun 09, 2015
by
Julien Muchembled
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
logger: drop payload of big packets in unit tests
parent
51c4f647
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
4 deletions
+11
-4
neo/lib/logger.py
neo/lib/logger.py
+10
-3
neo/tests/__init__.py
neo/tests/__init__.py
+1
-1
No files found.
neo/lib/logger.py
View file @
24b1d024
...
@@ -137,8 +137,9 @@ class NEOLogger(Logger):
...
@@ -137,8 +137,9 @@ class NEOLogger(Logger):
return
return
raise
raise
def
backlog
(
self
,
max_size
=
1
<<
24
):
def
backlog
(
self
,
max_size
=
1
<<
24
,
max_packet
=
None
):
with
self
:
with
self
:
self
.
_max_packet
=
max_packet
self
.
_max_size
=
max_size
self
.
_max_size
=
max_size
if
max_size
is
None
:
if
max_size
is
None
:
self
.
flush
()
self
.
flush
()
...
@@ -219,8 +220,11 @@ class NEOLogger(Logger):
...
@@ -219,8 +220,11 @@ class NEOLogger(Logger):
ip
,
port
=
r
.
addr
ip
,
port
=
r
.
addr
peer
=
'%s %s (%s:%u)'
%
(
'>'
if
r
.
outgoing
else
'<'
,
peer
=
'%s %s (%s:%u)'
%
(
'>'
if
r
.
outgoing
else
'<'
,
uuid_str
(
r
.
uuid
),
ip
,
port
)
uuid_str
(
r
.
uuid
),
ip
,
port
)
msg
=
r
.
msg
if
msg
is
not
None
:
msg
=
buffer
(
msg
)
self
.
_db
.
execute
(
"INSERT INTO packet VALUES (NULL,?,?,?,?,?,?)"
,
self
.
_db
.
execute
(
"INSERT INTO packet VALUES (NULL,?,?,?,?,?,?)"
,
(
r
.
created
,
r
.
_name
,
r
.
msg_id
,
r
.
code
,
peer
,
buffer
(
r
.
msg
)
))
(
r
.
created
,
r
.
_name
,
r
.
msg_id
,
r
.
code
,
peer
,
msg
))
else
:
else
:
pathname
=
os
.
path
.
relpath
(
r
.
pathname
,
*
neo
.
__path__
)
pathname
=
os
.
path
.
relpath
(
r
.
pathname
,
*
neo
.
__path__
)
self
.
_db
.
execute
(
"INSERT INTO log VALUES (NULL,?,?,?,?,?,?)"
,
self
.
_db
.
execute
(
"INSERT INTO log VALUES (NULL,?,?,?,?,?,?)"
,
...
@@ -260,6 +264,9 @@ class NEOLogger(Logger):
...
@@ -260,6 +264,9 @@ class NEOLogger(Logger):
def
packet
(
self
,
connection
,
packet
,
outgoing
):
def
packet
(
self
,
connection
,
packet
,
outgoing
):
if
self
.
_db
is
not
None
:
if
self
.
_db
is
not
None
:
body
=
packet
.
_body
if
self
.
_max_packet
and
self
.
_max_packet
<
len
(
body
):
body
=
None
self
.
_queue
(
PacketRecord
(
self
.
_queue
(
PacketRecord
(
created
=
time
(),
created
=
time
(),
msg_id
=
packet
.
_id
,
msg_id
=
packet
.
_id
,
...
@@ -267,7 +274,7 @@ class NEOLogger(Logger):
...
@@ -267,7 +274,7 @@ class NEOLogger(Logger):
outgoing
=
outgoing
,
outgoing
=
outgoing
,
uuid
=
connection
.
getUUID
(),
uuid
=
connection
.
getUUID
(),
addr
=
connection
.
getAddress
(),
addr
=
connection
.
getAddress
(),
msg
=
packet
.
_
body
))
msg
=
body
))
logging
=
NEOLogger
()
logging
=
NEOLogger
()
...
...
neo/tests/__init__.py
View file @
24b1d024
...
@@ -67,7 +67,7 @@ IP_VERSION_FORMAT_DICT = {
...
@@ -67,7 +67,7 @@ IP_VERSION_FORMAT_DICT = {
ADDRESS_TYPE
=
socket
.
AF_INET
ADDRESS_TYPE
=
socket
.
AF_INET
logging
.
default_root_handler
.
handle
=
lambda
record
:
None
logging
.
default_root_handler
.
handle
=
lambda
record
:
None
logging
.
backlog
(
None
)
logging
.
backlog
(
None
,
1
<<
20
)
debug
.
register
()
debug
.
register
()
# prevent "signal only works in main thread" errors in subprocesses
# prevent "signal only works in main thread" errors in subprocesses
...
...
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