Attributes for simple customizations. More...
Public Member Functions | |
def | __init__ |
Default values for various settings. More... | |
def | log_to_console |
Send log messages to STDERR. More... | |
def | log_to_file |
Send log messages to a file. More... | |
def | log_level |
Set the level of logging verbosity. More... | |
Attributes for simple customizations.
This class has the following attributes to allow simple customizations. In the list below, the parenthesized term specifies the type of the attribute and the term in square brackets is the attribute's default value.
active_border_color
(int) [0xFF0000]: This attribute specifies the color of the border of the window with the input focus. It should be a three-byte RGB packed into a single integer. The easiest way to specify this is as a 24-bit hex number, where byte 0 is blue, byte 1 is green, and byte 2 is red. By default, the active window's border color is red. inactive_border_color
(int) [0xFFFFFF]: This attribute specifies the color of unfocused windows. By default, this color is white. active_border_size
(int) [1]: This attribute specifies the size (in pixels) of the border of the window with the input focus. inactive_border_size
(int) [1]: This attribute specifies the border size (in pixels) of inactive windows.logger
(dict) [see below]: This field is passed to logging.config.dictConfig(). The default configuration sets up a logging.NullHandler to suppress Minx's log messages.To enable logging, use either log_to_console() to send log messages to STDERR or log_to_file() to send them to a file. You can also use log_level() to configure the level of verbosity.
The above three functions should be enough to configure logging for the most common cases. However, you can further customize logging by retrieving the keys of the logger dict and reassigning them to the desired values. The following paragraphs provide some details.
logger['formatters']['minx_formatter']
will get you a reference to the formatter for Minx's log messages. This formatter is itself a dict with the keys 'format'
and 'datefmt'
. Consult the Python logging documentation for further details about formatters.
logger['handlers']['minx_handler']
yields Minx's logging handler, which is also a dict with keys 'class'
and 'formatter'
. As mentioned above, the handler's 'class'
is 'logging.NullHandler'
. The value of the 'formatter'
key is 'minx_formatter'
. You should reset 'class'
to another logging handler class (e.g., 'logging.FileHandler'
). You should also set other keys appropriately. Consult the Python logging module's documentation for more info.
Instead of using the predefined 'minx_formatter'
and 'minx_handler'
keys as described above, you can also reset the config
object's logger
attribute to anything you want.
terminal
(string) [xterm]: This field specifies the command to use for launching a terminal window. Your PATH variable will be searched to find it; so you don't have to specify a full path. Moreover, you can supply command-line arguments for the terminal program in this setting and they will be passed as-is. Minx's default configuration defines a <a href="../wiki/hooks-list.wiki::launch_terminal>key binding that uses the value of this setting. synchronize_xlib
(Boolean) [False]: If set to True
, Xlib calls will be synchronous; otherwise, the X protocol operates asynchronously. Synchronous mode can be useful for debugging. def minx.core.config.config.__init__ | ( | self) |
Default values for various settings.
Instantiating this class will result in a config object with default values for the various settings. Clients can then assign different values to the desired attributes to customize Minx and pass the modified config object to the wm constructor.
def minx.core.config.config.log_level | ( | self, | |
level | |||
) |
Set the level of logging verbosity.
level | The log level from the Python logging module. |
The default log level is logging.WARNING
. Thus, only WARNING
, ERROR
, and CRITICAL
messages will be printed. However, with this function, you can change the log level to either produce more or fewer messages.
Consult the Python logging documentation for more details about logging levels.
def minx.core.config.config.log_to_console | ( | self) |
Send log messages to STDERR.
This is a convenience function that allows you to avoid dealing directly with the config.logger
attribute's complicated dict-of-dict-of-dict structure. Using it, you can easily configure Minx's log messages to be printed to STDERR.
def minx.core.config.config.log_to_file | ( | self, | |
name, | |||
mode = 'w' |
|||
) |
Send log messages to a file.
name | Log file's name. |
mode | Log file open mode; default = 'w'. |
One of the most common configurations for logging is to send log messages to a file. This function configures the config.logger
attribute so that log messages will be written to the named file. By default, the log will be overwritten. However, if you use the value 'a' for the mode
parameter, log messages will be appended to the file.
As described earlier, you can configure Minx's logging by directly manipulating the config.logger
dict. However, since that process can be somewhat convoluted and because sending log messages to a file is a fairly common thing to do, it's easier to use this function.