Skip to content

Commit efd85b5

Browse files
committed
view logs
1 parent a5ba92f commit efd85b5

1 file changed

Lines changed: 50 additions & 1 deletion

File tree

docs/examples/sqlmesh_cli_crash_course.md

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -679,7 +679,8 @@ This is great to catch issues before wasting runtime in your data warehouse. You
679679
You'll use these commands ad hoc to validate your changes are behaving as expected. Audits (data tests) are a great first step, and you'll want to evolve into to feel confident about the changes. The workflow is as follows:
680680

681681
1. Render the model to verify the SQL is looking as expected
682-
2. Run in debug mode to verify SQLMesh's behavior.
682+
2. Run in verbose mode to verify SQLMesh's behavior.
683+
3. View the logs easily in your terminal.
683684

684685
### Render your SQL Changes
685686

@@ -850,6 +851,54 @@ This is useful to see exactly what SQLMesh is doing in the physical and virtual
850851
✔ Virtual layer updated
851852
```
852853

854+
### View Logs Easily
855+
856+
Each time you perform a SQLMesh command, it creates a log file in the `logs` directory. This is useful to see what exact queries were executed to apply your changes. Admittedly, this is outside of native functionality, but it's a quick and easy way to view the logs.
857+
858+
```bash
859+
# install this open source tool that enhances the default `cat` command
860+
brew install bat
861+
```
862+
863+
```bash
864+
bat --theme='ansi' $(ls -t logs/ | head -n 1 | sed 's/^/logs\//')
865+
```
866+
867+
- In simple terms this command works like this: "Show me the contents of the newest log file in the logs directory, with nice formatting and syntax highlighting.”
868+
- press `q` to quit out of big files in the terminal
869+
870+
??? "Example Output"
871+
872+
This is the log file for the `sqlmesh plan dev` command. If you want to see the log file directly, you can click on the file path in the output directly to open it in your code editor.
873+
874+
```bash
875+
──────┬──────────────────────────────────────────────────────────────────────────────────────────────
876+
│ File: logs/sqlmesh_2025_04_18_12_34_35.log
877+
──────┼──────────────────────────────────────────────────────────────────────────────────────────────
878+
1 │ 2025-04-18 12:34:35,715 - MainThread - sqlmesh.core.config.connection - INFO - Creating new D
879+
│ uckDB adapter for data files: {'db.db'} (connection.py:319)
880+
2 │ 2025-04-18 12:34:35,951 - MainThread - sqlmesh.core.console - WARNING - Linter warnings for /
881+
│ Users/sung/Desktop/git_repos/sqlmesh-cli-revamp/models/incremental_by_partition.sql:
882+
3 │ - nomissingaudits: Model `audits` must be configured to test data quality. (console.py:1848)
883+
4 │ 2025-04-18 12:34:35,953 - MainThread - sqlmesh.core.console - WARNING - Linter warnings for /
884+
│ Users/sung/Desktop/git_repos/sqlmesh-cli-revamp/models/seed_model.sql:
885+
5 │ - nomissingaudits: Model `audits` must be configured to test data quality. (console.py:1848)
886+
6 │ 2025-04-18 12:34:35,953 - MainThread - sqlmesh.core.console - WARNING - Linter warnings for /
887+
│ Users/sung/Desktop/git_repos/sqlmesh-cli-revamp/models/incremental_by_unique_key.sql:
888+
7 │ - nomissingaudits: Model `audits` must be configured to test data quality. (console.py:1848)
889+
8 │ 2025-04-18 12:34:35,953 - MainThread - sqlmesh.core.console - WARNING - Linter warnings for /
890+
│ Users/sung/Desktop/git_repos/sqlmesh-cli-revamp/models/incremental_model.sql:
891+
9 │ - nomissingaudits: Model `audits` must be configured to test data quality. (console.py:1848)
892+
10 │ 2025-04-18 12:34:35,954 - MainThread - sqlmesh.core.config.connection - INFO - Using existing
893+
│ DuckDB adapter due to overlapping data file: db.db (connection.py:309)
894+
11 │ 2025-04-18 12:34:37,071 - MainThread - sqlmesh.core.snapshot.evaluator - INFO - Listing data
895+
│ objects in schema db.sqlmesh__sqlmesh_example (evaluator.py:338)
896+
12 │ 2025-04-18 12:34:37,072 - MainThread - sqlmesh.core.engine_adapter.base - INFO - Executing SQ
897+
│ L: SELECT CURRENT_CATALOG() (base.py:2128)
898+
13 │ 2025-04-18 12:34:37,072 - MainThread - sqlmesh.core.engine_adapter.base - INFO - Executing SQ
899+
│ L: SELECT CURRENT_CATALOG() (base.py:2128)
900+
```
901+
853902
## **Run Commands**
854903

855904
=== "SQLMesh"

0 commit comments

Comments
 (0)