Skip to content
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

Feature logger #21

Merged
merged 10 commits into from
Aug 26, 2024
Merged

Feature logger #21

merged 10 commits into from
Aug 26, 2024

Conversation

smellilac
Copy link
Contributor

No description provided.

Copy link

deepsource-io bot commented Jul 26, 2024

Here's the code health analysis summary for commits 82e74db..3fdc42d. View details on DeepSource ↗.

Analysis Summary

AnalyzerStatusSummaryLink
DeepSource C# LogoC#✅ SuccessView Check ↗

💡 If you’re a repository administrator, you can configure the quality gates from the settings.

@smellilac
Copy link
Contributor Author

Git asking to add to name of "LogMessage" method, because because it sees Task in the method return parameter, but I use
Task.CompletedTask; so it doesn't make sense

@HEJOK254
Copy link
Owner

Git asking to add to name of "LogMessage" method, because because it sees Task in the method return parameter, but I use
Task.CompletedTask; so it doesn't make sense

There seems to be a lot of debate in the c# community regarding the naming of async functions. I chose to go with Microsoft's guidelines, and add the Async suffix to the method names, as DeepSource tells me to do.

The internet has different opinions about adding the Async suffix to Tasks without the async modifier aswell. I'd rename it to LogMessageAsync, but I'm not sure how others like it. I'm not really sure what to do here to be honest

@smellilac
Copy link
Contributor Author

Git asking to add to name of "LogMessage" method, because because it sees Task in the method return parameter, but I use
Task.CompletedTask; so it doesn't make sense

There seems to be a lot of debate in the c# community regarding the naming of async functions. I chose to go with Microsoft's guidelines, and add the Async suffix to the method names, as DeepSource tells me to do.

The internet has different opinions about adding the Async suffix to Tasks without the async modifier aswell. I'd rename it to LogMessageAsync, but I'm not sure how others like it. I'm not really sure what to do here to be honest

In this case it is not necessary, since the method does not perform asynchronous operations.
I think it would be more misleading than reflective of the asynchronicity.

@HEJOK254
Copy link
Owner

In this case it is not necessary, since the method does not perform asynchronous operations.
I think it would be more misleading than reflective of the asynchronicity.

In this case, the issue can be ignored by adding a comment in the same line, or the line above: skipcq: CS-R1073

@smellilac
Copy link
Contributor Author

In this case it is not necessary, since the method does not perform asynchronous operations.
I think it would be more misleading than reflective of the asynchronicity.

In this case, the issue can be ignored by adding a comment in the same line, or the line above: skipcq: CS-R1073

It was good idea :)

@HEJOK254
Copy link
Owner

HEJOK254 commented Aug 1, 2024

Sorry for the delay, I'm going to try to review the pr today and suggest some changes if needed

Copy link
Owner

@HEJOK254 HEJOK254 left a comment

Choose a reason for hiding this comment

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

I've reviewed the changes, and everything seems to be working great, however I made come suggestions here and there.

Keep in mind that these are just suggestions :)

Program.cs Outdated Show resolved Hide resolved
Commands/InteractionServiceHandler.cs Outdated Show resolved Hide resolved
Commands/InteractionServiceHandler.cs Outdated Show resolved Hide resolved
Commands/InteractionServiceHandler.cs Outdated Show resolved Hide resolved
Commands/InteractionServiceHandler.cs Outdated Show resolved Hide resolved
LoggerConfig/LoggerImplementation/AutoLog.cs Outdated Show resolved Hide resolved
LoggerConfig/LoggerImplementation/AutoLog.cs Outdated Show resolved Hide resolved
LoggerConfig/LoggerImplementation/AutoLog.cs Outdated Show resolved Hide resolved
LoggerConfig/LoggerImplementation/AutoLog.cs Outdated Show resolved Hide resolved
LoggerConfig/SerilogConfiguration.cs Outdated Show resolved Hide resolved
@HEJOK254 HEJOK254 added the enhancement New feature or request label Aug 2, 2024
@smellilac smellilac requested a review from HEJOK254 August 2, 2024 11:43
@HEJOK254 HEJOK254 linked an issue Aug 3, 2024 that may be closed by this pull request
@smellilac
Copy link
Contributor Author

You don't merge PR.
Want to add/correct something?

@HEJOK254
Copy link
Owner

HEJOK254 commented Aug 8, 2024

You don't merge PR.
Want to add/correct something?

Sorry, I've been out of town for a few days, so I wasn't able to review it

I should be back in a few days, and I'll try to review it when I can

Sorry for the delay

Copy link
Owner

@HEJOK254 HEJOK254 left a comment

Choose a reason for hiding this comment

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

I've reviewed the changes, sorry for the delay

QuickEdit.Logger/LoggerImplementation/AutoLog.cs Outdated Show resolved Hide resolved
Copy link
Owner

Choose a reason for hiding this comment

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

I meant the namespace in the file, not the folder name, sorry :/

So the folder would be called Logger (and the file path would be /Logger/SerilogConfiguration.cs), while the namespace on line 9 could be for example QuickEdit.Logger

@smellilac
Copy link
Contributor Author

delay

No problem. Glad to have you back!

@smellilac
Copy link
Contributor Author

smellilac commented Aug 14, 2024

I renamed the main folder to "Logger" and deleted the "LoggerImplementation" folder.

I hope we understand each other correctly now, if not, please let me know.

Copy link
Owner

@HEJOK254 HEJOK254 left a comment

Choose a reason for hiding this comment

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

It's all good now, but I think AutoLog and SerilogConfiguration should be in the same namespace, since they're only 2 classes, and they're related

Logger/SerilogConfiguration.cs Outdated Show resolved Hide resolved
Program.cs Outdated Show resolved Hide resolved
@HEJOK254 HEJOK254 self-requested a review August 15, 2024 10:28
HEJOK254
HEJOK254 previously approved these changes Aug 17, 2024
Copy link
Owner

@HEJOK254 HEJOK254 left a comment

Choose a reason for hiding this comment

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

Looks good!

I'd clean up the commit history a bit by doing an interactive rebase if you're ok with that. It would basically rewrite the commit history, in such a way that, for example, some of the small commits fixing an issue with the previous commit, which are quite common when working on a feature, could be merged into one, cleaning up the history a bit before getting merged.

This would also require a force push, to rewrite the commits. I always make sure to keep a backup of the branch, though, in case something goes wrong.

After that, I would slightly clean up all the files, like for example fixing some broken indentations in some places probably caused by me forgetting to add them in the review suggestions :P

I'm not an expert at git, and this is pretty much my first time collaborating with other people on GitHub (thanks :)), which is why I'm always asking about everything. I can just leave the commit history as is and merge the PR, or squash merge it if needed, but I just thought it would be better to tidy it up a bit.

@smellilac
Copy link
Contributor Author

Looks good!

I'd clean up the commit history a bit by doing an interactive rebase if you're ok with that. It would basically rewrite the commit history, in such a way that, for example, some of the small commits fixing an issue with the previous commit, which are quite common when working on a feature, could be merged into one, cleaning up the history a bit before getting merged.

This would also require a force push, to rewrite the commits. I always make sure to keep a backup of the branch, though, in case something goes wrong.

After that, I would slightly clean up all the files, like for example fixing some broken indentations in some places probably caused by me forgetting to add them in the review suggestions :P

I'm not an expert at git, and this is pretty much my first time collaborating with other people on GitHub (thanks :)), which is why I'm always asking about everything. I can just leave the commit history as is and merge the PR, or squash merge it if needed, but I just thought it would be better to tidy it up a bit.

Yes, indeed, the PR looks dirty, so I'm all for you cleaning it up.

I'm also far from being a professional in git and this is also my first work in collaboration (thank you very much too!), but as far as I understand, I can't help with cleaning the commits, since I don't have the necessary rights in your repository. However, I can clean the code and upload the commit.

After which you will start cleaning, okay?

@HEJOK254
Copy link
Owner

However, I can clean the code and upload the commit.

Yeah, you can do that if you want.
I was basically thinking of fixing the indentations and formatting, plus maybe removing the unused using directives. All of that can be achieved by running a clean-up in Visual Studio, as far as I'm aware, and additionally double-checking if everything is correct and works properly.

I can do it if you don't want to, and as for the history clean-up, I wanted to do it in this pull request, so on your fork, in your branch, as I think I should have the necessary permissions for it, but I'm not sure yet.

After that, I'll merge the pr

@smellilac
Copy link
Contributor Author

After that, I'll merge the pr

Ok, I didn't know it was so easy to clean up code from extra spaces and unused directives.

In that case, I'm waiting for your code cleaning, as well as cleaning up commits.

smellilac and others added 7 commits August 22, 2024 15:22
Fix DeepSource flagging `AutoLog.LogMessage()` as async (CS-R1073)
Co-authored-by: Jakub Dębski <90698026+HEJOK254@users.noreply.github.com>
Improved log messages by:
 - Adding more error information to the log messages
 - Making them less verbose
 - Adding additional debug information in debug mode (config.json)

Co-authored-by: Jakub Dębski <90698026+HEJOK254@users.noreply.github.com>
Co-authored-by: Jakub Dębski <90698026+HEJOK254@users.noreply.github.com>
Fixed things like:
 - indentation
 - formatting
 - file format (Central European (Windows) -> UTF-8)
 - access modifiers (program class is now internal)
 - removed unused `using` directives
@HEJOK254
Copy link
Owner

I pushed the changes to HEJOK254/Discord-QuickEdit/feature/logger-preview, instead of force pushing it to your branch, so we can discuss the changes and change things if needed, without having to force push on your branch all the time.

Please check if everything looks ok, or if I should rename/delete/squash etc. some commits. I tried to keep the commits small, which should help in troubleshooting in case one of them introduced some issue, while also grouping together changes regarding the same "feature", like for example improving the log messages.

If you have any suggestions, let me know, and I'll be happy to change it

@smellilac
Copy link
Contributor Author

If you have any suggestions, let me know, and I'll be happy to change it

I looked at the commits in this branch. They look clean and structured. I have no ideas/wishes, in my opinion you did everything well.

Copy link
Owner

@HEJOK254 HEJOK254 left a comment

Choose a reason for hiding this comment

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

While reviewing the code before merging, a few things have caught my eye, that I think should be fixed

Sorry I'm noticing about it just now

Logger/SerilogConfiguration.cs Outdated Show resolved Hide resolved
Logger/SerilogConfiguration.cs Outdated Show resolved Hide resolved
smellilac and others added 3 commits August 26, 2024 16:18
- Removed log enrichment
- Changed the path to the log file to the universal directory

Co-authored-by: Jakub Dębski <90698026+HEJOK254@users.noreply.github.com>
Since 76c6a1 the package `Serilog.Enrichers.Environment` is not needed anymore, as it's unused

Forgot to remove it while reviewing the PR whoops
Empty interpolated string (CS-W1000)

Forgot to remove that `$` while reviewing the PR whoops (76c6a12)
@HEJOK254
Copy link
Owner

I forgot to remove that $ sign in SerilogConfiguration.cs in the review suggestion, which was causing the DeepSource issue, and I also forgot to add a suggestion to remove the Serilog Enricher, which is now unused, so I went ahead and committed the fixes myself, hope that's not an issue

Anyway, I think the PR is ready to be merged. If you have any questions or any more changes you would like to make, let me know, if not, I'll merge it soon :)

@smellilac
Copy link
Contributor Author

Anyway, I think the PR is ready to be merged. If you have any questions or any more changes you would like to make, let me know, if not, I'll merge it soon :)

No questions or suggestions.

Thank you for working together!

@HEJOK254
Copy link
Owner

No questions or suggestions.

Ok, I'll merge it now

Thanks for helping me with the project :)

@HEJOK254 HEJOK254 merged commit 64bc013 into HEJOK254:dev Aug 26, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Implement a (proper) logger
2 participants