jumpserver/terminal/ssh_config.py

102 lines
2.6 KiB
Python
Raw Normal View History

2016-09-25 03:30:02 +00:00
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
import logging
import os
BASE_DIR = os.path.dirname(os.path.abspath(__name__))
class Config:
2016-09-25 11:53:55 +00:00
SSH_HOST = ''
SSH_PORT = 2200
LOG_LEVEL = 'INFO'
2016-09-25 03:30:02 +00:00
LOG_DIR = os.path.join(BASE_DIR, 'logs')
2016-09-25 11:53:55 +00:00
LOG_FILENAME = 'ssh_server.log'
2016-09-25 03:30:02 +00:00
LOGGING = {
'version': 1,
2016-09-25 11:53:55 +00:00
'disable_existing_loggers': False,
2016-09-25 03:30:02 +00:00
'formatters': {
'verbose': {
'format': '%(levelname)s %(asctime)s %(module)s %(process)d %(thread)d %(message)s'
},
'main': {
'datefmt': '%Y-%m-%d %H:%M:%S',
'format': '%(asctime)s [%(module)s %(levelname)s] %(message)s',
},
'simple': {
'format': '%(levelname)s %(message)s'
},
},
'handlers': {
'null': {
'level': 'DEBUG',
'class': 'logging.NullHandler',
},
'console': {
'level': 'DEBUG',
'class': 'logging.StreamHandler',
2016-09-25 11:53:55 +00:00
'formatter': 'main',
'stream': 'ext://sys.stdout',
2016-09-25 03:30:02 +00:00
},
'file': {
'level': 'DEBUG',
'class': 'logging.FileHandler',
'formatter': 'main',
2016-09-25 11:53:55 +00:00
'mode': 'a',
'filename': os.path.join(LOG_DIR, LOG_FILENAME),
2016-09-25 03:30:02 +00:00
},
},
'loggers': {
'jumpserver': {
'handlers': ['console', 'file'],
2016-09-25 11:53:55 +00:00
# 'level': LOG_LEVEL_CHOICES.get(LOG_LEVEL, None) or LOG_LEVEL_CHOICES.get('info')
2016-09-25 03:30:02 +00:00
'level': LOG_LEVEL,
2016-09-25 11:53:55 +00:00
'propagate': True,
2016-09-25 03:30:02 +00:00
},
2016-09-25 11:53:55 +00:00
'jumpserver.web_ssh_server': {
2016-09-25 03:30:02 +00:00
'handlers': ['console', 'file'],
2016-09-25 11:53:55 +00:00
# 'level': LOG_LEVEL_CHOICES.get(LOG_LEVEL, None) or LOG_LEVEL_CHOICES.get('info')
2016-09-25 03:30:02 +00:00
'level': LOG_LEVEL,
2016-09-25 11:53:55 +00:00
'propagate': True,
2016-09-25 03:30:02 +00:00
},
2016-09-25 11:53:55 +00:00
'jumpserver.ssh_server': {
2016-09-25 03:30:02 +00:00
'handlers': ['console', 'file'],
2016-09-25 11:53:55 +00:00
# 'level': LOG_LEVEL_CHOICES.get(LOG_LEVEL, None) or LOG_LEVEL_CHOICES.get('info')
2016-09-25 03:30:02 +00:00
'level': LOG_LEVEL,
2016-09-25 11:53:55 +00:00
'propagate': True,
2016-09-25 03:30:02 +00:00
}
}
}
def __init__(self):
pass
def __getattr__(self, item):
return None
2016-09-25 11:53:55 +00:00
class DevelopmentConfig(Config):
pass
class ProductionConfig(Config):
pass
class TestingConfig(Config):
pass
config = {
'development': DevelopmentConfig,
'production': ProductionConfig,
'testing': TestingConfig,
'default': DevelopmentConfig,
}
env = 'default'