Skip to content

[WIP] Format SQL query logs with DECLARE statements#169

Closed
Claude wants to merge 1 commit into
mainfrom
claude/format-sql-query-logs
Closed

[WIP] Format SQL query logs with DECLARE statements#169
Claude wants to merge 1 commit into
mainfrom
claude/format-sql-query-logs

Conversation

@Claude

@Claude Claude AI commented May 19, 2026

Copy link
Copy Markdown
Contributor

Thanks for asking me to work on this. I will get started on it and keep this PR's description up to date as I form a plan and make progress.


This section details on the original issue you should resolve

<issue_title>Format SQL query logs with DECLARE statements and readable multi-line output</issue_title>
<issue_description>When SQL queries are logged (slow queries, errors, etc.), the output is currently hard-to-read pino JSON with escaped newlines/tabs. It should instead print as proper multi-line SQL with the parameters declared at the top.

  • Current Output (from logs)
"query":"SELECT *\nFROM Table\tWHERE Id = @Id",
"parameters":{"Id":{"name":"Id","io":1,"value":5}}
  • Desired Output
DECLARE @Id INT = 5

SELECT *
FROM Table WHERE Id = @Id
  • What Changes Are Needed

Create a formatting helper that takes { query, parameters } and returns a string like:

DECLARE @Param1 TYPE1 = Value1
DECLARE @Param2 TYPE2 = Value2

SELECT ...
  1. Map mssql type constructors (Int, VarChar, DateTime2, Bit, etc.) to their SQL type names.
  2. Handle string quoting ('value'), NULL (= NULL), and date formatting in DECLARE lines.
  3. Preserve actual newlines/tabs in the query (don't JSON-escape them).
  4. Apply the helper at all 3 logging sites in the MSSQL module — slow query threshold logger, max query time warning logger, and query error logger.</issue_description>

Comments on the Issue (you are @claude[agent] in this section)

@Claude Claude AI linked an issue May 19, 2026 that may be closed by this pull request
@Claude Claude AI requested a review from yenduttjain May 19, 2026 07:47
Copilot stopped work on behalf of yenduttjain due to an error May 19, 2026 07:47
@yash-sharma-spraxa yash-sharma-spraxa deleted the claude/format-sql-query-logs branch June 5, 2026 06:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Format SQL query logs with DECLARE statements and readable multi-line output

3 participants