Interface ICodeLog
A special logger for dynamic code (Razor, WebApi). It is always available to add messages to insights.
[PublicApi]
public interface ICodeLog
Remarks
Added in v15, replaces the then removed ILog
interface.
Properties
Preserve
Determines if this log should be preserved in the short term. Like for live-analytics / live-insights. Default is true.
In scenarios like search-indexing it will default to false.
You can then do Log.Preserve = true;
to temporarily activate it while debugging.
bool Preserve { get; set; }
Property Value
Methods
Add(string, string, string, int)
Add a message log entry
string Add(string message, string cPath = null, string cName = null, int cLine = 0)
Parameters
message
stringMessage to log
cPath
stringauto pre filled by the compiler - the path to the code file
cName
stringauto pre filled by the compiler - the method name
cLine
intauto pre filled by the compiler - the code line
Returns
Call(string, string, bool, string, string, int)
Add a log entry for method call, returning a method to call when done
Action<string> Call(string parameters = null, string message = null, bool useTimer = false, string cPath = null, string cName = null, int cLine = 0)
Parameters
parameters
stringwhat was passed to the call in the brackets
message
stringthe message to log
useTimer
boolenable a timer from call/close
cPath
stringauto pre filled by the compiler - the path to the code file
cName
stringauto pre filled by the compiler - the method name
cLine
intauto pre filled by the compiler - the code line
Returns
Call<T>(string, string, bool, string, string, int)
Add a log entry for method call, returning a method to call when done
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
parameters
stringwhat was passed to the call in the brackets
message
stringthe message to log
useTimer
boolenable a timer from call/close
cPath
stringauto pre filled by the compiler - the path to the code file
cName
stringauto pre filled by the compiler - the method name
cLine
intauto pre filled by the compiler - the code line
Returns
Type Parameters
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
void Exception(Exception ex, string cPath = null, string cName = null, int cLine = 0)
Parameters
ex
ExceptionThe Exception object
cPath
stringauto pre filled by the compiler - the path to the code file
cName
stringauto pre filled by the compiler - the method name
cLine
intauto pre filled by the compiler - the code line
Warn(string, string, string, int)
Add a warning log entry
void Warn(string message, string cPath = null, string cName = null, int cLine = 0)