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, the only place in the docs describing that the BAML_LOG variable can be customized is in the terminal page.
However, the user may need to customize this behaviour from within their client code. It's not documented anywhere as far as I can tell. I have the following two use cases where I do not want the info log, I just want BAML to only display warnings (adding unnecessary steps and a wasted code execution each time, because I always forget to set BAML_LOG=WARN every time I run a new project).
Some additional questions
How can users set this variable in their Python code itself? So they don't need to worry about environment variables. I tried the below and it doesn't work in Python, the entire info log is spat out and I am forced to run export BAML_LOG=WARN every time.
# How to get BAML's log settings set in Python code?importosos.environ["BAML_LOG"] ="WARN"# The above does nothing - the entire info log is still printed to the console
Jupyter notebook and interactive code sessions
I also sometimes experiment with BAML workflows in Jupyter interactive code cells. In such cases, there doesn't seem to be a way to customize the BAML log behaviour via cell magic. For example, the below does nothing.
%env BAML_LOG=WARN
Basically, the problem is that I always have to run export BAML_LOG=WARN every time (which I commonly forget to do), and there should ideally be a documented way to do this in every client language's code so that the user can have the setting done, version controlled via git, and they can forget about it and focus on other parts :).
The text was updated successfully, but these errors were encountered:
I think the annoyance of having to downgrade the logging level manually from info to warn can be partially addressed by my discussion question. But in general, I'd still like to learn how to customize the log settings more programmatically rather than via manual export commands.
we spoke on Discord -- noted we can add a generator config to select a default
prrao87
changed the title
[Docs]: Insufficient docs for handling BAML log settings in Python and other languages
[Feature]: Add generator config to allow user to switch default logging behaviour from "info" to "warn"
Feb 11, 2025
prrao87
changed the title
[Feature]: Add generator config to allow user to switch default logging behaviour from "info" to "warn"
feature: Add generator config to allow user to switch default logging behaviour from "info" to "warn"
Feb 11, 2025
Currently, the only place in the docs describing that the
BAML_LOG
variable can be customized is in the terminal page.However, the user may need to customize this behaviour from within their client code. It's not documented anywhere as far as I can tell. I have the following two use cases where I do not want the info log, I just want BAML to only display warnings (adding unnecessary steps and a wasted code execution each time, because I always forget to set
BAML_LOG=WARN
every time I run a new project).Some additional questions
How can users set this variable in their Python code itself? So they don't need to worry about environment variables. I tried the below and it doesn't work in Python, the entire info log is spat out and I am forced to run
export BAML_LOG=WARN
every time.Jupyter notebook and interactive code sessions
I also sometimes experiment with BAML workflows in Jupyter interactive code cells. In such cases, there doesn't seem to be a way to customize the BAML log behaviour via cell magic. For example, the below does nothing.
Basically, the problem is that I always have to run
export BAML_LOG=WARN
every time (which I commonly forget to do), and there should ideally be a documented way to do this in every client language's code so that the user can have the setting done, version controlled via git, and they can forget about it and focus on other parts :).The text was updated successfully, but these errors were encountered: