Logging is an extremely useful way to help debugging your design. Not only does it provide one place to collect your messages from the mask generation, such as version numbers of Nazca and PDKs, or DRC information, it also stores this information so it is not lost after you close a layout session.
To activate logging in Nazca you can utilize the
nd.logfile(name, stdout, level) method. The logging is based on the standard Python logging and provides logging levels DEBUG, INFO, WARNING, and ERROR. The minimum level logged is INFO by default and can be changed like level=”DEBUG”.
The “name” keyword is to provide the name of the log file, to which a “.log” suffix will be added. By using “name=__file__” a Python internal variable, the logfile will be based on your active filename, e.g. for file ‘thisfilename.py’ the logfile will be saved under “thisfilename.py.log”.
Log messages to stdout (the terminal) can be switched off via stdout=False (default=True) and you clean up the terminal and use the .log file to browse through the messages.
The logger starts directly when called, adding the date-time and the Nazca-Design version. Hence, by the placing the logger above other Nazca imports, those (nazca) modules’ log messages are added to the Nazca log file, such as module (pdk) versions.
# example created by Bright Photonics import nazca as nd # start logging: nd.logfile(name=__file__, stdout=False) # adding your own log messages to the log file: nd.logger.info('my info') nd.logger.warning('my warning') nd.logger.error('my error')
The logger collects the Nazca internal log messages, but you can also send your own log messages to the log file as shown in the code above. Available log levels are debug, info, warning, error, and exception. Best practice is to have no warnings or errors in the log file of your final layout.