Rework logging

This commit is contained in:
messense 2017-02-24 14:01:37 +08:00
parent bfbcdf8b86
commit 4cd3b89394
No known key found for this signature in database
GPG Key ID: BB41A8A2C716CCA9
5 changed files with 13 additions and 5 deletions

View File

@ -12,7 +12,6 @@ from sanic.config import Config
from sanic.constants import HTTP_METHODS
from sanic.exceptions import ServerError, URLBuildError, SanicException
from sanic.handlers import ErrorHandler
from sanic.log import log
from sanic.response import HTTPResponse
from sanic.router import Router
from sanic.server import serve, serve_multiple, HttpProtocol
@ -21,6 +20,9 @@ from sanic.testing import TestClient
from sanic.views import CompositionView
log = logging.getLogger(__name__)
class Sanic:
def __init__(self, name=None, router=None, error_handler=None):

View File

@ -1,4 +1,5 @@
import sys
import logging
from traceback import format_exc, extract_tb
from sanic.exceptions import (
@ -10,9 +11,10 @@ from sanic.exceptions import (
TRACEBACK_LINE_HTML,
TRACEBACK_STYLE,
TRACEBACK_WRAPPER_HTML)
from sanic.log import log
from sanic.response import text, html
log = logging.getLogger(__name__)
class ErrorHandler:
handlers = None

View File

@ -1,3 +1,4 @@
import logging
from cgi import parse_header
from collections import namedtuple
from http.cookies import SimpleCookie
@ -10,9 +11,9 @@ except ImportError:
from json import loads as json_loads
from sanic.exceptions import InvalidUsage
from sanic.log import log
log = logging.getLogger(__name__)
DEFAULT_HTTP_CONTENT_TYPE = "application/octet-stream"
# HTTP/1.1: https://www.w3.org/Protocols/rfc2616/rfc2616-sec7.html#sec7.2.1
# > If the media type remains unknown, the recipient SHOULD treat it

View File

@ -1,5 +1,6 @@
import asyncio
import os
import logging
import traceback
import warnings
from functools import partial
@ -19,11 +20,11 @@ try:
except ImportError:
async_loop = asyncio
from sanic.log import log
from sanic.request import Request
from sanic.exceptions import (
RequestTimeout, PayloadTooLarge, InvalidUsage, ServerError)
log = logging.getLogger(__name__)
current_time = None

View File

@ -1,5 +1,7 @@
from sanic.log import log
import logging
log = logging.getLogger(__name__)
HOST = '127.0.0.1'
PORT = 42101