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
I have searched the existing issues, and I could not find an existing issue for this bug
Current Behavior
When using the dbtRunner with a callback function overrides the level of the current stdout to the level at which the file logging is set if logging.basicConfig was used.
The stdout is being given debug log, even when the log level is set to info
Expected Behavior
Only the log level info or the level set by --log-level are printed to stout
Steps To Reproduce
The below code should work on a simple DBT project
import logging
logger = logging.getLogger(__name__)
logger.info("This should not be seen")
logging.basicConfig(level=logging.INFO)
logger.warning("This should be seen")
logger.debug("This is a debug message")
from dbt.events.base_types import EventMsg
from dbt.contracts.graph.manifest import Manifest
from dbt.cli.main import dbtRunner, dbtRunnerResult
def dbt_callback(event: EventMsg) -> None:
return
res: dbtRunnerResult = dbtRunner(callbacks=[dbt_callback]).invoke(["--log-level","info","--log-level-file","debug","parse"])
Relevant log output
this is the first few lines from STDOUT, not the log file. I have removed the log path and profiles_dir.
:25:40.506397 [info ] [MainThread]: Running with dbt=1.5.1
DEBUG:file_log:16:25:40.508398 [debug] [MainThread]: running dbt with arguments {'printer_width': '80', 'indirect_selection': 'eager', 'write_json': 'True', 'log_cache_events': 'False', 'partial_parse': 'True', 'cache_selected_only': 'False', 'warn_error': 'None', 'version_check': 'True', 'debug': 'False', 'log_path': 'MANUALLY_REMOVED', 'fail_fast': 'False', 'profiles_dir': 'MANUALLY_REMOVED', 'use_colors': 'True', 'use_experimental_parser': 'False', 'no_print': 'None', 'quiet': 'False', 'log_format': 'default', 'introspect': 'True', 'warn_error_options': 'WarnErrorOptions(include=[], exclude=[])', 'static_parser': 'True', 'target_path': 'None', 'send_anonymous_usage_stats': 'True'}
github-actionsbot
changed the title
[Bug] DBT when using Programmatic invocations with callbacks overrides stdout to file log level
[CT-2703] [Bug] DBT when using Programmatic invocations with callbacks overrides stdout to file log level
Jun 14, 2023
@stevensnicholas Thank you for opening this issue. I've opened a PR which would fix this issue in dbt 1.6. In the meantime, the only way to sidestep this behavior might be to configure your logger directly, rather than calling basicConfig(), which adds a stdout logger to the root logger.
Is this a new bug in dbt-core?
Current Behavior
When using the dbtRunner with a callback function overrides the level of the current stdout to the level at which the file logging is set if logging.basicConfig was used.
The stdout is being given debug log, even when the log level is set to info
Expected Behavior
Only the log level info or the level set by --log-level are printed to stout
Steps To Reproduce
The below code should work on a simple DBT project
Relevant log output
Environment
Which database adapter are you using with dbt?
redshift
Additional Context
No response
The text was updated successfully, but these errors were encountered: