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
Levin Zimmermann
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):
return
raise
def
backlog
(
self
,
max_size
=
1
<<
24
):
def
backlog
(
self
,
max_size
=
1
<<
24
,
max_packet
=
None
):
with
self
:
self
.
_max_packet
=
max_packet
self
.
_max_size
=
max_size
if
max_size
is
None
:
self
.
flush
()
...
...
@@ -219,8 +220,11 @@ class NEOLogger(Logger):
ip
,
port
=
r
.
addr
peer
=
'%s %s (%s:%u)'
%
(
'>'
if
r
.
outgoing
else
'<'
,
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,?,?,?,?,?,?)"
,
(
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
:
pathname
=
os
.
path
.
relpath
(
r
.
pathname
,
*
neo
.
__path__
)
self
.
_db
.
execute
(
"INSERT INTO log VALUES (NULL,?,?,?,?,?,?)"
,
...
...
@@ -260,6 +264,9 @@ class NEOLogger(Logger):
def
packet
(
self
,
connection
,
packet
,
outgoing
):
if
self
.
_db
is
not
None
:
body
=
packet
.
_body
if
self
.
_max_packet
and
self
.
_max_packet
<
len
(
body
):
body
=
None
self
.
_queue
(
PacketRecord
(
created
=
time
(),
msg_id
=
packet
.
_id
,
...
...
@@ -267,7 +274,7 @@ class NEOLogger(Logger):
outgoing
=
outgoing
,
uuid
=
connection
.
getUUID
(),
addr
=
connection
.
getAddress
(),
msg
=
packet
.
_
body
))
msg
=
body
))
logging
=
NEOLogger
()
...
...
neo/tests/__init__.py
View file @
24b1d024
...
...
@@ -67,7 +67,7 @@ IP_VERSION_FORMAT_DICT = {
ADDRESS_TYPE
=
socket
.
AF_INET
logging
.
default_root_handler
.
handle
=
lambda
record
:
None
logging
.
backlog
(
None
)
logging
.
backlog
(
None
,
1
<<
20
)
debug
.
register
()
# 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