0
|
1 import logging
|
|
2
|
|
3 DATABASE_ENGINE = "sqlite" # sqlite or mysql
|
|
4 DATABASE_NAME = "PyCrawler" # Database name
|
|
5 DATABASE_HOST = "/PyCrawler.db" # Host address of mysql server or file location of sqlite db
|
|
6 DATABASE_PORT = "" # Port number as a string. Not used with sqlite
|
|
7 DATABASE_USER = "" # Not used with sqlite
|
|
8 DATABASE_PASS = "" # Not used with sqlite
|
|
9
|
|
10 DEBUG = True # Whether or not to show DEBUG level messages
|
|
11 USE_COLORS = True # Whether or not colors should be used when outputting text
|
|
12
|
|
13 LOGGING = { # dictConfig for output stream and file logging
|
|
14 'version': 1,
|
|
15 'disable_existing_loggers': False,
|
|
16
|
|
17 'formatters': {
|
|
18 'console': {
|
|
19 'format': '[%(asctime)s] %(levelname)s::%(module)s - %(message)s',
|
|
20 },
|
|
21 'file': {
|
|
22 'format': '[%(asctime)s] %(levelname)s::(P:%(process)d T:%(thread)d)::%(module)s - %(message)s',
|
|
23 },
|
|
24 },
|
|
25
|
|
26 'handlers': {
|
|
27 'console': {
|
|
28 'class': 'ColorStreamHandler.ColorStreamHandler',
|
|
29 'formatter':'console',
|
|
30 'level': 'DEBUG',
|
|
31 'use_colors': USE_COLORS,
|
|
32 },
|
|
33 'file': {
|
|
34 'class': 'logging.handlers.TimedRotatingFileHandler',
|
|
35 'formatter':'file',
|
|
36 'level': 'INFO',
|
|
37 'when': 'midnight',
|
|
38 'filename': 'pycrawler.log',
|
|
39 'interval': 1,
|
|
40 'backupCount': 0,
|
|
41 'encoding': None,
|
|
42 'delay': False,
|
|
43 'utc': False,
|
|
44 },
|
|
45 },
|
|
46
|
|
47 'loggers': {
|
|
48 'crawler_logger': {
|
|
49 'handlers': ['console', 'file'],
|
|
50 'level': 'DEBUG' if DEBUG else 'INFO',
|
|
51 'propagate': True,
|
|
52 },
|
|
53 }
|
|
54 } |