Expand description
§Notify
This crate provides an interface to the org.freedesktop.Notifications interface. It also implements a log:Logger controlled entirely through the environment that can optionally send log messages to the Desktop Environment via Notifications.
notify::notify will send a notification to the client, whereas notify::action will send a notification with a list of prospective actions, to which the function will return the action chosen by the user, if any.
To use as a logger, simply call notify::init to initialize notify as the program logger, after which simply use warn!, log!, etc as usual. Control over the messages and level is done via two environment variables:
RUST_LOGcontrol messages output to the terminal, identical to howenv_loggerworks.NOTIFYcontrols notifications sent to the Desktop Environment. By default, logs withlog::Level::Errorwill be both printed to the terminal, and displayed via a Notification. Notifications can be displayed entirely at runtime by settingNOTIFY=none.
A binary can be compiled from the repository, providing a means to notify the command line.
Enums§
- Error
- Errors for the NotifyLogger.
- Urgency
- The urgency level of a Notification. The Desktop Environment is free to interpret this as it wants. This should, therefore, be seen as a suggestion.
Statics§
- LEVEL
- The current log level, set by the RUST_LOG environment variable
- PROMPT_
LEVEL - The current level to which messages should be notified. By default, only errors cause prompts. This is controlled via the NOTIFY environment variable, and can be set to none to only log to the terminal.
Functions§
- action
- Send a Notification across the User Bus with a set of Actions. The selected Action, if the user choose one, is returned.
- init
- Initialize the NotifyLogger as the program’s Logger.
- init_
error - Initialize the NotifyLogger as the program’s Logger, but print to stderr instead of stdout. Note that this only applies to direct logging, notification call fallback still prints to stdout.
- level_
color - Get the color that should be used for particular log level.
- level_
name - Get the pretty name of a log level.
- level_
urgency - Get the recommended notification urgency for each level.
- notify
- Send a stateless Notification across the User Bus. If there is a failure sending the message, it will be sent to the terminal.
- set_
notifier - Set an optional Notifier function that is called instead of the notify() function defined here, such as to run the binary compiled by this crate in cases of SetUID, where we cannot communicate to the User Bus in this process.