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

CSHARP-4279: Logs truncation #891

Merged
merged 1 commit into from
Oct 12, 2022
Merged

Conversation

BorisDog
Copy link
Contributor

@BorisDog BorisDog commented Oct 4, 2022

Part of DRIVERS-1204

@BorisDog BorisDog requested review from DmitryLukyanov and JamesKovacs and removed request for DmitryLukyanov October 4, 2022 01:33
@JamesKovacs JamesKovacs requested review from rstam and removed request for JamesKovacs October 4, 2022 20:57
@rstam
Copy link
Contributor

rstam commented Oct 7, 2022

As I start to review this PR I'm finding a number of naming issues that I would have raised earlier if I had been part of earlier PRs.

As a general rule class names should not be plural (e.g., string not strings, Guid not Guids) with a few exceptions like XyzSettings.

Accordingly, I would like to see the following names changed in the new logging code:

EventsLogger => EventLogger
StructuredLogsTemplates => StructuredLogTemplate
LoggingFactory => LoggerFactory (because it returns an ILoggerFactory not an ILoggingFactory)
EventsPublisher => EventPublisher
EventsLogsFormattingOptions => EventLogFormattingOptions
Extentions => Extensions (spelling)
LogsTemplateProvider => LogTemplateProvider

It would probably make sense to make these changes in a separate PR addressing only the name changes and then rebase this PR on master after pushing those changes to master.

Copy link
Contributor

@rstam rstam left a comment

Choose a reason for hiding this comment

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

See comment about name changes that should be done as a separate PR before this one.

@rstam rstam self-requested a review October 7, 2022 18:48
@rstam
Copy link
Contributor

rstam commented Oct 7, 2022

Boris agrees the renamings should be in a separate PR but he wants to do it after this one, so I'm resuming review of this ignoring the naming issues for now.

https://jira.mongodb.org/browse/CSHARP-4348

namespace MongoDB.Driver.Core.Configuration
{
/// <summary>
/// Represents the settings for using SSL.
Copy link
Contributor

Choose a reason for hiding this comment

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

/// Represents the settings for logging.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, fixed.

public ILoggerFactory LoggerFactory { get; }

/// <summary>
/// Gets the maximal document size in chars
Copy link
Contributor

Choose a reason for hiding this comment

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

/// Gets the maximum document size in chars

"maximal" doesn't sound quite right to me.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

/// Initializes a new instance of the <see cref="LoggingSettings"/> class.
/// </summary>
/// <param name="loggerFactory">The logging factory.</param>
/// <param name="maxDocumentSize">The maximal document size in chars.</param>
Copy link
Contributor

Choose a reason for hiding this comment

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

    /// <param name="loggerFactory">The logger factory.</param>
    /// <param name="maxDocumentSize">The maximum document size in chars.</param>

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.


return
LoggerFactory == rhs.LoggerFactory &&
MaxDocumentSize == rhs.MaxDocumentSize;
Copy link
Contributor

Choose a reason for hiding this comment

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

Optionally could be simplified to:

        return
            rhs != null && // or equivalently: !object.ReferenceEquals(rhs, null)
            LoggerFactory == rhs.LoggerFactory &&
            MaxDocumentSize == rhs.MaxDocumentSize;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point, done.

/// <param name="obj">The <see cref="System.Object" /> to compare with this instance.</param>
/// <returns>
/// <c>true</c> if the specified <see cref="System.Object" /> is equal to this instance; otherwise, <c>false</c>.
/// </returns>
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of repeating the doc comments from the base class just use:

    /// <inheritdoc/>

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

/// </summary>
/// <returns>
/// A hash code for this instance.
/// </returns>
Copy link
Contributor

Choose a reason for hiding this comment

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

    /// <inheritdoc/>

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@BorisDog BorisDog requested a review from rstam October 7, 2022 20:38
Copy link
Contributor

@rstam rstam left a comment

Choose a reason for hiding this comment

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

LGTM

@BorisDog BorisDog requested a review from rstam October 11, 2022 21:07
Copy link
Contributor

@rstam rstam left a comment

Choose a reason for hiding this comment

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

Probably LGTM but I had some minor questions.

public void LogAndPublish<TEvent>(TEvent @event) where TEvent : struct, IEvent
=> LogAndPublish(null, @event);
public void LogAndPublish<TEvent>(TEvent @event, bool skipLog = false) where TEvent : struct, IEvent
=> LogAndPublish(null, @event, skipLog);
Copy link
Contributor

Choose a reason for hiding this comment

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

It's called skipLogging everywhere else

Copy link
Contributor

Choose a reason for hiding this comment

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

Not all overloads of LogAndPublish take the new skipLogging parameter.

I assume that's intentional?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Renamed.
The other overload is not used in places with where skipping logging is required. So for simplicity added only where it is necessary.
Side note: I believe that this parameter will be removed in CSHARP-3823

Copy link
Contributor

@rstam rstam left a comment

Choose a reason for hiding this comment

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

LGTM

@BorisDog BorisDog merged commit c0d3b4c into mongodb:master Oct 12, 2022
dnickless pushed a commit to dnickless/mongo-csharp-driver that referenced this pull request Aug 24, 2023
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.

2 participants