@@ -24,7 +24,7 @@ to use the debug level for long periods of time since a debug message is logged
2424
2525Here's a usage example:
2626
27- ``` c#
27+ ``` csharp
2828using SharpHook .Data ;
2929using SharpHook .Logging ;
3030
@@ -50,7 +50,7 @@ message format and arguments so you don't have to do it yourself.
5050SharpHook.Reactive contains the ` IReactiveLogSource ` and its implementation – ` ReactiveLogSourceAdapter ` . Here's a
5151usage example:
5252
53- ``` c#
53+ ``` csharp
5454using SharpHook .Logging ;
5555using SharpHook .Native ;
5656using SharpHook .Reactive .Logging ;
@@ -68,7 +68,7 @@ scheduler can be set for the `MessageLogged` observable.
6868
6969SharpHook.R3 contains the ` IR3LogSource ` and its implementation – ` R3LogSourceAdapter ` . Here's a usage example:
7070
71- ``` c#
71+ ``` csharp
7272using SharpHook .Logging ;
7373using SharpHook .Native ;
7474using SharpHook .R3 .Logging ;
@@ -97,21 +97,21 @@ usually shouldn't use it.
9797When calling ` SetLoggerProc ` , the function must be wrapped into a delegate reference and the reference must be stored
9898to prevent garbage collection. This is because the following code:
9999
100- ``` c#
100+ ``` csharp
101101provider .SetLoggerProc (someObj .SomeMethod , IntPtr .Zero );
102102```
103103
104104is actually transformed into this code by the C# compiler:
105105
106- ``` c#
106+ ``` csharp
107107provider .SetLoggerProc (new LoggerProc (someObj .SomeMethod ), IntPtr .Zero );
108108```
109109
110110The CLR protects the ` LoggerProc ` reference from being garbage-collected only until the ` SetLoggerProc ` methods exits
111111(which happens almost instantly). The CLR does not and cannot know that the reference will be used later and so it will
112112happily collect this reference thinking it's not needed anymore. Instead, the following should be done:
113113
114- ``` c#
114+ ``` csharp
115115LoggerProc loggerProc = someObj .SomeMethod ; // This reference should be stored, e.g., as a field of the object
116116provider .SetLoggerProc (loggerProc , IntPtr .Zero );
117117```
@@ -134,7 +134,7 @@ arguments. It then parses the log message and the log format and extracts the ar
134134
135135If you want to use your own callback, then its form should be the following:
136136
137- ``` c#
137+ ``` csharp
138138private void OnLog (LogLevel level , IntPtr userData , IntPtr format , IntPtr args )
139139{
140140 // Filter by log level if needed
0 commit comments