Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
2b65fc8a
Kaydet (Commit)
2b65fc8a
authored
Eyl 12, 2010
tarafından
Vinay Sajip
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #9827: clarified LogRecord documentation.
üst
69976a7f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
21 deletions
+30
-21
logging.rst
Doc/library/logging.rst
+30
-21
No files found.
Doc/library/logging.rst
Dosyayı görüntüle @
2b65fc8a
...
...
@@ -540,10 +540,10 @@ Useful Handlers
In addition to the base :class:`Handler` class, many useful subclasses are
provided:
#. :class:`StreamHandler` instances send
error
messages to streams (file-like
#. :class:`StreamHandler` instances send messages to streams (file-like
objects).
#. :class:`FileHandler` instances send
error
messages to disk files.
#. :class:`FileHandler` instances send messages to disk files.
.. module:: logging.handlers
...
...
@@ -552,31 +552,31 @@ provided:
directly. Instead, use :class:`RotatingFileHandler` or
:class:`TimedRotatingFileHandler`.
#. :class:`RotatingFileHandler` instances send
error
messages to disk
#. :class:`RotatingFileHandler` instances send messages to disk
files, with support for maximum log file sizes and log file rotation.
#. :class:`TimedRotatingFileHandler` instances send
error
messages to
#. :class:`TimedRotatingFileHandler` instances send messages to
disk files, rotating the log file at certain timed intervals.
#. :class:`SocketHandler` instances send
error
messages to TCP/IP
#. :class:`SocketHandler` instances send messages to TCP/IP
sockets.
#. :class:`DatagramHandler` instances send
error
messages to UDP
#. :class:`DatagramHandler` instances send messages to UDP
sockets.
#. :class:`SMTPHandler` instances send
error
messages to a designated
#. :class:`SMTPHandler` instances send messages to a designated
email address.
#. :class:`SysLogHandler` instances send
error
messages to a Unix
#. :class:`SysLogHandler` instances send messages to a Unix
syslog daemon, possibly on a remote machine.
#. :class:`NTEventLogHandler` instances send
error
messages to a
#. :class:`NTEventLogHandler` instances send messages to a
Windows NT/2000/XP event log.
#. :class:`MemoryHandler` instances send
error
messages to a buffer
#. :class:`MemoryHandler` instances send messages to a buffer
in memory, which is flushed whenever specific criteria are met.
#. :class:`HTTPHandler` instances send
error
messages to an HTTP
#. :class:`HTTPHandler` instances send messages to an HTTP
server using either ``GET`` or ``POST`` semantics.
#. :class:`WatchedFileHandler` instances watch the file they are
...
...
@@ -675,7 +675,7 @@ functions.
d = {'
clientip
': '
192.168.0.1
', '
user
': '
fbloggs
'}
logging.warning("Protocol problem: %s", "connection reset", extra=d)
would print something like
::
would print something like::
2006-02-08 22:20:02,165 192.168.0.1 fbloggs Protocol problem: connection reset
...
...
@@ -842,6 +842,7 @@ functions.
and 2.2.x, which do not include the :mod:`logging` package in the standard
library.
.. _logger:
Logger Objects
--------------
...
...
@@ -1441,16 +1442,16 @@ Although logging is thread-safe, and logging to a single file from multiple
threads in a single process *is* supported, logging to a single file from
*multiple processes* is *not* supported, because there is no standard way to
serialize access to a single file across multiple processes in Python. If you
need to log to a single file from multiple processes,
the best way of doing
t
his is to have all the processes log to a :class:`SocketHandler`, and have a
separate process which implements a socket server which reads from the socket
and logs to file. (If you prefer, you can dedicate one thread in one of the
existing processes to perform this function.) The following section document
s
this approach in more detail and includes a working socket receiver which can
be
used as a starting point for you to adapt in your own applications.
need to log to a single file from multiple processes,
one way of doing this is
t
o have all the processes log to a :class:`SocketHandler`, and have a separate
process which implements a socket server which reads from the socket and logs
to file. (If you prefer, you can dedicate one thread in one of the existing
processes to perform this function.) The following section documents thi
s
approach in more detail and includes a working socket receiver which can be
used as a starting point for you to adapt in your own applications.
If you are using a recent version of Python which includes the
:mod:`multiprocessing` module, you c
an
write your own handler which uses the
:mod:`multiprocessing` module, you c
ould
write your own handler which uses the
:class:`Lock` class from this module to serialize access to the file from
your processes. The existing :class:`FileHandler` and subclasses do not make
use of :mod:`multiprocessing` at present, though they may do so in the future.
...
...
@@ -1594,6 +1595,8 @@ these affect you, you can use an alternative serialization scheme by overriding
the :meth:`makePickle` method and implementing your alternative there, as
well as adapting the above script to use your alternative serialization.
.. _arbitrary-object-messages:
Using arbitrary objects as messages
-----------------------------------
...
...
@@ -1957,6 +1960,11 @@ timed intervals.
The
extensions
are
date
-
and
-
time
based
,
using
the
strftime
format
``%
Y
-%
m
-%
d_
%
H
-%
M
-%
S
``
or
a
leading
portion
thereof
,
depending
on
the
rollover
interval
.
When
computing
the
next
rollover
time
for
the
first
time
(
when
the
handler
is
created
),
the
last
modification
time
of
an
existing
log
file
,
or
else
the
current
time
,
is
used
to
compute
when
the
next
rotation
will
occur
.
If
the
*
utc
*
argument
is
true
,
times
in
UTC
will
be
used
;
otherwise
local
time
is
used
.
...
...
@@ -2452,6 +2460,8 @@ Currently, the useful mapping keys in a :class:`LogRecord` are:
+-------------------------+-----------------------------------------------+
| ``%(process)d`` | Process ID (if available). |
+-------------------------+-----------------------------------------------+
| ``%(processName)s`` | Process name (if available). |
+-------------------------+-----------------------------------------------+
| ``%(message)s`` | The logged message, computed as ``msg % |
| | args``. |
+-------------------------+-----------------------------------------------+
...
...
@@ -2465,7 +2475,6 @@ Currently, the useful mapping keys in a :class:`LogRecord` are:
specified, ``'
%(
message
)
s
'`` is used. If no *datefmt* is specified, the
ISO8601 date format is used.
.. method:: format(record)
The record'
s
attribute
dictionary
is
used
as
the
operand
to
a
string
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment