ICON Plugin Development: Logging from modules in util folder

Hi Matt - the best way of logging from here is to pass a logger instance from an action/connection to the classes/functions within the util files. A good approach here is to create a class that encompasses your util functions and then instantiate that with a logger instance (perhaps from your connection). This way you can avoid passing the logger instance each time you call a function. Example code…

class Util:
    
    def __init__(self, logger):
        self.logger = logger
        
    def some_function(self):
        self.logger.info("Logging something here...")

Let me know if you have any other questions around this!

1 Like