Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
ZODB
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
Nicolas Wavrant
ZODB
Commits
df73acc6
Commit
df73acc6
authored
Jan 16, 2003
by
Fred Drake
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- move the datatype for logging levels into the zLOG schema component
- add at least something of a test for the datatype
parent
0b0b84d2
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
7 deletions
+41
-7
src/zLOG/component.xml
src/zLOG/component.xml
+7
-7
src/zLOG/datatypes.py
src/zLOG/datatypes.py
+20
-0
src/zLOG/tests/testzLogConfig.py
src/zLOG/tests/testzLogConfig.py
+14
-0
No files found.
src/zLOG/component.xml
View file @
df73acc6
...
...
@@ -8,7 +8,7 @@
<key
name=
"format"
default=
"------\n%(asctime)s %(message)s"
datatype=
".log_format"
/>
<key
name=
"dateformat"
default=
"%Y-%m-%dT%H:%M:%S"
/>
<key
name=
"level"
default=
"info"
datatype=
"
logging-
level"
/>
<key
name=
"level"
default=
"info"
datatype=
"
.logging_
level"
/>
</sectiontype>
<sectiontype
name=
"syslog-handler"
datatype=
".syslog_handler"
...
...
@@ -18,7 +18,7 @@
<key
name=
"format"
default=
"%(message)s"
datatype=
".log_format"
/>
<key
name=
"dateformat"
default=
"%Y-%m-%dT%H:%M:%S"
/>
<key
name=
"level"
default=
"info"
datatype=
"
logging-
level"
/>
<key
name=
"level"
default=
"info"
datatype=
"
.logging_
level"
/>
</sectiontype>
<!--
...
...
@@ -28,7 +28,7 @@
<key name="format" default="%(message)s"
datatype=".log_format"/>
<key name="dateformat" default="%Y-%m-%dT%H:%M:%S"/>
<key name="level" default="info" datatype="
logging-
level"/>
<key name="level" default="info" datatype="
.logging_
level"/>
</sectiontype>
<sectiontype name="http_handler" datatype=".http_handler"
...
...
@@ -38,7 +38,7 @@
<key name="format" default="%(asctime)s %(message)s"
datatype=".log_format"/>
<key name="dateformat" default="%Y-%m-%dT%H:%M:%S"/>
<key name="level" default="info" datatype="
logging-
level"/>
<key name="level" default="info" datatype="
.logging_
level"/>
</sectiontype>
<sectiontype name="smtp_handler" datatype=".smtp_handler"
...
...
@@ -50,7 +50,7 @@
<key name="format" default="%(asctime)s %(message)s"
datatype=".log_format"/>
<key name="dateformat" default="%Y-%m-%dT%H:%M:%S"/>
<key name="level" default="info" datatype="
logging-
level"/>
<key name="level" default="info" datatype="
.logging_
level"/>
</sectiontype>
<sectiontype name="null_handler" datatype=".null_handler"
...
...
@@ -61,12 +61,12 @@
<key name="constructor" datatype="constructor" required="yes"/>
<key name="formatter" datatype="constructor"
default="logging.Formatter()"/>
<key name="level" default="info" datatype="
logging-
level"/>
<key name="level" default="info" datatype="
.logging_
level"/>
</sectiontype>
-->
<sectiontype
name=
"logger"
datatype=
".logger"
>
<key
name=
"level"
datatype=
"
logging-
level"
default=
"info"
/>
<key
name=
"level"
datatype=
"
.logging_
level"
default=
"info"
/>
<multisection
type=
"loghandler"
attribute=
"handlers"
name=
"*"
/>
</sectiontype>
...
...
src/zLOG/datatypes.py
View file @
df73acc6
...
...
@@ -20,6 +20,26 @@ from zLOG.factory import Factory
# log-related datatypes
_logging_levels
=
{
"critical"
:
50
,
"fatal"
:
50
,
"error"
:
40
,
"warn"
:
30
,
"info"
:
20
,
"debug"
:
10
,
"all"
:
0
,
}
def
logging_level
(
value
):
s
=
str
(
value
).
lower
()
if
_logging_levels
.
has_key
(
s
):
return
_logging_levels
[
s
]
else
:
v
=
int
(
s
)
if
v
<
0
or
v
>
50
:
raise
ValueError
(
"log level not in range: "
+
`v`
)
return
v
_log_format_variables
=
{
'name'
:
''
,
'levelno'
:
'3'
,
...
...
src/zLOG/tests/testzLogConfig.py
View file @
df73acc6
...
...
@@ -19,6 +19,7 @@ import logging
import
unittest
import
ZConfig
import
zLOG.datatypes
import
zLOG.LogHandlers
import
zLOG.tests
...
...
@@ -45,6 +46,19 @@ class TestzLOGConfig(unittest.TestCase):
self
.
assert_
(
not
handler
)
return
conf
def
test_logging_level
(
self
):
# Make sure the expected names are supported; it's not clear
# how to check the values in a meaningful way.
convert
=
zLOG
.
datatypes
.
logging_level
convert
(
"all"
)
convert
(
"debug"
)
convert
(
"info"
)
convert
(
"warn"
)
convert
(
"error"
)
convert
(
"fatal"
)
convert
(
"critical"
)
self
.
assertRaises
(
ValueError
,
convert
,
"hopefully-not-a-valid-value"
)
def
test_config_without_logger
(
self
):
conf
=
self
.
get_config
(
""
)
self
.
assert_
(
conf
.
logger
is
None
)
...
...
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