【发布时间】:2012-07-13 02:30:04
【问题描述】:
在使用 appcfg.py request_logs 时,它显示“将下载日志复制到 [输出文件路径]”。用于存储临时文件的谷歌应用引擎位置在哪里?
编辑1
在使用 appcfg.py request_logs 时,我注意到第一个程序会首先将日志下载到临时位置,然后将这些文件复制到用户指定的输出文件。我正在寻找数据在复制到目标日志文件之前存储的位置。
【问题讨论】:
标签: google-app-engine tmp
在使用 appcfg.py request_logs 时,它显示“将下载日志复制到 [输出文件路径]”。用于存储临时文件的谷歌应用引擎位置在哪里?
在使用 appcfg.py request_logs 时,我注意到第一个程序会首先将日志下载到临时位置,然后将这些文件复制到用户指定的输出文件。我正在寻找数据在复制到目标日志文件之前存储的位置。
【问题讨论】:
标签: google-app-engine tmp
我不确定我是否理解您的问题,但如果您从应用引擎项目目录(您的 app.yaml 文件所在的位置)运行这样的命令:
appcfg.py request_logs . logs.out
然后输出将在同一目录(您的项目目录)中的文件logs.out 中结束。
【讨论】:
我发现GAE首先使用标准临时文件来存储日志。然后将它们复制到所需的输出文件位置。
def DownloadLogs(self):
"""Download the requested logs.
This will write the logs to the file designated by
self.output_file, or to stdout if the filename is '-'.
Multiple roundtrips to the server may be made.
"""
StatusUpdate('Downloading request logs for %s %s.' %
(self.config.application, self.version_id))
tf = tempfile.TemporaryFile()
last_offset = None
try:
while True:
try:
new_offset = self.RequestLogLines(tf, last_offset)
if not new_offset or new_offset == last_offset:
break
last_offset = new_offset
except KeyboardInterrupt:
StatusUpdate('Keyboard interrupt; saving data downloaded so far.')
break
StatusUpdate('Copying request logs to %r.' % self.output_file)
if self.output_file == '-':
of = sys.stdout
else:
try:
of = open(self.output_file, self.write_mode)
except IOError, err:
StatusUpdate('Can\'t write %r: %s.' % (self.output_file, err))
sys.exit(1)
try:
line_count = CopyReversedLines(tf, of)
finally:
of.flush()
if of is not sys.stdout:
of.close()
finally:
tf.close()
StatusUpdate('Copied %d records.' % line_count)
【讨论】: