Interface ICodeLog
A special logger for dynamic code (Razor, WebApi). It is always available to add messages to insights.
Namespace: ToSic.Sxc.Code
Assembly: ToSic.Sxc.dll
Syntax
[PublicApi]
public interface ICodeLog
Remarks
Added in v15, replaces the then removed ILog
interface.
Methods
| Improve this Doc View SourceAdd(string, string, string, int)
Add a message log entry
Declaration
string Add(string message, string cPath = null, string cName = null, int cLine = 0)
Parameters
Type | Name | Description |
---|---|---|
string | message | Message to log |
string | cPath | auto pre filled by the compiler - the path to the code file |
string | cName | auto pre filled by the compiler - the method name |
int | cLine | auto pre filled by the compiler - the code line |
Returns
Type | Description |
---|---|
string |
Call(string, string, bool, string, string, int)
Add a log entry for method call, returning a method to call when done
Declaration
Action<string> Call(string parameters = null, string message = null, bool useTimer = false, string cPath = null, string cName = null, int cLine = 0)
Parameters
Type | Name | Description |
---|---|---|
string | parameters | what was passed to the call in the brackets |
string | message | the message to log |
bool | useTimer | enable a timer from call/close |
string | cPath | auto pre filled by the compiler - the path to the code file |
string | cName | auto pre filled by the compiler - the method name |
int | cLine | auto pre filled by the compiler - the code line |
Returns
Type | Description |
---|---|
Action<string> |
Call<T>(string, string, bool, string, string, int)
Add a log entry for method call, returning a method to call when done
Declaration
Func<T, string, T> Call<T>(string parameters = null, string message = null, bool useTimer = false, string cPath = null, string cName = null, int cLine = 0)
Parameters
Type | Name | Description |
---|---|---|
string | parameters | what was passed to the call in the brackets |
string | message | the message to log |
bool | useTimer | enable a timer from call/close |
string | cPath | auto pre filled by the compiler - the path to the code file |
string | cName | auto pre filled by the compiler - the method name |
int | cLine | auto pre filled by the compiler - the code line |
Returns
Type | Description |
---|---|
Func<T, string, T> |
Type Parameters
Name | Description |
---|---|
T |
Remarks
Not used much, but major change in V15 - the first value in the result is the data, the second is the string to log.
Before in the ILog
it was (message, data), new is (data, message)
Exception(Exception, string, string, int)
Add an exception as special log entry
Declaration
void Exception(Exception ex, string cPath = null, string cName = null, int cLine = 0)
Parameters
Type | Name | Description |
---|---|---|
Exception | ex | The Exception object |
string | cPath | auto pre filled by the compiler - the path to the code file |
string | cName | auto pre filled by the compiler - the method name |
int | cLine | auto pre filled by the compiler - the code line |
Warn(string, string, string, int)
Add a warning log entry
Declaration
void Warn(string message, string cPath = null, string cName = null, int cLine = 0)
Parameters
Type | Name | Description |
---|---|---|
string | message | |
string | cPath | auto pre filled by the compiler - the path to the code file |
string | cName | auto pre filled by the compiler - the method name |
int | cLine | auto pre filled by the compiler - the code line |