-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
refactor(core): Move Logger to core
(no-changelog)
#12310
Conversation
Codecov ReportAttention: Patch coverage is 📢 Thoughts on this report? Let us know! |
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.
Thanks for taking this on! Code looks good, will give it a spin soon!
PS: I think we can omit (no-changelog)
for refactor
PRs
if (!this.isScopingEnabled) return info; | ||
|
||
const { scopes } = info.metadata; | ||
const { scopes } = (info as unknown as { metadata: LogMetadata }).metadata; |
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.
Why is this better than the original?
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.
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.
So confused, this should've been erroring out in cli
then? Also the TransformableInfo
type is left open [key: string | symbol]: any;
so worst case we shouldn't need the unknown
intermediary or? info.metadata as LogMetadata
export type LogMetadata = { | ||
[key: string]: unknown; | ||
scopes?: LogScope[]; | ||
file?: string; | ||
function?: string; | ||
}; | ||
export type Logger = Record< | ||
Exclude<LogLevel, 'silent'>, | ||
(message: string, metadata?: LogMetadata) => void | ||
>; | ||
export type LogLocationMetadata = Pick<LogMetadata, 'file' | 'function'>; |
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.
- Instead of picking from
LogMetadata
I wonder if it'd be more readable to defineLogLocationMetadata
as those two properties and intersect this type to createLogMetadata
? - I'm not clear just from this what
Logger
is here as opposed to theLogger
service. The proxy? Maybe we can docline this?
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.
I just copied this code over. I think we can refactor this bit in the next step when we get rid of more of the LoggerProxy
code.
if (!this.isScopingEnabled) return info; | ||
|
||
const { scopes } = info.metadata; | ||
const { scopes } = (info as unknown as { metadata: LogMetadata }).metadata; |
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.
So confused, this should've been erroring out in cli
then? Also the TransformableInfo
type is left open [key: string | symbol]: any;
so worst case we shouldn't need the unknown
intermediary or? info.metadata as LogMetadata
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.
Why remove the .service.
infix?
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.
I prefer the file name and the DI class names to align. I can add the .service
back, but then I prefer to rename the class to LoggerService
. Would that be acceptable?
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.
Turning all the logger
references to loggerService
makes the code everywhere more verbose for little gain. Do we need to be so consistent? I always thought of the -Service
suffix as an easy way to name classes that otherwise would be hard to name like WorklowService
but that doesn't really apply for the logger.
If the alternative is making all code more verbose, I'd rather omit the .service.
infix here. But I also notice that this is also inconsistent in that we're having some DI services infixed and some not.
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.
we don't need to rename all variables. I just meant the class. So the only change would be change the class name in this file to LoggerService
, and renaming the file back to logger.service.ts
.
however I personally the Service
suffix in this particular case not very useful.
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.
however I personally the Service suffix in this particular case not very useful.
Agree! In any case if this renaming won't cause lots of changes everywhere, I'd be happy with what you decide.
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.
Changes look good. There are some failing tests, likely needs merging master.
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.
Workflow tests seem to be failing for other PRs so I expect they're unrelated: https://github.com/n8n-io/n8n/actions/runs/12432707679/job/34712821182
|
n8n Run #8464
Run Properties:
|
Project |
n8n
|
Branch Review |
master
|
Run status |
Failed #8464
|
Run duration | 04m 14s |
Commit |
471d7b9420: 🌳 master 🖥️ browsers:node18.12.0-chrome107 🤖 PR User 🗃️ e2e/*
|
Committer | कारतोफ्फेलस्क्रिप्ट™ |
View all properties for this run ↗︎ |
Test results | |
---|---|
Failures |
1
|
Flaky |
2
|
Pending |
0
|
Skipped |
0
|
Passing |
276
|
View all changes introduced in this branch ↗︎ |
Tests for review
14-mapping.cy.ts • 1 failed test
Test | Artifacts | |
---|---|---|
Data mapping > maps expressions from json view |
Test Replay
Screenshots
Video
|
The first 5 failed specs are shown, see all 52 specs in Cypress Cloud.
45-ai-assistant.cy.ts • 1 flaky test
Test | Artifacts | |
---|---|---|
AI Assistant::enabled > should resize assistant chat down |
Test Replay
Screenshots
Video
|
19-execution.cy.ts • 1 flaky test
Test | Artifacts | |
---|---|---|
Execution > connections should be colored differently for pinned data > when executing a node |
Test Replay
Screenshots
Video
|
✅ All Cypress E2E specs passed |
Summary
This PR moved the
Logger
ton8n-core
, so that we can stop usingconsole.*
andLoggerproxy
in more places.Review / Merge checklist
release/backport
(if the PR is an urgent fix that needs to be backported)