To activate logging in Nazca you can utilize the
nd.logfile() method. The logging is based on the standard Python logging. The “name” keyword is to provide the name of the log file, to which “.log” is 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 can be switched off via stdout=False (default=True).
The logger starts directly when called, adding e.g. 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.