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
Xavier Thompson
neoppod
Commits
366d595a
Commit
366d595a
authored
Jul 16, 2012
by
Julien Muchembled
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
neolog: new --from option to show more recent records
parent
1d8a0dbe
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
6 deletions
+21
-6
neo/scripts/neolog.py
neo/scripts/neolog.py
+21
-6
No files found.
neo/scripts/neolog.py
View file @
366d595a
...
@@ -27,21 +27,29 @@ class Log(object):
...
@@ -27,21 +27,29 @@ class Log(object):
_log_id
=
_packet_id
=
-
1
_log_id
=
_packet_id
=
-
1
_protocol_date
=
None
_protocol_date
=
None
def
__init__
(
self
,
db_path
,
decode_all
,
date_format
):
def
__init__
(
self
,
db_path
,
decode_all
=
False
,
date_format
=
None
,
filter_from
=
None
):
self
.
_date_format
=
'%F %T'
if
date_format
is
None
else
date_format
self
.
_date_format
=
'%F %T'
if
date_format
is
None
else
date_format
self
.
_decode_all
=
decode_all
self
.
_decode_all
=
decode_all
self
.
_default_name
=
os
.
path
.
splitext
(
os
.
path
.
basename
(
db_path
))[
0
]
self
.
_default_name
=
os
.
path
.
splitext
(
os
.
path
.
basename
(
db_path
))[
0
]
self
.
_db
=
sqlite3
.
connect
(
db_path
)
self
.
_db
=
sqlite3
.
connect
(
db_path
)
self
.
_filter_from
=
filter_from
def
__iter__
(
self
):
def
__iter__
(
self
):
db
=
self
.
_db
db
=
self
.
_db
try
:
try
:
db
.
execute
(
"BEGIN"
)
db
.
execute
(
"BEGIN"
)
yield
yield
nl
=
db
.
execute
(
"SELECT * FROM log WHERE id>?"
,
nl
=
"SELECT * FROM log WHERE id>?"
(
self
.
_log_id
,))
np
=
"SELECT * FROM packet WHERE id>?"
np
=
db
.
execute
(
"SELECT * FROM packet WHERE id>?"
,
date
=
self
.
_filter_from
(
self
.
_packet_id
,))
if
date
:
self
.
_filter_from
date
=
" AND date>=%f"
%
date
nl
+=
date
np
+=
date
nl
=
db
.
execute
(
nl
,
(
self
.
_log_id
,))
np
=
db
.
execute
(
np
,
(
self
.
_packet_id
,))
try
:
try
:
p
=
np
.
next
()
p
=
np
.
next
()
self
.
_reload
(
p
[
1
])
self
.
_reload
(
p
[
1
])
...
@@ -172,12 +180,19 @@ def main():
...
@@ -172,12 +180,19 @@ def main():
parser
.
add_option
(
'-s'
,
'--sleep-interval'
,
type
=
"float"
,
default
=
1
,
parser
.
add_option
(
'-s'
,
'--sleep-interval'
,
type
=
"float"
,
default
=
1
,
help
=
'with -f, sleep for approximately N seconds (default 1.0)'
help
=
'with -f, sleep for approximately N seconds (default 1.0)'
' between iterations'
,
metavar
=
'N'
)
' between iterations'
,
metavar
=
'N'
)
parser
.
add_option
(
'--from'
,
dest
=
'filter_from'
,
type
=
"float"
,
help
=
'show records more recent that timestamp N if N > 0,'
' or now+N if N < 0'
,
metavar
=
'N'
)
options
,
args
=
parser
.
parse_args
()
options
,
args
=
parser
.
parse_args
()
if
options
.
sleep_interval
<=
0
:
if
options
.
sleep_interval
<=
0
:
parser
.
error
(
"sleep_interval must be positive"
)
parser
.
error
(
"sleep_interval must be positive"
)
if
not
args
:
if
not
args
:
parser
.
error
(
"no log specified"
)
parser
.
error
(
"no log specified"
)
log_list
=
[
Log
(
db_path
,
options
.
all
,
options
.
date
)
for
db_path
in
args
]
filter_from
=
options
.
filter_from
if
filter_from
and
filter_from
<
0
:
filter_from
+=
time
.
time
()
log_list
=
[
Log
(
db_path
,
options
.
all
,
options
.
date
,
filter_from
)
for
db_path
in
args
]
if
options
.
follow
:
if
options
.
follow
:
try
:
try
:
pid_list
=
options
.
flush
or
()
pid_list
=
options
.
flush
or
()
...
...
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