mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
test that 4 occurences of log "skipping url replacement" are found
This commit is contained in:
parent
b5b35c9fc8
commit
a6dd3178b1
2 changed files with 26 additions and 0 deletions
|
|
@ -8,6 +8,8 @@ import os
|
|||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
import logging
|
||||
from logging.handlers import BufferingHandler
|
||||
|
||||
from functools import wraps
|
||||
from contextlib import contextmanager
|
||||
|
|
@ -157,3 +159,18 @@ def get_settings():
|
|||
settings['DIRECT_TEMPLATES'] = ['archives']
|
||||
settings['filenames'] = {}
|
||||
return settings
|
||||
|
||||
|
||||
class LogCountHandler(BufferingHandler):
|
||||
"""
|
||||
Capturing and counting logged messages.
|
||||
"""
|
||||
|
||||
def __init__(self, capacity=1000):
|
||||
logging.handlers.BufferingHandler.__init__(self, capacity)
|
||||
|
||||
def count_logs(self, msg=None, level=None):
|
||||
return len([l for l in self.buffer
|
||||
if (msg is None or re.match(msg, l.getMessage()))
|
||||
and (level is None or l.levelno == level)
|
||||
])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue