diff --git a/logs.py b/logs.py
index ab88cdc..9af2576 100644
--- a/logs.py
+++ b/logs.py
@@ -1,48 +1,13 @@
"""Render recent responses and logs."""
import calendar
-import datetime
-import html
-import logging
-import re
-import time
-import urllib.request, urllib.parse, urllib.error
import urllib.parse
from flask import render_template
-from google.cloud import ndb
-from google.cloud.logging import Client
-import humanize
-from oauth_dropins.webutil import flask_util, util
-from oauth_dropins.webutil.appengine_info import APP_ID
-import webapp2
-from oauth_dropins.webutil.flask_util import error
+from oauth_dropins.webutil import logs, util
from app import app, cache
from models import Response
-LEVELS = {
- logging.DEBUG: 'D',
- logging.INFO: 'I',
- logging.WARNING: 'W',
- logging.ERROR: 'E',
- logging.CRITICAL: 'F',
-}
-
-CACHE_TIME = datetime.timedelta(days=1)
-MAX_LOG_AGE = datetime.timedelta(days=30)
-# App Engine's launch, roughly
-MIN_START_TIME = time.mktime(datetime.datetime(2008, 4, 1).timetuple())
-
-SANITIZE_RE = re.compile(r"""
- ((?:access|api|oauth)?[ _]?
- (?:code|consumer_key|consumer_secret|nonce|secret|signature|token|verifier)
- (?:u?['"])?
- (?:=|:|\ |,\ |%3D)\ *
- (?:u?['"])?
- )
- [^ &='"]+
-""", flags=re.VERBOSE | re.IGNORECASE)
-
@app.get('/responses')
def responses():
@@ -60,166 +25,7 @@ def responses():
return render_template('responses.html', responses=responses)
-def sanitize(msg):
- """Sanitizes access tokens and Authorization headers."""
- return SANITIZE_RE.sub(r'\1...', msg)
-
-
-def url(when, key):
- """Returns the relative URL (no scheme or host) to a log page.
-
- Args:
- when: datetime
- key: ndb.Key
- """
- return 'log?start_time=%s&key=%s' % (
- calendar.timegm(when.utctimetuple()), key.urlsafe().decode())
-
-
-def maybe_link(when, key, time_class='dt-updated', link_class=''):
- """Returns an HTML snippet with a timestamp and maybe a log page link.
-
- Example:
-
-
-
-
-
- The tag is only included if the timestamp is 30 days old or less, since
- Stackdriver's basic tier doesn't store logs older than that:
- https://cloud.google.com/monitoring/accounts/tiers#logs_ingestion
- https://github.com/snarfed/bridgy/issues/767
-
- Args:
- when: datetime
- key: ndb.Key
- time_class: string, optional class value for the