<@ULVA73B9P> I have set PREFECT_LOGGING_MARKUP=Tru...
# ask-marvin
k
@Marvin I have set PREFECT_LOGGING_MARKUP=True. It shows like this in the UI
Copy code
logging: {
  "markup": true
}
When I try to use markup in the log, the markup is not applied and it shows up as [green]logger[/]. What am I doing wrong?
Copy code
task_run_logger.info(f"another [green]logger[/] logged this")
m
It appears that you've correctly set
PREFECT_LOGGING_MARKUP=True
, which should enable Rich's markup in Prefect logs. However, if the markup is not being applied, there might be some nuances to consider: 1. Markup Interpretation: Prefect's logging might not interpret the markup correctly if there are issues with the logger configuration or how it's being applied in the code. Ensure that your logger is configured to process markup. 2. Loggers Configuration: Prefect may not capture log statements from libraries that your flows and tasks use by default. You can specify additional loggers to include using the
PREFECT_LOGGING_EXTRA_LOGGERS
setting. This can be done by setting the environment variable or in a profile. 3. Potential Misinterpretation: Strings containing square brackets might be inaccurately interpreted, leading to incomplete output. Ensure that the markup syntax is correctly formatted and not conflicting with other parts of your code. For more details, you can refer to Prefect's logging documentation: Prefect Logging Documentation and Settings Reference. If these suggestions don't resolve the issue, reviewing your logger configuration or checking for any conflicting settings might help.
k
I am using the default
task_run_logger = get_run_logger()
can you give me a code snippet of proper use of markup?
does the prefect UI not show the markup?
j
Hey Koen at the moment the UI only supports ANSI color codes not the full set that rich does (which is pretty expansive) If you do something like this:
Copy code
<http://logger.info|logger.info>(f"Hello flow,\u001b[32mThis text will be green\u001b")
it should work
k
Hi Jake, thanks for your input! I had it set up the way you mentioned but the rich markup seemed like the cleaner approach. I'll wait for this to be enabled and use it like this in the mean time 🙂
🙌 1
👍 1