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

Documentation changes #83

Merged
merged 1 commit into from
Jan 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ private CacheEntry CreateCacheEntry(Type type)
var ti = type.GetTypeInfo();
var classDestructurer = ti.GetCustomAttribute<ITypeDestructuringAttribute>();
if (classDestructurer != null)
return new((o, f) => classDestructurer.CreateLogEventPropertyValue(o, f));
return new(classDestructurer.CreateLogEventPropertyValue);

var properties = type.GetPropertiesRecursive().ToList();
if (!_options.IgnoreNullProperties
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
using Serilog.Events;

namespace Destructurama.Attributed;

/// <summary>
Expand All @@ -6,9 +8,9 @@ namespace Destructurama.Attributed;
public class AttributedDestructuringPolicyOptions
{
/// <summary>
/// By setting IgnoreNullProperties to true no need to set [NotLoggedIfNull] for every logged property.
/// Custom types implementing IEnumerable, will be destructed as StructureValue and affected by IgnoreNullProperties
/// only in case at least one property (or the type itself) has Destructurama attribute applied.
/// By setting this property to <see langword="true"/> no need to set <see cref="NotLoggedIfNullAttribute"/>
/// for every logged property. Custom types implementing IEnumerable, will be destructed as <see cref="StructureValue"/>
/// and affected by this property only in case at least one property (or the type itself) has Destructurama attribute applied.
/// </summary>
public bool IgnoreNullProperties { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@
namespace Destructurama.Attributed;

/// <summary>
/// Base interfaces for all <see cref="Attribute"/>s that override how a property is destructured.
/// Base interface for all Destructurama attributes that override how a property is destructured.
/// </summary>
public interface IPropertyDestructuringAttribute
{
/// <summary>
/// Attempt to create a replacement <see cref="LogEventProperty"/> for a property.
/// </summary>
/// <param name="name">The current property name.</param>
/// <param name="value">The current property value</param>
/// <param name="value">The current property value.</param>
/// <param name="propertyValueFactory">The current <see cref="ILogEventPropertyValueFactory"/>.</param>
/// <param name="property">The <see cref="LogEventProperty"/> to use as a replacement.</param>
/// <returns><code>true</code>If a replacement <see cref="LogEventProperty"/> has been derived.</returns>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// Copyright 2020 Destructurama Contributors, Serilog Contributors
//
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//
// http://www.apache.org/licenses/LICENSE-2.0
//
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand All @@ -15,16 +15,16 @@
namespace Destructurama.Attributed;

/// <summary>
/// Base interfaces for all <see cref="Attribute"/>s that determine should a property be ignored.
/// Base interface for all Destructurama attributes that determine should a property be ignored.
/// </summary>
public interface IPropertyOptionalIgnoreAttribute
{
/// <summary>
/// Determine should a property be ignored
/// </summary>
/// <param name="name">The current property name</param>
/// <param name="value">The current property value</param>
/// <param name="type">The current property type</param>
/// <param name="name">The current property name.</param>
/// <param name="value">The current property value.</param>
/// <param name="type">The current property type.</param>
/// <returns></returns>
bool ShouldPropertyBeIgnored(string name, object? value, Type type);
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
namespace Destructurama.Attributed;

/// <summary>
/// Base interfaces for all <see cref="Attribute"/>s that override how a property type type is destructured.
/// Base interface for all Destructurama attributes that override how a property type is destructured.
/// </summary>
public interface ITypeDestructuringAttribute
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,11 @@ public class LogAsScalarAttribute : Attribute, ITypeDestructuringAttribute, IPro
/// <summary>
/// Construct a <see cref="LogAsScalarAttribute"/>.
/// </summary>
/// <param name="isMutable">Whether the scalar value should be converted into a string before
/// being passed down the (asynchronous) logging pipeline. For mutable types, specify
/// <code>true</code>, otherwise leave as false.</param>
/// <param name="isMutable">
/// Whether the scalar value should be converted into a string before
/// being passed down the (asynchronous) logging pipeline. For mutable
/// types, specify <code>true</code>, otherwise leave as false.
/// </param>
public LogAsScalarAttribute(bool isMutable = false)
{
_isMutable = isMutable;
Expand Down
3 changes: 3 additions & 0 deletions src/Destructurama.Attributed/Attributed/LogMaskedAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,17 @@ public class LogMaskedAttribute : Attribute, IPropertyDestructuringAttribute
/// If set, the property value will be set to this text.
/// </summary>
public string Text { get; set; } = DEFAULT_MASK;

/// <summary>
/// Shows the first x characters in the property value.
/// </summary>
public int ShowFirst { get; set; }

/// <summary>
/// Shows the last x characters in the property value.
/// </summary>
public int ShowLast { get; set; }

/// <summary>
/// If set, it will swap out each character with the default value. Note that this
/// property will be ignored if <see cref="Text"/> has been set to custom value.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
namespace Destructurama.Attributed;

/// <summary>
/// Apply to a property to use a replace the current value.
/// Apply to a property to replace the current value.
/// </summary>
[AttributeUsage(AttributeTargets.Property)]
public class LogReplacedAttribute : Attribute, IPropertyDestructuringAttribute
Expand All @@ -29,7 +29,7 @@ public class LogReplacedAttribute : Attribute, IPropertyDestructuringAttribute
private readonly string _replacement;

/// <summary>
/// The RegexOptions that will be applied. Defaults to <see cref="RegexOptions.None"/>
/// The options that will be applied. Defaults to <see cref="RegexOptions.None"/>
/// </summary>
public RegexOptions Options { get; set; }

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// Copyright 2020 Destructurama Contributors, Serilog Contributors
//
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//
// http://www.apache.org/licenses/LICENSE-2.0
//
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand All @@ -15,7 +15,7 @@
namespace Destructurama.Attributed;

/// <summary>
/// Specified that a property with null value should not be included when destructuring an object for logging.
/// Specified that a property with <see langword="null"/> value should not be included when destructuring an object for logging.
/// </summary>
[AttributeUsage(AttributeTargets.Property)]
public class NotLoggedIfNullAttribute : Attribute, IPropertyOptionalIgnoreAttribute
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ public static class LoggerConfigurationAppSettingsExtensions
public static LoggerConfiguration UsingAttributes(this LoggerDestructuringConfiguration configuration) =>
configuration.With<AttributedDestructuringPolicy>();


/// <summary>
/// Adds a custom <see cref="IDestructuringPolicy"/> to enable manipulation of how objects
/// are logged to Serilog using attributes.
/// </summary>
/// <param name="configuration">The logger configuration to apply configuration to.</param>
/// <param name="configure">Configure Destructurama options</param>
/// <param name="configure">Delegate to configure Destructurama options.</param>
/// <returns>An object allowing configuration to continue.</returns>
public static LoggerConfiguration UsingAttributes(this LoggerDestructuringConfiguration configuration,
Action<AttributedDestructuringPolicyOptions> configure)
public static LoggerConfiguration UsingAttributes(this LoggerDestructuringConfiguration configuration, Action<AttributedDestructuringPolicyOptions> configure)
{
var policy = new AttributedDestructuringPolicy(configure);
return configuration.With(policy);
Expand Down
Loading