-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
1,498 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
// Use IntelliSense to learn about possible attributes. | ||
// Hover to view descriptions of existing attributes. | ||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | ||
"version": "0.2.0", | ||
"configurations": [] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
{ | ||
// See https://go.microsoft.com/fwlink/?LinkId=733558 | ||
// for the documentation about the tasks.json format | ||
"version": "2.0.0", | ||
"tasks": [ | ||
{ | ||
"label": "build", | ||
"command": "dotnet", | ||
"type": "shell", | ||
"args": [ | ||
"build", | ||
"/property:GenerateFullPaths=true", | ||
"/consoleloggerparameters:NoSummary" | ||
], | ||
"group": "build", | ||
"presentation": { | ||
"reveal": "silent" | ||
}, | ||
"problemMatcher": "$msCompile" | ||
}, | ||
{ | ||
"label": "clean", | ||
"command": "dotnet", | ||
"type": "shell", | ||
"args": [ | ||
"clean", | ||
"/property:GenerateFullPaths=true", | ||
"/consoleloggerparameters:NoSummary" | ||
], | ||
"group": "build", | ||
"presentation": { | ||
"reveal": "silent" | ||
}, | ||
"problemMatcher": [] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
// This file is part of the TA.Ascom.ReactiveCommunications project | ||
// | ||
// Copyright © 2015-2020 Tigra Astronomy, all rights reserved. | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated | ||
// documentation files (the "Software"), to deal in the Software without restriction, including without limitation | ||
// the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to | ||
// permit persons to whom the Software is furnished to do so. The Software comes with no warranty of any kind. | ||
// You make use of the Software entirely at your own risk and assume all liability arising from your use thereof. | ||
// | ||
// File: DegenerateLogBuilder.cs Last modified: 2020-07-14@09:03 by Tim Long | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Diagnostics; | ||
|
||
namespace TA.Utils.Core.Diagnostics | ||
{ | ||
/// <summary> | ||
/// A degenerate log builder that does nothing and produces no output. | ||
/// Can be used as a default log builder when logging is disabled. | ||
/// Implements the <see cref="TA.Utils.Core.Diagnostics.IFluentLogBuilder" /> | ||
/// </summary> | ||
/// <seealso cref="TA.Utils.Core.Diagnostics.IFluentLogBuilder" /> | ||
public sealed class DegenerateLogBuilder : IFluentLogBuilder | ||
{ | ||
/// <inheritdoc /> | ||
public IFluentLogBuilder Exception(Exception exception) => this; | ||
|
||
/// <inheritdoc /> | ||
public IFluentLogBuilder LoggerName(string loggerName) => this; | ||
|
||
/// <inheritdoc /> | ||
public IFluentLogBuilder Message(string message) => this; | ||
|
||
/// <inheritdoc /> | ||
public IFluentLogBuilder Message(string format, params object[] args) => this; | ||
|
||
/// <inheritdoc /> | ||
public IFluentLogBuilder Message(IFormatProvider provider, string format, params object[] args) => this; | ||
|
||
/// <inheritdoc /> | ||
public IFluentLogBuilder Property(string name, object value) => this; | ||
|
||
/// <inheritdoc /> | ||
public IFluentLogBuilder Properties(IDictionary<string, object> properties) => this; | ||
|
||
/// <inheritdoc /> | ||
public IFluentLogBuilder TimeStamp(DateTime timeStamp) => this; | ||
|
||
/// <inheritdoc /> | ||
public IFluentLogBuilder StackTrace(StackTrace stackTrace, int userStackFrame) => this; | ||
|
||
/// <inheritdoc /> | ||
public void Write(string callerMemberName = null, string callerFilePath = null, | ||
int callerLineNumber = default) { } | ||
|
||
/// <inheritdoc /> | ||
public void WriteIf(Func<bool> condition, string callerMemberName = null, string callerFilePath = null, | ||
int callerLineNumber = default) { } | ||
|
||
/// <inheritdoc /> | ||
public void WriteIf(bool condition, string callerMemberName = null, string callerFilePath = null, | ||
int callerLineNumber = default) { } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// This file is part of the TA.Ascom.ReactiveCommunications project | ||
// | ||
// Copyright © 2015-2020 Tigra Astronomy, all rights reserved. | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated | ||
// documentation files (the "Software"), to deal in the Software without restriction, including without limitation | ||
// the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to | ||
// permit persons to whom the Software is furnished to do so. The Software comes with no warranty of any kind. | ||
// You make use of the Software entirely at your own risk and assume all liability arising from your use thereof. | ||
// | ||
// File: DegenerateLoggerService.cs Last modified: 2020-07-14@09:02 by Tim Long | ||
|
||
namespace TA.Utils.Core.Diagnostics | ||
{ | ||
/// <summary> | ||
/// This is the default logging service used if non is supplied by the user. The service does | ||
/// nothing and produces no output. It is essentially "logging disabled". | ||
/// </summary> | ||
public sealed class DegenerateLoggerService : ILog | ||
{ | ||
private static IFluentLogBuilder builder = new DegenerateLogBuilder(); | ||
/// <inheritdoc /> | ||
public IFluentLogBuilder Trace(string callerFilePath = null) => builder; | ||
|
||
/// <inheritdoc /> | ||
public IFluentLogBuilder Debug(string callerFilePath = null) => builder; | ||
|
||
/// <inheritdoc /> | ||
public IFluentLogBuilder Info(string callerFilePath = null) => builder; | ||
|
||
/// <inheritdoc /> | ||
public IFluentLogBuilder Warn(string callerFilePath = null) => builder; | ||
|
||
/// <inheritdoc /> | ||
public IFluentLogBuilder Error(string callerFilePath = null) => builder; | ||
|
||
/// <inheritdoc /> | ||
public IFluentLogBuilder Fatal(string callerFilePath = null) => builder; | ||
|
||
/// <inheritdoc /> | ||
public void Shutdown() { } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
// This file is part of the TA.Ascom.ReactiveCommunications project | ||
// | ||
// Copyright © 2015-2020 Tigra Astronomy, all rights reserved. | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated | ||
// documentation files (the "Software"), to deal in the Software without restriction, including without limitation | ||
// the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to | ||
// permit persons to whom the Software is furnished to do so. The Software comes with no warranty of any kind. | ||
// You make use of the Software entirely at your own risk and assume all liability arising from your use thereof. | ||
// | ||
// File: IFluentLogBuilder.cs Last modified: 2020-07-14@07:01 by Tim Long | ||
|
||
using System; | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using System.Diagnostics; | ||
using System.Runtime.CompilerServices; | ||
|
||
namespace TA.Utils.Core.Diagnostics | ||
{ | ||
/// <summary> | ||
/// Fluent Log Builder | ||
/// </summary> | ||
public interface IFluentLogBuilder | ||
{ | ||
/// <summary> | ||
/// Add an exception to the log entry. | ||
/// </summary> | ||
IFluentLogBuilder Exception(Exception exception); | ||
|
||
/// <summary> | ||
/// Set the log (source) name. By default, this is the name of the source file. | ||
/// </summary> | ||
IFluentLogBuilder LoggerName(string loggerName); | ||
|
||
/// <summary> | ||
/// Sets the message template for the log entry. | ||
/// The message may be a simple plain text string, | ||
/// it may contain numbered substitution tokens like string.Format, | ||
/// or it may contain named substitution tokens enclosed in {braces} | ||
/// </summary> | ||
IFluentLogBuilder Message(string message); | ||
|
||
/// <summary> | ||
/// Sets the message template and property values for the log entry. | ||
/// The format string may use numbered positional placeholders like string.Format, | ||
/// or it may contain named substitution tokens enclosed in {braces}. | ||
/// </summary> | ||
IFluentLogBuilder Message(string format, params object[] args); | ||
|
||
/// <summary> | ||
/// Sets the message template and property values for the log entry. | ||
/// The format provider will be used when rendering the property values. | ||
/// </summary> | ||
IFluentLogBuilder Message(IFormatProvider provider, string format, params object[] args); | ||
|
||
/// <summary> | ||
/// Adds a named property and value pair to the log entry. | ||
/// </summary> | ||
IFluentLogBuilder Property(string name, object value); | ||
|
||
/// <summary> | ||
/// Adds a collection of property/value pairs to the log entry. | ||
/// </summary> | ||
IFluentLogBuilder Properties(IDictionary<string,object> properties); | ||
|
||
/// <summary> | ||
/// Sets the time stamp of the log entry. | ||
/// If not set, the log entry will be timed at the moment Write() was called. | ||
/// </summary> | ||
IFluentLogBuilder TimeStamp(DateTime timeStamp); | ||
|
||
/// <summary> | ||
/// Adds a stack trace to the log entry. | ||
/// </summary> | ||
IFluentLogBuilder StackTrace(StackTrace stackTrace, int userStackFrame); | ||
|
||
/// <summary> | ||
/// Writes the log entry. | ||
/// </summary> | ||
void Write([CallerMemberName] string callerMemberName = null, [CallerFilePath] string callerFilePath = null, | ||
[CallerLineNumber] int callerLineNumber = default); | ||
|
||
/// <summary> | ||
/// Writes the log entry if the supplied predicate is true. | ||
/// </summary> | ||
void WriteIf(Func<bool> condition, [CallerMemberName] string callerMemberName = null, | ||
[CallerFilePath] string callerFilePath = null, [CallerLineNumber] int callerLineNumber = default); | ||
|
||
/// <summary> | ||
/// Writes the log entry if the boolean condition is true. | ||
/// </summary> | ||
void WriteIf(bool condition, [CallerMemberName] string callerMemberName = null, | ||
[CallerFilePath] string callerFilePath = null, [CallerLineNumber] int callerLineNumber = default); | ||
} | ||
} |
Oops, something went wrong.