Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

Star Trek Lives!


devel / comp.lang.python / Re: Question about logging.config.dictConfig

SubjectAuthor
* Question about logging.config.dictConfigIvan \"Rambius\" Ivanov
`- Re: Question about logging.config.dictConfigStefan Ram

1
Question about logging.config.dictConfig

<mailman.1785.1675810721.20444.python-list@python.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=21620&group=comp.lang.python#21620

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!news.szaf.org!fu-berlin.de!uni-berlin.de!not-for-mail
From: rambiusp...@gmail.com (Ivan \"Rambius\" Ivanov)
Newsgroups: comp.lang.python
Subject: Question about logging.config.dictConfig
Date: Tue, 7 Feb 2023 17:58:26 -0500
Lines: 85
Message-ID: <mailman.1785.1675810721.20444.python-list@python.org>
References: <CAE9rwzMOXCEhsiqDnoGbzhLn1iM3P=PPsda9HrEgX2z_nqYTmA@mail.gmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
X-Trace: news.uni-berlin.de 1DAq/SsDl7uVo8gnsFYVdQLhGbDFTrZ7eiwn5YxjbhBQ==
Return-Path: <rambiusparkisanius@gmail.com>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=gmail.com header.i=@gmail.com header.b=ogAVL2o/;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.032
X-Spam-Evidence: '*H*': 0.94; '*S*': 0.00; 'def': 0.04; 'prints':
0.09; 'log': 0.12; 'import': 0.15; "'':": 0.16; "'default':":
0.16; 'main()': 0.16; 'nothing.': 0.16; 'received:209.85.217':
0.16; 'setup.': 0.16; 'python': 0.16; 'subject:Question': 0.19;
'to:addr:python-list': 0.20; 'run': 0.23; 'help.': 0.25;
'configure': 0.26; 'wrong': 0.28; 'default': 0.31; 'module': 0.31;
'wondering': 0.31; 'to:name:python': 0.32; 'message-
id:@mail.gmail.com': 0.32; 'but': 0.32; 'received:google.com':
0.34; 'trying': 0.35; 'from:addr:gmail.com': 0.35; "skip:' 10":
0.37; 'using': 0.37; 'received:209.85': 0.37; 'put': 0.38;
'received:209': 0.39; 'use': 0.39; 'hello,': 0.40; 'want': 0.40;
'try': 0.40; 'to:': 0.62; 'here': 0.62; 'similar': 0.65;
'details.': 0.76; 'out.': 0.80; 'mega': 0.84; 'url-ip:195/8': 0.84
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
h=to:subject:message-id:date:from:mime-version:from:to:cc:subject
:date:message-id:reply-to;
bh=59f8EzHnlkR6YwgvuScGJv8EVdYegQUfbHKlrMnP6d0=;
b=ogAVL2o/ye3v4AtUotr7tNaoyLQihj6XrAmD2q0ab6qaan4L6R2JtgU4iOXJZVwvXJ
K+cJ88nfYTgEZHu25Fi4kqwCtZAVgLT3Jntu4lXKM3oyrZ3WNml35zRkc8cXtELTb1wo
2jQ8miCbim1y0fO+Q3Wl0FP+Z7KHhzAryjyuEaYCSgdvUYLC+3TnlqJDEyXbNNTzYjvc
64DvBSY1uwAZ7pvsmR8w8t+xpb5NZ3JsQjYPFEeQ09cDn1qR0qRRFkEZo1K/P/cUunDV
Sacx+m7kyT71ZuEOTZZisJhWWULgEVVCsQdl9EOYB40e1SYBZHnKxilDE+Sgs8Su3c3Y
II2w==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20210112;
h=to:subject:message-id:date:from:mime-version:x-gm-message-state
:from:to:cc:subject:date:message-id:reply-to;
bh=59f8EzHnlkR6YwgvuScGJv8EVdYegQUfbHKlrMnP6d0=;
b=c+EkW5mZw1LCrvesl++VqQmqf+/eZlQN2GE1JXn/9boxQHCsK6Z5Xo+xlzDTChcPnr
7Y/dwHmsMvHS1SR7emwVkNwZBKHj0zg3mx1w+v1wOMRh2aNTr7urctKYRNYsDwohEszf
TOzDWUqcVtsgRxh28L1ur/BkUbq7LT8OBFp8h0QjelM6PEZPqUz2YNGqEKDbkQ412wev
cybZ6E02kLhHft1I2PRfHlkkb2xDFMyWM8trArMlDziIoLKfh5EdtPJHbDDO9VmjnncI
13/DvqFG85JByiTWpXgWGnaYJ0YvGLVMCpxK1FH8/GnBTgC81w1ttUK5o3SK4T7+jz5a
3Flw==
X-Gm-Message-State: AO0yUKXQoGqdm0Zoiqxzv0jDUZ0JqH08tWiQb0kN82FwrPBUbZ55af61
wJ89Ei09SerZQhRcJBbBz+HY6WdMGm64xCCNtUAigUrbwjs=
X-Google-Smtp-Source: AK7set+WzRMLFfy8nfYnp2QSgcd1qmc9DbBlcvnlpa8voEwDENswBsLuyTCwNGQ2t/lLzfhdm4NWSz+LfyI6QcS1Jnc=
X-Received: by 2002:a67:fbd0:0:b0:3fa:eea6:96f with SMTP id
o16-20020a67fbd0000000b003faeea6096fmr1037613vsr.22.1675810717876; Tue, 07
Feb 2023 14:58:37 -0800 (PST)
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://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: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <CAE9rwzMOXCEhsiqDnoGbzhLn1iM3P=PPsda9HrEgX2z_nqYTmA@mail.gmail.com>
 by: Ivan \Rambius\ Ivano - Tue, 7 Feb 2023 22:58 UTC

Hello,

I am trying to configure my loggers using dictConfig, but they do not
print anything. Here are more details.

I have several python scripts that use a similar logging setup. I put
the common configuration in a separate module myloggingconf.py:

# myloggingconf.py
import logging

def configure_logging():
default = logging.Formatter('%(asctime)s %(levelname)-7s %(name)s
%(funcName)s %(message)s')

consoleHandler = logging.StreamHandler()
consoleHandler.setFormatter(default)

rootLogger = logging.getLogger()
rootLogger.addHandler(consoleHandler)
rootLogger.setLevel(logging.INFO)

Then I use it in the other scripts as:

# uselog.py
import logging
import os

from myloggingconf import configure_logging

logger = logging.getLogger(os.path.basename(__file__))

def dosmth():
logger.debug("debug")
logger.info("info")
logger.warning("warning")
logger.error("error")

def main():
configure_logging()
dosmth()

if __name__ == '__main__':
main()

This works correctly and the log messages about INFO print out. Now I
want to try dictConfig. I changed myloggingconf.configure_logging to:

# myloggingconf.py
import logging.config

def configure_logging():
config = {
'version': 1,
'disable_existing_loggers': True,
'formatters': {
'default': {
'fmt': '%(asctime)s %(levelname)-7s %(name)s
%(funcName)s %(message)s'
}
},
'handlers': {
'stdout': {
'level': 'DEBUG',
'class': 'logging.StreamHandler',
'formatter': 'default',
}
},
'loggers': {
'': {
'handlers': ['stdout'],
'level': 'DEBUG'
}
}
}
logging.config.dictConfig(config)

When I run uselog.py it prints nothing. I am wondering what is wrong
with the second configuration. I will appreciate any help.

Regards
rambius

--
Tangra Mega Rock: http://www.radiotangra.com

Re: Question about logging.config.dictConfig

<logging-20230208002818@ram.dialup.fu-berlin.de>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=21622&group=comp.lang.python#21622

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: ram...@zedat.fu-berlin.de (Stefan Ram)
Newsgroups: comp.lang.python
Subject: Re: Question about logging.config.dictConfig
Date: 7 Feb 2023 23:29:26 GMT
Organization: Stefan Ram
Lines: 55
Expires: 1 Jan 2024 11:59:58 GMT
Message-ID: <logging-20230208002818@ram.dialup.fu-berlin.de>
References: <CAE9rwzMOXCEhsiqDnoGbzhLn1iM3P=PPsda9HrEgX2z_nqYTmA@mail.gmail.com> <mailman.1785.1675810721.20444.python-list@python.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Trace: news.uni-berlin.de OV4ALsuzs6mz9IAn/Grl/Q+txvwmN39pMCLNdbOo3lnTYn
X-Copyright: (C) Copyright 2023 Stefan Ram. All rights reserved.
Distribution through any means other than regular usenet
channels is forbidden. It is forbidden to publish this
article in the Web, to change URIs of this article into links,
and to transfer the body without this notice, but quotations
of parts in other Usenet posts are allowed.
X-No-Archive: Yes
Archive: no
X-No-Archive-Readme: "X-No-Archive" is set, because this prevents some
services to mirror the article in the web. But the article may
be kept on a Usenet archive server with only NNTP access.
X-No-Html: yes
Content-Language: en-US
Accept-Language: de-DE, en-US, it, fr-FR
 by: Stefan Ram - Tue, 7 Feb 2023 23:29 UTC

"Ivan \"Rambius\" Ivanov" <rambiusparkisanius@gmail.com> writes:
># uselog.py

I haven't really learned how to use logging yet, but made
this observation just by trial and error:

The following modified "uselog.py" prints nothing here:

# uselog.py
import logging
import os

from myloggingconf import configure_logging

def dosmth():
logger.debug("debug")
logger.info("info")
logger.warning("warning")
logger.error("error")

def main():
global logger
logger = logging.getLogger(os.path.basename(__file__))
configure_logging()
dosmth()

if __name__ == '__main__':
main()

, but when I swap two lines, it prints something:

# uselog.py
import logging
import os

from myloggingconf import configure_logging

def dosmth():
logger.debug("debug")
logger.info("info")
logger.warning("warning")
logger.error("error")

def main():
global logger
configure_logging()
logger = logging.getLogger(os.path.basename(__file__))
dosmth()

if __name__ == '__main__':
main()
.

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor