-
Notifications
You must be signed in to change notification settings - Fork 3
Introduced a pluggable logging system #20
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
base: stable
Are you sure you want to change the base?
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
|
Isn't Sourcery a blast? |
|
Yes it is, but I can't change the logging system, I'll try to review with the bugfix only :) |
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: