hikari.internal.ux#
User-experience extensions and utilities.
Module Contents#
- hikari.internal.ux.init_logging(flavor, allow_color, force_color)[source]#
Attempt to initialize logging for the user.
If any handlers already exist, this is ignored entirely. This ensures the user can use any existing logging configuration without us interfering. You can manually disable this by passing
None
as theflavor
parameter.- Parameters
- flavor
typing.Optional
[None
,str
,typing.Dict
[str
,typing.Any
]] The hint for configuring logging.
This can be
None
to not enable logging automatically.If you pass a
str
or aint
, it is interpreted as the global logging level to use, and should match one of"DEBUG"
,"INFO"
,"WARNING"
,"ERROR"
or"CRITICAL"
, ifstr
. The configuration will be set up to use acolorlog
coloured logger, and to use a sane logging format strategy. The output will be written tosys.stderr
using this configuration.If you pass a
dict
, it is treated as the mapping to pass tologging.config.dictConfig
. If the dict defines any handlers, default handlers will not be setup.- allow_colorbool
If
False
, no colour is allowed. IfTrue
, the output device must be supported for this to returnTrue
.- force_colorbool
If
True
, returnTrue
always, otherwise only returnTrue
if the device supports colour output and theallow_color
flag is notFalse
.
- flavor
- hikari.internal.ux.print_banner(package, allow_color, force_color, extra_args=None)[source]#
Print a banner of choice to
sys.stdout
.Inspired by Spring Boot, we display an ASCII logo on startup. This is styled to grab the user’s attention, and contains info such as the library version, the Python interpreter, the OS, and links to our Discord server and documentation. Users can override this by placing a
banner.txt
in some package and referencing it in this call.Note
The
banner.txt
must be in the root folder of the package.- Parameters
- package
typing.Optional
[str
] The package to find the
banner.txt
in, orNone
if no banner should be shown.- allow_colorbool
If
False
, no colour is allowed. IfTrue
, the output device must be supported for this to returnTrue
.- force_colorbool
If
True
, returnTrue
always, otherwise only returnTrue
if the device supports colour output and theallow_color
flag is notFalse
.- extra_args
typing.Optional
[typing.Dict
[str
,str
]] If provided, extra $-substitutions to use when printing the banner. Default substitutions can not be overwritten.
- package
- Raises
ValueError
If
extra_args
contains a default $-substitution.