-
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.
Browse files
Browse the repository at this point in the history
* add ApiKey to appsettings.json in tests * apply naming suggestions by Rider IDE * inject mocked IJSRuntime * HttpMethod should be String not type HttpMethod * wip fixing tests * simple fix * fix tests * cleanup * cleanup * test cleanup * more cleanup * restore file * ci: dotnet formatting * simplify job * test break formatting * fix format * dotnet format * fixing warnings * fix warnings * 5 warnings * ci: Code formatting (#7) * ci: dotnet formatting * simplify job * test break formatting * fix format * dotnet format * fix acronym formatting * dotnet format * refactor: remove .NetCore from Raygun.NetCore.Blazor * WIP * fix visibility after refactor * more refactor * fix merge errors * docs: update README.md * feat: Internal RaygunLogger * cleanup * cleanup post-merge * cleanup logger implementation * add logger to readme * Improve RaygunLogger implementation * optimization
- Loading branch information
1 parent
37d4a26
commit 7ba47e8
Showing
10 changed files
with
248 additions
and
12 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
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,34 @@ | ||
namespace Raygun.Blazor.Logging | ||
{ | ||
/// <summary> | ||
/// Raygun logger interface. | ||
/// </summary> | ||
internal interface IRaygunLogger | ||
{ | ||
/// <summary> | ||
/// Prints an error message with level Error. | ||
/// </summary> | ||
/// <param name="message"></param> | ||
void Error(string message); | ||
/// <summary> | ||
/// Prints a warning message with level Warning. | ||
/// </summary> | ||
/// <param name="message"></param> | ||
void Warning(string message); | ||
/// <summary> | ||
/// Prints an information message with level Info. | ||
/// </summary> | ||
/// <param name="message"></param> | ||
void Info(string message); | ||
/// <summary> | ||
/// Prints a debug message with level Debug. | ||
/// </summary> | ||
/// <param name="message"></param> | ||
void Debug(string message); | ||
/// <summary> | ||
/// Prints a verbose message with level Verbose. | ||
/// </summary> | ||
/// <param name="message"></param> | ||
void Verbose(string message); | ||
} | ||
} |
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,33 @@ | ||
namespace Raygun.Blazor.Logging | ||
{ | ||
/// <summary> | ||
/// Hierarchy level for internal logs | ||
/// </summary> | ||
public enum RaygunLogLevel | ||
{ | ||
/// <summary> | ||
/// Use to disable console logs | ||
/// </summary> | ||
None = 0, | ||
/// <summary> | ||
/// Highest level of error | ||
/// </summary> | ||
Error, | ||
/// <summary> | ||
/// Warning level of error | ||
/// </summary> | ||
Warning, | ||
/// <summary> | ||
/// Information level of error | ||
/// </summary> | ||
Info, | ||
/// <summary> | ||
/// Debugging level of error | ||
/// </summary> | ||
Debug, | ||
/// <summary> | ||
/// Lowest level of error | ||
/// </summary> | ||
Verbose | ||
} | ||
} |
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,83 @@ | ||
using System; | ||
|
||
namespace Raygun.Blazor.Logging | ||
{ | ||
/// <summary> | ||
/// Implementation of the Raygun logger. | ||
/// </summary> | ||
internal class RaygunLogger : IRaygunLogger | ||
{ | ||
private readonly RaygunLogLevel _logLevel; | ||
private static RaygunLogger? _raygunLogger; | ||
|
||
/// <summary> | ||
/// Create or retrieve instance of IRaygunLogger. | ||
/// Returns null if the logLevel is None. | ||
/// </summary> | ||
internal static IRaygunLogger? Create(RaygunLogLevel logLevel) | ||
{ | ||
_raygunLogger = logLevel == RaygunLogLevel.None ? null : _raygunLogger ?? new RaygunLogger(logLevel); | ||
return _raygunLogger; | ||
} | ||
|
||
private RaygunLogger(RaygunLogLevel logLevel) | ||
{ | ||
_logLevel = logLevel; | ||
Warning("[RaygunLogger] Internal logger initialized with log level: " + _logLevel); | ||
Warning("[RaygunLogger] Disable internal logger by setting LogLevel to None in Raygun settings"); | ||
} | ||
|
||
private const string RaygunPrefix = "Raygun:"; | ||
|
||
/// <inheritdoc /> | ||
public void Error(string message) | ||
{ | ||
Log(RaygunLogLevel.Error, message); | ||
} | ||
|
||
/// <inheritdoc /> | ||
public void Warning(string message) | ||
{ | ||
Log(RaygunLogLevel.Warning, message); | ||
} | ||
|
||
/// <inheritdoc /> | ||
public void Info(string message) | ||
{ | ||
Log(RaygunLogLevel.Info, message); | ||
} | ||
|
||
/// <inheritdoc /> | ||
public void Debug(string message) | ||
{ | ||
Log(RaygunLogLevel.Debug, message); | ||
} | ||
|
||
/// <inheritdoc /> | ||
public void Verbose(string message) | ||
{ | ||
Log(RaygunLogLevel.Verbose, message); | ||
} | ||
|
||
private void Log(RaygunLogLevel level, string message) | ||
{ | ||
if (_logLevel == RaygunLogLevel.None) | ||
{ | ||
return; | ||
} | ||
|
||
if (level > _logLevel) return; | ||
|
||
try | ||
{ | ||
// Only log the first letter of the log level e.g. "I" for Info | ||
var initial = level.ToString()[0..1].ToUpper(); | ||
Console.WriteLine($"{RaygunPrefix} [{initial}] {message}"); | ||
} | ||
catch | ||
{ | ||
// ignored | ||
} | ||
} | ||
} | ||
} |
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
Oops, something went wrong.