MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / basicConfig

Function basicConfig

tools/python-3.11.9-amd64/Lib/logging/__init__.py:1946–2067  ·  view source on GitHub ↗

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

(**kwargs)

Source from the content-addressed store, hash-verified

1944#---------------------------------------------------------------------------
1945
1946def basicConfig(**kwargs):
1947 """
1948 Do basic configuration for the logging system.
1949
1950 This function does nothing if the root logger already has handlers
1951 configured, unless the keyword argument *force* is set to ``True``.
1952 It is a convenience method intended for use by simple scripts
1953 to do one-shot configuration of the logging package.
1954
1955 The default behaviour is to create a StreamHandler which writes to
1956 sys.stderr, set a formatter using the BASIC_FORMAT format string, and
1957 add the handler to the root logger.
1958
1959 A number of optional keyword arguments may be specified, which can alter
1960 the default behaviour.
1961
1962 filename Specifies that a FileHandler be created, using the specified
1963 filename, rather than a StreamHandler.
1964 filemode Specifies the mode to open the file, if filename is specified
1965 (if filemode is unspecified, it defaults to 'a').
1966 format Use the specified format string for the handler.
1967 datefmt Use the specified date/time format.
1968 style If a format string is specified, use this to specify the
1969 type of format string (possible values '%', '{', '$', for
1970 %-formatting, :meth:`str.format` and :class:`string.Template`
1971 - defaults to '%').
1972 level Set the root logger level to the specified level.
1973 stream Use the specified stream to initialize the StreamHandler. Note
1974 that this argument is incompatible with 'filename' - if both
1975 are present, 'stream' is ignored.
1976 handlers If specified, this should be an iterable of already created
1977 handlers, which will be added to the root logger. Any handler
1978 in the list which does not have a formatter assigned will be
1979 assigned the formatter created in this function.
1980 force If this keyword is specified as true, any existing handlers
1981 attached to the root logger are removed and closed, before
1982 carrying out the configuration as specified by the other
1983 arguments.
1984 encoding If specified together with a filename, this encoding is passed to
1985 the created FileHandler, causing it to be used when the file is
1986 opened.
1987 errors If specified together with a filename, this value is passed to the
1988 created FileHandler, causing it to be used when the file is
1989 opened in text mode. If not specified, the default value is
1990 `backslashreplace`.
1991
1992 Note that you could specify a stream created using open(filename, mode)
1993 rather than passing the filename and mode in. However, it should be
1994 remembered that StreamHandler does not close its stream (since it may be
1995 using sys.stdout or sys.stderr), whereas FileHandler closes its stream
1996 when the handler is closed.
1997
1998 .. versionchanged:: 3.2
1999 Added the ``style`` parameter.
2000
2001 .. versionchanged:: 3.3
2002 Added the ``handlers`` parameter. A ``ValueError`` is now thrown for
2003 incompatible arguments (e.g. ``handlers`` specified together with

Callers 6

criticalFunction · 0.85
errorFunction · 0.85
warningFunction · 0.85
infoFunction · 0.85
debugFunction · 0.85
logFunction · 0.85

Calls 13

_acquireLockFunction · 0.85
StreamHandlerClass · 0.85
_releaseLockFunction · 0.85
removeHandlerMethod · 0.80
setFormatterMethod · 0.80
addHandlerMethod · 0.80
FileHandlerClass · 0.70
FormatterClass · 0.70
popMethod · 0.45
closeMethod · 0.45
joinMethod · 0.45
keysMethod · 0.45

Tested by

no test coverage detected