-
Notifications
You must be signed in to change notification settings - Fork 110
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Steve Boytsun <steve@clockwokrlabs.io>
- Loading branch information
1 parent
9f62399
commit 2b09c8d
Showing
10 changed files
with
217 additions
and
72 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,179 @@ | ||
namespace SpacetimeDB; | ||
|
||
using System.Runtime.CompilerServices; | ||
using System.Text; | ||
using SpacetimeDB.Internal; | ||
|
||
public static class Log | ||
{ | ||
/// <summary> | ||
/// Write an error message to module log | ||
/// </summary> | ||
/// <param name="message">Message to log</param> | ||
/// <param name="RESERVED_target"><b>!!! DO NOT USE !!!</b> Value for this parameter will be automatically generated at compile time. Providing this parameter could lead to undefined behavior</param> | ||
/// <param name="RESERVED_filename"><b>!!! DO NOT USE !!!</b> Value for this parameter will be automatically generated at compile time. Providing this parameter could lead to undefined behavior</param> | ||
/// <param name="RESERVED_lineNumber"><b>!!! DO NOT USE !!!</b> Value for this parameter will be automatically generated at compile time. Providing this parameter could lead to undefined behavior</param> | ||
public static void Debug( | ||
string message, | ||
[CallerMemberName] string RESERVED_target = "", | ||
[CallerFilePath] string RESERVED_filename = "", | ||
[CallerLineNumber] uint RESERVED_lineNumber = 0 | ||
) => | ||
LogInternal( | ||
message, | ||
FFI.LogLevel.Debug, | ||
RESERVED_target, | ||
RESERVED_filename, | ||
RESERVED_lineNumber | ||
); | ||
|
||
/// <summary> | ||
/// Write a trace message to module log | ||
/// </summary> | ||
/// <param name="message">Message to log</param> | ||
/// <param name="RESERVED_target"><b>!!! DO NOT USE !!!</b> Value for this parameter will be automatically generated at compile time. Providing this parameter could lead to undefined behavior</param> | ||
/// <param name="RESERVED_filename"><b>!!! DO NOT USE !!!</b> Value for this parameter will be automatically generated at compile time. Providing this parameter could lead to undefined behavior</param> | ||
/// <param name="RESERVED_lineNumber"><b>!!! DO NOT USE !!!</b> Value for this parameter will be automatically generated at compile time. Providing this parameter could lead to undefined behavior</param> | ||
public static void Trace( | ||
string message, | ||
[CallerMemberName] string RESERVED_target = "", | ||
[CallerFilePath] string RESERVED_filename = "", | ||
[CallerLineNumber] uint RESERVED_lineNumber = 0 | ||
) => | ||
LogInternal( | ||
message, | ||
FFI.LogLevel.Trace, | ||
RESERVED_target, | ||
RESERVED_filename, | ||
RESERVED_lineNumber | ||
); | ||
|
||
/// <summary> | ||
/// Write an info message to module log | ||
/// </summary> | ||
/// <param name="message">Message to log</param> | ||
/// <param name="RESERVED_target"><b>!!! DO NOT USE !!!</b> Value for this parameter will be automatically generated at compile time. Providing this parameter could lead to undefined behavior</param> | ||
/// <param name="RESERVED_filename"><b>!!! DO NOT USE !!!</b> Value for this parameter will be automatically generated at compile time. Providing this parameter could lead to undefined behavior</param> | ||
/// <param name="RESERVED_lineNumber"><b>!!! DO NOT USE !!!</b> Value for this parameter will be automatically generated at compile time. Providing this parameter could lead to undefined behavior</param> | ||
public static void Info( | ||
string message, | ||
[CallerMemberName] string RESERVED_target = "", | ||
[CallerFilePath] string RESERVED_filename = "", | ||
[CallerLineNumber] uint RESERVED_lineNumber = 0 | ||
) => | ||
LogInternal( | ||
message, | ||
FFI.LogLevel.Info, | ||
RESERVED_target, | ||
RESERVED_filename, | ||
RESERVED_lineNumber | ||
); | ||
|
||
/// <summary> | ||
/// Write a warning message to module log | ||
/// </summary> | ||
/// <param name="message">Message to log</param> | ||
/// <param name="RESERVED_target"><b>!!! DO NOT USE !!!</b> Value for this parameter will be automatically generated at compile time. Providing this parameter could lead to undefined behavior</param> | ||
/// <param name="RESERVED_filename"><b>!!! DO NOT USE !!!</b> Value for this parameter will be automatically generated at compile time. Providing this parameter could lead to undefined behavior</param> | ||
/// <param name="RESERVED_lineNumber"><b>!!! DO NOT USE !!!</b> Value for this parameter will be automatically generated at compile time. Providing this parameter could lead to undefined behavior</param> | ||
public static void Warn( | ||
string message, | ||
[CallerMemberName] string RESERVED_target = "", | ||
[CallerFilePath] string RESERVED_filename = "", | ||
[CallerLineNumber] uint RESERVED_lineNumber = 0 | ||
) => | ||
LogInternal( | ||
message, | ||
FFI.LogLevel.Warn, | ||
RESERVED_target, | ||
RESERVED_filename, | ||
RESERVED_lineNumber | ||
); | ||
|
||
/// <summary> | ||
/// Write an error message to module log | ||
/// </summary> | ||
/// <param name="message">Message to log</param> | ||
/// <param name="RESERVED_target"><b>!!! DO NOT USE !!!</b> Value for this parameter will be automatically generated at compile time. Providing this parameter could lead to undefined behavior</param> | ||
/// <param name="RESERVED_filename"><b>!!! DO NOT USE !!!</b> Value for this parameter will be automatically generated at compile time. Providing this parameter could lead to undefined behavior</param> | ||
/// <param name="RESERVED_lineNumber"><b>!!! DO NOT USE !!!</b> Value for this parameter will be automatically generated at compile time. Providing this parameter could lead to undefined behavior</param> | ||
public static void Error( | ||
string message, | ||
[CallerMemberName] string RESERVED_target = "", | ||
[CallerFilePath] string RESERVED_filename = "", | ||
[CallerLineNumber] uint RESERVED_lineNumber = 0 | ||
) => | ||
LogInternal( | ||
message, | ||
FFI.LogLevel.Error, | ||
RESERVED_target, | ||
RESERVED_filename, | ||
RESERVED_lineNumber | ||
); | ||
|
||
/// <summary> | ||
/// Write an exception message to module log | ||
/// </summary> | ||
/// <param name="message">Message to log</param> | ||
/// <param name="RESERVED_target"><b>!!! DO NOT USE !!!</b> Value for this parameter will be automatically generated at compile time. Providing this parameter could lead to undefined behavior</param> | ||
/// <param name="RESERVED_filename"><b>!!! DO NOT USE !!!</b> Value for this parameter will be automatically generated at compile time. Providing this parameter could lead to undefined behavior</param> | ||
/// <param name="RESERVED_lineNumber"><b>!!! DO NOT USE !!!</b> Value for this parameter will be automatically generated at compile time. Providing this parameter could lead to undefined behavior</param> | ||
public static void Exception( | ||
string message, | ||
[CallerMemberName] string RESERVED_target = "", | ||
[CallerFilePath] string RESERVED_filename = "", | ||
[CallerLineNumber] uint RESERVED_lineNumber = 0 | ||
) => | ||
LogInternal( | ||
message, | ||
FFI.LogLevel.Error, | ||
RESERVED_target, | ||
RESERVED_filename, | ||
RESERVED_lineNumber | ||
); | ||
|
||
/// <summary> | ||
/// Write an exception message and stacktrace to module log | ||
/// </summary> | ||
/// <param name="exception">Exception to log</param> | ||
/// <param name="RESERVED_target"><b>!!! DO NOT USE !!!</b> Value for this parameter will be automatically generated at compile time. Providing this parameter could lead to undefined behavior</param> | ||
/// <param name="RESERVED_filename"><b>!!! DO NOT USE !!!</b> Value for this parameter will be automatically generated at compile time. Providing this parameter could lead to undefined behavior</param> | ||
/// <param name="RESERVED_lineNumber"><b>!!! DO NOT USE !!!</b> Value for this parameter will be automatically generated at compile time. Providing this parameter could lead to undefined behavior</param> | ||
public static void Exception( | ||
Exception exception, | ||
[CallerMemberName] string RESERVED_target = "", | ||
[CallerFilePath] string RESERVED_filename = "", | ||
[CallerLineNumber] uint RESERVED_lineNumber = 0 | ||
) => | ||
LogInternal( | ||
exception.ToString(), | ||
FFI.LogLevel.Error, | ||
RESERVED_target, | ||
RESERVED_filename, | ||
RESERVED_lineNumber | ||
); | ||
|
||
private static void LogInternal( | ||
string text, | ||
FFI.LogLevel level, | ||
string target, | ||
string filename, | ||
uint lineNumber | ||
) | ||
{ | ||
var target_bytes = Encoding.UTF8.GetBytes(target); | ||
var filename_bytes = Encoding.UTF8.GetBytes(filename); | ||
var text_bytes = Encoding.UTF8.GetBytes(text); | ||
|
||
FFI._console_log( | ||
level, | ||
target_bytes, | ||
(uint)target_bytes.Length, | ||
filename_bytes, | ||
(uint)filename_bytes.Length, | ||
lineNumber, | ||
text_bytes, | ||
(uint)text_bytes.Length | ||
); | ||
} | ||
} |
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
Oops, something went wrong.
2b09c8d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Benchmarking failed. Please check the workflow run for details.
2b09c8d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Benchmarking failed. Please check the workflow run for details.