Skip to content

Discord adapter#27

Open
Dobri9909 wants to merge 1 commit into
LuckboxGG:masterfrom
Dobri9909:1-feature
Open

Discord adapter#27
Dobri9909 wants to merge 1 commit into
LuckboxGG:masterfrom
Dobri9909:1-feature

Conversation

@Dobri9909
Copy link
Copy Markdown

No description provided.

type Config = LoggerAdapterConfig & {
webhookId: string,
token: string,
regex: RegExp,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets support multiple regexes

[SupportedLogLevels.Warn]: 3,
[SupportedLogLevels.Info]: 4,
[SupportedLogLevels.Debug]: 5,
[SupportedLogLevels.Debug]: 6,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

huh?

'content': message,
});
} catch (err) {
console.log('Something when wrong', err);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

went*

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't let the error propagate to the appropriate error handler instead?

}

public log(message: LogMessage): void {
const formattedMessageArray = this.formatMessage(message);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perhaps format the message only if any of the args match regex?

public log(message: LogMessage): void {
const formattedMessageArray = this.formatMessage(message);

if (formattedMessageArray.find((fmessage) => this.regex.test(fmessage))) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this necessary in order for the message to get logged? Looking at the other adapters, these are supposed to provide a general-purpose implementation which this functionality doesn't quite fit in. A better solution to this would be to create a decorator with the same interface as the rest of the adapters, but which will only log messages if they're matching certain criteria i.e. log level, arguments etc. This way we could implement application-specific logic, without polluting the logging library in general.

'content': message,
});
} catch (err) {
console.log('Something when wrong', err);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't let the error propagate to the appropriate error handler instead?

}
}

private formatMessage(message: LogMessage) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does a message formatted using this method look in Discord? Isn't there a better way to format the messages using its own formatting capabilities? For example:

image

Or rather have the format configurable.

Comment thread package.json
{
"name": "@luckbox/logger-factory",
"version": "4.0.0",
"version": "5.0.0",
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The proposed changes don't mandate a major version bump.

Comment thread package.json
},
"engines": {
"node": ">=12.14"
"node": ">=16"
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we're using anything that isn't present in Node 12, so this constraint seems rather unnecessary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants