| Copyright | Will Thompson Iñaki García Etxebarria and Jonas Platte |
|---|---|
| License | LGPL-2.1 |
| Maintainer | Iñaki García Etxebarria |
| Safe Haskell | Safe-Inferred |
| Language | Haskell2010 |
GI.Soup.Objects.Logger
Description
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 loggerNew,
optionally configure it with loggerSetRequestFilter,
loggerSetResponseFilter, and loggerSetPrinter,
and then attach it to a session (or multiple sessions) with
sessionAddFeature.
By default, the debugging output is sent to <literal>stdout</literal>, and looks something like:
<informalexample><screen> > POST /unauth HTTP/1.1 > Soup-Debug-Timestamp: 1200171744 > Soup-Debug: SoupSessionAsync 1 (0x612190), SoupMessage 1 (0x617000), SoupSocket 1 (0x612220) > Host: localhost > Content-Type: text/plain > Connection: close > > This is a test.
< 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 </screen></informalexample>
The <literal>Soup-Debug-Timestamp</literal> line gives the time (as a <type>time_t</type>) when the request was sent, or the response fully received.
The <literal>Soup-Debug</literal> line gives further debugging
information about the Session, Message, and Socket
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), which means that if you have not made the complete request body available at that point, it will not be logged.
The response is logged just after the last byte of the response
body is read from the network (from the Message::got_body or
Message::got_informational signal), which means that the
Message::got_headers signal, and anything triggered off it
(such as authenticate) will be emitted
<emphasis>before</emphasis> the response headers are actually
logged.
If the response doesn't happen to trigger the
Message::got_body nor Message::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.
Synopsis
- newtype Logger = Logger (ManagedPtr Logger)
- class (GObject o, IsDescendantOf Logger o) => IsLogger o
- toLogger :: (MonadIO m, IsLogger o) => o -> m Logger
- loggerAttach :: (HasCallStack, MonadIO m, IsLogger a, IsSession b) => a -> b -> m ()
- loggerDetach :: (HasCallStack, MonadIO m, IsLogger a, IsSession b) => a -> b -> m ()
- loggerNew :: (HasCallStack, MonadIO m) => LoggerLogLevel -> Int32 -> m Logger
- loggerSetPrinter :: (HasCallStack, MonadIO m, IsLogger a) => a -> LoggerPrinter -> m ()
- loggerSetRequestFilter :: (HasCallStack, MonadIO m, IsLogger a) => a -> LoggerFilter -> m ()
- loggerSetResponseFilter :: (HasCallStack, MonadIO m, IsLogger a) => a -> LoggerFilter -> m ()
- constructLoggerLevel :: (IsLogger o, MonadIO m) => LoggerLogLevel -> m (GValueConstruct o)
- getLoggerLevel :: (MonadIO m, IsLogger o) => o -> m LoggerLogLevel
- setLoggerLevel :: (MonadIO m, IsLogger o) => o -> LoggerLogLevel -> m ()
- constructLoggerMaxBodySize :: (IsLogger o, MonadIO m) => Int32 -> m (GValueConstruct o)
- getLoggerMaxBodySize :: (MonadIO m, IsLogger o) => o -> m Int32
- setLoggerMaxBodySize :: (MonadIO m, IsLogger o) => o -> Int32 -> m ()
Exported types
Memory-managed wrapper type.
Instances
| Eq Logger Source # | |
| GObject Logger Source # | |
Defined in GI.Soup.Objects.Logger | |
| ManagedPtrNewtype Logger Source # | |
Defined in GI.Soup.Objects.Logger Methods toManagedPtr :: Logger -> ManagedPtr Logger | |
| TypedObject Logger Source # | |
Defined in GI.Soup.Objects.Logger | |
| HasParentTypes Logger Source # | |
Defined in GI.Soup.Objects.Logger | |
| IsGValue (Maybe Logger) Source # | Convert |
Defined in GI.Soup.Objects.Logger Methods gvalueGType_ :: IO GType gvalueSet_ :: Ptr GValue -> Maybe Logger -> IO () gvalueGet_ :: Ptr GValue -> IO (Maybe Logger) | |
| type ParentTypes Logger Source # | |
Defined in GI.Soup.Objects.Logger | |
class (GObject o, IsDescendantOf Logger o) => IsLogger o Source #
Instances
| (GObject o, IsDescendantOf Logger o) => IsLogger o Source # | |
Defined in GI.Soup.Objects.Logger | |
Methods
Click to display all available methods, including inherited ones
Methods
addFeature, attach, bindProperty, bindPropertyFull, detach, forceFloating, freezeNotify, getv, hasFeature, isFloating, notify, notifyByPspec, ref, refSink, removeFeature, runDispose, stealData, stealQdata, thawNotify, unref, watchClosure.
Getters
getData, getProperty, getQdata.
Setters
setData, setDataFull, setPrinter, setProperty, setRequestFilter, setResponseFilter.
attach
Arguments
| :: (HasCallStack, MonadIO m, IsLogger a, IsSession b) | |
| => a |
|
| -> b |
|
| -> m () |
Deprecated: Use sessionAddFeature instead.
Sets logger to watch session and print debug information for
its messages.
(The session will take a reference on logger, which will be
removed when you call loggerDetach, or when the session is
destroyed.)
detach
Arguments
| :: (HasCallStack, MonadIO m, IsLogger a, IsSession b) | |
| => a |
|
| -> b |
|
| -> m () |
Deprecated: Use sessionRemoveFeature instead.
Stops logger from watching session.
new
Arguments
| :: (HasCallStack, MonadIO m) | |
| => LoggerLogLevel |
|
| -> Int32 |
|
| -> m Logger | Returns: a new |
Creates a new Logger with the given debug level. If level is
LoggerLogLevelBody, maxBodySize gives the maximum number of
bytes of the body that will be logged. (-1 means "no limit".)
If you need finer control over what message parts are and aren't
logged, use loggerSetRequestFilter and
loggerSetResponseFilter.
setPrinter
Arguments
| :: (HasCallStack, MonadIO m, IsLogger a) | |
| => a |
|
| -> LoggerPrinter |
|
| -> m () |
Sets up an alternate log printing routine, if you don't want the log to go to <literal>stdout</literal>.
setRequestFilter
loggerSetRequestFilter Source #
Arguments
| :: (HasCallStack, MonadIO m, IsLogger a) | |
| => a |
|
| -> LoggerFilter |
|
| -> m () |
Sets up a filter to determine the log level for a given request.
For each HTTP request logger will invoke requestFilter to
determine how much (if any) of that request to log. (If you do not
set a request filter, logger will just always log requests at the
level passed to loggerNew.)
setResponseFilter
loggerSetResponseFilter Source #
Arguments
| :: (HasCallStack, MonadIO m, IsLogger a) | |
| => a |
|
| -> LoggerFilter |
|
| -> m () |
Sets up a filter to determine the log level for a given response.
For each HTTP response logger will invoke responseFilter to
determine how much (if any) of that response to log. (If you do not
set a response filter, logger will just always log responses at
the level passed to loggerNew.)
Properties
level
The level of logging output
Since: 2.56
constructLoggerLevel :: (IsLogger o, MonadIO m) => LoggerLogLevel -> m (GValueConstruct o) Source #
Construct a GValueConstruct with valid value for the “level” property. This is rarely needed directly, but it is used by new.
getLoggerLevel :: (MonadIO m, IsLogger o) => o -> m LoggerLogLevel Source #
Get the value of the “level” property.
When overloading is enabled, this is equivalent to
get logger #level
setLoggerLevel :: (MonadIO m, IsLogger o) => o -> LoggerLogLevel -> m () Source #
Set the value of the “level” property.
When overloading is enabled, this is equivalent to
setlogger [ #level:=value ]
maxBodySize
If Logger:level is LoggerLogLevelBody, this gives
the maximum number of bytes of the body that will be logged.
(-1 means "no limit".)
Since: 2.56
constructLoggerMaxBodySize :: (IsLogger o, MonadIO m) => Int32 -> m (GValueConstruct o) Source #
Construct a GValueConstruct with valid value for the “max-body-size” property. This is rarely needed directly, but it is used by new.
getLoggerMaxBodySize :: (MonadIO m, IsLogger o) => o -> m Int32 Source #
Get the value of the “max-body-size” property.
When overloading is enabled, this is equivalent to
get logger #maxBodySize
setLoggerMaxBodySize :: (MonadIO m, IsLogger o) => o -> Int32 -> m () Source #
Set the value of the “max-body-size” property.
When overloading is enabled, this is equivalent to
setlogger [ #maxBodySize:=value ]