Python logging (was Re: What should go to stdout/stderr and why Python logging write everything to stderr?)

2023-01-06 Thread Weatherby,Gerard
FWIW, it wasn’t too difficult to build a logging handler to send messages to Slack. https://pypi.org/project/slack-webclient-logger/ -- https://mail.python.org/mailman/listinfo/python-list

Re: What should go to stdout/stderr and why Python logging write everything to stderr?

2023-01-06 Thread Peter J. Holzer
On 2023-01-05 12:29:33 -0800, Grant Edwards wrote: > On 2023-01-05, Thomas Passin wrote: > > > The logging system is so configurable that... > > I find it almost impossible to use unless I copy a working example I > find somewhere. ;) I usually copy the working example fro

Re: asyncio and tkinter (was: What should go to stdout/stderr and why Python logging write everything to stderr?)

2023-01-05 Thread Thomas Passin
import logging import tkinter # This program was tested on Windows, it is experimental. # It should open a tkinter root window. # Ctrl-E should create a task. You should be able to create # a new task even while one task is already running. # Each task will end after about 10 seconds. # Ctrl-X should

Re: What should go to stdout/stderr and why Python logging write everything to stderr?

2023-01-05 Thread Thomas Passin
On 1/5/2023 4:24 PM, Stefan Ram wrote: You often can replace threads in tkinter by coroutines using asyncio when you write a replacement for the mainloop of tkinter that uses asyncio. Now, try to read only the official documentation of asyncio and tkinter and figure out only from

Re: What should go to stdout/stderr and why Python logging write everything to stderr?

2023-01-05 Thread Thomas Passin
On 1/5/2023 4:28 PM, Weatherby,Gerard wrote: logging.basicConfig() logging.info(“Nice to know”) logging.debug(“Details for when things are funky”) logging.warn(“Trouble is brewing”) Not quite - >>> import logging >>> logging.basicConfig() >>> logging.info("

Re: What should go to stdout/stderr and why Python logging write everything to stderr?

2023-01-05 Thread Grant Edwards
a log level on the command line. * Allow logging to a file as specified on the command line. * Optional timestamps for log messages. I know, without doubt, that it can easily do all those things. I just never seem to be able to figure out how unless I can find example code to look at. -- Gran

Re: What should go to stdout/stderr and why Python logging write everything to stderr?

2023-01-05 Thread Weatherby,Gerard
/stderr and why Python logging write everything to stderr? *** Attention: This is an external email. Use caution responding, opening attachments or clicking on links. *** On 2023-01-05, Thomas Passin wrote: > The logging system is so configurable that... I find it almost impossible to use unles

Re: What should go to stdout/stderr and why Python logging write everything to stderr?

2023-01-05 Thread Thomas Passin
On 1/5/2023 3:29 PM, Grant Edwards wrote: On 2023-01-05, Thomas Passin wrote: The logging system is so configurable that... I find it almost impossible to use unless I copy a working example I find somewhere. ;) I'm not at all surprised that the OP didn't understand how it works. I've been

Re: What should go to stdout/stderr and why Python logging write everything to stderr?

2023-01-05 Thread Grant Edwards
On 2023-01-05, Thomas Passin wrote: > The logging system is so configurable that... I find it almost impossible to use unless I copy a working example I find somewhere. ;) I'm not at all surprised that the OP didn't understand how it works. I've been writing Python programs for over 20 ye

Re: What should go to stdout/stderr and why Python logging write everything to stderr?

2023-01-05 Thread Thomas Passin
On 1/5/2023 2:18 PM, Peter J. Holzer wrote: On 2023-01-05 08:31:40 -0500, Thomas Passin wrote: The logging system is so configurable that a user could set a different destination for each level of logging. So it seems that the O.P.'s original question about why the package's developers choose

Re: What should go to stdout/stderr and why Python logging write everything to stderr?

2023-01-05 Thread Peter J. Holzer
On 2023-01-05 08:31:40 -0500, Thomas Passin wrote: > The logging system is so configurable that a user could set a different > destination for each level of logging. So it seems that the O.P.'s original > question about why the package's developers choose stderr for all levels can >

Re: What should go to stdout/stderr and why Python logging write everything to stderr?

2023-01-05 Thread Thomas Passin
On 1/5/2023 6:27 AM, Peter J. Holzer wrote: On 2023-01-04 12:32:40 -0500, Thomas Passin wrote: On 1/3/2023 10:35 AM, c.bu...@posteo.jp wrote: The logging module write everything to stderr no matter which logging level is used. The OP wrote this, but it's not so by default. By default

Re: What should go to stdout/stderr and why Python logging write everything to stderr?

2023-01-05 Thread Peter J. Holzer
On 2023-01-04 12:32:40 -0500, Thomas Passin wrote: > On 1/3/2023 10:35 AM, c.bu...@posteo.jp wrote: > > The logging module write everything to stderr no matter which logging > > level is used. > > The OP wrote this, but it's not so by default. By default it is - sort

Re: What should go to stdout/stderr and why Python logging write everything to stderr?

2023-01-04 Thread Chris Angelico
this the "usual applicaton output"? > > > > If not, what messages should go into logging.info()? Can you name me > > some examples? > > Example: > > write an app that prints the contents of a file. > > The application output is the contents of the file

Re: What should go to stdout/stderr and why Python logging write everything to stderr?

2023-01-04 Thread Barry Scott
ite an app that prints the contents of a file. The application output is the contents of the file. The logging might be this when all is working: INFO About to open INFO Wrote bytes from The logging might be this when there is a problem: INFO About to open ERROR Failed to open - Does that he

Re: What should go to stdout/stderr and why Python logging write everything to stderr?

2023-01-04 Thread Barry Scott
e designer of an application, to decide how it works. You will take into account conventions that your users will expect you to follow. If the logging module helps you then use it, but you are not forced by logging to design your app is a particular way. The default behavior of the loggi

Re: What should go to stdout/stderr and why Python logging write everything to stderr?

2023-01-04 Thread Thomas Passin
On 1/3/2023 10:35 AM, c.bu...@posteo.jp wrote: The logging module write everything to stderr no matter which logging level is used. The OP wrote this, but it's not so by default. There is a HOW-TO page that explains this and how to get the logging package to log everything to a file, along

Re: What should go to stdout/stderr and why Python logging write everything to stderr?

2023-01-04 Thread Peter J. Holzer
On 2023-01-03 21:24:20 +, c.bu...@posteo.jp wrote: > The main question here is why does Python deciecded to make all logs go to > stderr? It doesn't. The Python logging system provides a plethora of handlers to log to lots of different places. Only the StreamHandler defaults to w

Re: What should go to stdout/stderr and why Python logging write everything to stderr?

2023-01-04 Thread Peter J. Holzer
On 2023-01-04 16:46:37 +1100, Chris Angelico wrote: > On Wed, 4 Jan 2023 at 15:11, Eryk Sun wrote: > > On 1/3/23, Chris Angelico wrote: > > > writing the FD is the same as using stdout > > > > Except stdout may be buffered. Maybe I'm overly lax in my terminology, but I frequently use the term

Re: What should go to stdout/stderr and why Python logging write everything to stderr?

2023-01-04 Thread Barry Scott
On 04/01/2023 06:46, Chris Angelico wrote: I've known some systems to have a trigger of "reading on FD 0 flushes FD 1" C++ has this feature: Quote from https://en.cppreference.com/w/cpp/io/cin "Once |std::cin| is constructed, std::cin.tie() returns ::cout

Re: What should go to stdout/stderr and why Python logging write everything to stderr?

2023-01-04 Thread Barry Scott
On 04/01/2023 02:26, Chris Angelico wrote: Reading/writing the FD is the same as using stdout (technically you'd write to fd 1 and read from fd 0), but yes, can use /dev/tty to reach for the console directly. I think the logic is more like checking that stdin is a tty then using the tty it

Re: What should go to stdout/stderr and why Python logging write everything to stderr?

2023-01-04 Thread 2QdxY4RzWzUUiLuE
On 2023-01-04 at 12:02:55 +, "Weatherby,Gerard" wrote: > Dealing with stdout / stderr is bash is just syntax. I don’t always > remember it off the top of my head but … stackoverflow.com. https://tldp.org/LDP/abs/html/io-redirection.html > On Linux at least it’s possible to pipe to

Re: What should go to stdout/stderr and why Python logging write everything to stderr?

2023-01-04 Thread Weatherby,Gerard
nuary 3, 2023 at 5:18 PM To: python-list@python.org Subject: Re: What should go to stdout/stderr and why Python logging write everything to stderr? *** Attention: This is an external email. Use caution responding, opening attachments or clicking on links. *** Maybe some day an interface and

Re: What should go to stdout/stderr and why Python logging write everything to stderr?

2023-01-03 Thread Chris Angelico
On Wed, 4 Jan 2023 at 17:26, Eryk Sun wrote: > > On 1/3/23, Chris Angelico wrote: > > > > FDs can also be buffered. If it's buffering you want to avoid, don't > > mess around with exactly which one you're writing to, just flush. > > I meant to flush a C FILE stream or Python file before writing

Re: What should go to stdout/stderr and why Python logging write everything to stderr?

2023-01-03 Thread Eryk Sun
On 1/3/23, Chris Angelico wrote: > > FDs can also be buffered. If it's buffering you want to avoid, don't > mess around with exactly which one you're writing to, just flush. I meant to flush a C FILE stream or Python file before writing directly to the file descriptor, in order to avoid

Re: What should go to stdout/stderr and why Python logging write everything to stderr?

2023-01-03 Thread Eryk Sun
On 1/3/23, Grant Edwards wrote: > > That's definitely a better option, but I'm pretty sure I've seen > multiple examples over the decades where fd 0 was used instead. Was > /dev/tty a "recent" enough invention that I would have seen > application code that was written before it existed? Or maybe

Re: What should go to stdout/stderr and why Python logging write everything to stderr?

2023-01-03 Thread Chris Angelico
On Wed, 4 Jan 2023 at 16:21, Grant Edwards wrote: > > On 2023-01-04, Chris Angelico wrote: > > On Wed, 4 Jan 2023 at 09:52, Grant Edwards > > wrote: > >> > >>> I can't think of a specific example, but I know I have piped the output > >>> of a program while at the same time interacting with a

Re: What should go to stdout/stderr and why Python logging write everything to stderr?

2023-01-03 Thread Chris Angelico
On Wed, 4 Jan 2023 at 15:11, Eryk Sun wrote: > > On 1/3/23, Chris Angelico wrote: > > > > writing the FD is the same as using stdout > > Except stdout may be buffered. One should probably flush the buffer > before each raw write to the file descriptor. FDs can also be buffered. If it's

Re: What should go to stdout/stderr and why Python logging write everything to stderr?

2023-01-03 Thread Grant Edwards
On 2023-01-04, Chris Angelico wrote: > On Wed, 4 Jan 2023 at 09:52, Grant Edwards wrote: >> >>> I can't think of a specific example, but I know I have piped the output >>> of a program while at the same time interacting with a prompt on stderr. >>> A rare thing, though. >> >> Programs that ask

Re: What should go to stdout/stderr and why Python logging write everything to stderr?

2023-01-03 Thread Eryk Sun
On 1/3/23, Chris Angelico wrote: > > writing the FD is the same as using stdout Except stdout may be buffered. One should probably flush the buffer before each raw write to the file descriptor. > use /dev/tty to reach for the console directly. On Windows, open "CON" (read or write), "CONIN$"

Re: What should go to stdout/stderr and why Python logging write everything to stderr?

2023-01-03 Thread Chris Angelico
On Wed, 4 Jan 2023 at 10:28, Stefan Ram wrote: > > c.bu...@posteo.jp writes: > >But I don't want to make all log levels go to stdout. Just DEBUG and > >INFO. > > The following was stripped down from something some guy > posted on a web site, maybe it was "rkachach". Yet another shining

Re: What should go to stdout/stderr and why Python logging write everything to stderr?

2023-01-03 Thread Chris Angelico
On Wed, 4 Jan 2023 at 09:52, Grant Edwards wrote: > > On 2023-01-03, Michael Torrie wrote: > > On 1/3/23 11:45, Keith Thompson wrote: > >> MRAB writes: > >> [...] > >>> The purpose of stderr is to display status messages, logging and error > >

Re: What should go to stdout/stderr and why Python logging write everything to stderr?

2023-01-03 Thread Grant Edwards
On 2023-01-03, Michael Torrie wrote: > On 1/3/23 11:45, Keith Thompson wrote: >> MRAB writes: >> [...] >>> The purpose of stderr is to display status messages, logging and error >>> messages, even user prompts, and not mess up the program's actual >>>

Re: What should go to stdout/stderr and why Python logging write everything to stderr?

2023-01-03 Thread Chris Angelico
On Wed, 4 Jan 2023 at 09:17, Michael Torrie wrote: > > On 1/3/23 11:45, Keith Thompson wrote: > > MRAB writes: > > [...] > >> The purpose of stderr is to display status messages, logging and error > >> messages, even user prompts, and not mess

Re: What should go to stdout/stderr and why Python logging write everything to stderr?

2023-01-03 Thread 2QdxY4RzWzUUiLuE
On 2023-01-03 at 21:24:20 +, c.bu...@posteo.jp wrote: > The main question here is why does Python deciecded to make all logs > go to stderr? It makes sense to send all logging to one destination, and stderr is that place. > Maybe I totally misunderstood the intention of log

Re: What should go to stdout/stderr and why Python logging write everything to stderr?

2023-01-03 Thread Michael Torrie
On 1/3/23 11:45, Keith Thompson wrote: > MRAB writes: > [...] >> The purpose of stderr is to display status messages, logging and error >> messages, even user prompts, and not mess up the program's actual >> output. This is important on a *nix system where you might

Re: What should go to stdout/stderr and why Python logging write everything to stderr?

2023-01-03 Thread Chris Angelico
On Wed, 4 Jan 2023 at 08:25, wrote: > > Am 03.01.2023 17:51 schrieb r...@zedat.fu-berlin.de: > > logging.getLogger().addHandler( logging.StreamHandler( sys.stdout )) > > But I don't want to make all log levels go to stdout. Just DEBUG and > INFO. But this would be a workaround. But why are DEBUG

Re: What should go to stdout/stderr and why Python logging write everything to stderr?

2023-01-03 Thread Cameron Simpson
On Jan 3, 2023, at 10:38 AM, c.bu...@posteo.jp wrote: this posting isn't about asking for a technical solution. My intention is to understand the design decision Python's core developers made in context of that topic. The logging module write everything to stderr no matter which logging level

Re: What should go to stdout/stderr and why Python logging write everything to stderr?

2023-01-03 Thread c . buhtz
Am 03.01.2023 17:51 schrieb r...@zedat.fu-berlin.de: logging.getLogger().addHandler( logging.StreamHandler( sys.stdout )) But I don't want to make all log levels go to stdout. Just DEBUG and INFO. But this would be a workaround. The main question here is why does Python deciecded to make

Re: What should go to stdout/stderr and why Python logging write everything to stderr?

2023-01-03 Thread Eryk Sun
On 1/3/23, Weatherby,Gerard wrote: > If sys.stdout is a tty, it typically flushes on newline. e. g. Sorry if I wasn't clear. Yes, a tty file will be buffered, but it's line buffering, which isn't an issue as long as lines are written to stdout. I was referring to full buffering of pipe and disk

Re: What should go to stdout/stderr and why Python logging write everything to stderr?

2023-01-03 Thread Weatherby,Gerard
s From: Python-list on behalf of Eryk Sun Date: Tuesday, January 3, 2023 at 1:33 PM To: c.bu...@posteo.jp Cc: python-list@python.org Subject: Re: What should go to stdout/stderr and why Python logging write everything to stderr? *** Attention: This is an external email. Use caution responding,

Re: What should go to stdout/stderr and why Python logging write everything to stderr?

2023-01-03 Thread Thomas Passin
On 1/3/2023 11:51 AM, Stefan Ram wrote: Thomas Passin writes: On 1/3/2023 10:35 AM, c.bu...@posteo.jp wrote: Also, I think it would be confusing to sometimes have logging output go to stdout and other times go to stderr. In UNIX, the output of a program can be redirected, so error

Re: What should go to stdout/stderr and why Python logging write everything to stderr?

2023-01-03 Thread Keith Thompson
MRAB writes: [...] > The purpose of stderr is to display status messages, logging and error > messages, even user prompts, and not mess up the program's actual > output. This is important on a *nix system where you might be piping > the output of one program into the input of anoth

Re: What should go to stdout/stderr and why Python logging write everything to stderr?

2023-01-03 Thread Eryk Sun
and only written to the OS file when the buffer fills up or is manually flushed. > Why does logging behave different? DEBUG and INFO imho should go to > stdout not stderr. The standard file for error messages and other diagnostic information is sys.stderr. This file should never

Re: What should go to stdout/stderr and why Python logging write everything to stderr?

2023-01-03 Thread Weatherby,Gerard
and why Python logging write everything to stderr? *** Attention: This is an external email. Use caution responding, opening attachments or clicking on links. *** On 2023-01-03 15:35, c.bu...@posteo.jp wrote: > Hello, > > this posting isn't about asking for a technical solution. My

Re: What should go to stdout/stderr and why Python logging write everything to stderr?

2023-01-03 Thread Richard Damon
 > On Jan 3, 2023, at 10:38 AM, c.bu...@posteo.jp wrote: > Hello, > > this posting isn't about asking for a technical solution. My intention > is to understand the design decision Python's core developers made in > context of that topic. > > The logging module wr

Re: What should go to stdout/stderr and why Python logging write everything to stderr?

2023-01-03 Thread MRAB
On 2023-01-03 15:35, c.bu...@posteo.jp wrote: Hello, this posting isn't about asking for a technical solution. My intention is to understand the design decision Python's core developers made in context of that topic. The logging module write everything to stderr no matter which logging level

Re: What should go to stdout/stderr and why Python logging write everything to stderr?

2023-01-03 Thread Thomas Passin
On 1/3/2023 10:35 AM, c.bu...@posteo.jp wrote: Hello, this posting isn't about asking for a technical solution. My intention is to understand the design decision Python's core developers made in context of that topic. The logging module write everything to stderr no matter which logging level

What should go to stdout/stderr and why Python logging write everything to stderr?

2023-01-03 Thread c.buhtz
Hello, this posting isn't about asking for a technical solution. My intention is to understand the design decision Python's core developers made in context of that topic. The logging module write everything to stderr no matter which logging level is used. The argparse module does it more

Re: Logging

2022-11-19 Thread Cameron Simpson
On 20Nov2022 12:36, Chris Angelico wrote: On Sun, 20 Nov 2022 at 12:27, Cameron Simpson wrote: But really, is there any problem which cannot be solved with a decorator? I've even got a @decorator decorator for my decorators. Do you have a @toomanydecorators decorator to reduce the number of

Re: Logging

2022-11-19 Thread Chris Angelico
On Sun, 20 Nov 2022 at 12:27, Cameron Simpson wrote: > > On 19Nov2022 18:26, Thomas Passin wrote: > >>The alternative is to just replace every calling function which uses > >>my_ugly_debug() to directly call a logging.whatever() call. > > > >Maybe a place for a decorator... > > Indeed, though I

Re: Logging

2022-11-19 Thread Cameron Simpson
On 19Nov2022 18:26, Thomas Passin wrote: The alternative is to just replace every calling function which uses my_ugly_debug() to directly call a logging.whatever() call. Maybe a place for a decorator... Indeed, though I don't think the OP is up to decorators yet. But really, is there any

Re: Logging

2022-11-19 Thread Thomas Passin
On 11/19/2022 5:27 PM, Cameron Simpson wrote: On 19Nov2022 11:08, Stefan Ram wrote: writes: You are expected to implement logging feature to an existing code which uses the function below. [...] You are not allowed to make changes in my_ugly_debug, so find another way.  If found

Re: Logging

2022-11-19 Thread Cameron Simpson
On 19Nov2022 11:08, Stefan Ram wrote: writes: You are expected to implement logging feature to an existing code which uses the function below. [...] You are not allowed to make changes in my_ugly_debug, so find another way. If found a solution that is even more ugly than your function. I

Logging

2022-11-19 Thread Baran Gökçekli
How can I solve this question? There is a module called ‘logging’ to employ logging facility in Python. import logging logging. info('Just a normal message' ) Logging.warning('Not fatal but still noted') logging.error('There is something wrong') You are expected to implement logging feature

Re: Ref-strings in logging messages (was: Performance issue with CPython 3.10 + Cython)

2022-10-24 Thread Barry Scott
> On 8 Oct 2022, at 11:50, Weatherby,Gerard wrote: > > Logging does support passing a callable, if indirectly. It only calls __str__ > on the object passed if debugging is enabled. > > class Defer: > > def __init__(self,fn): > self.fn = f

Re: Ref-strings in logging messages (was: Performance issue with CPython 3.10 + Cython)

2022-10-08 Thread Weatherby,Gerard
Logging does support passing a callable, if indirectly. It only calls __str__ on the object passed if debugging is enabled. class Defer: def __init__(self,fn): self.fn = fn def __str__(self): return self.fn() def some_expensive_function(): return "

Re: Ref-strings in logging messages (was: Performance issue with CPython 3.10 + Cython)

2022-10-07 Thread Julian Smith
he culprit was me. As lazy as I am, I have used f-strings all over the > >>> place in calls to `logging.logger.debug()` and friends, evaluating all > >>> arguments regardless of whether the logger was enabled or not. > >>> > >> I thought there was some d

Re: Ref-strings in logging messages (was: Performance issue with CPython 3.10 + Cython)

2022-10-07 Thread Barry
> On 7 Oct 2022, at 19:09, Weatherby,Gerard wrote: > The obvious way to avoid log generation is: > > if logger.isEnableFor(logging.DEBUG): >logger.debug( expensive processing ) > > > Of course, having logging alter program flow could lead to hard to d

Re: Ref-strings in logging messages (was: Performance issue with CPython 3.10 + Cython)

2022-10-07 Thread Weatherby,Gerard
The obvious way to avoid log generation is: if logger.isEnableFor(logging.DEBUG): logger.debug( expensive processing ) Of course, having logging alter program flow could lead to hard to debug bugs. From: Python-list on behalf of Barry Date: Friday, October 7, 2022 at 1:30 PM

Re: Ref-strings in logging messages (was: Performance issue with CPython 3.10 + Cython)

2022-10-07 Thread Barry
calls to `logging.logger.debug()` and friends, evaluating all >>> arguments regardless of whether the logger was enabled or not. >>> >> I thought there was some discussion about whether and how to efficiently >> admit f-strings to the logging package. I'm guessing that's not

Re: Ref-strings in logging messages (was: Performance issue with CPython 3.10 + Cython)

2022-10-07 Thread MRAB
was enabled or not. I thought there was some discussion about whether and how to efficiently admit f-strings to the logging package. I'm guessing that's not gone anywhere (yet). Letting you pass in a callable to call might help because that you could use lambda. -- https://mail.python.org/mailman

Re: Ref-strings in logging messages (was: Performance issue with CPython 3.10 + Cython)

2022-10-07 Thread Barry
all >> arguments regardless of whether the logger was enabled or not. >> > > I thought there was some discussion about whether and how to efficiently > admit f-strings to the logging package. I'm guessing that's not gone > anywhere (yet). That cannot be done as the f-string is co

Re: Ref-strings in logging messages (was: Performance issue with CPython 3.10 + Cython)

2022-10-07 Thread Skip Montanaro
y as I am, I have used f-strings all over the >> place in calls to `logging.logger.debug()` and friends, evaluating all >> arguments regardless of whether the logger was enabled or not. >> > > I thought there was some discussion about whether and how to efficiently >

Ref-strings in logging messages (was: Performance issue with CPython 3.10 + Cython)

2022-10-07 Thread Skip Montanaro
ere was some discussion about whether and how to efficiently admit f-strings to the logging package. I'm guessing that's not gone anywhere (yet). Skip -- https://mail.python.org/mailman/listinfo/python-list

Re: Logging into single file from multiple modules in python when TimedRotatingFileHandler is used

2022-06-27 Thread Peter J. Holzer
rently after midnight. I got to know why it is so but > couldn't get how I can solve it. > Issue was because of serialization in logging when multiple processes ^^ > are involved. I think this is crucial point. Not "multi

Re: Logging into single file from multiple modules in python when TimedRotatingFileHandler is used

2022-06-22 Thread Dieter Maurer
rently after >midnight. I got to know why it is so but couldn't get how I can solve it. >Issue was because of serialization in logging when multiple processes are >involved. > >Below is log_config.py which is used by all other modules to get the logger >and log. >import logging &

Re: Logging into single file from multiple modules in python when TimedRotatingFileHandler is used

2022-06-22 Thread Lars Liedtke
The process that is writing the file must be told that rotation has happened for it to work. Other wise all the logs keep being write to the original file via the FD that the process has. logrotate's config include how to tell the process the log file needs reopening. Thanks for

Re: Logging into single file from multiple modules in python when TimedRotatingFileHandler is used

2022-06-22 Thread Barry Scott
> On 22 Jun 2022, at 11:06, Lars Liedtke wrote: > > Could be unrelated and only a part of a solution, but if you are on a unixoid > system, you could use logrotate, instead of TimedRotatingFileHandler. > logfrotate ensures that the logging service does not realize, its lo

Re: Logging into single file from multiple modules in python when TimedRotatingFileHandler is used

2022-06-22 Thread Lars Liedtke
of TimedRotatingFileHandler, my log behaves differently after midnight. I got to know why it is so but couldn't get how I can solve it. Issue was because of serialization in logging when multiple processes are involved. Could be unrelated and only a part of a solution, but if you

Logging into single file from multiple modules in python when TimedRotatingFileHandler is used

2022-06-21 Thread Chethan Kumar S
Hi all, Need help with below query on python logging module. I have a main process which makes use of different other modules. And these modules also use other modules. I need to log all the logs into single log file. Due to use of TimedRotatingFileHandler, my log behaves differently after

Re: logging library python

2022-04-27 Thread Dan Stromberg
You probably want getLogger(__name__) ...or something close to it. ‪On Wed, Apr 27, 2022 at 12:58 PM ‫תמר ווסה‬‎ wrote:‬ > hello, > we have many scripts of one project. what is the right way to define the > logger to all scripts? we tried to create class that define the logger >

logging library python

2022-04-27 Thread תמר ווסה
hello, we have many scripts of one project. what is the right way to define the logger to all scripts? we tried to create class that define the logger configuration+generic function (handler functions to write generic log message), and each script define an instance of the class. But the log

[issue411881] Use of "except:" in logging module

2022-04-10 Thread admin
Change by admin : -- github: None -> 34244 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

Re: Add a method to list the current named logging levels

2022-03-30 Thread Mats Wichmann
You > potentially might have issues with other Python implementations, but > I'm pretty sure CPython has logging._nameToLevel with the same > semantics for quite a while. since 2013, it looks like. -- https://mail.python.org/mailman/listinfo/python-list

Re: Add a method to list the current named logging levels

2022-03-30 Thread Tim Chase
On 2022-03-30 16:37, Barry wrote: > Is logging.getLevelNamesMapping() what you are looking for? Is this in some version newer than the 3.8 that comes stock on my machine? $ python3 -q >>> import logging >>> logging.getLevelNamesMapping() Traceback (most recent

Re: Add a method to list the current named logging levels

2022-03-30 Thread Chris Angelico
rote: > > >>> > > >>> Edward Spencer wrote at 2021-9-2 10:02 -0700: > > >>>> Sometimes I like to pass the logging level up to the command line > > >>>> params so my user can specific what level of logging they want. > > >&g

Re: Add a method to list the current named logging levels

2022-03-30 Thread Edward Spencer
在 2022年3月30日星期三 UTC+1 16:38:26, 写道: > > On 30 Mar 2022, at 16:11, Edward Spencer wrote: > > > > 在 2021年9月3日星期五 UTC+1 18:50:51, 写道: > >>>> On 2 Sep 2021, at 23:38, Dieter Maurer wrote: > >>> > >>> Edward Spencer wrote at 2021-9-2

Re: Add a method to list the current named logging levels

2022-03-30 Thread Barry
> On 30 Mar 2022, at 16:11, Edward Spencer wrote: > > 在 2021年9月3日星期五 UTC+1 18:50:51, 写道: >>>> On 2 Sep 2021, at 23:38, Dieter Maurer wrote: >>> >>> Edward Spencer wrote at 2021-9-2 10:02 -0700: >>>> Sometimes I like to pass the logging l

Re: Add a method to list the current named logging levels

2022-03-30 Thread Edward Spencer
在 2021年9月3日星期五 UTC+1 18:50:51, 写道: > > On 2 Sep 2021, at 23:38, Dieter Maurer wrote: > > > > Edward Spencer wrote at 2021-9-2 10:02 -0700: > >> Sometimes I like to pass the logging level up to the command line params > >> so my user can specific what

[issue45171] stacklevel handling in logging module is inconsistent

2022-03-27 Thread Vinay Sajip
Vinay Sajip added the comment: New changeset c12ba6b2ff7908c8970b978f149d51ecd3fb195c by Jouke Witteveen in branch 'main': bpo-45171: Remove tests of deprecated logger.warn(). (GH-32139) https://github.com/python/cpython/commit/c12ba6b2ff7908c8970b978f149d51ecd3fb195c --

[issue45171] stacklevel handling in logging module is inconsistent

2022-03-27 Thread Jouke Witteveen
Change by Jouke Witteveen : -- pull_requests: +30220 pull_request: https://github.com/python/cpython/pull/32139 ___ Python tracker ___

[issue45171] stacklevel handling in logging module is inconsistent

2022-03-27 Thread Karthikeyan Singaravelan
Karthikeyan Singaravelan added the comment: The commit seems to emit a deprecation warning in test_logging. Probably the warning needs to be handled while setting trigger = self.logger.warn PYTHONWARNINGS=always ./python -Wall -m test test_logging 0:00:00 load avg:

[issue45171] stacklevel handling in logging module is inconsistent

2022-03-27 Thread Vinay Sajip
Vinay Sajip added the comment: New changeset 5ca6d7469be53960843df39bb900e9c3359f127f by Jouke Witteveen in branch 'main': bpo-45171: Fix stacklevel handling in logging. (GH-28287) https://github.com/python/cpython/commit/5ca6d7469be53960843df39bb900e9c3359f127f -- nosy

[issue46557] Logging captured warnings with a format string unnecessarily groups warnings together

2022-03-15 Thread Vinay Sajip
Vinay Sajip added the comment: New changeset d8066b420b888591f485d132e62979d07abfc3f4 by Michael P. Nitowski in branch 'main': bpo-46557: Log captured warnings without format string (GH-30975) https://github.com/python/cpython/commit/d8066b420b888591f485d132e62979d07abfc3f4 --

[issue46200] Discourage logging f-strings due to security considerations

2022-02-19 Thread Arie Bovenberg
Arie Bovenberg added the comment: Thanks @gregory.p.smith! I didn't know about discuss.python.org. I created a new topic there: https://discuss.python.org/t/safer-logging-methods-for-f-strings-and-new-style-formatting/13802 -- ___ Python tracker

[issue46200] Discourage logging f-strings due to security considerations

2022-02-18 Thread Gregory P. Smith
Gregory P. Smith added the comment: A new system of logging APIs has been on several of our (core dev and otherwise) minds ever since f-strings were introduced. For this specific issue, agreed that documentation is key. The old logging APIs cannot change. And practically preventing

Re: Logging user activity

2022-02-08 Thread Jack Dangler
or manipulated the data in the database. The code is written python and used django framework. I've connected django with oracle cloud database. So now I want to if the basic logging details can be used to store the record of these activities in the log file in the server. There are three places where you can

Re: Logging user activity

2022-02-07 Thread Cameron Simpson
e is written python and used django >framework. I've connected django with oracle cloud database. So now I >want to if the basic logging details can be used to store the record of >these activities in the log file in the server. It would be of great >help. For the file,

Re: Logging user activity

2022-02-07 Thread Peter J. Holzer
se. The code is written python and used django > framework. I've connected django with oracle cloud database. So now I > want to if the basic logging details can be used to store the record > of these activities in the log file in the server. There are three places where you can do that in

Logging user activity

2022-02-07 Thread blessy carol
connected django with oracle cloud database. So now I want to if the basic logging details can be used to store the record of these activities in the log file in the server. It would be of great help. Thanks & Regards, Blessy. -- https://mail.python.org/mailman/listinfo/python-list

[issue46200] Discourage logging f-strings due to security considerations

2022-02-04 Thread Tin Tvrtković
new logging APIs, there are better APIs out there (look at the structlog library). Also the old APIs would have to stay for a *long* time since everybody's using them. Adding clever typing overloads seems actually realistic and useful to me. But that depends on the LiteralString PEP being

[issue46200] Discourage logging f-strings due to security considerations

2022-02-04 Thread Erlend E. Aasland
Change by Erlend E. Aasland : -- nosy: -erlendaasland ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue46200] Discourage logging f-strings due to security considerations

2022-02-03 Thread Arie Bovenberg
Arie Bovenberg added the comment: @rhettinger @tinchester I definitely see now that f-strings should have a place in logging. But do you agree that f-strings don't mix 100% safely with the current logger API? What are your thoughts on a safer set of logger functions (see my comments above

[issue46200] Discourage logging f-strings due to security considerations

2022-02-03 Thread Raymond Hettinger
Raymond Hettinger added the comment: In a favor of deferred substitution, the cookbook should have a recipe where substituted messages are logged to a file and the unsubstituted message stored in SQLite3 database with the parameters stored as JSON.This gives both human readable output

[issue46200] Discourage logging f-strings due to security considerations

2022-02-03 Thread Raymond Hettinger
Raymond Hettinger added the comment: > Eric is absolutely right, due to function calls being > somewhat slow in Python the performance argument in > practice falls in favor of f-strings. Also f-strings can evaluate expressions in the template which is also a big win: f('Pending

[issue46200] Discourage logging f-strings due to security considerations

2022-02-02 Thread Tin Tvrtković
Tin Tvrtković added the comment: Eric is absolutely right, due to function calls being somewhat slow in Python the performance argument in practice falls in favor of f-strings. So if they're faster, more readable, and more convenient to write, no wonder people prefer them (including me).

[issue46557] Logging captured warnings with a format string unnecessarily groups warnings together

2022-01-28 Thread Vinay Sajip
Change by Vinay Sajip : -- type: behavior -> enhancement versions: -Python 3.10, Python 3.7, Python 3.8, Python 3.9 ___ Python tracker ___

[issue46557] Logging captured warnings with a format string unnecessarily groups warnings together

2022-01-27 Thread Michael P. Nitowski
Michael P. Nitowski added the comment: Of course, here's an example script to reproduce: ``` import logging import warnings import sentry_sdk from sentry_sdk.integrations.logging import LoggingIntegration logging.captureWarnings(True) sentry_logging = LoggingIntegration( level

[issue46557] Logging captured warnings with a format string unnecessarily groups warnings together

2022-01-27 Thread Michael P. Nitowski
Change by Michael P. Nitowski : -- keywords: +patch pull_requests: +29154 stage: -> patch review pull_request: https://github.com/python/cpython/pull/30975 ___ Python tracker

  1   2   3   4   5   6   7   8   9   10   >