From 1fb640c313e8d33b3967ad5f460e79231f77e09a Mon Sep 17 00:00:00 2001 From: Eli Uriegas Date: Mon, 8 May 2017 20:36:57 -0700 Subject: [PATCH 1/5] Fix camel case module --- docs/sanic/logging.md | 6 +++--- sanic/config.py | 3 ++- sanic/defaultFilter.py | 13 ------------- 3 files changed, 5 insertions(+), 17 deletions(-) delete mode 100644 sanic/defaultFilter.py diff --git a/docs/sanic/logging.md b/docs/sanic/logging.md index c38a1c55..fae8c5ad 100644 --- a/docs/sanic/logging.md +++ b/docs/sanic/logging.md @@ -85,12 +85,12 @@ By default, log_config parameter is set to use sanic.config.LOGGING dictionary f And `filters`: -- accessFilter (using sanic.defaultFilter.DefaultFilter)
+- accessFilter (using sanic.default_filter.DefaultFilter)
The filter that allows only levels in `DEBUG`, `INFO`, and `NONE(0)` -- errorFilter (using sanic.defaultFilter.DefaultFilter)
- The filter taht allows only levels in `WARNING`, `ERROR`, and `CRITICAL` +- errorFilter (using sanic.default_filter.DefaultFilter)
+ The filter that allows only levels in `WARNING`, `ERROR`, and `CRITICAL` There are two `loggers` used in sanic, and **must be defined if you want to create your own logging configuration**: diff --git a/sanic/config.py b/sanic/config.py index c12037fe..3cf8f1ec 100644 --- a/sanic/config.py +++ b/sanic/config.py @@ -1,10 +1,11 @@ -from sanic.defaultFilter import DefaultFilter import os import sys import syslog import platform import types +from sanic.default_filter import DefaultFilter + SANIC_PREFIX = 'SANIC_' _address_dict = { diff --git a/sanic/defaultFilter.py b/sanic/defaultFilter.py deleted file mode 100644 index 9e9508ec..00000000 --- a/sanic/defaultFilter.py +++ /dev/null @@ -1,13 +0,0 @@ -import logging - - -class DefaultFilter(logging.Filter): - def __init__(self, param=None): - self.param = param - - def filter(self, record): - if self.param is None: - return True - if record.levelno in self.param: - return True - return False From 3e88ec18e2928b88c5f3f102403c6685b991b902 Mon Sep 17 00:00:00 2001 From: Eli Uriegas Date: Mon, 8 May 2017 20:37:44 -0700 Subject: [PATCH 2/5] Actually add file >.> --- sanic/default_filter.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 sanic/default_filter.py diff --git a/sanic/default_filter.py b/sanic/default_filter.py new file mode 100644 index 00000000..9e9508ec --- /dev/null +++ b/sanic/default_filter.py @@ -0,0 +1,13 @@ +import logging + + +class DefaultFilter(logging.Filter): + def __init__(self, param=None): + self.param = param + + def filter(self, record): + if self.param is None: + return True + if record.levelno in self.param: + return True + return False From bfcd499cc2acda9c8bf08e790afa0eb92fbd6c5f Mon Sep 17 00:00:00 2001 From: Eli Uriegas Date: Mon, 8 May 2017 20:41:34 -0700 Subject: [PATCH 3/5] Remove default_filter module, put into logging --- docs/sanic/logging.md | 4 ++-- sanic/config.py | 2 +- sanic/default_filter.py | 13 ------------- sanic/log.py | 14 ++++++++++++++ 4 files changed, 17 insertions(+), 16 deletions(-) delete mode 100644 sanic/default_filter.py diff --git a/docs/sanic/logging.md b/docs/sanic/logging.md index fae8c5ad..e0f0c318 100644 --- a/docs/sanic/logging.md +++ b/docs/sanic/logging.md @@ -85,11 +85,11 @@ By default, log_config parameter is set to use sanic.config.LOGGING dictionary f And `filters`: -- accessFilter (using sanic.default_filter.DefaultFilter)
+- accessFilter (using sanic.logging.DefaultFilter)
The filter that allows only levels in `DEBUG`, `INFO`, and `NONE(0)` -- errorFilter (using sanic.default_filter.DefaultFilter)
+- errorFilter (using sanic.logging.DefaultFilter)
The filter that allows only levels in `WARNING`, `ERROR`, and `CRITICAL` There are two `loggers` used in sanic, and **must be defined if you want to create your own logging configuration**: diff --git a/sanic/config.py b/sanic/config.py index 3cf8f1ec..461b1a59 100644 --- a/sanic/config.py +++ b/sanic/config.py @@ -4,7 +4,7 @@ import syslog import platform import types -from sanic.default_filter import DefaultFilter +from sanic.logging import DefaultFilter SANIC_PREFIX = 'SANIC_' diff --git a/sanic/default_filter.py b/sanic/default_filter.py deleted file mode 100644 index 9e9508ec..00000000 --- a/sanic/default_filter.py +++ /dev/null @@ -1,13 +0,0 @@ -import logging - - -class DefaultFilter(logging.Filter): - def __init__(self, param=None): - self.param = param - - def filter(self, record): - if self.param is None: - return True - if record.levelno in self.param: - return True - return False diff --git a/sanic/log.py b/sanic/log.py index cce4a64f..760ad1c6 100644 --- a/sanic/log.py +++ b/sanic/log.py @@ -1,4 +1,18 @@ import logging + +class DefaultFilter(logging.Filter): + + def __init__(self, param=None): + self.param = param + + def filter(self, record): + if self.param is None: + return True + if record.levelno in self.param: + return True + return False + + log = logging.getLogger('sanic') netlog = logging.getLogger('network') From bb6de53f28dfa8a4bc5b49cb092bb2bc458f38f2 Mon Sep 17 00:00:00 2001 From: Eli Uriegas Date: Mon, 8 May 2017 20:44:19 -0700 Subject: [PATCH 4/5] Fix docs --- docs/sanic/logging.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/sanic/logging.md b/docs/sanic/logging.md index e0f0c318..be2aa9b3 100644 --- a/docs/sanic/logging.md +++ b/docs/sanic/logging.md @@ -85,11 +85,11 @@ By default, log_config parameter is set to use sanic.config.LOGGING dictionary f And `filters`: -- accessFilter (using sanic.logging.DefaultFilter)
+- accessFilter (using sanic.log.DefaultFilter)
The filter that allows only levels in `DEBUG`, `INFO`, and `NONE(0)` -- errorFilter (using sanic.logging.DefaultFilter)
+- errorFilter (using sanic.log.DefaultFilter)
The filter that allows only levels in `WARNING`, `ERROR`, and `CRITICAL` There are two `loggers` used in sanic, and **must be defined if you want to create your own logging configuration**: From ac5e1a6ebd4643066b2af593e4fe1ca80d1e7788 Mon Sep 17 00:00:00 2001 From: Eli Uriegas Date: Mon, 8 May 2017 20:47:20 -0700 Subject: [PATCH 5/5] Fix import --- sanic/config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sanic/config.py b/sanic/config.py index 461b1a59..2f2cf49b 100644 --- a/sanic/config.py +++ b/sanic/config.py @@ -4,7 +4,7 @@ import syslog import platform import types -from sanic.logging import DefaultFilter +from sanic.log import DefaultFilter SANIC_PREFIX = 'SANIC_'