本文整理汇总了Python中waflib.Logs.make_logger方法的典型用法代码示例。如果您正苦于以下问题:Python Logs.make_logger方法的具体用法?Python Logs.make_logger怎么用?Python Logs.make_logger使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类waflib.Logs
的用法示例。
在下文中一共展示了Logs.make_logger方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post_init
# 需要导入模块: from waflib import Logs [as 别名]
# 或者: from waflib.Logs import make_logger [as 别名]
def post_init(self):
"""TODO remove this method, ugh"""
self.cachedir = os.path.join(self.bldnode.abspath(), Build.CACHE_DIR)
path = os.path.join(self.bldnode.abspath(), WAF_CONFIG_LOG)
self.logger = Logs.make_logger(path, 'cfg')
"""
import logging
logger = logging.getLogger('cfg')
hdlr = logging.FileHandler(path, 'w')
formatter = logging.Formatter('%(message)s')
hdlr.setFormatter(formatter)
logger.addHandler(hdlr)
logger.setLevel(logging.INFO)
self.logger = logger
"""
app = getattr(Context.g_module, 'APPNAME', '')
if app:
ver = getattr(Context.g_module, 'VERSION', '')
if ver:
app = "%s (%s)" % (app, ver)
now = time.ctime()
pyver = sys.hexversion
systype = sys.platform
args = " ".join(sys.argv)
wafver = Context.WAFVERSION
abi = Context.ABI
self.to_log(conf_template % vars())
示例2: execute
# 需要导入模块: from waflib import Logs [as 别名]
# 或者: from waflib.Logs import make_logger [as 别名]
def execute(self):
super(TestContext, self).execute()
log_path = os.path.join(Context.top_dir, Context.out_dir, "test.log")
self.logger = Logs.make_logger(log_path, "test")
test_cases = []
cases = set(fnmatch.filter(self.test_cases.keys(), self.options.test_filter))
if not cases:
self.fatal("no tests found: %s\n" % pattern)
for case in cases:
test_cases.append(self.test_cases[case])
test_cases.sort(key=lambda case: case.target)
failures = 0
for case in test_cases:
self.start_msg("Testing %s" % case.target)
case_time = Timer()
with tempfile.NamedTemporaryFile() as log:
try:
case.execute(self, log)
self.end_msg("passed (%s)" % case_time, "GREEN")
except AssertionError as e:
self.to_log(str(e))
self.to_log(open(log.name).read())
self.end_msg("failed (%s)" % case_time, "RED")
failures += 1
if failures == 1:
self.fatal("1 test failed")
elif failures > 1:
self.fatal("%d tests failed" % failures)
示例3: __init__
# 需要导入模块: from waflib import Logs [as 别名]
# 或者: from waflib.Logs import make_logger [as 别名]
def __init__(self, global_context, cmd_argv, options_context, pkg, run_node):
super(ConfigureWafContext, self).__init__(global_context, cmd_argv, options_context, pkg, run_node)
run_path = self.run_node.abspath()
source_path = self.top_node.abspath()
build_path = self.build_node.abspath()
_init(run_path=run_path, source_path=source_path, build_path=build_path)
opts = OptionsContext()
opts.load("compiler_c")
opts.load("custom_python", tooldir=[WAF_TOOLDIR])
opts.parse_args([])
self.waf_options_context = opts
waf_context = create_context("configure", run_dir=source_path)
waf_context.options = Options.options
waf_context.init_dirs()
waf_context.cachedir = waf_context.bldnode.make_node(Build.CACHE_DIR)
waf_context.cachedir.mkdir()
path = os.path.join(waf_context.bldnode.abspath(), WAF_CONFIG_LOG)
waf_context.logger = Logs.make_logger(path, 'cfg')
self.waf_context = waf_context
self._old_path = None
示例4: execute
# 需要导入模块: from waflib import Logs [as 别名]
# 或者: from waflib.Logs import make_logger [as 别名]
def execute(self):
"""See Context.prepare"""
self.init_dirs()
self.cachedir = self.bldnode.make_node(Build.CACHE_DIR)
self.cachedir.mkdir()
path = os.path.join(self.bldnode.abspath(), WAF_CONFIG_LOG)
self.logger = Logs.make_logger(path, 'cfg')
app = getattr(Context.g_module, 'APPNAME', '')
if app:
ver = getattr(Context.g_module, 'VERSION', '')
if ver:
app = "%s (%s)" % (app, ver)
now = time.ctime()
pyver = sys.hexversion
systype = sys.platform
args = " ".join(sys.argv)
wafver = Context.WAFVERSION
abi = Context.ABI
self.to_log(conf_template % vars())
self.msg('Setting top to', self.srcnode.abspath())
self.msg('Setting out to', self.bldnode.abspath())
if id(self.srcnode) == id(self.bldnode):
Logs.warn('setting top == out')
elif id(self.path) != id(self.srcnode):
if self.srcnode.is_child_of(self.path):
Logs.warn('Using an uncommon top directory')
super(ConfigurationContext, self).execute()
self.store()
Context.top_dir = self.srcnode.abspath()
Context.out_dir = self.bldnode.abspath()
# this will write a configure lock so that subsequent builds will
# consider the current path as the root directory (see prepare_impl).
# to remove: use 'waf distclean'
env = ConfigSet.ConfigSet()
env['argv'] = sys.argv
env['options'] = Options.options.__dict__
env.run_dir = Context.run_dir
env.top_dir = Context.top_dir
env.out_dir = Context.out_dir
# conf.hash & conf.files hold wscript files paths and hash
# (used only by Configure.autoconfig)
env['hash'] = self.hash
env['files'] = self.files
env['environ'] = dict(self.environ)
env.store(Context.run_dir + os.sep + Options.lockfile)
env.store(Context.top_dir + os.sep + Options.lockfile)
env.store(Context.out_dir + os.sep + Options.lockfile)
示例5: execute
# 需要导入模块: from waflib import Logs [as 别名]
# 或者: from waflib.Logs import make_logger [as 别名]
def execute(self):
"""
See :py:func:`waflib.Context.Context.execute`
"""
self.init_dirs()
self.cachedir = self.bldnode.make_node(Build.CACHE_DIR)
self.cachedir.mkdir()
path = os.path.join(self.bldnode.abspath(), WAF_CONFIG_LOG)
self.logger = Logs.make_logger(path, 'cfg')
app = getattr(Context.g_module, 'APPNAME', '')
if app:
ver = getattr(Context.g_module, 'VERSION', '')
if ver:
app = "%s (%s)" % (app, ver)
params = {'now': time.ctime(), 'pyver': sys.hexversion, 'systype': sys.platform, 'args': " ".join(sys.argv), 'wafver': Context.WAFVERSION, 'abi': Context.ABI, 'app': app}
self.to_log(conf_template % params)
self.msg('Setting top to', self.srcnode.abspath())
self.msg('Setting out to', self.bldnode.abspath())
if id(self.srcnode) == id(self.bldnode):
Logs.warn('Setting top == out')
elif id(self.path) != id(self.srcnode):
if self.srcnode.is_child_of(self.path):
Logs.warn('Are you certain that you do not want to set top="." ?')
super(ConfigurationContext, self).execute()
self.store()
Context.top_dir = self.srcnode.abspath()
Context.out_dir = self.bldnode.abspath()
# this will write a configure lock so that subsequent builds will
# consider the current path as the root directory (see prepare_impl).
# to remove: use 'waf distclean'
env = ConfigSet.ConfigSet()
env.argv = sys.argv
env.options = Options.options.__dict__
env.config_cmd = self.cmd
env.run_dir = Context.run_dir
env.top_dir = Context.top_dir
env.out_dir = Context.out_dir
# conf.hash & conf.files hold wscript files paths and hash
# (used only by Configure.autoconfig)
env.hash = self.hash
env.files = self.files
env.environ = dict(self.environ)
if not self.env.NO_LOCK_IN_RUN and not getattr(Options.options, 'no_lock_in_run'):
env.store(os.path.join(Context.run_dir, Options.lockfile))
if not self.env.NO_LOCK_IN_TOP and not getattr(Options.options, 'no_lock_in_top'):
env.store(os.path.join(Context.top_dir, Options.lockfile))
if not self.env.NO_LOCK_IN_OUT and not getattr(Options.options, 'no_lock_in_out'):
env.store(os.path.join(Context.out_dir, Options.lockfile))
示例6: benchmarks_format_output
# 需要导入模块: from waflib import Logs [as 别名]
# 或者: from waflib.Logs import make_logger [as 别名]
def benchmarks_format_output (bch):
from waflib import Logs
logfile = os.path.join (bch.bldnode.abspath(), "benchmarks.log")
bch.logger = Logs.make_logger (logfile, "benchmarks")
def compute_score (data):
S = 0.0
prev_elt = None
for d in data:
eps = d["eps"]
time = d["time"]
if not prev_elt is None:
prev_eps, prev_time = prev_elt
log10_eps = -math.log10(eps)
prev_log10_eps = -math.log10(prev_eps)
S += (log10_eps-prev_log10_eps)*(time+prev_time)/2
prev_elt = (eps, time)
return S
#if bch.options.BENCHS_CMP_TO:
# cmpdata = parse_results_file (bch.options.BENCHS_CMP_TO)
cmpdata = {}
D = getattr (bch, 'bench_results', {})
for benchs_name, benchs_data_dict in sorted(D.items(), key = lambda x:x[0]):
bch.msg ("===== %s =====" % benchs_name, "==========", color = "NORMAL")
for f, data in sorted(benchs_data_dict.items(), key = lambda x:x[0]):
bch.start_msg (f)
n = len (data)
S = compute_score (data)
msg = "%d measure%s, Score = %g" % (n, "s" if n > 1 else "", S)
color = "CYAN"
cmpS, _ = cmpdata.get (f, (None, None))
if cmpS:
percent = 100.*(S/cmpS-1.)
msg += " (%0.2f%%)" % percent
if percent <= 0:
color = "GREEN"
elif percent >= 2.5:
color = "RED"
else:
color = "YELLOW"
bch.end_msg (msg, color = color)
if hasattr (bch, "bench_errors"):
sep = os.linesep + " - "
bch.fatal (sep.join (["Benchmarks errors:"] + bch.bench_errors))
示例7: benchmarks_format_output
# 需要导入模块: from waflib import Logs [as 别名]
# 或者: from waflib.Logs import make_logger [as 别名]
def benchmarks_format_output (bch):
# The logger is freed at the end of the benchmarks function but the tasks are
# performed afterwards, so we recreate the logger.
logfile = os.path.join (bch.bldnode.abspath(), "benchmarks_run.log")
bch.logger = Logs.make_logger (logfile, "benchmarks_run")
lst = sorted (getattr (bch, 'bench_results', []), key = lambda x:x[0])
for (f, ret, log) in lst:
bch.start_msg (f.relpath ())
if ret == 0:
bch.end_msg (log.relpath())
else:
bch.end_msg ("Error", color = "RED")
Logs.free_logger (bch.logger)
bch.logger = None
示例8: execute
# 需要导入模块: from waflib import Logs [as 别名]
# 或者: from waflib.Logs import make_logger [as 别名]
def execute(self):
self.init_dirs()
self.cachedir=self.bldnode.make_node(Build.CACHE_DIR)
self.cachedir.mkdir()
path=os.path.join(self.bldnode.abspath(),WAF_CONFIG_LOG)
self.logger=Logs.make_logger(path,'cfg')
app=getattr(Context.g_module,'APPNAME','')
if app:
ver=getattr(Context.g_module,'VERSION','')
if ver:
app="%s (%s)"%(app,ver)
now=time.ctime()
pyver=sys.hexversion
systype=sys.platform
args=" ".join(sys.argv)
wafver=Context.WAFVERSION
abi=Context.ABI
self.to_log(conf_template%vars())
self.msg('Setting top to',self.srcnode.abspath())
self.msg('Setting out to',self.bldnode.abspath())
if id(self.srcnode)==id(self.bldnode):
Logs.warn('Setting top == out (remember to use "update_outputs")')
elif id(self.path)!=id(self.srcnode):
if self.srcnode.is_child_of(self.path):
Logs.warn('Are you certain that you do not want to set top="." ?')
super(ConfigurationContext,self).execute()
self.store()
Context.top_dir=self.srcnode.abspath()
Context.out_dir=self.bldnode.abspath()
env=ConfigSet.ConfigSet()
env['argv']=sys.argv
env['options']=Options.options.__dict__
env.run_dir=Context.run_dir
env.top_dir=Context.top_dir
env.out_dir=Context.out_dir
env['hash']=self.hash
env['files']=self.files
env['environ']=dict(self.environ)
if not self.env.NO_LOCK_IN_RUN:
env.store(Context.run_dir+os.sep+Options.lockfile)
if not self.env.NO_LOCK_IN_TOP:
env.store(Context.top_dir+os.sep+Options.lockfile)
if not self.env.NO_LOCK_IN_OUT:
env.store(Context.out_dir+os.sep+Options.lockfile)
示例9: execute
# 需要导入模块: from waflib import Logs [as 别名]
# 或者: from waflib.Logs import make_logger [as 别名]
def execute(self):
self.init_dirs()
self.cachedir=self.bldnode.make_node(Build.CACHE_DIR)
self.cachedir.mkdir()
path=os.path.join(self.bldnode.abspath(),self.cmd+".log")
self.logger=Logs.make_logger(path,'cfg')
app=getattr(Context.g_module,'APPNAME','')
if app:
ver=getattr(Context.g_module,'VERSION','')
if ver:
app="%s (%s)"%(app,ver)
if id(self.srcnode)==id(self.bldnode):
Logs.warn('Setting top == out (remember to use "update_outputs")')
elif id(self.path)!=id(self.srcnode):
if self.srcnode.is_child_of(self.path):
Logs.warn('Are you certain that you do not want to set top="." ?')
Context.top_dir=self.srcnode.abspath()
Context.out_dir=self.bldnode.abspath()
self.work()
示例10: prebuild
# 需要导入模块: from waflib import Logs [as 别名]
# 或者: from waflib.Logs import make_logger [as 别名]
def prebuild(ctx):
try:
os.makedirs('build/waf')
except OSError:
pass
ctx.logger = Logs.make_logger('build/waf/prebuild.log', 'prebuild')
# Preconfiguration to decide target name
out = 'build/waf/'
preconfigureContext = PreconfigurationContext()
preconfigureContext.out_dir = out
preconfigureContext.options = ctx.options
preconfigureContext.execute()
# Real configuration
out = 'build/waf/'+preconfigureContext.env.TARGETNAME
configureContext = ConfigurationContext()
configureContext.out_dir = out
configureContext.init_dirs()
configureContext.options = ctx.options
configureContext.env = preconfigureContext.env
configureContext.env.VARIANT = ctx.variant
try:
configureContext.execute()
except Exception as e:
ctx.start_msg("configuring toolchain ")
ctx.end_msg("failed", color="RED")
print e
pass
else:
ctx.start_msg("configuring toolchain ")
ctx.end_msg("ok", color="GREEN")
# build
buildContext = CustomBuildContext()
buildContext.options = ctx.options
buildContext.variant = ctx.variant
buildContext.cmd = ctx.variant
buildContext.execute()
示例11: __init__
# 需要导入模块: from waflib import Logs [as 别名]
# 或者: from waflib.Logs import make_logger [as 别名]
def __init__(self, cmd_argv, options_context, pkg, run_node):
super(ConfigureWafContext, self).__init__(cmd_argv, options_context, pkg, run_node)
run_path = self.run_node.abspath()
source_path = self.top_node.abspath()
build_path = self.build_node.abspath()
_init(run_path=run_path, source_path=source_path, build_path=build_path)
opts = OptionsContext()
opts.parse_args([])
opts.load("compiler_c")
Options.options.check_c_compiler = "gcc"
self.waf_options_context = opts
waf_context = create_context("configure", run_dir=source_path)
waf_context.options = Options.options
waf_context.init_dirs()
waf_context.cachedir = waf_context.bldnode.make_node(Build.CACHE_DIR)
waf_context.cachedir.mkdir()
path = os.path.join(waf_context.bldnode.abspath(), WAF_CONFIG_LOG)
waf_context.logger = Logs.make_logger(path, 'cfg')
self.waf_context = waf_context
# FIXME: this is wrong (not taking into account sub packages)
has_compiled_code = len(pkg.extensions) > 0 or len(pkg.compiled_libraries) > 0
if not has_compiled_code:
if pkg.subpackages:
for v in pkg.subpackages.values():
if len(v.extensions) > 0 or len(v.compiled_libraries) > 0:
has_compiled_code = True
break
conf = self.waf_context
if has_compiled_code:
conf.load("compiler_c")
conf.load("python")
conf.check_python_version((2,4,2))
conf.check_python_headers()
# HACK for mac os x
if sys.platform == "darwin":
conf.env["CC"] = ["/usr/bin/gcc-4.0"]
self._old_path = None
示例12: execute
# 需要导入模块: from waflib import Logs [as 别名]
# 或者: from waflib.Logs import make_logger [as 别名]
def execute(self):
self.init_dirs()
self.cachedir=self.bldnode.make_node(Build.CACHE_DIR)
self.cachedir.mkdir()
path=os.path.join(self.bldnode.abspath(),WAF_CONFIG_LOG)
self.logger=Logs.make_logger(path,'cfg')
app=getattr(Context.g_module,'APPNAME','')
if app:
ver=getattr(Context.g_module,'VERSION','')
if ver:
app="%s (%s)"%(app,ver)
params={'now':time.ctime(),'pyver':sys.hexversion,'systype':sys.platform,'args':" ".join(sys.argv),'wafver':Context.WAFVERSION,'abi':Context.ABI,'app':app}
self.to_log(conf_template%params)
self.msg('Setting top to',self.srcnode.abspath())
self.msg('Setting out to',self.bldnode.abspath())
if id(self.srcnode)==id(self.bldnode):
Logs.warn('Setting top == out')
elif id(self.path)!=id(self.srcnode):
if self.srcnode.is_child_of(self.path):
Logs.warn('Are you certain that you do not want to set top="." ?')
super(ConfigurationContext,self).execute()
self.store()
Context.top_dir=self.srcnode.abspath()
Context.out_dir=self.bldnode.abspath()
env=ConfigSet.ConfigSet()
env.argv=sys.argv
env.options=Options.options.__dict__
env.config_cmd=self.cmd
env.run_dir=Context.run_dir
env.top_dir=Context.top_dir
env.out_dir=Context.out_dir
env.hash=self.hash
env.files=self.files
env.environ=dict(self.environ)
if not self.env.NO_LOCK_IN_RUN and not getattr(Options.options,'no_lock_in_run'):
env.store(os.path.join(Context.run_dir,Options.lockfile))
if not self.env.NO_LOCK_IN_TOP and not getattr(Options.options,'no_lock_in_top'):
env.store(os.path.join(Context.top_dir,Options.lockfile))
if not self.env.NO_LOCK_IN_OUT and not getattr(Options.options,'no_lock_in_out'):
env.store(os.path.join(Context.out_dir,Options.lockfile))
示例13: build
# 需要导入模块: from waflib import Logs [as 别名]
# 或者: from waflib.Logs import make_logger [as 别名]
def build(bld):
env = bld.env
zpy = bld.zpy
if not bld.logger:
#...use default name until we actually need multiple builds
_log_name = 'build'
_log_file = '%s.log' % _log_name
_log_path = pth.join(bld.bldnode.abspath(), '%s.log' % _log_name)
bld.logger = Logs.make_logger(_log_path, _log_name)
bld.o = bld.root.make_node(zpy.o)
bld.py = bld.bldnode.find_node('python')
dists = sorted(zpy.dist.keys())
bld.add_group()
bld(features='zpy-update', target=dists)
bld.add_group()
bld(features='zpy-profile')
bld.add_group()
bld(features='zpy-extension', target='setuptools')
bld.add_group()
bld(features='zpy-extension', target=dists,
excl=('python', 'setuptools', 'versiontools'))
bld.add_group()
bld(features='zpy-replay')
bld.add_group()
bld(features='zpy-final')
#if bld.cmd.endswith(('install', 'build')):
# bld.add_post_fun(test)
if bld.cmd.endswith(('install'),) and zpy.ins:
install(bld)
示例14: execute
# 需要导入模块: from waflib import Logs [as 别名]
# 或者: from waflib.Logs import make_logger [as 别名]
def execute(self):
# copy-paste from the original method, but without the cache file creation
self.init_dirs()
path = os.path.join(self.bldnode.abspath(), 'config.log')
self.logger = Logs.make_logger(path, 'cfg')
app = getattr(Context.g_module, 'APPNAME', '')
if app:
ver = getattr(Context.g_module, 'VERSION', '')
if ver:
app = "%s (%s)" % (app, ver)
now = time.ctime()
pyver = sys.hexversion
systype = sys.platform
args = " ".join(sys.argv)
wafver = Context.WAFVERSION
abi = Context.ABI
self.to_log(Configure.conf_template % vars())
super(Configure.ConfigurationContext, self).execute()
示例15: benchmarks_format_output
# 需要导入模块: from waflib import Logs [as 别名]
# 或者: from waflib.Logs import make_logger [as 别名]
def benchmarks_format_output (bch):
from waflib import Logs
logfile = os.path.join (bch.bldnode.abspath(), "benchmarks.log")
bch.logger = Logs.make_logger (logfile, "benchmarks")
if not bch.cmp_only:
bch.msg ("", "", color="NORMAL")
bch.msg ("##### %s #####" % BenchCurrentRef(), "##########", color="NORMAL")
fmt = "{:^9{fmt}} {:^9{fmt}} {:^9{fmt}} {:^9{fmt}}"
D = bch.bench_results[BenchCurrentRef()]
for groupname, groupdict in sorted(D.items(), key = lambda x:x[0]):
bch.msg ("===== %s =====" % groupname, "==========", color = "NORMAL")
for k,v in groupdict["args"].items():
bch.msg ("args: %s" % k, v, color = "NORMAL")
for f, data in sorted(groupdict["data"].items(), key = lambda x:x[0]):
head = fmt.format ("min", "av", "max", "std", fmt="s")
bch.msg (f, head, color = "CYAN")
for eps in reversed(sorted(set(d["eps"] for d in data))):
eps_time = set (d["time"] for d in data if d["eps"] == eps)
m, M, av, std = set_stats (eps_time)
c = "YELLOW" if M/m > 2 else "NORMAL"
row = fmt.format (m, av, M, std, fmt=".2e")
bch.msg (" eps = %r" % eps, row, color=c)
for k, D in bch.bench_cmp.items():
bch.msg (" ", " ", color="NORMAL")
bch.msg ("##### Comparison #####", "##########", color = "NORMAL")
bch.msg ("reference", str(k[0]), color = "NORMAL")
bch.msg ("compare with", str(k[1]), color = "NORMAL")
for groupname, groupdict in sorted(D.items(), key = lambda x:x[0]):
bch.msg ("===== %s =====" % groupname, "==========", color = "NORMAL")
for f, data in sorted(groupdict.items(), key = lambda x:x[0]):
bch.msg (f, "std1/std0 (av1-av0)/std0 #cells1/#cells0", color = "CYAN")
for eps_data in data:
msg_s = " eps = %r" % eps_data["eps"]
rstd = eps_data["std1/std0"]
r = eps_data["(av1-av0)/std0"]
rc = eps_data["#cells1/#cells0"]
fmt = " %s%.2f%s %s%.2f%s %.2f"
if rstd >= BENCHS_INSTABLE_FACTOR:
c1 = Logs.colors.RED
elif rstd <= 1./BENCHS_INSTABLE_FACTOR:
c1 = Logs.colors.GREEN
else:
c1 = Logs.colors.NORMAL
args = [ c1, rstd, Logs.colors.NORMAL ]
if r >= BENCHS_CMP_REGRESSION_FACTOR:
c2 = Logs.colors.RED
elif -r >= BENCHS_CMP_IMPROVMENT_FACTOR:
c2 = Logs.colors.GREEN
else:
c2 = Logs.colors.NORMAL
args += [ c2, r, Logs.colors.NORMAL, rc ]
bch.msg (msg_s, fmt % tuple(args))
if bch.bench_errors:
sep = os.linesep + " - "
bch.fatal (sep.join (["Benchmarks errors:"] + bch.bench_errors))