-
Notifications
You must be signed in to change notification settings - Fork 1
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
feat: add logger service #24
base: main
Are you sure you want to change the base?
Conversation
WalkthroughA new Changes
Poem
Recent review detailsConfiguration used: CodeRabbit UI Files selected for processing (2)
Additional comments not posted (9)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 0
Outside diff range, codebase verification and nitpick comments (7)
src/app/core/services/logger.service.ts (7)
1-1
: Consider adding a brief class-level comment.Adding a comment at the beginning of the class to describe its purpose and usage can improve readability and maintainability.
+/** + * LoggerService provides structured logging capabilities. + * It includes methods for logging at various severity levels and formats log messages into a JSON structure. + */
11-36
: Add comments to describe the parameters and the return value.Adding comments to describe the parameters and the return value can improve readability and maintainability.
+/** + * Formats log messages into a JSON structure. + * @param {string} level - The log level (e.g., INFO, WARN, ERROR, FATAL). + * @param {string} severity - The severity of the log message. + * @param {string} tracebackId - The traceback identifier. + * @param {string} screenName - The name of the screen where the log originated. + * @param {string} source - The source of the log message. + * @param {string} deviceInfo - Information about the device. + * @param {string} data - Additional data to log. + * @param {string} message - The log message. + * @param {string} [stackTrace=''] - The stack trace (optional). + * @param {string} [timestamp=''] - The timestamp (optional). + * @returns {string} The formatted log message as a JSON string. + */
38-65
: Add comments to describe the parameters.Adding comments to describe the parameters can improve readability and maintainability.
+/** + * Logs messages at various severity levels. + * @param {string} level - The log level (e.g., INFO, WARN, ERROR, FATAL). + * @param {string} severity - The severity of the log message. + * @param {string} tracebackId - The traceback identifier. + * @param {string} screenName - The name of the screen where the log originated. + * @param {string} source - The source of the log message. + * @param {string} deviceInfo - Information about the device. + * @param {string} data - Additional data to log. + * @param {string} message - The log message. + * @param {string} [stackTrace] - The stack trace (optional). + * @param {string} [timestamp] - The timestamp (optional). + */
67-89
: Add comments to describe the parameters.Adding comments to describe the parameters can improve readability and maintainability.
+/** + * Logs messages at the INFO level. + * @param {string} severity - The severity of the log message. + * @param {string} tracebackId - The traceback identifier. + * @param {string} screenName - The name of the screen where the log originated. + * @param {string} source - The source of the log message. + * @param {string} deviceInfo - Information about the device. + * @param {string} data - Additional data to log. + * @param {string} message - The log message. + * @param {string} [stackTrace] - The stack trace (optional). + */
91-112
: Add comments to describe the parameters.Adding comments to describe the parameters can improve readability and maintainability.
+/** + * Logs messages at the WARN level. + * @param {string} severity - The severity of the log message. + * @param {string} tracebackId - The traceback identifier. + * @param {string} screenName - The name of the screen where the log originated. + * @param {string} source - The source of the log message. + * @param {string} deviceInfo - Information about the device. + * @param {string} data - Additional data to log. + * @param {string} message - The log message. + * @param {string} [stackTrace] - The stack trace (optional). + */
114-135
: Add comments to describe the parameters.Adding comments to describe the parameters can improve readability and maintainability.
+/** + * Logs messages at the ERROR level. + * @param {string} severity - The severity of the log message. + * @param {string} tracebackId - The traceback identifier. + * @param {string} screenName - The name of the screen where the log originated. + * @param {string} source - The source of the log message. + * @param {string} deviceInfo - Information about the device. + * @param {string} data - Additional data to log. + * @param {string} message - The log message. + * @param {string} [stackTrace] - The stack trace (optional). + */
137-158
: Add comments to describe the parameters.Adding comments to describe the parameters can improve readability and maintainability.
+/** + * Logs messages at the FATAL level. + * @param {string} severity - The severity of the log message. + * @param {string} tracebackId - The traceback identifier. + * @param {string} screenName - The name of the screen where the log originated. + * @param {string} source - The source of the log message. + * @param {string} deviceInfo - Information about the device. + * @param {string} data - Additional data to log. + * @param {string} message - The log message. + * @param {string} [stackTrace] - The stack trace (optional). + */
providedIn: 'root', | ||
}) | ||
export class LoggerService { | ||
private sessionId = 'sample-session-id'; // Replace with actual session ID logic |
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.
Add a method here to generate a session Id too.
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.
added a method for generating session id
stackTrace?: string, | ||
): void { | ||
this.log( | ||
'WARN', |
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.
All the values like log level, severity should come from enum values.
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.
added enum values for log level and severity and used them in logger service
level: string, | ||
severity: string, | ||
tracebackId: string, | ||
screenName: string, |
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 should handle filling up most generic fields like screenName, deviceInfo, source, timestamp etc.
When in use we only add message and stacktrace. Also what is the plan/idea for tracebackId?
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.
wrote function for filling these generic fields
The tracebackId will be a unique identifier for each log entry, helping us trace and correlate related logs. It's generated using a combination of the current timestamp and a random value to ensure uniqueness.
(I saw this was added in initial setup for pickleball logger service file, so I added it here too)
Changes in PR:
Summary by CodeRabbit