# Path: library/config/database.py

# 
# Path: library/utils/time_conv.py
# def timestamp2datetime(stamp=0 , fmt='%Y-%m-%d %H:%M:%S'):
#     '''
#     将时间戳转化指定格式的时间
#     :parm :
#         stamp：时间戳，如果没有指定表示当前时间，如果不是数字型，返回错误
#         smt：转化时间格式
#     :return :
#         转化后的时间
#     '''
# 
#     try :
#         stamp = float(stamp)
#     except :
#         return False
# 
#     if int(stamp) == 0 :
#         stamp = time.time()
# 
#     try :
#         strptm = time.localtime(stamp)
#     except :
#         return False
# 
#     return time.strftime(fmt , strptm)


import os
from library.config.database import redis_config
from library.utils.time_conv import timestamp2datetime
SESSION_COOKIE_AGE = 60 * 60 * 4
SESSION_SAVE_EVERY_REQUEST = True
SESSION_EXPIRE_AT_BROWSER_CLOSE = True  # 关闭浏览器，则COOKIE失效
SESSION_REDIS = {
    'host': sess_redis_conf['host'],
    'port': sess_redis_conf['port'],
    'db': sess_redis_conf['db'],
    'password': sess_redis_conf['pwd'],
    'prefix': 'lykchat:session',
    'socket_timeout': redis_config['socket_timeout']
}

LOGGING = {
    'version': 1,
    'disable_existing_loggers': True,
    'formatters': {
       'standard': {
            'format': '%(asctime)s %(pathname)s:%(lineno)d %(module)s:%(funcName)s %(levelname)s %(message)s'
        },  # 日志格式
       'min': {
            'format': '%(asctime)s %(levelname)s %(message)s'
        }  # 日志格式   
    },
    'filters': {
    },
    'handlers': {
        'default': {
            'level':'INFO',  # 允许保存日志的最低级别
            'class':'logging.handlers.RotatingFileHandler',
            # 'class':'logging.handlers.TimedRotatingFileHandler',

# Path: library/config/database.py

# 
# Path: library/utils/time_conv.py
# def timestamp2datetime(stamp=0 , fmt='%Y-%m-%d %H:%M:%S'):
#     '''
#     将时间戳转化指定格式的时间
#     :parm :
#         stamp：时间戳，如果没有指定表示当前时间，如果不是数字型，返回错误
#         smt：转化时间格式
#     :return :
#         转化后的时间
#     '''
# 
#     try :
#         stamp = float(stamp)
#     except :
#         return False
# 
#     if int(stamp) == 0 :
#         stamp = time.time()
# 
#     try :
#         strptm = time.localtime(stamp)
#     except :
#         return False
# 
#     return time.strftime(fmt , strptm)


# Path: lykchat/settings.py
import os
from library.config.database import redis_config
from library.utils.time_conv import timestamp2datetime

SESSION_COOKIE_AGE = 60 * 60 * 4
SESSION_SAVE_EVERY_REQUEST = True
SESSION_EXPIRE_AT_BROWSER_CLOSE = True  # 关闭浏览器，则COOKIE失效
SESSION_REDIS = {
    'host': sess_redis_conf['host'],
    'port': sess_redis_conf['port'],
    'db': sess_redis_conf['db'],
    'password': sess_redis_conf['pwd'],
    'prefix': 'lykchat:session',
    'socket_timeout': redis_config['socket_timeout']
}

LOGGING = {
    'version': 1,
    'disable_existing_loggers': True,
    'formatters': {
       'standard': {
            'format': '%(asctime)s %(pathname)s:%(lineno)d %(module)s:%(funcName)s %(levelname)s %(message)s'
        },  # 日志格式
       'min': {
            'format': '%(asctime)s %(levelname)s %(message)s'
        }  # 日志格式   
    },
    'filters': {
    },
    'handlers': {
        'default': {
            'level':'INFO',  # 允许保存日志的最低级别
            'class':'logging.handlers.RotatingFileHandler',
            # 'class':'logging.handlers.TimedRotatingFileHandler',

            'filename': BASE_DIR + '/logs/lykchat_' + timestamp2datetime(fmt='%Y-%m-%d') + '.log',  # 日志输出文件