You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, a user has to manually set up a logger function. For example:
defsetup_logger(level=logging.INFO) ->None:
"""Setup the logger from the openeo_gfmap package to the assigned level."""globalpipeline_logpipeline_log=logging.getLogger("pipeline_sar")
pipeline_log.setLevel(level)
stream_handler=logging.StreamHandler()
pipeline_log.addHandler(stream_handler)
formatter=logging.Formatter("%(asctime)s|%(name)s|%(levelname)s: %(message)s")
stream_handler.setFormatter(formatter)
# Exclude the other loggers from other librariesclassManagerLoggerFilter(logging.Filter):
"""Filter to only accept the OpenEO-GFMAP manager logs."""deffilter(self, record):
returnrecord.namein [pipeline_log.name]
stream_handler.addFilter(ManagerLoggerFilter())
We could provide a basic setup_logger function like this in GFMap, such that the user only needs to specify the loglevel.
The text was updated successfully, but these errors were encountered:
I might be missing some context, but some quick feedback
global pipeline_log
It shouldn't be necessary to use globals here. logging.getLogger("pipeline_sar") will return the same object even if called from different places, so no need to pass things around with globals.
That ManagerLoggerFilter pattern looks a bit dangerous because it will suppress everything (warnings and errors) from other components, which might hide actual problems.
I think something like the following has the same intent, but will not hide warnings/errors:
importlogginglogging.basicConfig(level=logging.INFO) # you can also specify a custom format here# Set default log level to warning ...logging.getLogger().setLevel(logging.WARNING)
# ... but use INFO level for our own logslogging.getLogger("pipeline_sar").setLevel(logging.INFO)
Currently, a user has to manually set up a logger function. For example:
We could provide a basic setup_logger function like this in GFMap, such that the user only needs to specify the loglevel.
The text was updated successfully, but these errors were encountered: