-
Notifications
You must be signed in to change notification settings - Fork 1
Implement log tagging for SDK logs #69
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: main
Are you sure you want to change the base?
Conversation
1dcaaca to
9cd8095
Compare
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.
TBH I don't understand this whole complexity behind. So, what we want achieve is just prefixing SDK logs with [SDK] or sth like that, and possibly user logs with [USER]. Most likely I don't understand security issues here, but seems a bit like an overkill to me and sth that can overcomplicate our lifes. Let's discuss this on call.
6c7d0fc to
51e57d8
Compare
Added SDK prefix ('SDK: ') to all logs coming from the SDK itself.
The class 'sdkconsole' isn't exported and so it shouldn't be possible to
generate it.
It's a convenience class, so that I was able to replace console logs
with minimal changes.
Split the communication into two channels, one for "SDK" and one for the 3rd party user called "USER". The channel name is written in front of the message (e.g: `[SDK] Uploading users`). The SDK needs to do additional steps to use the SDK channel, but 3rd party users don't.
52f571f to
87a94c1
Compare
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 added few suggestions, will probably add more comments in second review. However, since logger overrides console, can we use console.log/error/warn... at all other places, let's have clear distinction here?
Also, let's ask @navneel99 for quick review after tomorrow's meeting.
src/logger/logger.ts
Outdated
| export class Logger extends Console { | ||
| private options?: WorkerAdapterOptions; | ||
| private tags: EventContext & { dev_oid: string }; | ||
| private isVerifiedChannel: boolean = false; // false = unverified (default), true = verified |
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.
isSdkChannel rather than verified?
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.
Renamed
src/logger/logger.ts
Outdated
|
|
||
| const logObject = { | ||
| message, | ||
| verified: this.isVerifiedChannel, |
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.
Can we add this to tags variable?
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
| super(process.stdout, process.stderr); | ||
| this.options = options; | ||
| this.tags = { | ||
| ...event.payload.event_context, |
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.
Let's add verified here and we rather have something like sdk_log? verified is not self-explainatory in my opinion.
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've renamed the verified to sdk_log and moved it to tags.
| options, | ||
| }: SpawnFactoryInterface<ConnectorState>): Promise<void> { | ||
| const logger = new Logger({ event, options }); | ||
| const logger = getInternalLogger(new Logger({ event, options })); |
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.
Can we rather have factory function for this class (e.g. createLogger(isSdkLogger: boolean)?
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'm not entirely sure how to implement that.
createLogger(isSdkLogger: boolean, logger: Logger)
or
createLogger(isSdkLogger: boolean, event: EventContext, options: any)?
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.
Like this?
createLogger(isSdkLogger: boolean, event: AirdropEvent, options: any)
Description
This PR changes how the SDK internal logs are printed. As it currently stands, the SDK logs are all prefixed with
SDK:.Connected Issues
Checklist
npm run testOR no tests needed.npm run test:backwards-compatibility.