本文整理汇总了Python中twisted.python.logfile.DailyLogFile.fromFullPath方法的典型用法代码示例。如果您正苦于以下问题:Python DailyLogFile.fromFullPath方法的具体用法?Python DailyLogFile.fromFullPath怎么用?Python DailyLogFile.fromFullPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类twisted.python.logfile.DailyLogFile
的用法示例。
在下文中一共展示了DailyLogFile.fromFullPath方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: make_logfile_observer
# 需要导入模块: from twisted.python.logfile import DailyLogFile [as 别名]
# 或者: from twisted.python.logfile.DailyLogFile import fromFullPath [as 别名]
def make_logfile_observer(path, show_source=False):
"""
Make an observer that writes out to C{path}.
"""
from twisted.logger import FileLogObserver
from twisted.python.logfile import DailyLogFile
f = DailyLogFile.fromFullPath(path)
def _render(event):
if event.get("log_system", u"-") == u"-":
logSystem = u"{:<10} {:>6}".format("Controller", os.getpid())
else:
logSystem = event["log_system"]
if show_source and event.get("log_namespace") is not None:
logSystem += " " + event.get("cb_namespace", event.get("log_namespace", ''))
if event.get("log_format", None) is not None:
eventText = formatEvent(event)
else:
eventText = ""
if "log_failure" in event:
# This is a traceback. Print it.
eventText = eventText + event["log_failure"].getTraceback()
eventString = NOCOLOUR_FORMAT.format(
formatTime(event["log_time"]), logSystem, eventText) + os.linesep
return eventString
return FileLogObserver(f, _render)
示例2: run_normal
# 需要导入模块: from twisted.python.logfile import DailyLogFile [as 别名]
# 或者: from twisted.python.logfile.DailyLogFile import fromFullPath [as 别名]
def run_normal(self):
if self.debug:
log.startLogging(sys.stdout)
else:
log.startLogging(DailyLogFile.fromFullPath(self.logfile))
log.msg("portal server listen %s" % self.portal_host)
reactor.listenUDP(self.listen_port, self, interface=self.portal_host)
示例3: makeService
# 需要导入模块: from twisted.python.logfile import DailyLogFile [as 别名]
# 或者: from twisted.python.logfile.DailyLogFile import fromFullPath [as 别名]
def makeService(_config):
global config
config = _config
if config['logpath'] != None:
logFilePath = os.path.abspath(config['logpath'])
logFile = DailyLogFile.fromFullPath(logFilePath)
else:
logFile = sys.stdout
log.startLogging(logFile)
lumenService = service.MultiService()
# Bayeux Service
import bayeux
bayeuxFactory = bayeux.BayeuxServerFactory()
bayeuxService = internet.TCPServer(config['port'], bayeuxFactory)
bayeuxService.setServiceParent(lumenService)
# WebConsole Service
import webconsole
site = server.Site(webconsole.WebConsole())
webConsoleService = internet.TCPServer(config['webport'], site)
webConsoleService.setServiceParent(lumenService)
application = service.Application("lumen")
lumenService.setServiceParent(application)
return lumenService
示例4: noiseControl
# 需要导入模块: from twisted.python.logfile import DailyLogFile [as 别名]
# 或者: from twisted.python.logfile.DailyLogFile import fromFullPath [as 别名]
def noiseControl(options):
# terminal noise/info logic
# allows the specification of the log file location
if not options["loud"]:
log_path = options["log"]
log.startLogging(DailyLogFile.fromFullPath(log_path))
return None
示例5: _createLogFile
# 需要导入模块: from twisted.python.logfile import DailyLogFile [as 别名]
# 或者: from twisted.python.logfile.DailyLogFile import fromFullPath [as 别名]
def _createLogFile(self, uuid):
logDirPath = '{cwd}\\..\\logs\\aiprocesses'.format(cwd=os.getcwd())
if not os.path.exists(logDirPath):
os.mkdir(logDirPath)
logFilePath = '{dir}\\{uuid}.log'.format(dir=logDirPath, uuid=uuid)
log.startLogging(DailyLogFile.fromFullPath(logFilePath))
示例6: init_logging
# 需要导入模块: from twisted.python.logfile import DailyLogFile [as 别名]
# 或者: from twisted.python.logfile.DailyLogFile import fromFullPath [as 别名]
def init_logging(logdir, logname):
if DEBUG_LEVEL > 0:
log.startLogging(sys.stdout)
if not os.path.exists(logdir):
os.makedirs(logdir)
logfile = get_path(os.path.join(logdir, logname))
log.startLogging(DailyLogFile.fromFullPath(logfile))
示例7: __init__
# 需要导入模块: from twisted.python.logfile import DailyLogFile [as 别名]
# 或者: from twisted.python.logfile.DailyLogFile import fromFullPath [as 别名]
def __init__(self):
try:
logfile = DailyLogFile.fromFullPath(cfg.logging.filename)
except AssertionError:
raise AssertionError("Assertion error attempting to open the log file: {0}. Does the directory exist?".format(cfg.logging.filename))
twistedlogger.startLogging(logfile, setStdout=False)
示例8: logToDir
# 需要导入模块: from twisted.python.logfile import DailyLogFile [as 别名]
# 或者: from twisted.python.logfile.DailyLogFile import fromFullPath [as 别名]
def logToDir(directory='logs', LOG_TYPE=('console',), OBSERVER=MyLogObserver):
"""Call this to write logs to the specified directory,
optionally override the FileLogObserver.
"""
for name in LOG_TYPE:
path = os.path.join(directory, name + '.log')
logfile = DailyLogFile.fromFullPath(path)
logs[name] = OBSERVER(logfile)
示例9: start_logging
# 需要导入模块: from twisted.python.logfile import DailyLogFile [as 别名]
# 或者: from twisted.python.logfile.DailyLogFile import fromFullPath [as 别名]
def start_logging(opts):
from twisted.python import log
from twisted.python.logfile import DailyLogFile
if opts.logfile:
logfile = DailyLogFile.fromFullPath(opts.logfile)
else:
logfile = sys.stderr
log.startLogging(logfile)
示例10: start_logging
# 需要导入模块: from twisted.python.logfile import DailyLogFile [as 别名]
# 或者: from twisted.python.logfile.DailyLogFile import fromFullPath [as 别名]
def start_logging(self):
"""Starts logging to log file or stdout depending on config."""
if self.use_log:
if self.log_stdout:
log.startLogging(sys.stdout)
else:
log_file = os.path.expanduser(self.log_file)
log.startLogging(DailyLogFile.fromFullPath(log_file))
示例11: _handle_logging
# 需要导入模块: from twisted.python.logfile import DailyLogFile [as 别名]
# 或者: from twisted.python.logfile.DailyLogFile import fromFullPath [as 别名]
def _handle_logging(self):
"""
Start logging to file if there is some file configuration and we
are not running in development mode
"""
if self.development is False and self._log_file is not None:
self.already_logging = True
log.startLogging(DailyLogFile.fromFullPath(self.log_file))
示例12: start_logging
# 需要导入模块: from twisted.python.logfile import DailyLogFile [as 别名]
# 或者: from twisted.python.logfile.DailyLogFile import fromFullPath [as 别名]
def start_logging(opts):
from twisted.python import log
from twisted.python.logfile import DailyLogFile
if opts.logfile:
logfile = DailyLogFile.fromFullPath(opts.logfile)
else:
logfile = sys.stderr
log.startLogging(logfile)
log.msg("Open files limit: %d" % resource.getrlimit(resource.RLIMIT_NOFILE)[0])
示例13: init
# 需要导入模块: from twisted.python.logfile import DailyLogFile [as 别名]
# 或者: from twisted.python.logfile.DailyLogFile import fromFullPath [as 别名]
def init(cls, target='stdout', log_level=2, filename='twistd.log'):
cls.filename = filename
cls.target = target
cls.log_level = log_level
if cls.target is 'file':
logfile = get_filename(filename=cls.filename)
log.startLogging(DailyLogFile.fromFullPath(logfile))
else:
log.startLogging(stdout)
示例14: configure
# 需要导入模块: from twisted.python.logfile import DailyLogFile [as 别名]
# 或者: from twisted.python.logfile.DailyLogFile import fromFullPath [as 别名]
def configure(**options):
global logLevel, logFile
LEVELS = {
'debug': logging.DEBUG,
'info': logging.INFO,
'warning': logging.WARNING,
'error': logging.ERROR,
'critical': logging.CRITICAL
}
logLevel = LEVELS[options.get('loglevel', 'info').lower()]
logging.basicConfig(level=logLevel)
logFile = options.get('logfile', None)
if logFile:
# defaultMode=0644 # workaround for https://twistedmatrix.com/trac/ticket/7026
log.startLogging(DailyLogFile.fromFullPath(logFile,defaultMode=0644))
else:
log.startLogging(sys.stdout)
示例15: main
# 需要导入模块: from twisted.python.logfile import DailyLogFile [as 别名]
# 或者: from twisted.python.logfile.DailyLogFile import fromFullPath [as 别名]
def main(options):
connection = settings.REDIS_CLASS()
log.startLogging(sys.stdout)
log.startLogging(DailyLogFile.fromFullPath(os.path.join(settings.LOG_DIRECTORY, 'master.log')), setStdout=1)
log.addObserver(RedisLogObserver(connection).emit)
factory = TwitterJobTrackerFactory(connection, TwitterJob, settings.MAX_CLIENTS, options=options)
reactor.listenTCP(settings.JT_PORT + options.ha, factory)
reactor.run()