Accessing VM log messages using Beacon

The virtual machine has a logging system that usually prints to the console several types of log messages.

However, as they are only printed to the console, these log messages cannot be accessed from within the image and combined with other application-specific Beacon Object subclass: #Beacon instanceVariableNames: 'announcer' classVariableNames: 'instance' package: 'Beacon-Core-Beacon' signals for debugging. With GtVirtualMachineBeacon Object subclass: #GtVirtualMachineBeacon instanceVariableNames: 'semaphore semaphoreIndex process signalMap' classVariableNames: '' package: 'GToolkit-VirtualMachine-Logger' we can access log messages from inside the image as Beacon signals.

When starting the logging we specify what types of log messages we want to have accessible as Beacon signals. We use GtVirtualMachineLevelSignal GtVirtualMachineSignal subclass: #GtVirtualMachineLevelSignal instanceVariableNames: '' classVariableNames: '' package: 'GToolkit-VirtualMachine-Logger' to enable all default types of log messages.

GtVirtualMachineBeacon startFor: GtVirtualMachineLevelSignal
  

Alternatively, we can indicate individual types of log messages.

GtVirtualMachineBeacon startFor: GtVirtualMachineTraceSignal, GtVirtualMachineDebugSignal
  

Now we can use any Beacon logger to consume these messages, as normal Beacon signals.

CircularMemoryLogger startFor: GtVirtualMachineLevelSignal.
  

We can inspect the logger and stop collecting signals when we are done. Saving the image for example, generares several signals.

CircularMemoryLogger instance
  

When done we can also stop the Beacon signals from comming from the VM into the image.

GtVirtualMachineBeacon stop.
  

Custom log events

When debugging the VM, custom types of log messages could be added. We can enable them using GtVirtualMachineGenericSignal GtVirtualMachineSignal subclass: #GtVirtualMachineGenericSignal instanceVariableNames: 'name' classVariableNames: '' package: 'GToolkit-VirtualMachine-Logger' .

For example, if the VM has a log message of type SOCKET we can enable it using the snippt below:

GtVirtualMachineBeacon startFor: (
	GtVirtualMachineGenericSignal named: 'SOCKET')
  

Then we could have a logger that only select Beacon signals for SOCKET log events.

CircularMemoryLogger startFor: (
	GtVirtualMachineGenericSignal where: [ :signal | 
		signal name = 'SOCKET' ])