Participer au site avec un Tip
Rechercher
 

Améliorations / Corrections

Vous avez des améliorations (ou des corrections) à proposer pour ce document : je vous remerçie par avance de m'en faire part, cela m'aide à améliorer le site.

Emplacement :

Description des améliorations :

Vous êtes un professionnel et vous avez besoin d'une formation ? Deep Learning avec Python
et Keras et Tensorflow
Voir le programme détaillé
Module « logging » Python 3.13.2

Fonction basicConfig - module logging

Signature de la fonction basicConfig

def basicConfig(**kwargs) 

Description

help(logging.basicConfig)

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 the logging package.

The default behaviour is to create a StreamHandler which writes to
sys.stderr, set a formatter using the BASIC_FORMAT format string, and
add the handler to the root logger.

A number of optional keyword arguments may be specified, which can alter
the default behaviour.

filename  Specifies that a FileHandler be created, using the specified
          filename, rather than a StreamHandler.
filemode  Specifies the mode to open the file, if filename is specified
          (if filemode is unspecified, it defaults to 'a').
format    Use the specified format string for the handler.
datefmt   Use the specified date/time format.
style     If a format string is specified, use this to specify the
          type of format string (possible values '%', '{', '$', for
          %-formatting, :meth:`str.format` and :class:`string.Template`
          - defaults to '%').
level     Set the root logger level to the specified level.
stream    Use the specified stream to initialize the StreamHandler. Note
          that this argument is incompatible with 'filename' - if both
          are present, 'stream' is ignored.
handlers  If specified, this should be an iterable of already created
          handlers, which will be added to the root logger. Any handler
          in the list which does not have a formatter assigned will be
          assigned the formatter created in this function.
force     If this keyword  is specified as true, any existing handlers
          attached to the root logger are removed and closed, before
          carrying out the configuration as specified by the other
          arguments.
encoding  If specified together with a filename, this encoding is passed to
          the created FileHandler, causing it to be used when the file is
          opened.
errors    If specified together with a filename, this value is passed to the
          created FileHandler, causing it to be used when the file is
          opened in text mode. If not specified, the default value is
          `backslashreplace`.

Note that you could specify a stream created using open(filename, mode)
rather than passing the filename and mode in. However, it should be
remembered that StreamHandler does not close its stream (since it may be
using sys.stdout or sys.stderr), whereas FileHandler closes its stream
when the handler is closed.

.. versionchanged:: 3.2
   Added the ``style`` parameter.

.. versionchanged:: 3.3
   Added the ``handlers`` parameter. A ``ValueError`` is now thrown for
   incompatible arguments (e.g. ``handlers`` specified together with
   ``filename``/``filemode``, or ``filename``/``filemode`` specified
   together with ``stream``, or ``handlers`` specified together with
   ``stream``.

.. versionchanged:: 3.8
   Added the ``force`` parameter.

.. versionchanged:: 3.9
   Added the ``encoding`` and ``errors`` parameters.


Vous êtes un professionnel et vous avez besoin d'une formation ? Mise en oeuvre d'IHM
avec Qt et PySide6
Voir le programme détaillé