Logging [¶]
Logging and formatting.
Overview
The initial phase of a project that generates machine code is not always smooth. Failure cases are common not just at the beginning phase, but also during the development or refactoring. AsmJit provides logging functionality to address this issue. AsmJit does already a good job with function overloading to prevent from emitting unencodable instructions, but it can't prevent from emitting machine code that is correct at instruction level, but doesn't work when it's executed asa whole. Logging has always been an important part of AsmJit's infrastructure and looking at logs can sometimes reveal code generation issues quickly.
AsmJit provides API for logging and formatting:
- Logger - A logger that you can pass to CodeHolder and all emitters that inherit from BaseEmitter.
- FormatOptions - Formatting options that can change how instructions and operands are formatted.
- Formatter - A namespace that provides functions that can format input data like Operand, Reg, Label, and BaseNode into String.
AsmJit's Logger serves the following purposes:
- Provides a basic foundation for logging.
- Abstract class leaving the implementation on users. The following built-in implementations are provided for simplicity:
- FileLogger implements logging into a standard
FILE
stream. - StringLogger serializes all logs into a String instance.
- FileLogger implements logging into a standard
AsmJit's FormatOptions provides the following to customize the formatting of instructions and operands through: