summaryrefslogtreecommitdiff
path: root/python/qpid/log.py
diff options
context:
space:
mode:
authorRafael H. Schloming <rhs@apache.org>2008-03-11 14:29:17 +0000
committerRafael H. Schloming <rhs@apache.org>2008-03-11 14:29:17 +0000
commit5c70b29392ab7f7252d7923d98616794f6200eab (patch)
tree23caf5119ab5bc73530d4d3747ca56ce16838de4 /python/qpid/log.py
parentd38d509af075300441ad858b1bb7680ac6b8e5ca (diff)
downloadqpid-python-5c70b29392ab7f7252d7923d98616794f6200eab.tar.gz
added convenience API for turning on logging; added logging for controls and commands; made logging prettier
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@635939 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'python/qpid/log.py')
-rw-r--r--python/qpid/log.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/python/qpid/log.py b/python/qpid/log.py
new file mode 100644
index 0000000000..1fd7d74136
--- /dev/null
+++ b/python/qpid/log.py
@@ -0,0 +1,28 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+from logging import getLogger, StreamHandler, Formatter
+from logging import DEBUG, INFO, WARN, ERROR, CRITICAL
+
+def enable(name=None, level=WARN, file=None):
+ log = getLogger(name)
+ handler = StreamHandler(file)
+ handler.setFormatter(Formatter("%(asctime)s %(levelname)s %(message)s"))
+ log.addHandler(handler)
+ log.setLevel(level)