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
cbabd7ec
Kaydet (Commit)
cbabd7ec
authored
Eki 10, 2009
tarafından
Vinay Sajip
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #7086: Added TCP support to SysLogHandler and tidied up some anachronisms in the code.
üst
bec4d57a
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
32 additions
and
14 deletions
+32
-14
logging.rst
Doc/library/logging.rst
+13
-5
__init__.py
Lib/logging/__init__.py
+2
-2
config.py
Lib/logging/config.py
+1
-1
handlers.py
Lib/logging/handlers.py
+13
-6
NEWS
Misc/NEWS
+3
-0
No files found.
Doc/library/logging.rst
Dosyayı görüntüle @
cbabd7ec
...
...
@@ -763,11 +763,13 @@ functions.
Does
basic
configuration
for
the
logging
system
by
creating
a
:
class
:`
StreamHandler
`
with
a
default
:
class
:`
Formatter
`
and
adding
it
to
the
root
logger
.
The
function
does
nothing
if
any
handlers
have
been
defined
for
the
root
logger
.
The
functions
:
func
:`
debug
`,
:
func
:`
info
`,
:
func
:`
warning
`,
root
logger
.
The
functions
:
func
:`
debug
`,
:
func
:`
info
`,
:
func
:`
warning
`,
:
func
:`
error
`
and
:
func
:`
critical
`
will
call
:
func
:`
basicConfig
`
automatically
if
no
handlers
are
defined
for
the
root
logger
.
This
function
does
nothing
if
the
root
logger
already
has
handlers
configured
for
it
.
The
following
keyword
arguments
are
supported
.
+--------------+---------------------------------------------+
...
...
@@ -1957,16 +1959,22 @@ The :class:`SysLogHandler` class, located in the :mod:`logging.handlers` module,
supports
sending
logging
messages
to
a
remote
or
local
Unix
syslog
.
..
class
::
SysLogHandler
(
address
=(
'localhost'
,
SYSLOG_UDP_PORT
),
facility
=
LOG_USER
)
..
class
::
SysLogHandler
(
address
=(
'localhost'
,
SYSLOG_UDP_PORT
),
facility
=
LOG_USER
,
socktype
=
socket
.
SOCK_DGRAM
)
Returns
a
new
instance
of
the
:
class
:`
SysLogHandler
`
class
intended
to
communicate
with
a
remote
Unix
machine
whose
address
is
given
by
*
address
*
in
the
form
of
a
``(
host
,
port
)``
tuple
.
If
*
address
*
is
not
specified
,
``(
'localhost'
,
514
)``
is
used
.
The
address
is
used
to
open
a
UDP
socket
.
An
``(
'localhost'
,
514
)``
is
used
.
The
address
is
used
to
open
a
socket
.
An
alternative
to
providing
a
``(
host
,
port
)``
tuple
is
providing
an
address
as
a
string
,
for
example
"/dev/log"
.
In
this
case
,
a
Unix
domain
socket
is
used
to
send
the
message
to
the
syslog
.
If
*
facility
*
is
not
specified
,
:
const
:`
LOG_USER
`
is
used
.
:
const
:`
LOG_USER
`
is
used
.
The
type
of
socket
opened
depends
on
the
*
socktype
*
argument
,
which
defaults
to
:
const
:`
socket
.
SOCK_DGRAM
`
and
thus
opens
a
UDP
socket
.
To
open
a
TCP
socket
(
for
use
with
the
newer
syslog
daemons
such
as
rsyslog
),
specify
a
value
of
:
const
:`
socket
.
SOCK_STREAM
`.
..
versionchanged
::
3.2
*
socktype
*
was
added
.
..
method
::
close
()
...
...
Lib/logging/__init__.py
Dosyayı görüntüle @
cbabd7ec
...
...
@@ -46,8 +46,8 @@ except ImportError:
__author__
=
"Vinay Sajip <vinay_sajip@red-dove.com>"
__status__
=
"production"
__version__
=
"0.5.0.
7
"
__date__
=
"
20 January
2009"
__version__
=
"0.5.0.
9
"
__date__
=
"
09 October
2009"
#---------------------------------------------------------------------------
# Miscellaneous module data
...
...
Lib/logging/config.py
Dosyayı görüntüle @
cbabd7ec
...
...
@@ -19,7 +19,7 @@ Configuration functions for the logging package for Python. The core package
is based on PEP 282 and comments thereto in comp.lang.python, and influenced
by Apache's log4j system.
Copyright (C) 2001-200
8
Vinay Sajip. All Rights Reserved.
Copyright (C) 2001-200
9
Vinay Sajip. All Rights Reserved.
To use, simply 'import logging' and log away!
"""
...
...
Lib/logging/handlers.py
Dosyayı görüntüle @
cbabd7ec
# Copyright 2001-200
7
by Vinay Sajip. All Rights Reserved.
# Copyright 2001-200
9
by Vinay Sajip. All Rights Reserved.
#
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose and without fee is hereby granted,
...
...
@@ -41,6 +41,7 @@ DEFAULT_UDP_LOGGING_PORT = 9021
DEFAULT_HTTP_LOGGING_PORT
=
9022
DEFAULT_SOAP_LOGGING_PORT
=
9023
SYSLOG_UDP_PORT
=
514
SYSLOG_TCP_PORT
=
514
_MIDNIGHT
=
24
*
60
*
60
# number of seconds in a day
...
...
@@ -155,7 +156,7 @@ class TimedRotatingFileHandler(BaseRotatingHandler):
If backupCount is > 0, when rollover is done, no more than backupCount
files are kept - the oldest ones are deleted.
"""
def
__init__
(
self
,
filename
,
when
=
'h'
,
interval
=
1
,
backupCount
=
0
,
encoding
=
None
,
delay
=
0
,
utc
=
False
):
def
__init__
(
self
,
filename
,
when
=
'h'
,
interval
=
1
,
backupCount
=
0
,
encoding
=
None
,
delay
=
False
,
utc
=
False
):
BaseRotatingHandler
.
__init__
(
self
,
filename
,
'a'
,
encoding
,
delay
)
self
.
when
=
when
.
upper
()
self
.
backupCount
=
backupCount
...
...
@@ -690,7 +691,8 @@ class SysLogHandler(logging.Handler):
"CRITICAL"
:
"critical"
}
def
__init__
(
self
,
address
=
(
'localhost'
,
SYSLOG_UDP_PORT
),
facility
=
LOG_USER
):
def
__init__
(
self
,
address
=
(
'localhost'
,
SYSLOG_UDP_PORT
),
facility
=
LOG_USER
,
socktype
=
socket
.
SOCK_DGRAM
):
"""
Initialize a handler.
...
...
@@ -702,13 +704,16 @@ class SysLogHandler(logging.Handler):
self
.
address
=
address
self
.
facility
=
facility
self
.
socktype
=
socktype
if
isinstance
(
address
,
str
):
self
.
unixsocket
=
1
self
.
_connect_unixsocket
(
address
)
else
:
self
.
unixsocket
=
0
self
.
socket
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_DGRAM
)
self
.
socket
=
socket
.
socket
(
socket
.
AF_INET
,
socktype
)
if
socktype
==
socket
.
SOCK_STREAM
:
self
.
socket
.
connect
(
address
)
self
.
formatter
=
None
def
_connect_unixsocket
(
self
,
address
):
...
...
@@ -781,8 +786,10 @@ class SysLogHandler(logging.Handler):
except
socket
.
error
:
self
.
_connect_unixsocket
(
self
.
address
)
self
.
socket
.
send
(
msg
)
el
se
:
el
if
self
.
socktype
==
socket
.
SOCK_DGRAM
:
self
.
socket
.
sendto
(
msg
,
self
.
address
)
else
:
self
.
socket
.
sendall
(
msg
)
except
(
KeyboardInterrupt
,
SystemExit
):
raise
except
:
...
...
Misc/NEWS
Dosyayı görüntüle @
cbabd7ec
...
...
@@ -87,6 +87,9 @@ C-API
Library
-------
- Issue #7086: Added TCP support to SysLogHandler, and tidied up some
anachronisms in the code which were a relic of 1.5.2 compatibility.
- Issue #7082: When falling back to the MIME 'name' parameter, the
correct place to look for it is the Content-Type header.
...
...
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