forked from windelbouwman/lognplot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlogbar.py
More file actions
40 lines (28 loc) · 1013 Bytes
/
Copy pathlogbar.py
File metadata and controls
40 lines (28 loc) · 1013 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
from .axis import Axis
class LogBar:
""" Like a chart, but contains tracks of log messages.
"""
def __init__(self, db):
self.x_axis = Axis()
self.log_tracks = []
self.db = db
def has_track(self, name):
for track in self.log_tracks:
if track.name == name:
return True
return False
def add_track(self, name):
if not self.has_track(name):
self.log_tracks.append(LogTrack(self.db, name))
def clear_tracks(self):
self.log_tracks.clear()
class LogTrack:
""" A single log track, refering to a log message stream in the database. """
def __init__(self, db, name):
self._db = db
self.name = name
def query_summary(self, timespan=None):
return self._db.query_summary(self.name, timespan=timespan)
def query(self, selection_timespan, min_count):
# TODO: cache calls here?
return self._db.query(self.name, selection_timespan, min_count)