feat(go/fio): debug logging via slog at LOG_LEVEL=DEBUG
All checks were successful
Deploy to K8s / deploy (push) Successful in 8s
All checks were successful
Deploy to K8s / deploy (push) Successful in 8s
Wires slog.SetDefault to honour LOG_LEVEL in all CLI commands and adds debug logs on the Fio fetch path so a silent "fetched 0 transaction(s)" can be diagnosed without code changes: - fio.New: which client variant (api/transparent) was selected - apiClient: GET URL (token redacted as ****), HTTP status, body bytes, parsed transaction count - transparentClient: GET URL, HTTP status, body bytes, plus parser stats (raw rows from second table, kept, dropped_bad_date, dropped_nonpositive_amount) Also suppresses the --print-fio-table block when zero transactions were fetched, so the bare header no longer prints under that condition. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
"log/slog"
|
||||
"net/http"
|
||||
"regexp"
|
||||
"strings"
|
||||
@@ -28,6 +29,10 @@ func (c *transparentClient) FetchTransactions(ctx context.Context, from, to time
|
||||
from.Format("2.1.2006"),
|
||||
to.Format("2.1.2006"),
|
||||
)
|
||||
slog.Debug("fio transparent: GET",
|
||||
"url", url,
|
||||
"from", from.Format("2006-01-02"), "to", to.Format("2006-01-02"))
|
||||
|
||||
req, err := http.NewRequestWithContext(ctx, http.MethodGet, url, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -37,6 +42,7 @@ func (c *transparentClient) FetchTransactions(ctx context.Context, from, to time
|
||||
return nil, err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
slog.Debug("fio transparent: response", "status", resp.StatusCode)
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
return nil, fmt.Errorf("fio transparent: HTTP %d", resp.StatusCode)
|
||||
}
|
||||
@@ -44,6 +50,7 @@ func (c *transparentClient) FetchTransactions(ctx context.Context, from, to time
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
slog.Debug("fio transparent: body read", "body_bytes", len(body))
|
||||
return parseTransparentHTML(body)
|
||||
}
|
||||
|
||||
@@ -63,6 +70,7 @@ func parseTransparentHTML(body []byte) ([]Transaction, error) {
|
||||
rows := extractSecondTableRows(body)
|
||||
|
||||
var txns []Transaction
|
||||
var droppedBadDate, droppedNonpositive int
|
||||
for _, row := range rows {
|
||||
col := func(i int) string {
|
||||
if i < len(row) {
|
||||
@@ -72,7 +80,12 @@ func parseTransparentHTML(body []byte) ([]Transaction, error) {
|
||||
}
|
||||
dateStr := parseCzechDate(col(tColDate))
|
||||
amount := parseCzechAmount(col(tColAmount))
|
||||
if dateStr == "" || amount <= 0 {
|
||||
if dateStr == "" {
|
||||
droppedBadDate++
|
||||
continue
|
||||
}
|
||||
if amount <= 0 {
|
||||
droppedNonpositive++
|
||||
continue
|
||||
}
|
||||
txns = append(txns, Transaction{
|
||||
@@ -86,6 +99,11 @@ func parseTransparentHTML(body []byte) ([]Transaction, error) {
|
||||
BankID: "", // not available on HTML path
|
||||
})
|
||||
}
|
||||
slog.Debug("fio transparent: parsed",
|
||||
"raw_rows", len(rows),
|
||||
"kept", len(txns),
|
||||
"dropped_bad_date", droppedBadDate,
|
||||
"dropped_nonpositive_amount", droppedNonpositive)
|
||||
return txns, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user