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
c204c70c
Kaydet (Commit)
c204c70c
authored
Eyl 05, 1996
tarafından
Guido van Rossum
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Added logging support.
üst
e5e46e0d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
60 additions
and
0 deletions
+60
-0
cgi.py
Lib/cgi.py
+60
-0
No files found.
Lib/cgi.py
Dosyayı görüntüle @
c204c70c
...
@@ -183,6 +183,8 @@ sequences. Use this if you need to display text that might contain
...
@@ -183,6 +183,8 @@ sequences. Use this if you need to display text that might contain
such characters in HTML. To translate URLs for inclusion in the HREF
such characters in HTML. To translate URLs for inclusion in the HREF
attribute of an <A> tag, use urllib.quote().
attribute of an <A> tag, use urllib.quote().
log(fmt, ...): write a line to a log file; see docs for initlog().
Caring about security
Caring about security
---------------------
---------------------
...
@@ -349,6 +351,11 @@ first two lines have been printed, a traceback will be displayed.
...
@@ -349,6 +351,11 @@ first two lines have been printed, a traceback will be displayed.
Because no HTML interpretation is going on, the traceback will
Because no HTML interpretation is going on, the traceback will
readable.
readable.
When all else fails, you may want to insert calls to log() to your
program or even to a copy of the cgi.py file. Note that this requires
you to set cgi.logfile to the name of a world-writable file before the
first call to log() is made!
Good luck!
Good luck!
...
@@ -409,6 +416,59 @@ import string
...
@@ -409,6 +416,59 @@ import string
import
sys
import
sys
import
os
import
os
# Logging support
# ===============
logfile
=
""
# Filename to log to, if not empty
logfp
=
None
# File object to log to, if not None
def
initlog
(
*
allargs
):
"""Write a log message, if there is a log file.
Even though this function is called initlog(), you should always
use log(); log is a variable that is set either to initlog
(initially), to dolog (once the log file has been opened), or to
nolog (when logging is disabled).
The first argument is a format string; the remaining arguments (if
any) are arguments to the
%
operator, so e.g.
log("
%
s:
%
s", "a", "b")
will write "a: b" to the log file, followed by a newline.
If the global logfp is not None, it should be a file object to
which log data is written.
If the global logfp is None, the global logfile may be a string
giving a filename to open, in append mode. This file should be
world writable!!! If the file can't be opened, logging is
silently disabled (since there is no safe place where we could
send an error message).
"""
global
logfp
,
log
if
logfile
and
not
logfp
:
try
:
logfp
=
open
(
logfile
,
"a"
)
except
IOError
:
pass
if
not
logfp
:
log
=
nolog
else
:
log
=
dolog
apply
(
log
,
allargs
)
def
dolog
(
fmt
,
*
args
):
"""Write a log message to the log file. See initlog() for docs."""
logfp
.
write
(
fmt
%
args
+
"
\n
"
)
def
nolog
(
*
allargs
):
"""Dummy function, assigned to log when logging is disabled."""
pass
log
=
initlog
# The current logging function
# Parsing functions
# Parsing functions
# =================
# =================
...
...
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