ソースを参照

[enh] logging added

Adam Tauber 10 年 前
コミット
6cbd29f674
共有1 個のファイルを変更した11 個の追加1 個の削除を含む
  1. 11
    1
      searx/__init__.py

+ 11
- 1
searx/__init__.py ファイルの表示

@@ -15,9 +15,9 @@ along with searx. If not, see < http://www.gnu.org/licenses/ >.
15 15
 (C) 2013- by Adam Tauber, <asciimoo@gmail.com>
16 16
 '''
17 17
 
18
+import logging
18 19
 from os import environ
19 20
 from os.path import realpath, dirname, join, abspath
20
-from searx.https_rewrite import load_https_rules
21 21
 try:
22 22
     from yaml import load
23 23
 except:
@@ -45,7 +45,17 @@ else:
45 45
 with open(settings_path) as settings_yaml:
46 46
     settings = load(settings_yaml)
47 47
 
48
+if settings.get('server', {}).get('debug'):
49
+    logging.basicConfig(level=logging.DEBUG)
50
+else:
51
+    logging.basicConfig(level=logging.WARNING)
52
+
53
+logger = logging.getLogger('searx')
54
+
48 55
 # load https rules only if https rewrite is enabled
49 56
 if settings.get('server', {}).get('https_rewrite'):
50 57
     # loade https rules
58
+    from searx.https_rewrite import load_https_rules
51 59
     load_https_rules(https_rewrite_path)
60
+
61
+logger.info('Initialisation done')