本文整理汇总了Python中tornado.wsgi.WSGIContainer._log方法的典型用法代码示例。如果您正苦于以下问题:Python WSGIContainer._log方法的具体用法?Python WSGIContainer._log怎么用?Python WSGIContainer._log使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tornado.wsgi.WSGIContainer
的用法示例。
在下文中一共展示了WSGIContainer._log方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: tornado
# 需要导入模块: from tornado.wsgi import WSGIContainer [as 别名]
# 或者: from tornado.wsgi.WSGIContainer import _log [as 别名]
def tornado(port):
from tornado.wsgi import WSGIContainer
from tornado.httpserver import HTTPServer
from tornado.ioloop import IOLoop
app = create_app()
wsgi_container = WSGIContainer(app)
wsgi_container._log = lambda *args, **kwargs: None
http_server = HTTPServer(wsgi_container)
http_server.listen(port)
IOLoop.instance().start()
示例2: tornado
# 需要导入模块: from tornado.wsgi import WSGIContainer [as 别名]
# 或者: from tornado.wsgi.WSGIContainer import _log [as 别名]
def tornado(port):
from tornado.web import Application, FallbackHandler
from tornado.wsgi import WSGIContainer
from tornado.httpserver import HTTPServer
from tornado.ioloop import IOLoop
app = flask.current_app
wsgi_container = WSGIContainer(app)
wsgi_container._log = lambda *args, **kwargs: None
handlers = [('.*', FallbackHandler, {'fallback': wsgi_container})]
tornado_app = Application(handlers, debug=app.debug)
http_server = HTTPServer(tornado_app)
http_server.listen(port)
log.info("Hambar109 Tornado listening on port %r", port)
IOLoop.instance().start()
示例3: runCouchPotato
# 需要导入模块: from tornado.wsgi import WSGIContainer [as 别名]
# 或者: from tornado.wsgi.WSGIContainer import _log [as 别名]
def runCouchPotato(options, base_path, args, data_dir = None, log_dir = None, Env = None, desktop = None):
try:
locale.setlocale(locale.LC_ALL, "")
encoding = locale.getpreferredencoding()
except (locale.Error, IOError):
encoding = None
# for OSes that are poorly configured I'll just force UTF-8
if not encoding or encoding in ('ANSI_X3.4-1968', 'US-ASCII', 'ASCII'):
encoding = 'UTF-8'
# Do db stuff
db_path = os.path.join(data_dir, 'couchpotato.db')
# Backup before start and cleanup old databases
new_backup = os.path.join(data_dir, 'db_backup', str(int(time.time())))
# Create path and copy
if not os.path.isdir(new_backup): os.makedirs(new_backup)
src_files = [options.config_file, db_path, db_path + '-shm', db_path + '-wal']
for src_file in src_files:
if os.path.isfile(src_file):
shutil.copy2(src_file, os.path.join(new_backup, os.path.basename(src_file)))
# Remove older backups, keep backups 3 days or at least 3
backups = []
for directory in os.listdir(os.path.dirname(new_backup)):
backup = os.path.join(os.path.dirname(new_backup), directory)
if os.path.isdir(backup):
backups.append(backup)
total_backups = len(backups)
for backup in backups:
if total_backups > 3:
if tryInt(os.path.basename(backup)) < time.time() - 259200:
for src_file in src_files:
b_file = os.path.join(backup, os.path.basename(src_file))
if os.path.isfile(b_file):
os.remove(b_file)
os.rmdir(backup)
total_backups -= 1
# Register environment settings
Env.set('encoding', encoding)
Env.set('app_dir', base_path)
Env.set('data_dir', data_dir)
Env.set('log_path', os.path.join(log_dir, 'CouchPotato.log'))
Env.set('db_path', 'sqlite:///' + db_path)
Env.set('cache_dir', os.path.join(data_dir, 'cache'))
Env.set('cache', FileSystemCache(os.path.join(Env.get('cache_dir'), 'python')))
Env.set('console_log', options.console_log)
Env.set('quiet', options.quiet)
Env.set('desktop', desktop)
Env.set('daemonized', options.daemon)
Env.set('args', args)
Env.set('options', options)
# Determine debug
debug = options.debug or Env.setting('debug', default = False, type = 'bool')
Env.set('debug', debug)
# Development
development = Env.setting('development', default = False, type = 'bool')
Env.set('dev', development)
# Disable logging for some modules
for logger_name in ['enzyme', 'guessit', 'subliminal', 'apscheduler']:
logging.getLogger(logger_name).setLevel(logging.ERROR)
for logger_name in ['gntp', 'migrate']:
logging.getLogger(logger_name).setLevel(logging.WARNING)
# Use reloader
reloader = debug is True and development and not Env.get('desktop') and not options.daemon
# Logger
logger = logging.getLogger()
formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s', '%m-%d %H:%M:%S')
level = logging.DEBUG if debug else logging.INFO
logger.setLevel(level)
logging.addLevelName(19, 'INFO')
# To screen
if (debug or options.console_log) and not options.quiet and not options.daemon:
hdlr = logging.StreamHandler(sys.stderr)
hdlr.setFormatter(formatter)
logger.addHandler(hdlr)
# To file
hdlr2 = handlers.RotatingFileHandler(Env.get('log_path'), 'a', 500000, 10)
hdlr2.setFormatter(formatter)
logger.addHandler(hdlr2)
# Start logging & enable colors
import color_logs
from couchpotato.core.logger import CPLog
log = CPLog(__name__)
log.debug('Started with options %s', options)
#.........这里部分代码省略.........
示例4: runCouchPotato
# 需要导入模块: from tornado.wsgi import WSGIContainer [as 别名]
# 或者: from tornado.wsgi.WSGIContainer import _log [as 别名]
def runCouchPotato(options, base_path, args, data_dir=None, log_dir=None, Env=None, desktop=None):
try:
locale.setlocale(locale.LC_ALL, "")
encoding = locale.getpreferredencoding()
except (locale.Error, IOError):
encoding = None
# for OSes that are poorly configured I'll just force UTF-8
if not encoding or encoding in ("ANSI_X3.4-1968", "US-ASCII", "ASCII"):
encoding = "UTF-8"
# Do db stuff
db_path = os.path.join(data_dir, "couchpotato.db")
# Backup before start and cleanup old databases
new_backup = os.path.join(data_dir, "db_backup", str(int(time.time())))
# Create path and copy
if not os.path.isdir(new_backup):
os.makedirs(new_backup)
src_files = [options.config_file, db_path, db_path + "-shm", db_path + "-wal"]
for src_file in src_files:
if os.path.isfile(src_file):
shutil.copy2(src_file, os.path.join(new_backup, os.path.basename(src_file)))
# Remove older backups, keep backups 3 days or at least 3
backups = []
for directory in os.listdir(os.path.dirname(new_backup)):
backup = os.path.join(os.path.dirname(new_backup), directory)
if os.path.isdir(backup):
backups.append(backup)
total_backups = len(backups)
for backup in backups:
if total_backups > 3:
if int(os.path.basename(backup)) < time.time() - 259200:
for src_file in src_files:
b_file = os.path.join(backup, os.path.basename(src_file))
if os.path.isfile(b_file):
os.remove(b_file)
os.rmdir(backup)
total_backups -= 1
# Register environment settings
Env.set("encoding", encoding)
Env.set("app_dir", base_path)
Env.set("data_dir", data_dir)
Env.set("log_path", os.path.join(log_dir, "CouchPotato.log"))
Env.set("db_path", "sqlite:///" + db_path)
Env.set("cache_dir", os.path.join(data_dir, "cache"))
Env.set("cache", FileSystemCache(os.path.join(Env.get("cache_dir"), "python")))
Env.set("console_log", options.console_log)
Env.set("quiet", options.quiet)
Env.set("desktop", desktop)
Env.set("args", args)
Env.set("options", options)
# Determine debug
debug = options.debug or Env.setting("debug", default=False, type="bool")
Env.set("debug", debug)
# Development
development = Env.setting("development", default=False, type="bool")
Env.set("dev", development)
# Disable logging for some modules
for logger_name in ["enzyme", "guessit", "subliminal", "apscheduler"]:
logging.getLogger(logger_name).setLevel(logging.ERROR)
for logger_name in ["gntp", "migrate"]:
logging.getLogger(logger_name).setLevel(logging.WARNING)
# Use reloader
reloader = debug is True and development and not Env.get("desktop") and not options.daemon
# Logger
logger = logging.getLogger()
formatter = logging.Formatter("%(asctime)s %(levelname)s %(message)s", "%m-%d %H:%M:%S")
level = logging.DEBUG if debug else logging.INFO
logger.setLevel(level)
logging.addLevelName(19, "INFO")
# To screen
if (debug or options.console_log) and not options.quiet and not options.daemon:
hdlr = logging.StreamHandler(sys.stderr)
hdlr.setFormatter(formatter)
logger.addHandler(hdlr)
# To file
hdlr2 = handlers.RotatingFileHandler(Env.get("log_path"), "a", 500000, 10)
hdlr2.setFormatter(formatter)
logger.addHandler(hdlr2)
# Start logging & enable colors
import color_logs
from couchpotato.core.logger import CPLog
log = CPLog(__name__)
log.debug("Started with options %s", options)
#.........这里部分代码省略.........