-
Notifications
You must be signed in to change notification settings - Fork 0
Implement comprehensive logging system #8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement comprehensive logging system #8
Conversation
Introduces a new logging service that logs to both console and database. Includes a new Log model for storing log entries and adds a new logs command. Co-authored-by: dan <dan@dans.im>
|
Cursor Agent can help with this pull request. Just |
Co-authored-by: dan <dan@dans.im>
Co-authored-by: dan <dan@dans.im>
dansimau
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good so far, but we need to also update all the existing log call sites to use the new logging service.
|
@cursoragent can you address code review feedback? |
|
I refactored the application's logging mechanism by introducing a dedicated
4 tasks completed
Learn more about Cursor Agents |
Co-authored-by: dan <dan@dans.im>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the final PR Bugbot will review for you during this billing cycle
Your free Bugbot reviews will reset on October 26
Details
You are on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle.
To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.
|
|
||
| func runLogsCommand(fromTime, toTime, lastDuration, entityID string) error { | ||
| // Open database connection using default path | ||
| db, err := store.Open("sqlite.db") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| if err != nil { | ||
| slog.Error("Error turning off light", "entity", l.GetID(), "error", err) | ||
| entityID := l.GetID() | ||
| l.connection.loggingService.Error("Error turning off light", &entityID, "entity", entityID, "error", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Variable Shadowing in Error Handling
The entityID variable is shadowed in the error handling blocks of TurnOn and TurnOff methods for Light and InputBoolean entities. The variable is already declared earlier in the function and can be reused.
Additional Locations (1)
|
|
||
| slog.Info("Button pressed", "entity", b.GetID(), "times", b.pressedTimes) | ||
| entityID := b.GetID() | ||
| b.connection.loggingService.Info("Button pressed", &entityID, "entity", entityID, "times", b.pressedTimes) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Button Action Method Fails Without Nil Check
The Button.Action method accesses b.connection.loggingService without a nil check for b.connection. If the connection is nil, this causes a panic. This differs from other entity methods (e.g., Light.TurnOn/TurnOff) that gracefully fall back to slog in similar situations.
Add a new logging service that persists application logs to the SQLite database and provides a CLI command for viewing and filtering them, fulfilling the requirements of TIK-5.
Linear Issue: TIK-5
Note
Introduce a database-backed logging service (with retention/pruning) and a new
hal logsCLI to view/filter logs; integrate logging across core and entities.logging.Servicefor unified console+DB logging with daily pruning and 30‑day retention (logging/service.go), plus tests (logging/service_test.go).Info,Error,Debug,Warnwrite to DB viastore.Log.hal logscommand (cmd/hal/commands/logs.go) to display logs with filters:--from,--to,--last,--entity-id; ordered chronologically.cmd/hal/main.go).slogcalls withloggingServiceinconnection.go,entity_button.go,entity_input_boolean.go,entity_light.go.loggingServicewith the app lifecycle.store.Logmodel and migrate instore/sqlite.go.github.com/spf13/cobrato direct dep; update.gitignoreto ignore DB files and/halbinary.Written by Cursor Bugbot for commit 2dd36b4. This will update automatically on new commits. Configure here.