Search code examples
pythoncocotb

How to reduce log line size in Cocotb


In cocotb testbench log printing in terminal have really long line :

28204007.00ns INFO     cocotb.regression                         regression.py:341  in _log_test_summary               **************************************************************************************************************
                                                                                                                       ** TEST                                                  PASS/FAIL  SIM TIME(NS)  REAL TIME(S)  RATIO(NS/S) **
                                                                                                                       **************************************************************************************************************

This is too long for most xterminals. Is there options to reduce lines length ? Maybe we can hide some information like message line number or function name ?


Solution

  • Ok found it. Thanks to leftink there is an os environment variable to define to have reduced lines log length : COCOTB_REDUCED_LOG_FMT

    To have reduced log length we can simply export variable in our terminal :

    $ export COCOTB_REDUCED_LOG_FMT=1

    If we want to have it by default, we can add it to our makefile :

        export COCOTB_REDUCED_LOG_FMT=1
        SIM=ghdl
        TOPLEVEL=mydesign
        VHDL_SOURCES =$(PWD)/../..
        [...]
    

    This will give us a reduced lines length log :

    28204007.00ns INFO     **************************************************************************************************************
                           ** TEST                                                  PASS/FAIL  SIM TIME(NS)  REAL TIME(S)  RATIO(NS/S) **
                           **************************************************************************************************************
    

    Matching with standard terminals.