Robin Hood Log Protocol (RHLP) |
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
Example:
connection-sn = 1*DIGIT
field-type = 1*32(ALPHA | DIGIT | "-")
field = 1*(TEXT)
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.
open-field = remote-address SP date
remote-address = 1*3DIGIT "." 1*3DIGIT "." 1*3DIGIT "." 1*3DIGIT ; An IP address
1 Open: 192.168.0.3 Tue, 30 Mar 1999 12:26:34
close-field = date
1 Close: Tue, 30 Mar 1999 12:26:37
request-field = Request-Line ; HTTP Request-Line as specified in RFC 2068
1 Request-Line: GET / HTTP/1.1
header-field = request-header ; HTTP Request-Header as specified in RFC 2068
1 Header: Referer: http://www.foo.bar.com/
status-field = Status-Line ; HTTP Status-Line as specified in RFC 2068
1 Status-Line: HTTP/1.1 200 OK
sending-field = content-length SP resource content-length = 1*DIGIT
resource = abs_path ; Absolue path of resource on server
abs_path = 1*("/" node )
node = ; any legal file name character
1 Sending: 2098 /boot/home/public_html/foo.html
sent-field = bytes-sent "bytes" SP time-to-send "ms" SP bytes-per-second "bytes/second" bytes-sent = 1*DIGIT ; total bytes actually sent. This may be less than content-lenth if an error occured.
time-to-send = 1*DIGIT ; time to send file response in miliseconds
bytes-per-second 1*DIGIT ; this may be inaccurate for small files
1 Sent: 2098 bytes 2650 ms 2262 bytes/second
exec-field = cgi_path cgi_path = abs_path ; Absolute path of CGI being executed.
1 Exec: /boot/home/public_html/cgi-bin/fortune
BeOS is a registered trademark of Be Inc.