A lightweight logging utility for dbt projects
Project description
dbt-logger
A logging utility that captures dbt command output and stores it in Snowflake for auditing and monitoring. Uses your existing dbt credentials - no additional configuration needed!
Installation
pip install dbt-logger
Quick Start
The simplest way - uses your existing dbt profiles.yml:
from dbt_logger import DbtLogger
# Automatically uses credentials from dbt profiles.yml
logger = DbtLogger(repo_name="my_analytics_project")
# Run dbt commands and log them
logger.run_command("dbt build")
logger.run_command("dbt run --select +sales_model")
That's it! Logs are automatically saved to [your_dbt_database].logging.dbt_logging
Configuration File (Optional)
Create dbt/dbt_logger.yml in your dbt project to configure logging destination:
# dbt/dbt_logger.yml
# Option 1: Custom schema in dbt database
schema: audit_logs
# Option 2: Completely separate database for logs
database: ADMIN_DB
schema: LOGGING
table_name: dbt_execution_logs
Precedence order:
- Parameters passed to
DbtLogger()(highest) - Settings in
dbt/dbt_logger.yml - Defaults:
{dbt_database}.logging.dbt_logging(lowest)
Configuration Options
Use Specific dbt Profile/Target
# Use a specific profile and target from profiles.yml
logger = DbtLogger(
repo_name="my_project",
profile_name="my_profile", # Optional: defaults to first profile
target="prod" # Optional: defaults to profile's default target
)
Override Logging Location in Code
# Override config file settings
logger = DbtLogger(
repo_name="my_project",
database="ADMIN_DB",
schema="LOGGING",
table_name="my_custom_logs"
)
Manual Connection Parameters (Advanced)
If you need to use different credentials than dbt:
from dbt_logger import DbtLogger, get_connection_params_from_env
# Option 1: From environment variables
connection_params = get_connection_params_from_env()
# Option 2: Manual dict
connection_params = {
'account': 'your_account',
'user': 'your_user',
'password': 'your_password',
'database': 'your_database',
'warehouse': 'your_warehouse',
}
logger = DbtLogger(
repo_name="my_project",
connection_params=connection_params
)
How It Works
- Reads your dbt profiles.yml - Automatically finds and parses your dbt configuration
- Supports private key auth - Works with your existing DBT_USER, DBT_PVK_PATH, DBT_PVK_PASS env vars
- Creates logging infrastructure - Auto-creates schema and table on first run
- Captures everything - Runs dbt commands and logs all output in real-time
- Stores in Snowflake - Saves command history for auditing and monitoring
Logging Table Schema
-- Default location: [your_dbt_database].logging.dbt_logging
CREATE TABLE dbt_logging (
repo_name STRING, -- Your dbt project/repo name
command STRING, -- The dbt command executed
stdout_log STRING, -- Complete command output
log_time TIMESTAMP_LTZ -- Execution timestamp
);
dbt profiles.yml Locations
The logger checks for profiles.yml in this order:
$DBT_PROFILES_DIR/profiles.yml./dbt/profiles/profiles.yml(current directory)~/.dbt/profiles.yml(default dbt location)
Features
- ✅ Zero Config - Uses your existing dbt credentials
- ✅ Private Key Auth - Full support for private key authentication
- ✅ Auto Setup - Creates schema and table automatically
- ✅ Real-time Output - See command output live while logging
- ✅ Flexible Storage - Default to dbt database or use separate logging database
- ✅ Environment Variables - Resolves Jinja env_var() expressions from profiles.yml
License
MIT License - see LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dbt_logger-0.1.0.tar.gz.
File metadata
- Download URL: dbt_logger-0.1.0.tar.gz
- Upload date:
- Size: 9.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2ef43c3097ccb20f9f98e0460c9c83a158fde9a52917ed944f2fc1125021810c
|
|
| MD5 |
f2df14d4f3781b2a176e939cbc215955
|
|
| BLAKE2b-256 |
71b1fa7fd46cc909d9e9ac9170115d380cb2b520fa46d7817d24936f171d9a56
|
Provenance
The following attestation bundles were made for dbt_logger-0.1.0.tar.gz:
Publisher:
publish.yml on TristanSchwartz/dbt-logger
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dbt_logger-0.1.0.tar.gz -
Subject digest:
2ef43c3097ccb20f9f98e0460c9c83a158fde9a52917ed944f2fc1125021810c - Sigstore transparency entry: 835744593
- Sigstore integration time:
-
Permalink:
TristanSchwartz/dbt-logger@8a29f206aa1d00d56011a222394e24a48caed755 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/TristanSchwartz
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@8a29f206aa1d00d56011a222394e24a48caed755 -
Trigger Event:
release
-
Statement type:
File details
Details for the file dbt_logger-0.1.0-py3-none-any.whl.
File metadata
- Download URL: dbt_logger-0.1.0-py3-none-any.whl
- Upload date:
- Size: 9.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eb58901724f2c4bbb6ecb0a70268979af4a058e4f94150bbe1f8651fe918bbcd
|
|
| MD5 |
78f35ff3021b77a9eb6f92764075b9cb
|
|
| BLAKE2b-256 |
6d1e40d5fbeff84b739b2fe4a9ab596387d8fb6a22777f857260b88ddafb7db6
|
Provenance
The following attestation bundles were made for dbt_logger-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on TristanSchwartz/dbt-logger
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dbt_logger-0.1.0-py3-none-any.whl -
Subject digest:
eb58901724f2c4bbb6ecb0a70268979af4a058e4f94150bbe1f8651fe918bbcd - Sigstore transparency entry: 835744598
- Sigstore integration time:
-
Permalink:
TristanSchwartz/dbt-logger@8a29f206aa1d00d56011a222394e24a48caed755 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/TristanSchwartz
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@8a29f206aa1d00d56011a222394e24a48caed755 -
Trigger Event:
release
-
Statement type: