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
f778bec8
Kaydet (Commit)
f778bec8
authored
Eyl 22, 2009
tarafından
Vinay Sajip
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed a typo, and added sections on optimization and using arbitrary objects as messages.
üst
e50a9fdd
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
48 additions
and
1 deletion
+48
-1
logging.rst
Doc/library/logging.rst
+48
-1
No files found.
Doc/library/logging.rst
Dosyayı görüntüle @
f778bec8
...
@@ -59,7 +59,7 @@ default handler so that debug messages are written to a file::
...
@@ -59,7 +59,7 @@ default handler so that debug messages are written to a file::
import logging
import logging
LOG_FILENAME = '
/
tmp
/
logging_example
.
out
'
LOG_FILENAME = '
/
tmp
/
logging_example
.
out
'
logging.basicConfig(filename=LOG_FILENAME,level=logging.DEBUG
,
)
logging.basicConfig(filename=LOG_FILENAME,level=logging.DEBUG)
logging.debug('
This
message
should
go
to
the
log
file
')
logging.debug('
This
message
should
go
to
the
log
file
')
...
@@ -1515,6 +1515,53 @@ printed on the console; on the server side, you should see something like::
...
@@ -1515,6 +1515,53 @@ printed on the console; on the server side, you should see something like::
69
myapp
.
area2
WARNING
Jail
zesty
vixen
who
grabbed
pay
from
quack
.
69
myapp
.
area2
WARNING
Jail
zesty
vixen
who
grabbed
pay
from
quack
.
69
myapp
.
area2
ERROR
The
five
boxing
wizards
jump
quickly
.
69
myapp
.
area2
ERROR
The
five
boxing
wizards
jump
quickly
.
Using
arbitrary
objects
as
messages
-----------------------------------
In
the
preceding
sections
and
examples
,
it
has
been
assumed
that
the
message
passed
when
logging
the
event
is
a
string
.
However
,
this
is
not
the
only
possibility
.
You
can
pass
an
arbitrary
object
as
a
message
,
and
its
:
meth
:`
__str__
`
method
will
be
called
when
the
logging
system
needs
to
convert
it
to
a
string
representation
.
In
fact
,
if
you
want
to
,
you
can
avoid
computing
a
string
representation
altogether
-
for
example
,
the
:
class
:`
SocketHandler
`
emits
an
event
by
pickling
it
and
sending
it
over
the
wire
.
Optimization
------------
Formatting
of
message
arguments
is
deferred
until
it
cannot
be
avoided
.
However
,
computing
the
arguments
passed
to
the
logging
method
can
also
be
expensive
,
and
you
may
want
to
avoid
doing
it
if
the
logger
will
just
throw
away
your
event
.
To
decide
what
to
do
,
you
can
call
the
:
meth
:`
isEnabledFor
`
method
which
takes
a
level
argument
and
returns
true
if
the
event
would
be
created
by
the
Logger
for
that
level
of
call
.
You
can
write
code
like
this
::
if
logger
.
isEnabledFor
(
logging
.
DEBUG
):
logger
.
debug
(
"Message with %s, %s"
,
expensive_func1
(),
expensive_func2
())
so
that
if
the
logger
's threshold is set above ``DEBUG``, the calls to
:func:`expensive_func1` and :func:`expensive_func2` are never made.
There are other optimizations which can be made for specific applications which
need more precise control over what logging information is collected. Here'
s
a
list
of
things
you
can
do
to
avoid
processing
during
logging
which
you
don
't
need:
+-----------------------------------------------+----------------------------------------+
| What you don'
t
want
to
collect
|
How
to
avoid
collecting
it
|
+===============================================+========================================+
|
Information
about
where
calls
were
made
from
.
|
Set
``
logging
.
_srcfile
``
to
``
None
``.
|
+-----------------------------------------------+----------------------------------------+
|
Threading
information
.
|
Set
``
logging
.
logThreads
``
to
``
0
``.
|
+-----------------------------------------------+----------------------------------------+
|
Process
information
.
|
Set
``
logging
.
logProcesses
``
to
``
0
``.
|
+-----------------------------------------------+----------------------------------------+
Also
note
that
the
core
logging
module
only
includes
the
basic
handlers
.
If
you
don
't import :mod:`logging.handlers` and :mod:`logging.config`, they won'
t
take
up
any
memory
.
..
_handler
:
..
_handler
:
...
...
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