hscdio-0.1.0.0: Haskell bindings to the libcdio disc-reading library.
Copyright(c) 2020-2021 Sam May
LicenseGPL-3.0-or-later
Maintainerag@eitilt.life
Stabilitystable
Portabilitynon-portable (requires libcdio)
Safe HaskellNone
LanguageHaskell2010

Foreign.Libcdio.Logging

Description

The underlying library is rather loud in its error and warning messages, potentially emitting a lot of impure terminal clutter even on some otherwise-pure functions. Very helpfully, it also provides a mechanism for integrating the logs with whatever framework is in place for the larger project; that mechanism can be leveraged to cache the logs in memory until specifically asked for, at which point they can be packaged into Haskell types. Some of the immediacy—and therefore user ability to match note to source—is unfortunately lost, but the apparent purity is worth it.

logging.h

Types

Symbols

Sound.Libcdio.Logging

Most functions have been re-contextulized as being provided through a LibcdioLogger instance, but the interface is otherwise unchanged.

Synopsis

Types

data LogEntry Source #

An unstructured message emitted from the library to let the user know what's going on behind the scenes.

Constructors

LogEntry 

Fields

data LogLevel Source #

How much detail should be recorded in the logs.

Message interaction

putLog :: LogEntry -> IO () Source #

Append a message to the logs.

readLog :: IO [LogEntry] Source #

Retrieve all messages currently in the log for further processing. Note that this retains the contents of the log for future calls; to remove them, a separate call to clearLog must be made.

>>> setupLogger
>>> putLog $ LogEntry LogWarn "Testing log reading"
>>> readLog
[LogEntry LogWarn "Testing log reading"]
>>> readLog
[LogEntry LogWarn "Testing log reading"]
>>> clearLog
>>> readLog
[]

clearLog :: IO () Source #

Empty all messages currently in the log. There is no way to selectively remove only some messages; if that is desired, call readLog first:

>>> setupLogger
>>> msgs <- readLog
>>> clearLog
>>> mapM_ putLog $ filter p msgs

Management

logCutoff :: IO LogLevel Source #

Check the current minimum severity which will be recorded in the logs.

See setLogCutoff.

setLogCutoff :: LogLevel -> IO () Source #

Set the minimum severity required for a message to be recorded in the logs.

See logCutoff.

setupLogger :: IO () Source #

Initialize the log-management backend to use the mechanisms provided by this library instead of just printing to standard output. While this will usually be taken care of automatically, it may still be necessary to call this explicitly if messages are being recorded before any disc session is opened.