1.18 <SoupLogger>

Class: <SoupLogger>

It derives from <GObject>.

Debug logging support

Logger watches a Session and logs the HTTP traffic that it generates, for debugging purposes. Many applications use an environment variable to determine whether or not to use Logger, and to determine the amount of debugging output.

To use Logger, first create a logger with Logger.new, optionally configure it with Logger.set_request_filter, Logger.set_response_filter, and Logger.set_printer, and then attach it to a session (or multiple sessions) with Session.add_feature.

By default, the debugging output is sent to stdout, and looks something like:

> POST /unauth HTTP/1.1
> Soup-Debug-Timestamp: 1200171744
> Soup-Debug: SoupSession 1 (0x612190), SoupMessage 1 (0x617000), GSocket 1 (0x612220)
> Host: localhost
> Content-Type: text/plain
> Connection: close

< HTTP/1.1 201 Created
< Soup-Debug-Timestamp: 1200171744
< Soup-Debug: SoupMessage 1 (0x617000)
< Date: Sun, 12 Jan 2008 21:02:24 GMT
< Content-Length: 0

The Soup-Debug-Timestamp line gives the time (as a time_t) when the request was sent, or the response fully received.

The Soup-Debug line gives further debugging information about the Session, Message, and <GSocket> involved; the hex numbers are the addresses of the objects in question (which may be useful if you are running in a debugger). The decimal IDs are simply counters that uniquely identify objects across the lifetime of the Logger. In particular, this can be used to identify when multiple messages are sent across the same connection.

Currently, the request half of the message is logged just before the first byte of the request gets written to the network (from the "starting" signal).

The response is logged just after the last byte of the response body is read from the network (from the "got-body" or "got-informational" signal), which means that the "got-headers" signal, and anything triggered off it (such as "authenticate") will be emitted before the response headers are actually logged.

If the response doesn’t happen to trigger the "got-body" nor "got-informational" signals due to, for example, a cancellation before receiving the last byte of the response body, the response will still be logged on the event of the "finished" signal.

Properties

Property: logger:level self

The level of logging output.

Its value is a <SoupLoggerLogLevel> (or, to set it, one of its symbols).

Set it with (set! (logger:level self) value).

Property: logger:max-body-size self

If Logger:level is body, this gives the maximum number of bytes of the body that will be logged. (-1 means "no limit".)

Its value is a 32-bit integer.

Set it with (set! (logger:max-body-size self) value).

Procedures

Method: logger:get-max-body-size self ⇒ %return
Method: get-max-body-size self ⇒ %return

Get the maximum body size for self.

self

Passed: a <SoupLogger>.

a <SoupLogger>

%return

Returned: a 32-bit integer.

the maximum body size, or -1 if unlimited

Procedure: logger:new level ⇒ %return

Creates a new Logger with the given debug level.

If you need finer control over what message parts are and aren’t logged, use Logger.set_request_filter and Logger.set_response_filter.

level

Passed: a <SoupLoggerLogLevel>, or one of its symbols.

the debug level

%return

Returned: a <SoupLogger>.

a new <SoupLogger>

Method: logger:set-max-body-size self max-body-size
Method: set-max-body-size self max-body-size

Sets the maximum body size for self (-1 means no limit).

self

Passed: a <SoupLogger>.

a <SoupLogger>

max-body-size

Passed: a 32-bit integer.

the maximum body size to log

Method: logger:set-printer self printer
Method: set-printer self printer

Sets up an alternate log printing routine, if you don’t want the log to go to stdout.

self

Passed: a <SoupLogger>.

a <SoupLogger>

printer

Passed: a procedure.

the callback for printing logging output

See SoupLoggerPrinter for how it is called.

printer-data

Not passed: guile-gi supplies it.

data to pass to the callback

destroy

Not passed: guile-gi supplies it.

a GDestroyNotify to free printer-data

See GDestroyNotify for how it is called.

Method: logger:set-request-filter self request-filter
Method: set-request-filter self request-filter

Sets up a filter to determine the log level for a given request.

For each HTTP request self will invoke request-filter to determine how much (if any) of that request to log. (If you do not set a request filter, self will just always log requests at the level passed to Logger.new.)

self

Passed: a <SoupLogger>.

a <SoupLogger>

request-filter

Passed: a procedure.

the callback for request debugging

See SoupLoggerFilter for how it is called.

filter-data

Not passed: guile-gi supplies it.

data to pass to the callback

destroy

Not passed: guile-gi supplies it.

a GDestroyNotify to free filter-data

See GDestroyNotify for how it is called.

Method: logger:set-response-filter self response-filter
Method: set-response-filter self response-filter

Sets up a filter to determine the log level for a given response.

For each HTTP response self will invoke response-filter to determine how much (if any) of that response to log. (If you do not set a response filter, self will just always log responses at the level passed to Logger.new.)

self

Passed: a <SoupLogger>.

a <SoupLogger>

response-filter

Passed: a procedure.

the callback for response debugging

See SoupLoggerFilter for how it is called.

filter-data

Not passed: guile-gi supplies it.

data to pass to the callback

destroy

Not passed: guile-gi supplies it.

a GDestroyNotify to free filter-data

See GDestroyNotify for how it is called.