logging, colors, terminal width and pretty-print
Global verbosity level, see waflib.Logs.debug() and waflib.Logs.error()
If 1 is given, then the system will perform a few verifications before enabling colors, such as checking whether the interpreter is running in a terminal. A value of zero will disable colors, and a value above 1 will force colors.
Parameters: | use (integer) – whether to enable colors or not |
---|
Returns the console width in characters.
Returns: | the number of characters per line |
---|---|
Return type: | int |
Returns the ansi sequence corresponding to the given color name. An empty string is returned when coloring is globally disabled.
Parameters: | cl (string) – color name in capital letters |
---|
Bases: logging.Filter
Waf logs are of the form ‘name: message’, and can be filtered by ‘waf –zones=name’. For example, the following:
from waflib import Logs
Logs.debug('test: here is a message')
Will be displayed only when executing:
$ waf --zones=test
Bases: logging.StreamHandler
Dispatches messages to stderr/stdout depending on the severity level
Bases: logging.Formatter
Simple log formatter which handles colors
global logger for Logs.debug, Logs.error, etc
Wraps logging.debug and discards messages if the verbosity level waflib.Logs.verbose ≤ 0
Wrap logging.errors, adds the stack trace when the verbosity level waflib.Logs.verbose ≥ 2
Initializes the logger waflib.Logs.log
Creates a simple logger, which is often used to redirect the context command output:
from waflib import Logs
bld.logger = Logs.make_logger('test.log', 'build')
bld.check(header_name='sadlib.h', features='cxx cprogram', mandatory=False)
# have the file closed immediately
Logs.free_logger(bld.logger)
# stop logging
bld.logger = None
The method finalize() of the command will try to free the logger, if any
Parameters: |
|
---|
Creates a memory logger to avoid writing concurrently to the main logger
Frees the resources held by the loggers created through make_logger or make_mem_logger. This is used for file cleanup and for handler removal (logger objects are re-used).
Prints messages in color immediately on stderr:
from waflib import Logs
Logs.pprint('RED', 'Something bad just happened')
Parameters: |
|
---|