Created
April 29, 2018 06:17
-
-
Save galvesribeiro/5baeb3662fbfaab27867d5f6428379e0 to your computer and use it in GitHub Desktop.
Blazor Logger
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
public static class Logger | |
{ | |
public static void Log(object message) | |
{ | |
RegisteredFunction.Invoke<bool>( | |
"Logger.Log", | |
JsonUtil.Serialize(message)); | |
} | |
public static void Error(object error) | |
{ | |
RegisteredFunction.Invoke<bool>( | |
"Logger.Error", | |
JsonUtil.Serialize(error)); | |
} | |
public static void Error(this BlazorComponent c, object error) => Error(error); | |
public static void Log(this BlazorComponent c, object message) => Log(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
Blazor.registerFunction('Logger.Log', function (message) { | |
console.log(JSON.parse(message)); | |
return true; | |
}); | |
Blazor.registerFunction('Logger.Error', function (message) { | |
console.error(JSON.parse(message)); | |
return true; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment