Do basic configuration for the logging system. This function does nothing if the root logger already has handlers configured, unless the keyword argument *force* is set to ``True``. It is a convenience method intended for use by simple scripts to do one-shot configuration of th
(**kwargs)
| 2014 | #--------------------------------------------------------------------------- |
| 2015 | |
| 2016 | def basicConfig(**kwargs): |
| 2017 | """ |
| 2018 | Do basic configuration for the logging system. |
| 2019 | |
| 2020 | This function does nothing if the root logger already has handlers |
| 2021 | configured, unless the keyword argument *force* is set to ``True``. |
| 2022 | It is a convenience method intended for use by simple scripts |
| 2023 | to do one-shot configuration of the logging package. |
| 2024 | |
| 2025 | The default behaviour is to create a StreamHandler which writes to |
| 2026 | sys.stderr, set a formatter using the BASIC_FORMAT format string, and |
| 2027 | add the handler to the root logger. |
| 2028 | |
| 2029 | A number of optional keyword arguments may be specified, which can alter |
| 2030 | the default behaviour. |
| 2031 | |
| 2032 | filename Specifies that a FileHandler be created, using the specified |
| 2033 | filename, rather than a StreamHandler. |
| 2034 | filemode Specifies the mode to open the file, if filename is specified |
| 2035 | (if filemode is unspecified, it defaults to 'a'). |
| 2036 | format Use the specified format string for the handler. |
| 2037 | datefmt Use the specified date/time format. |
| 2038 | style If a format string is specified, use this to specify the |
| 2039 | type of format string (possible values '%', '{', '$', for |
| 2040 | %-formatting, :meth:`str.format` and :class:`string.Template` |
| 2041 | - defaults to '%'). |
| 2042 | level Set the root logger level to the specified level. |
| 2043 | stream Use the specified stream to initialize the StreamHandler. Note |
| 2044 | that this argument is incompatible with 'filename' - if both |
| 2045 | are present, 'stream' is ignored. |
| 2046 | handlers If specified, this should be an iterable of already created |
| 2047 | handlers, which will be added to the root logger. Any handler |
| 2048 | in the list which does not have a formatter assigned will be |
| 2049 | assigned the formatter created in this function. |
| 2050 | force If this keyword is specified as true, any existing handlers |
| 2051 | attached to the root logger are removed and closed, before |
| 2052 | carrying out the configuration as specified by the other |
| 2053 | arguments. |
| 2054 | encoding If specified together with a filename, this encoding is passed to |
| 2055 | the created FileHandler, causing it to be used when the file is |
| 2056 | opened. |
| 2057 | errors If specified together with a filename, this value is passed to the |
| 2058 | created FileHandler, causing it to be used when the file is |
| 2059 | opened in text mode. If not specified, the default value is |
| 2060 | `backslashreplace`. |
| 2061 | |
| 2062 | Note that you could specify a stream created using open(filename, mode) |
| 2063 | rather than passing the filename and mode in. However, it should be |
| 2064 | remembered that StreamHandler does not close its stream (since it may be |
| 2065 | using sys.stdout or sys.stderr), whereas FileHandler closes its stream |
| 2066 | when the handler is closed. |
| 2067 | |
| 2068 | .. versionchanged:: 3.2 |
| 2069 | Added the ``style`` parameter. |
| 2070 | |
| 2071 | .. versionchanged:: 3.3 |
| 2072 | Added the ``handlers`` parameter. A ``ValueError`` is now thrown for |
| 2073 | incompatible arguments (e.g. ``handlers`` specified together with |
no test coverage detected