Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #30109
| Path | csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!news2.arglkargh.de!news.musoftware.de!wum.musoftware.de!border1.nntp.ams2.giganews.com!border3.nntp.ams.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!xlned.com!feeder7.xlned.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <vincent.vandevyvre@swing.be> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.001 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'url:launchpad': 0.05; 'subject:How': 0.09; 'advice.': 0.09; 'logger': 0.09; 'def': 0.10; 'from:addr:swing.be': 0.16; 'from:addr:vincent.vandevyvre': 0.16; 'from:name:vincent vande vyvre': 0.16; 'message-id:@swing.be': 0.16; 'oqapy': 0.16; 'paqager': 0.16; 'received:mobistar.be': 0.16; 'subject:export': 0.16; 'url:oqapy': 0.16; 'url:paqager': 0.16; 'url:qarte': 0.16; 'v.v.': 0.16; 'app': 0.19; 'module': 0.19; 'import': 0.21; 'skip:% 10': 0.22; "i've": 0.23; 'tried': 0.25; 'header:User-Agent:1': 0.26; 'logging': 0.27; 'module.': 0.27; 'skip:_ 10': 0.29; 'class': 0.29; 'code': 0.31; 'to:addr :python-list': 0.33; 'thanks': 0.34; 'skip:l 30': 0.35; 'subject:?': 0.35; 'but': 0.36; 'anything': 0.36; 'level': 0.37; 'skip:l 20': 0.38; 'to:addr:python.org': 0.39; 'received:192': 0.39; 'application': 0.40; 'skip:" 10': 0.40; 'received:192.168': 0.40; 'your': 0.60; 'received:80.12': 0.65 |
| Date | Tue, 25 Sep 2012 18:15:32 +0200 |
| From | Vincent Vande Vyvre <vincent.vandevyvre@swing.be> |
| User-Agent | Mozilla/5.0 (X11; Linux i686; rv:15.0) Gecko/20120827 Thunderbird/15.0 |
| MIME-Version | 1.0 |
| To | Python mail-list <python-list@python.org> |
| Subject | How to export a logging level? |
| Content-Type | text/plain; charset=ISO-8859-1 |
| Content-Transfer-Encoding | 7bit |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.1356.1348590190.27098.python-list@python.org> (permalink) |
| Lines | 40 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1348590190 news.xs4all.nl 6844 [2001:888:2000:d::a6]:48730 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:30109 |
Show key headers only | View raw
In my application I import a module and I want to set the same logging
level
as the main app to this module.
I've tried this code
main.py
import logging
logger = logging.getLogger(__name__)
lvl = logging.DEBUG
LOG_FORMAT = "%(asctime)-6s %(levelname)s: %(name)s - %(message)s"
logging.basicConfig(format=LOG_FORMAT, datefmt='%H:%M:%S', level=lvl)
from mymodule.myfile import MyClass
...
def load_myclass(self):
lvl = logger.getEffectiveLevel()
mc = MyClass(self, lvl)
myfile.py
import logging
logger = logging.getLogger(__name__)
class MyClass(object):
def __init__(self, main, lvl):
logger.setLevel(lvl)
If I set the level to logging.DEBUG I can see all infos from the main
but anything
from my module.
Thanks for your advice.
--
Vincent V.V.
Oqapy <https://launchpad.net/oqapy> . Qarte
<https://launchpad.net/qarte> . PaQager <https://launchpad.net/paqager>
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
How to export a logging level? Vincent Vande Vyvre <vincent.vandevyvre@swing.be> - 2012-09-25 18:15 +0200
csiph-web