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
0258ce8f
Kaydet (Commit)
0258ce8f
authored
Eyl 22, 2010
tarafından
Vinay Sajip
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
logging: Added QueueHandler.prepare and updated documentation.
üst
b5d23b4d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
13 deletions
+42
-13
logging.rst
Doc/library/logging.rst
+15
-1
handlers.py
Lib/logging/handlers.py
+27
-12
No files found.
Doc/library/logging.rst
Dosyayı görüntüle @
0258ce8f
...
...
@@ -944,6 +944,7 @@ Loggers have the following attributes and methods. Note that Loggers are never
instantiated directly, but always through the module-level function
``logging.getLogger(name)``.
.. class:: Logger
.. attribute:: Logger.propagate
...
...
@@ -2661,7 +2662,20 @@ supports sending logging messages to a queue, such as those implemented in the
..
method
::
emit
(
record
)
Sends
the
record
to
the
handler
's queue.
Enqueues
the
result
of
preparing
the
LogRecord
.
..
method
::
prepare
(
record
)
Prepares
a
record
for
queuing
.
The
object
returned
by
this
method
is
enqueued
.
The
base
implementation
formats
the
record
to
merge
the
message
and
arguments
,
and
removes
unpickleable
items
from
the
record
in
-
place
.
You
might
want
to
override
this
method
if
you
want
to
convert
the
record
to
a
dict
or
JSON
string
,
or
send
a
modified
copy
of
the
record
while
leaving
the
original
intact
.
..
method
::
enqueue
(
record
)
...
...
Lib/logging/handlers.py
Dosyayı görüntüle @
0258ce8f
...
...
@@ -1176,24 +1176,39 @@ class QueueHandler(logging.Handler):
"""
self
.
queue
.
put_nowait
(
record
)
def
prepare
(
self
,
record
):
"""
Prepares a record for queuing. The object returned by this
method is enqueued.
The base implementation formats the record to merge the message
and arguments, and removes unpickleable items from the record
in-place.
You might want to override this method if you want to convert
the record to a dict or JSON string, or send a modified copy
of the record while leaving the original intact.
"""
# The format operation gets traceback text into record.exc_text
# (if there's exception data), and also puts the message into
# record.message. We can then use this to replace the original
# msg + args, as these might be unpickleable. We also zap the
# exc_info attribute, as it's no longer needed and, if not None,
# will typically not be pickleable.
self
.
format
(
record
)
record
.
msg
=
record
.
message
record
.
args
=
None
record
.
exc_info
=
None
return
record
def
emit
(
self
,
record
):
"""
Emit a record.
Writes the LogRecord to the queue, preparing it f
or pickling f
irst.
Writes the LogRecord to the queue, preparing it first.
"""
try
:
# The format operation gets traceback text into record.exc_text
# (if there's exception data), and also puts the message into
# record.message. We can then use this to replace the original
# msg + args, as these might be unpickleable. We also zap the
# exc_info attribute, as it's no longer needed and, if not None,
# will typically not be pickleable.
self
.
format
(
record
)
record
.
msg
=
record
.
message
record
.
args
=
None
record
.
exc_info
=
None
self
.
enqueue
(
record
)
self
.
enqueue
(
self
.
prepare
(
record
))
except
(
KeyboardInterrupt
,
SystemExit
):
raise
except
:
...
...
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