Introduced a pluggable logging system #20
Open
davidp57 wants to merge 2 commits intoChromium18:stablefrom
Open
Introduced a pluggable logging system #20davidp57 wants to merge 2 commits intoChromium18:stablefrom
davidp57 wants to merge 2 commits intoChromium18:stablefrom
Conversation
- moved vec3check higher in the code (else it's not found by one of the callers - sorry for triggering this bug)
Reviewer's Guide by SourceryThis pull request introduces a pluggable logging system to the AIEN script, allowing for more flexible and controlled logging of information. It also moves the Sequence diagram for logging an errorsequenceDiagram
participant AIEN
participant Logger
participant env
AIEN->>AIEN: AIEN.loggers.get(AIEN.Id):error("Error message", ...)
AIEN->>Logger: error(text, ...)
Logger->>Logger: formatText(text, ...)
Logger->>Logger: splitText(text)
Logger->>env: env.error(self.name .. '|' .. levelChar .. '|' .. texts[i])
env-->>AIEN: Logs the error message
Sequence diagram for logging an info messagesequenceDiagram
participant AIEN
participant Logger
participant env
AIEN->>AIEN: AIEN.loggers.get(AIEN.Id):info("Info message", ...)
AIEN->>Logger: info(text, ...)
Logger->>Logger: formatText(text, ...)
Logger->>Logger: splitText(text)
Logger->>env: env.info(self.name .. '|' .. levelChar .. '|' .. texts[i])
env-->>AIEN: Logs the info message
Class diagram for AIEN.LoggerclassDiagram
class AIEN.Logger {
-name: string
-level: number
--
+new(name: string, level: string|number): AIEN.Logger
+setName(value: string): self
+getName(): string
+setLevel(value: string|number, force: boolean): self
+getLevel(): number
+error(text: string, ...)
+warn(text: string, ...)
+info(text: string, ...)
+debug(text: string, ...)
+trace(text: string, ...)
+wouldLogWarn(): boolean
+wouldLogInfo(): boolean
+wouldLogDebug(): boolean
+wouldLogTrace(): boolean
+splitText(text: string): string[]
+formatText(text: string, ...): string
}
note for AIEN.Logger "Represents a logger instance with configurable level and name."
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey @davidp57 - I've reviewed your changes - here's some feedback:
Overall Comments:
- Consider using a more structured configuration, such as a table, instead of global variables for log levels.
- The AIEN.p function has a recursion limit, but it might be better to avoid recursion altogether for performance reasons.
Here's what I looked at during the review
- 🟢 General issues: all looks good
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟢 Complexity: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Contributor
Author
|
Isn't Sourcery a blast? |
Owner
|
Yes it is, but I can't change the logging system, I'll try to review with the bugfix only :) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Usage
To use the logging system, simply pass a string template (as you would use for string.format) as the first parameter, the parameters being the values to fill in the template.
The parameters will automatically be checked for null and transformed as a string; if they contain a table, they'll be displayed as a table.
Summary by Sourcery
Introduce a pluggable logging system to replace direct env.info calls with a more flexible and configurable logging mechanism
New Features:
Enhancements:
Chores: