-
Notifications
You must be signed in to change notification settings - Fork 16
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(editor): Add CRITICAL
log level as alias for FATAL
(resolves #212).
#218
Conversation
WalkthroughThis change updates the tokenization rules within the Changes
Assessment against linked issues
Possibly related PRs
Suggested reviewers
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
🪧 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 (
|
Hi @junhaoliao , do I also need to submit an issue/PR in clp-ffi-js repo? Since there seems to be a necessary change to let decoder can set log level correctly. |
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
🧹 Nitpick comments (1)
src/components/Editor/MonacoInstance/theme.ts (1)
17-17
: Consider using a distinct color for CRITICAL in the DARK themeWhile the bold styling differentiates CRITICAL from WARN, they currently share the same foreground color ("#ce9178") in the DARK theme. Consider using a unique color for CRITICAL to improve visual distinction, similar to how the LIGHT theme implements different colors between WARN and CRITICAL.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
src/components/Editor/MonacoInstance/language.ts
(1 hunks)src/components/Editor/MonacoInstance/theme.ts
(2 hunks)src/components/Editor/MonacoInstance/typings.ts
(1 hunks)src/components/StatusBar/LogLevelSelect/LogLevelChip.tsx
(1 hunks)src/typings/logs.ts
(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
`**/*.{cpp,hpp,java,js,jsx,tpp,ts,tsx}`: - Prefer `false == ` rather than `!`.
**/*.{cpp,hpp,java,js,jsx,tpp,ts,tsx}
: - Preferfalse == <expression>
rather than!<expression>
.
src/typings/logs.ts
src/components/StatusBar/LogLevelSelect/LogLevelChip.tsx
src/components/Editor/MonacoInstance/language.ts
src/components/Editor/MonacoInstance/typings.ts
src/components/Editor/MonacoInstance/theme.ts
🧬 Code Definitions (3)
src/components/StatusBar/LogLevelSelect/LogLevelChip.tsx (1)
src/typings/logs.ts (1)
LOG_LEVEL
(57-57)
src/components/Editor/MonacoInstance/language.ts (1)
src/components/Editor/MonacoInstance/typings.ts (1)
TOKEN_NAME
(70-70)
src/components/Editor/MonacoInstance/theme.ts (1)
src/components/Editor/MonacoInstance/typings.ts (1)
TOKEN_NAME
(70-70)
🔇 Additional comments (5)
src/typings/logs.ts (1)
13-13
: Addition of CRITICAL log level looks goodThe new log level is appropriately positioned between WARN and ERROR in the severity hierarchy, which aligns with common logging conventions and the PR objective.
src/components/Editor/MonacoInstance/theme.ts (1)
35-35
: CRITICAL styling in LIGHT theme looks goodThe styling for CRITICAL matches ERROR and FATAL in the LIGHT theme, which correctly represents their equivalent severity levels.
src/components/Editor/MonacoInstance/typings.ts (1)
13-13
: Addition of CUSTOM_CRITICAL token name looks goodThe new token follows the consistent naming pattern of other log level tokens and is appropriately positioned in the enum.
src/components/Editor/MonacoInstance/language.ts (1)
27-30
: CRITICAL tokenization rule implementation looks goodThe implementation correctly adds a tokenization rule for the "CRITICAL" string that maps to the new TOKEN_NAME.CUSTOM_CRITICAL. The structure is consistent with other log level tokenization rules.
src/components/StatusBar/LogLevelSelect/LogLevelChip.tsx (1)
21-21
: LGTM! Appropriate mapping for CRITICAL log level.The addition of CRITICAL log level mapped to "danger" color correctly aligns with the PR objective of giving it the same severity as ERROR and FATAL log levels.
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.
The changes look clean. Nice work!
One thing I noticed is that this introduces an additional log level. A possible alternative could be treating CRITICAL
(which is unique to Python’s logging library compared to other common logging frameworks) as an alias for FATAL
. You can refer to the existing handling of the WARNING
level as an alias for WARN
in the TOKEN_NAME.CUSTOM_WARN
regex. This way, we can avoid adding extra LOG_LEVEL
and token name entries.
Let me know your thoughts, and thanks again for the contribution!
Reference
Python maps FATAL
to CRITICAL
with an identical severity number:
https://github.com/python/cpython/blob/151d1bfd1bb7ca9a36bb0f2bd6df53d64a1ba2f2/Lib/logging/__init__.py#L99
Sorry I misunderstood the requirement of this PR before. I will modify it, thanks for the comments :) |
Hi @junhaoliao I think the log level filter does not work correctly for this case. For example, if select "FATAL" the |
Not a problem! I do see benefits with your proposed solution because it makes sense to show For now, adding an alias is more of a shortcut, and this shortcut makes sense only because Python's logging library treats Before we proceed to support |
That's right. Internally we have some discussions regarding how that can be addressed, but the potential implementations haven't been shared publicly at y-scope/clp-ffi-js#70 . Let me try to get some help from @LinZhihao-723 to add the descriptions, and we may continue the discussion from there. |
I heard @LinZhihao-723 is one of the busiest guys🥲 Oops, didn't see you only want to add descriptions. |
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.
For the PR title, how about:
feat(editor): Add `CRITICAL` log level as alias for `FATAL` (resolves #212).
CRITICAL
log level as alias for FATAL
(resolves #212).
I changed it |
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.
LGTM.
No problem! I have mentioned you in y-scope/clp-ffi-js#70 Let us know if you have any questions there |
Description
This PR is to fix #212 . Add
CRITICAL
into the log level support and set it has the same severity asFATAL
andERROR
. However, the log level filter doesn't work because theclp-ffi-js
'sdecode_range
doesn't recoginizeCRITICAL
as one of its log level, so the log level ofCRITICAL
log lines is 0 (UNKNOWN
). I found it by put a printout inClpIrDecoder/index.ts:150
, but the root cause seems to be inclp-ffi-js
.Checklist
breaking change.
Validation performed
CLPFileHandler
to a logger. Invoke.critical("some message")
as well asfatal
(but I found thatfatal
also appendsCRITCAL
log, it is essentially using.critical()
in the code) anderror
on the logger to append aCRITICAL
level message.CRITICAL
is bolded and of the same color withFATAL
andERROR
Summary by CodeRabbit