Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
Zope
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
Zope
Commits
bfe36e09
Commit
bfe36e09
authored
Nov 24, 2002
by
Chris McDonough
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removing unnecessary ZLogger module (superseded by zLOG support for PEP 282-based logging).
parent
898cd99a
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
0 additions
and
464 deletions
+0
-464
lib/python/ZLogger/FileLogger.py
lib/python/ZLogger/FileLogger.py
+0
-12
lib/python/ZLogger/ZLogger.py
lib/python/ZLogger/ZLogger.py
+0
-16
lib/python/ZLogger/__init__.py
lib/python/ZLogger/__init__.py
+0
-14
lib/python/ZLogger/stupidFileLogger.py
lib/python/ZLogger/stupidFileLogger.py
+0
-111
lib/python/ZLogger/syslog.py
lib/python/ZLogger/syslog.py
+0
-238
lib/python/ZLogger/syslogLogger.py
lib/python/ZLogger/syslogLogger.py
+0
-59
lib/python/ZLogger/test_logger.py
lib/python/ZLogger/test_logger.py
+0
-14
No files found.
lib/python/ZLogger/FileLogger.py
deleted
100644 → 0
View file @
898cd99a
class
FileLogger
:
""" a File Logger
This is just a stub, FileLogger should be smarter than
stupidFileLogger, but for the moment it's completely brain dead.
"""
def
__init__
(
self
):
pass
def
__call__
(
self
,
sub
,
sev
,
sum
,
det
,
err
):
print
'syslogger %s, %s, %s, %s, %s, %s'
%
(
self
,
sub
,
sev
,
sum
,
det
,
err
)
lib/python/ZLogger/ZLogger.py
deleted
100644 → 0
View file @
898cd99a
import
stupidFileLogger
import
syslogLogger
from
zLOG
import
*
loggers
=
(
stupidFileLogger
.
stupidFileLogger
(),
syslogLogger
.
syslogLogger
(),)
def
log_write
(
subsystem
,
severity
,
summary
,
detail
,
error
):
""" Hook into the logging system
The actual logic to determine what log messages go where will go
here. For now, everything goes to all loggers.
"""
for
logger
in
loggers
:
logger
(
subsystem
,
severity
,
summary
,
detail
,
error
)
lib/python/ZLogger/__init__.py
deleted
100644 → 0
View file @
898cd99a
##############################################################################
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
#
##############################################################################
import
ZLogger
lib/python/ZLogger/stupidFileLogger.py
deleted
100644 → 0
View file @
898cd99a
##############################################################################
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
#
##############################################################################
import
time
,
sys
,
os
,
thread
from
zLOG
import
severity_string
,
log_time
,
format_exception
_stupid_dest
=
None
_stupid_severity
=
None
_stupid_format
=
None
_no_stupid_log
=
[]
format_exception_only
=
None
class
stupidFileLogger
:
""" a stupid File Logger """
def
__call__
(
self
,
sub
,
sev
,
sum
,
det
,
err
):
stupid_log_write
(
sub
,
sev
,
sum
,
det
,
err
)
def
stupid_log_write
(
subsystem
,
severity
,
summary
,
detail
,
error
):
# Check where to log
global
_stupid_dest
,
_stupid_format
if
_stupid_dest
is
None
:
# EVENT_LOG_FILE is the preferred environment variable, but
# we accept STUPID_LOG_FILE as well
eget
=
os
.
environ
.
get
f
=
eget
(
'EVENT_LOG_FILE'
)
or
eget
(
'STUPID_LOG_FILE'
)
if
f
is
not
None
:
# if the envvar exists (might still be null)
if
f
:
_stupid_dest
=
open
(
f
,
'a'
)
else
:
_stupid_dest
=
sys
.
stderr
elif
eget
(
'Z_DEBUG_MODE'
):
_stupid_dest
=
sys
.
stderr
else
:
_stupid_dest
=
_no_stupid_log
# EVENT_LOG_FORMAT is the preferred environment variable, but
# we accept STUPID_LOG_FORMAT as well
fmt
=
eget
(
'EVENT_LOG_FORMAT'
)
or
eget
(
'STUPID_LOG_FORMAT'
)
if
fmt
is
not
None
:
_stupid_format
=
fmt
# Check id to log
if
_stupid_dest
is
_no_stupid_log
:
return
global
_stupid_severity
if
_stupid_severity
is
None
:
eget
=
os
.
environ
.
get
# EVENT_LOG_SEVERITY is the preferred environment variable, but
# we accept STUPID_LOG_SEVERITY as well
envvar
=
eget
(
'EVENT_LOG_SEVERITY'
)
or
eget
(
'STUPID_LOG_SEVERITY'
)
try
:
_stupid_severity
=
int
(
envvar
)
except
:
_stupid_severity
=
0
if
severity
<
_stupid_severity
:
return
if
_stupid_format
is
not
None
:
fmap
=
{
'time'
:
log_time
(),
'severity'
:
severity_string
(
severity
),
'subsystem'
:
subsystem
,
'summary'
:
summary
,
'detail'
:
detail
,
'thread'
:
thread
.
get_ident
()
}
try
:
s
=
_stupid_format
%
fmap
except
:
failedf
,
_stupid_format
=
_stupid_format
,
None
_stupid_dest
.
write
(
"------
\
n
%s %s zLOG Format string error
\
n
"
"The EVENT_LOG_FORMAT or STUPID_LOG_FORMAT"
"string '%s' caused an error, it wont be used."
%
(
fmap
[
'time'
],
severity_string
(
100
),
failedf
)
)
else
:
_stupid_dest
.
write
(
s
)
if
_stupid_format
is
None
:
_stupid_dest
.
write
(
"------
\
n
"
"%s %s %s %s
\
n
%s"
%
(
log_time
(),
severity_string
(
severity
),
subsystem
,
summary
,
detail
,
)
)
_stupid_dest
.
flush
()
if
error
:
try
:
_stupid_dest
.
write
(
''
.
join
(
format_exception
(
error
[
0
],
error
[
1
],
error
[
2
],
limit
=
100
)))
except
:
_stupid_dest
.
write
(
"%s: %s
\
n
"
%
error
[:
2
])
_stupid_dest
.
flush
()
lib/python/ZLogger/syslog.py
deleted
100644 → 0
View file @
898cd99a
# -*- Mode: Python; tab-width: 4 -*-
# From: "Samual M. Rushing" <rushing@nightmare.com>
# Date: Mon, 21 Apr 1997 16:10:42 -0500
# ======================================================================
# Copyright 1997 by Sam Rushing
#
# All Rights Reserved
#
# Permission to use, copy, modify, and distribute this software and
# its documentation for any purpose and without fee is hereby
# granted, provided that the above copyright notice appear in all
# copies and that both that copyright notice and this permission
# notice appear in supporting documentation, and that the name of Sam
# Rushing not be used in advertising or publicity pertaining to
# distribution of the software without specific, written prior
# permission.
#
# SAM RUSHING DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
# INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
# NO EVENT SHALL SAM RUSHING BE LIABLE FOR ANY SPECIAL, INDIRECT OR
# CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
# OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
# CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
# ======================================================================
"""socket interface to unix syslog.
On Unix, there are usually two ways of getting to syslog: via a
local unix-domain socket, or via the TCP service.
Usually "/dev/log" is the unix domain socket. This may be different
for other systems.
>>> my_client = syslog_client ('/dev/log')
Otherwise, just use the UDP version, port 514.
>>> my_client = syslog_client (('my_log_host', 514))
On win32, you will have to use the UDP version. Note that
you can use this to log to other hosts (and indeed, multiple
hosts).
This module is not a drop-in replacement for the python
<syslog> extension module - the interface is different.
Usage:
>>> c = syslog_client()
>>> c = syslog_client ('/strange/non_standard_log_location')
>>> c = syslog_client (('other_host.com', 514))
>>> c.log ('testing', facility='local0', priority='debug')
"""
# TODO: support named-pipe syslog.
# [see ftp://sunsite.unc.edu/pub/Linux/system/Daemons/syslog-fifo.tar.z]
# from <linux/sys/syslog.h>:
# ===========================================================================
# priorities/facilities are encoded into a single 32-bit quantity, where the
# bottom 3 bits are the priority (0-7) and the top 28 bits are the facility
# (0-big number). Both the priorities and the facilities map roughly
# one-to-one to strings in the syslogd(8) source code. This mapping is
# included in this file.
#
# priorities (these are ordered)
LOG_EMERG
=
0
# system is unusable
LOG_ALERT
=
1
# action must be taken immediately
LOG_CRIT
=
2
# critical conditions
LOG_ERR
=
3
# error conditions
LOG_WARNING
=
4
# warning conditions
LOG_NOTICE
=
5
# normal but significant condition
LOG_INFO
=
6
# informational
LOG_DEBUG
=
7
# debug-level messages
# facility codes
LOG_KERN
=
0
# kernel messages
LOG_USER
=
1
# random user-level messages
LOG_MAIL
=
2
# mail system
LOG_DAEMON
=
3
# system daemons
LOG_AUTH
=
4
# security/authorization messages
LOG_SYSLOG
=
5
# messages generated internally by syslogd
LOG_LPR
=
6
# line printer subsystem
LOG_NEWS
=
7
# network news subsystem
LOG_UUCP
=
8
# UUCP subsystem
LOG_CRON
=
9
# clock daemon
LOG_AUTHPRIV
=
10
# security/authorization messages (private)
# other codes through 15 reserved for system use
LOG_LOCAL0
=
16
# reserved for local use
LOG_LOCAL1
=
17
# reserved for local use
LOG_LOCAL2
=
18
# reserved for local use
LOG_LOCAL3
=
19
# reserved for local use
LOG_LOCAL4
=
20
# reserved for local use
LOG_LOCAL5
=
21
# reserved for local use
LOG_LOCAL6
=
22
# reserved for local use
LOG_LOCAL7
=
23
# reserved for local use
priority_names
=
{
"alert"
:
LOG_ALERT
,
"crit"
:
LOG_CRIT
,
"debug"
:
LOG_DEBUG
,
"emerg"
:
LOG_EMERG
,
"err"
:
LOG_ERR
,
"error"
:
LOG_ERR
,
# DEPRECATED
"info"
:
LOG_INFO
,
"notice"
:
LOG_NOTICE
,
"panic"
:
LOG_EMERG
,
# DEPRECATED
"warn"
:
LOG_WARNING
,
# DEPRECATED
"warning"
:
LOG_WARNING
,
}
facility_names
=
{
"auth"
:
LOG_AUTH
,
"authpriv"
:
LOG_AUTHPRIV
,
"cron"
:
LOG_CRON
,
"daemon"
:
LOG_DAEMON
,
"kern"
:
LOG_KERN
,
"lpr"
:
LOG_LPR
,
"mail"
:
LOG_MAIL
,
"news"
:
LOG_NEWS
,
"security"
:
LOG_AUTH
,
# DEPRECATED
"syslog"
:
LOG_SYSLOG
,
"user"
:
LOG_USER
,
"uucp"
:
LOG_UUCP
,
"local0"
:
LOG_LOCAL0
,
"local1"
:
LOG_LOCAL1
,
"local2"
:
LOG_LOCAL2
,
"local3"
:
LOG_LOCAL3
,
"local4"
:
LOG_LOCAL4
,
"local5"
:
LOG_LOCAL5
,
"local6"
:
LOG_LOCAL6
,
"local7"
:
LOG_LOCAL7
,
}
import
socket
class
syslog_client
:
def
__init__
(
self
,
address
=
'/dev/log'
):
self
.
address
=
address
if
type
(
address
)
==
type
(
''
):
try
:
# APUE 13.4.2 specifes /dev/log as datagram socket
self
.
socket
=
socket
.
socket
(
socket
.
AF_UNIX
,
socket
.
SOCK_DGRAM
)
self
.
socket
.
connect
(
address
)
except
:
# older linux may create as stream socket
self
.
socket
=
socket
.
socket
(
socket
.
AF_UNIX
,
socket
.
SOCK_STREAM
)
self
.
socket
.
connect
(
address
)
self
.
unix
=
1
else
:
self
.
socket
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_DGRAM
)
self
.
unix
=
0
# curious: when talking to the unix-domain '/dev/log' socket, a
# zero-terminator seems to be required. this string is placed
# into a class variable so that it can be overridden if
# necessary.
log_format_string
=
'<%d>%s
\
000
'
def
log
(
self
,
message
,
facility
=
LOG_USER
,
priority
=
LOG_INFO
):
message
=
self
.
log_format_string
%
(
self
.
encode_priority
(
facility
,
priority
),
message
)
if
self
.
unix
:
self
.
socket
.
send
(
message
)
else
:
self
.
socket
.
sendto
(
message
,
self
.
address
)
def
encode_priority
(
self
,
facility
,
priority
):
if
type
(
facility
)
==
type
(
''
):
facility
=
facility_names
[
facility
]
if
type
(
priority
)
==
type
(
''
):
priority
=
priority_names
[
priority
]
return
(
facility
<<
3
)
|
priority
def
close
(
self
):
if
self
.
unix
:
self
.
socket
.
close
()
if
__name__
==
'__main__'
:
"""
Unit test for syslog_client. Set up for the test by:
* tail -f /var/log/allstuf (to see the "normal" log messages).
* Running the test_logger.py script with a junk file name (which
will be opened as a Unix-domain socket). "Custom" log messages
will go here.
* Run this script, passing the same junk file name.
* Check that the "bogus" test throws, and that none of the rest do.
* Check that the 'default' and 'UDP' messages show up in the tail.
* Check that the 'non-std' message shows up in the test_logger
console.
* Finally, kill off the tail and test_logger, and clean up the
socket file.
"""
import
sys
,
traceback
if
len
(
sys
.
argv
)
!=
2
:
print
"Usage: syslog.py localSocketFilename"
sys
.
exit
()
def
test_client
(
desc
,
address
=
None
):
try
:
if
address
:
client
=
syslog_client
(
address
)
else
:
client
=
syslog_client
()
except
:
print
'syslog_client() [%s] ctor threw'
%
desc
traceback
.
print_exc
()
return
try
:
client
.
log
(
'testing syslog_client() [%s]'
%
desc
,
facility
=
'local0'
,
priority
=
'debug'
)
print
'syslog_client.log() [%s] did not throw'
%
desc
except
:
print
'syslog_client.log() [%s] threw'
%
desc
traceback
.
print_exc
()
test_client
(
'default'
)
test_client
(
'bogus file'
,
'/some/bogus/logsocket'
)
test_client
(
'nonstd file'
,
sys
.
argv
[
1
]
)
test_client
(
'UDP'
,
(
'localhost'
,
514
)
)
lib/python/ZLogger/syslogLogger.py
deleted
100644 → 0
View file @
898cd99a
##############################################################################
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
#
##############################################################################
from
syslog
import
syslog_client
,
LOG_ALERT
,
LOG_ERR
,
LOG_WARNING
,
LOG_NOTICE
from
syslog
import
LOG_INFO
,
LOG_DEBUG
import
os
,
traceback
pid_str
=
'[%s]: '
%
os
.
getpid
()
class
syslogLogger
:
""" a syslog Logger """
def
__init__
(
self
):
if
os
.
environ
.
has_key
(
'ZSYSLOG_SERVER'
):
(
addr
,
port
)
=
os
.
environ
[
'ZSYSLOG_SERVER'
].
split
(
':'
)
self
.
client
=
syslog_client
((
addr
,
int
(
port
)))
self
.
on
=
1
elif
os
.
environ
.
has_key
(
'ZSYSLOG'
):
self
.
client
=
syslog_client
(
os
.
environ
[
'ZSYSLOG'
])
self
.
on
=
1
else
:
self
.
on
=
0
def
__call__
(
self
,
sub
,
sev
,
sum
,
det
,
err
):
if
sev
>=
0
:
if
sev
>=
200
:
if
sev
>=
300
:
sev
=
LOG_ALERT
else
:
sev
=
LOG_ERR
else
:
if
sev
>=
100
:
sev
=
LOG_WARNING
else
:
sev
=
LOG_NOTICE
else
:
if
sev
>=
-
100
:
sev
=
LOG_INFO
else
:
sev
=
LOG_DEBUG
if
err
:
try
:
sum
=
sum
+
' : '
+
traceback
.
format_exception_only
(
err
[
0
],
err
[
1
]
)[
0
]
except
:
pass
if
self
.
on
:
self
.
client
.
log
(
sub
+
pid_str
+
sum
,
priority
=
sev
)
lib/python/ZLogger/test_logger.py
deleted
100644 → 0
View file @
898cd99a
import
sys
import
socket
import
select
print
"Simulating Unix-domain logging using file: %s"
%
sys
.
argv
[
1
]
log_socket
=
socket
.
socket
(
socket
.
AF_UNIX
,
socket
.
SOCK_DGRAM
)
log_socket
.
bind
(
sys
.
argv
[
1
]
)
while
1
:
n
=
select
.
select
(
[
log_socket
],
[],
[]
)
print
"."
,
if
n
>
0
:
print
log_socket
.
recv
(
1024
)
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