# -*- coding: utf-8 -*-
from . import BASE_DIR

# TODO: if you want to choose another directory, change LOG_DIR path.
LOG_DIR = BASE_DIR + '/log/'


APP_KEY = 'app'
INBOUND_KEY = 'inbound'
OUTBOUND_KEY = 'outbound'

LOGGING = {
    'version': 1,
    'disable_existing_loggers': True,
    'formatters': {
        'verbose': {
            'format': '%(levelname)s %(asctime)s %(module)s %(process)d %(thread)d %(message)s'
        },
        'simple': {
            'format': '%(levelname)s %(message)s'
        },
    },
    'handlers': {
        'app': {
            'level': 'INFO',
            'class': 'logging.handlers.RotatingFileHandler',
            'formatter': 'verbose',
            'filename': LOG_DIR + 'application.log'
        },
        'inbound': {
            'level': 'DEBUG',
            'class': 'logging.handlers.RotatingFileHandler',
            'formatter': 'verbose',
            'filename': LOG_DIR + 'inbound.log'
        },
        'outbound': {
            'level': 'DEBUG',
            'class': 'logging.handlers.RotatingFileHandler',
            'formatter': 'verbose',
            'filename': LOG_DIR + 'outbound.log'
        },
        'console': {
            'level': 'DEBUG',
            'class': 'logging.StreamHandler',
            'formatter': 'simple'
        }
    },
    'loggers': {
        APP_KEY: {
            # 'handlers': ['app'],
            'handlers': ['app', 'console'],
            'level': 'INFO',
            'propagate': False,
        },
        INBOUND_KEY: {
            'handlers': ['inbound'],
            'level': 'DEBUG',
            'backupCount': 4,
            'formatter': 'verbose',
        },
        OUTBOUND_KEY: {
            'handlers': ['outbound'],
            'level': 'DEBUG',
            'backupCount': 4,
            'formatter': 'verbose',
        }
    }
}

CHERRYPY_ACCESS_LOG = LOG_DIR + 'access.log'
CHERRYPY_ERROR_LOG = LOG_DIR + 'error.log'

@@ -347,32 +347,35 @@
  '%25(
-levelna
+ascti
 me)s 
+%5B
 %25(
-ascti
+levelna
 me)s
- 
+%5D %5B
 %25(mo
@@ -380,16 +380,17 @@
 module)s
+%5D
  %25(proce
@@ -421,32 +421,141 @@
 e)s'%0A        %7D,%0A
+        'normal' : %7B%0A            'format': '%25(asctime)s %5B%25(levelname)s%5D %5B%25(module)s%5D %25(message)s'%0A        %7D,%0A
         'simple'
@@ -581,16 +581,17 @@
 rmat': '
+%5B
 %25(leveln
@@ -595,16 +595,17 @@
 elname)s
+%5D
  %25(messa
@@ -771,39 +771,38 @@
   'formatter': '
-verbose
+normal
 ',%0A            '
@@ -981,39 +981,38 @@
   'formatter': '
-verbose
+normal
 ',%0A            '
@@ -1188,39 +1188,38 @@
   'formatter': '
-verbose
+normal
 ',%0A            '

change log format