@access_log_level(logging.WARN)
def log_view(request):
 if (not request.user.is_superuser):
  return HttpResponse(_('You must be a superuser.'))
 hostname = socket.gethostname()
 l = logging.getLogger()
 for h in l.handlers:
  if isinstance(h, desktop.log.log_buffer.FixedBufferHandler):
   return render('logs.mako', request, dict(log=[l for l in h.buf], query=request.GET.get('q', ''), hostname=hostname))
 return render('logs.mako', request, dict(log=[_('No logs found!')], query='', hostname=hostname))

@ access_log_level ( logging . WARN ) def log_view ( request ) : if ( not request . user . is_superuser ) : return HttpResponse ( _ ( 'You must be a superuser.' ) ) hostname = socket . gethostname ( ) l = logging . getLogger ( ) for h in l . handlers : if isinstance ( h , desktop . log . log_buffer . FixedBufferHandler ) : return render ( 'logs.mako' , request , dict ( log = [ l for l in h . buf ] , query = request . GET . get ( 'q' , '' ) , hostname = hostname ) ) return render ( 'logs.mako' , request , dict ( log = [ _ ( 'No logs found!' ) ] , query = '' , hostname = hostname ) )
we have a log handler that retains the last x characters of log messages .