def active_sessions(r, request): now = utctime() cutoff = float(request.GET.get('cutoff', '5')) then = now - cutoff return r.table('log_entries').filter( lambda e: (e['message'] == 'session start') | (e['message'] == 'session end') ).run()
def __init__(self, user=None, created=None, timestamp=None, message=None, level='INFO', logger='default', meta=None): self.user = user if not timestamp: if created: self.timestamp = mkutime(created) else: self.timestamp = utctime() else: self.timestamp = timestamp if not created: self.created = datetime.datetime.utcfromtimestamp(self.timestamp) else: self.created = created self.message = message self.id = str(uuid.uuid1()) self.level = level self.logger = logger self.meta = meta or {}