Logs
logging, colors, terminal width and pretty-print
-
waflib.Logs.get_term_cols()[source]
Get the console width in characters.
Returns: | the number of characters per line |
Return type: | int |
-
class waflib.Logs.color_dict[source]
Bases: object
attribute-based color access, eg: colors.PINK
-
class waflib.Logs.log_filter(name=None)[source]
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:
-
filter(rec)[source]
filter a record, adding the colors automatically
- error: red
- warning: yellow
Parameters: | rec – message to record |
-
class waflib.Logs.formatter[source]
Bases: logging.Formatter
Simple log formatter which handles colors
-
format(rec)[source]
Messages in warning, error or info mode are displayed in color by default
-
waflib.Logs.log
global logger for Logs.debug, Logs.error, etc
-
waflib.Logs.debug(*k, **kw)[source]
Wrap logging.debug, the output is filtered for performance reasons
-
waflib.Logs.error(*k, **kw)[source]
Wrap logging.errors, display the origin of the message when ‘-vv’ is set
-
waflib.Logs.warn(*k, **kw)[source]
Wrap logging.warn
-
waflib.Logs.info(*k, **kw)[source]
Wrap logging.info
-
waflib.Logs.init_log()[source]
Initialize the loggers globally
-
waflib.Logs.make_logger(path, name)[source]
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)
bld.logger = None
Parameters: |
- path (string) – file name to write the log output to
- name (string) – logger name (loggers are reused)
|
-
waflib.Logs.make_mem_logger(name, to_log, size=10000)[source]
Create a memory logger to avoid writing concurrently to the main logger
-
waflib.Logs.pprint(col, str, label='', sep='\n')[source]
Print messages in color immediately on stderr:
from waflib import Logs
Logs.pprint('RED', 'Something bad just happened')
Parameters: |
- col (string) – color name to use in Logs.colors_lst
- str (string or a value that can be printed by %s) – message to display
- label (string) – a message to add after the colored output
- sep (string) – a string to append at the end (line separator)
|