Show / Hide Table of Contents

Class FileLog

A file log for debugging

Inheritance
System.Object
FileLog
Namespace: HarmonyLib
Assembly: 0Harmony.dll
Syntax
public static class FileLog

Fields

| Improve this Doc View Source

indentChar

The indent character. The default is tab

Declaration
public static char indentChar
Field Value
Type Description
System.Char
| Improve this Doc View Source

indentLevel

The current indent level

Declaration
public static int indentLevel
Field Value
Type Description
System.Int32

Properties

| Improve this Doc View Source

LogPath

Full pathname of the log file, defaults to a file called harmony.log.txt on your Desktop

Declaration
public static string LogPath { get; }
Property Value
Type Description
System.String
| Improve this Doc View Source

LogWriter

Set this to make Harmony write its log content to this stream

Declaration
public static StreamWriter LogWriter { get; set; }
Property Value
Type Description
System.IO.StreamWriter

Methods

| Improve this Doc View Source

ChangeIndent(Int32)

Changes the indentation level

Declaration
public static void ChangeIndent(int delta)
Parameters
Type Name Description
System.Int32 delta

The value to add to the indentation level

| Improve this Doc View Source

Debug(String)

Log a string directly to disk if Harmony.DEBUG is true. Slower method that prevents missing information in case of a crash

Declaration
public static void Debug(string str)
Parameters
Type Name Description
System.String str

The string to log.

| Improve this Doc View Source

FlushBuffer()

Flushes the log buffer to disk (use in combination with LogBuffered)

Declaration
public static void FlushBuffer()
| Improve this Doc View Source

GetBuffer(Boolean)

Returns the log buffer and optionally empties it

Declaration
public static List<string> GetBuffer(bool clear)
Parameters
Type Name Description
System.Boolean clear

True to empty the buffer

Returns
Type Description
System.Collections.Generic.List<System.String>

The buffer.

| Improve this Doc View Source

Log(String)

Logs a string directly to disk. This method is slower but ensures that log information is not lost in case of a crash.

Declaration
public static void Log(string str)
Parameters
Type Name Description
System.String str

The string to log.

| Improve this Doc View Source

LogBuffered(List<String>)

Logs a list of string in a buffered way. Use this method only if you are sure that FlushBuffer will be called or else logging information is incomplete in case of a crash

Declaration
public static void LogBuffered(List<string> strings)
Parameters
Type Name Description
System.Collections.Generic.List<System.String> strings

A list of strings to log (they will not be re-indented)

| Improve this Doc View Source

LogBuffered(String)

Log a string in a buffered way. Use this method only if you are sure that FlushBuffer will be called or else logging information is incomplete in case of a crash

Declaration
public static void LogBuffered(string str)
Parameters
Type Name Description
System.String str

The string to log

| Improve this Doc View Source

LogBytes(Int64, Int32)

Logs some bytes as hex values

Declaration
public static void LogBytes(long ptr, int len)
Parameters
Type Name Description
System.Int64 ptr

The pointer to some memory

System.Int32 len

The length of bytes to log

| Improve this Doc View Source

LogIL(Mono.Cecil.Cil.VariableDefinition)

Logs information about a local variable in Intermediate Language (IL) code.

Declaration
public static void LogIL(Mono.Cecil.Cil.VariableDefinition variable)
Parameters
Type Name Description
Mono.Cecil.Cil.VariableDefinition variable

The representing the local variable to log. Must not be null.

Remarks

The logged information includes the variable's index, type, and whether it is pinned.

| Improve this Doc View Source

LogIL(Int32, Label)

Logs the intermediate language (IL) code at the specified position with the given label operand.

Declaration
public static void LogIL(int codePos, Label label)
Parameters
Type Name Description
System.Int32 codePos

The position in the IL code to log.

System.Reflection.Emit.Label label

The label operand associated with the IL code to log.

Remarks

Formats and logs the IL code position and label operand for detailed IL tracking or debugging.

| Improve this Doc View Source

LogIL(Int32, OpCode)

Logs the specified Intermediate Language (IL) operation code and its position in the code stream.

Declaration
public static void LogIL(int codePos, OpCode opcode)
Parameters
Type Name Description
System.Int32 codePos

The position of the IL operation code in the code stream.

System.Reflection.Emit.OpCode opcode

The IL operation code to log.

Remarks

This method formats the IL operation code and its position into a string and logs it.

| Improve this Doc View Source

LogIL(Int32, OpCode, Object)

Logs information about an Intermediate Language (IL) instruction, including its position, opcode, and operand.

Declaration
public static void LogIL(int codePos, OpCode opcode, object arg)
Parameters
Type Name Description
System.Int32 codePos

The position of the IL instruction within the method body.

System.Reflection.Emit.OpCode opcode

The System.Reflection.Emit.OpCode representing the operation to be performed.

System.Object arg

The operand associated with the IL instruction, or null if the instruction has no operand.

Remarks

This method formats and logs details about an IL instruction for debugging or analysis purposes. The logged output includes the instruction's position, opcode, and operand (if any).

| Improve this Doc View Source

LogILBlockBegin(Int32, ExceptionBlock)

Logs the beginning of an intermediate language (IL) exception handling block.

Declaration
public static void LogILBlockBegin(int codePos, ExceptionBlock block)
Parameters
Type Name Description
System.Int32 codePos

The position of the IL code where the block begins.

ExceptionBlock block

The ExceptionBlock representing the type of exception handling block to log. This includes information about the block type (e.g., try, catch, finally) and any associated metadata.

Remarks

Logs the start of an exception handling block (e.g., .try, .catch, .finally, .fault), adjusts indentation, and simulates a LEAVE opcode for consistency.

| Improve this Doc View Source

LogILBlockEnd(Int32, ExceptionBlock)

Logs the end of an intermediate language (IL) exception block.

Declaration
public static void LogILBlockEnd(int codePos, ExceptionBlock block)
Parameters
Type Name Description
System.Int32 codePos

The position in the IL code where the block ends.

ExceptionBlock block

The exception block to log. Must have a valid block type.

Remarks

This method handles the logging of specific types of exception blocks, such as the end of a try-catch or similar constructs. It adjusts the indentation level and outputs relevant information about the block's conclusion.

| Improve this Doc View Source

LogILComment(Int32, String)

Logs an inline comment at the specified code position.

Declaration
public static void LogILComment(int codePos, string comment)
Parameters
Type Name Description
System.Int32 codePos

The position in the code where the comment should be logged.

System.String comment

The comment text to log. Cannot be null or empty.

Remarks

This method formats the comment with the code position and logs it.

| Improve this Doc View Source

Reset()

Resets and deletes the log

Declaration
public static void Reset()
| Improve this Doc View Source

SetBuffer(List<String>)

Replaces the buffer with new lines

Declaration
public static void SetBuffer(List<string> buffer)
Parameters
Type Name Description
System.Collections.Generic.List<System.String> buffer

The lines to store

  • Improve this Doc
  • View Source
In This Article
Back to top Generated by DocFX