Robin Hood Log Protocol


Any BeApp which has a BApplication object can receive log data from the rhdaemon. To start receiving log messages, an application sends a BMessage containing a BMessenger to the rhdaemon's BApplication object (main thread). The BMessenger's target should be the BLooper and BHandler intended to receive the log messages. The message has a type code of MSG_ADD_LOG_SERVER and should contain a field named "log messenger" containing your BMessenger.

For example if you wanted your BApplication to receive log messages:

#include "RHMessages.h"
status_t RequestLogMessages( void )
{
	status_t status;
	
	BMessenger msgr( RH_APP_SIG, -1, &status );
	if( status != B_OK )
		return status;
	
	BMessage msg( MSG_ADD_LOG_SERVER );
	
	msg.AddMessenger( "log messenger", be_app_messenger );
	return msgr.SendMessage( &msg );
}	
	

Log-entry messages are sent to your targeted BLooper/BHandler. The log-entry message has a type code of MSG_LOG and contains a string field named "log string."

An example of receiving log messages:

#include "RHMessages.h"
void MyHandler::MessageReceived( BMessage *message )
{
	switch( message->what )
	{
		case MSG_LOG:
		{
			const char *s;
			s = message->FindString( "log string" );
			printf( "%s", s );
			break;
		}
		...
		

Each log-entry has the following format ( augmented Backus-Naur Form, see RFC 2068 or RFC 822 ):

log-entry = connection-sn SP field-type ":" [field] NL
connection-sn = 1*DIGIT
field-type = 1*32(ALPHA | DIGIT | "-")
field = 1*(TEXT)

Example:

1 Open: 192.168.0.3 Tue, 30 Mar 1999 12:26:34
1 Request-Line: GET /foo.html HTTP/1.1
1 Header: User-Agent: Mozilla/3.0 (compatible; NetPositive/2.0.1; BeOS)
1 Header: Accept: image/gif, image/jpeg, image/pjpeg, */*
1 Header: Referer: http://www.foo.bar.com/
1 Header: Host: www.foo.bar.com
1 Status-Line: HTTP/1.1 200 OK
1 Sending: 2098 /boot/home/public_html/foo.html
1 Sent: 2098 bytes 2650 ms 2262 bytes/second
1 Close: Tue, 30 Mar 1999 12:26:37

Log entries with the same connection-sn ( connection serial number ) are related to each other. The connection-sn identifies which TCP connection the log entry is associated with. If the client supports HTTP/1.1 persistant connections, more than one HTTP request may be made over the same connection.


Defined Field-Types