logging, colors, terminal width and pretty-print
Get the console width in characters.
Returns: | the number of characters per line |
---|---|
Return type: | int |
Bases: object
attribute-based color access, eg: colors.PINK
Bases: logging.Filter
The 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
filter a record, adding the colors automatically
Parameters: | rec – message to record |
---|
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
Wrap logging.debug, the output is filtered for performance reasons
Wrap logging.errors, display the origin of the message when ‘-vv’ is set
Create 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: |
|
---|
Create a memory logger to avoid writing concurrently to the main logger
Free 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).
Print messages in color immediately on stderr:
from waflib import Logs
Logs.pprint('RED', 'Something bad just happened')
Parameters: |
|
---|