Skip to content

Commit 39d0472

Browse files
committed
Ran dotnet format
1 parent d71d3f8 commit 39d0472

File tree

6 files changed

+58
-32
lines changed

6 files changed

+58
-32
lines changed

sample/ConsoleDemo/Program.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public class Program
1010
public static void Main()
1111
{
1212
ExceptionlessClient.Default.Startup("API_KEY");
13-
13+
1414
Log.Logger = new LoggerConfiguration()
1515
.MinimumLevel.Verbose()
1616
.WriteTo.Console(theme: AnsiConsoleTheme.Code)

sample/SampleWeb/Controllers/ValuesController.cs

+5-3
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public ValuesController(ILogger<ValuesController> logger)
2222
[HttpGet]
2323
public string Get()
2424
{
25-
_logger.LogInformation("Get was called");
25+
_logger.LogInformation("Get was called");
2626
return $"[{Activity.Current?.Id}] {User.Identity?.Name}";
2727
}
2828

@@ -32,7 +32,8 @@ public string AdvancedTopicUser()
3232
// This call is is authenticated so a user identity would automatically be set.
3333
// However we are overriding it with our own custom user. You may want to do this
3434
// in a microservice where you know the user but you may not be authenticated.
35-
using (LogContext.PushProperty(Event.KnownDataKeys.UserInfo, new UserInfo(User.Identity?.Name + " Custom", "Test User Full Name"), true)) {
35+
using (LogContext.PushProperty(Event.KnownDataKeys.UserInfo, new UserInfo(User.Identity?.Name + " Custom", "Test User Full Name"), true))
36+
{
3637
_logger.LogInformation("This log event will have a custom user set.");
3738
}
3839

@@ -43,7 +44,8 @@ public string AdvancedTopicUser()
4344
public string AdvancedTopicUserDescription(string description)
4445
{
4546
// User descriptions was intended to provide a description from an end user why an error happened.
46-
using (LogContext.PushProperty(Event.KnownDataKeys.UserDescription, new UserDescription(User.Identity?.Name, description), true)) {
47+
using (LogContext.PushProperty(Event.KnownDataKeys.UserDescription, new UserDescription(User.Identity?.Name, description), true))
48+
{
4749
_logger.LogError(new Exception("Test"), "This error event will have a user description set on it.");
4850
}
4951

sample/SampleWeb/Startup.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public Startup(IConfiguration configuration)
2222
// This method gets called by the runtime. Use this method to add services to the container.
2323
public void ConfigureServices(IServiceCollection services)
2424
{
25-
services.AddAuthentication("Test").AddScheme<AuthenticationSchemeOptions, TestAuthenticationHandler>("Test", options => {});
25+
services.AddAuthentication("Test").AddScheme<AuthenticationSchemeOptions, TestAuthenticationHandler>("Test", options => { });
2626
services.AddAuthorization();
2727
services.AddControllers();
2828
services.AddHttpContextAccessor();

src/Serilog.Sinks.Exceptionless/Sinks/Exceptionless/ExceptionlessClientExtensions.cs

+16-8
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@
88

99
namespace Serilog.Sinks.Exceptionless
1010
{
11-
public static class ExceptionlessClientExtensions {
12-
public static EventBuilder CreateFromLogEvent(this ExceptionlessClient client, LogEvent log) {
11+
public static class ExceptionlessClientExtensions
12+
{
13+
public static EventBuilder CreateFromLogEvent(this ExceptionlessClient client, LogEvent log)
14+
{
1315
string message = log.RenderMessage();
1416

1517
var builder = log.Exception != null
@@ -26,11 +28,13 @@ public static EventBuilder CreateFromLogEvent(this ExceptionlessClient client, L
2628
return builder;
2729
}
2830

29-
public static void SubmitFromLogEvent(this ExceptionlessClient client, LogEvent log) {
31+
public static void SubmitFromLogEvent(this ExceptionlessClient client, LogEvent log)
32+
{
3033
CreateFromLogEvent(client, log).Submit();
3134
}
3235

33-
internal static string GetSource(this LogEvent log) {
36+
internal static string GetSource(this LogEvent log)
37+
{
3438
if (log.Properties.TryGetValue(Constants.SourceContextPropertyName, out LogEventPropertyValue value))
3539
return value.FlattenProperties()?.ToString();
3640

@@ -77,30 +81,34 @@ internal static LogLevel GetLevel(this LogEventLevel log)
7781
/// by Serilog and brings properties closer to the structure of the original object.
7882
/// This enables Exceptionless to display the properties in a nicer way.
7983
/// </summary>
80-
internal static object FlattenProperties(this LogEventPropertyValue value) {
84+
internal static object FlattenProperties(this LogEventPropertyValue value)
85+
{
8186
if (value == null)
8287
return null;
8388

8489
if (value is ScalarValue scalar)
8590
return scalar.Value;
8691

87-
if (value is SequenceValue sequence) {
92+
if (value is SequenceValue sequence)
93+
{
8894
var flattenedProperties = new List<object>(sequence.Elements.Count);
8995
foreach (var element in sequence.Elements)
9096
flattenedProperties.Add(element.FlattenProperties());
9197

9298
return flattenedProperties;
9399
}
94100

95-
if (value is StructureValue structure) {
101+
if (value is StructureValue structure)
102+
{
96103
var flattenedProperties = new Dictionary<string, object>(structure.Properties.Count);
97104
foreach (var property in structure.Properties)
98105
flattenedProperties.Add(property.Name, property.Value.FlattenProperties());
99106

100107
return flattenedProperties;
101108
}
102109

103-
if (value is DictionaryValue dictionary) {
110+
if (value is DictionaryValue dictionary)
111+
{
104112
var flattenedProperties = new Dictionary<object, object>(dictionary.Elements.Count);
105113
foreach (var element in dictionary.Elements)
106114
flattenedProperties.Add(element.Key.Value, element.Value.FlattenProperties());

src/Serilog.Sinks.Exceptionless/Sinks/Exceptionless/ExceptionlessSink.cs

+21-12
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,13 @@
88
using Serilog.Core;
99
using Serilog.Events;
1010

11-
namespace Serilog.Sinks.Exceptionless {
11+
namespace Serilog.Sinks.Exceptionless
12+
{
1213
/// <summary>
1314
/// Exceptionless Sink
1415
/// </summary>
15-
public class ExceptionlessSink : ILogEventSink, IDisposable {
16+
public class ExceptionlessSink : ILogEventSink, IDisposable
17+
{
1618
private readonly string[] _defaultTags;
1719
private readonly Func<EventBuilder, EventBuilder> _additionalOperation;
1820
private readonly bool _includeProperties;
@@ -47,11 +49,13 @@ public ExceptionlessSink(
4749
Func<EventBuilder, EventBuilder> additionalOperation = null,
4850
bool includeProperties = true,
4951
LogEventLevel restrictedToMinimumLevel = LevelAlias.Minimum
50-
) {
52+
)
53+
{
5154
if (apiKey == null)
5255
throw new ArgumentNullException(nameof(apiKey));
5356

54-
_client = new ExceptionlessClient(config => {
57+
_client = new ExceptionlessClient(config =>
58+
{
5559
if (!String.IsNullOrEmpty(apiKey) && apiKey != "API_KEY_HERE")
5660
config.ApiKey = apiKey;
5761

@@ -84,23 +88,26 @@ public ExceptionlessSink(
8488
/// The minimum log event level required in order to write an event to the sink.
8589
/// </param>
8690
public ExceptionlessSink(
87-
Func<EventBuilder, EventBuilder> additionalOperation = null,
88-
bool includeProperties = true,
91+
Func<EventBuilder, EventBuilder> additionalOperation = null,
92+
bool includeProperties = true,
8993
ExceptionlessClient client = null,
9094
LogEventLevel restrictedToMinimumLevel = LevelAlias.Minimum
91-
) {
95+
)
96+
{
9297
_additionalOperation = additionalOperation;
9398
_includeProperties = includeProperties;
9499
_client = client ?? ExceptionlessClient.Default;
95100

96-
if (_client.Configuration.Resolver.HasDefaultRegistration<IExceptionlessLog, NullExceptionlessLog>()) {
101+
if (_client.Configuration.Resolver.HasDefaultRegistration<IExceptionlessLog, NullExceptionlessLog>())
102+
{
97103
_client.Configuration.UseLogger(new SelfLogLogger());
98104
}
99105

100106
_client.Configuration.SetDefaultMinLogLevel(restrictedToMinimumLevel.GetLevel());
101107
}
102108

103-
public void Emit(LogEvent logEvent) {
109+
public void Emit(LogEvent logEvent)
110+
{
104111
if (logEvent == null || !_client.Configuration.IsValid)
105112
return;
106113

@@ -110,7 +117,8 @@ public void Emit(LogEvent logEvent) {
110117

111118
var builder = _client.CreateFromLogEvent(logEvent).AddTags(_defaultTags);
112119

113-
if (_includeProperties) {
120+
if (_includeProperties)
121+
{
114122
foreach (var prop in logEvent.Properties)
115123
{
116124
switch (prop.Key)
@@ -142,7 +150,7 @@ public void Emit(LogEvent logEvent) {
142150
case "Tags":
143151
builder.AddTags(prop.Value.GetTags());
144152
break;
145-
default:
153+
default:
146154
builder.SetProperty(prop.Key, prop.Value.FlattenProperties());
147155
break;
148156
}
@@ -153,7 +161,8 @@ public void Emit(LogEvent logEvent) {
153161
builder.Submit();
154162
}
155163

156-
void IDisposable.Dispose() {
164+
void IDisposable.Dispose()
165+
{
157166
_client?.ProcessQueueAsync().GetAwaiter().GetResult();
158167
}
159168
}

src/Serilog.Sinks.Exceptionless/Sinks/Exceptionless/SelfLogLogger.cs

+14-7
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,32 @@
22
using Exceptionless.Logging;
33
using Serilog.Debugging;
44

5-
namespace Serilog.Sinks.Exceptionless {
6-
public class SelfLogLogger : IExceptionlessLog {
7-
public void Error(string message, string source = null, Exception exception = null) {
5+
namespace Serilog.Sinks.Exceptionless
6+
{
7+
public class SelfLogLogger : IExceptionlessLog
8+
{
9+
public void Error(string message, string source = null, Exception exception = null)
10+
{
811
SelfLog.WriteLine("Error: {0}, source: {1}, Exception: {2}", message, source, exception);
912
}
1013

11-
public void Info(string message, string source = null) {
14+
public void Info(string message, string source = null)
15+
{
1216
SelfLog.WriteLine("Info: {0}, source: {1}", message, source);
1317
}
1418

15-
public void Debug(string message, string source = null) {
19+
public void Debug(string message, string source = null)
20+
{
1621
SelfLog.WriteLine("Debug: {0}, source: {1}", message, source);
1722
}
1823

19-
public void Warn(string message, string source = null) {
24+
public void Warn(string message, string source = null)
25+
{
2026
SelfLog.WriteLine("Warn: {0}, source: {1}", message, source);
2127
}
2228

23-
public void Trace(string message, string source = null) {
29+
public void Trace(string message, string source = null)
30+
{
2431
SelfLog.WriteLine("Trace: {0}, source: {1}", message, source);
2532
}
2633

0 commit comments

Comments
 (0)