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
yncio 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 s

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 this

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
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.

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

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 develop

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 level

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 -

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 o

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

2023-01-04 Thread Barry Scott
: write 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 - Do

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

2023-01-04 Thread Barry Scott
you, the 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

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,

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

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 "s

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 &std::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 to

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 arbitrary

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

2023-01-04 Thread Weatherby,Gerard
hael Torrie Date: Tuesday, January 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. *** M

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 out-of-se

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 I

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 pr

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 buffering

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 fo

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$" (r

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 exampl

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 up the p

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 mig

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 log

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 all

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 f

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

2023-01-03 Thread Weatherby,Gerard
pt ends 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 respo

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

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

2023-01-03 Thread Eryk Sun
d 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 n

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

2023-01-03 Thread Weatherby,Gerard
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 int

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 mo

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 log

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 log

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 do

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 d

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 pr

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 a

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 expecte

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
ulprit 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&#

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

2022-10-07 Thread MRAB
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.o

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

2022-10-07 Thread Barry
>> 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-st

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 "mul

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 logg

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 clearing.

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 are

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 > configuration+g

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

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

2022-03-30 Thread Mats Wichmann
internal). 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 level

Re: Logging user activity

2022-02-08 Thread Jack Dangler
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 yo

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, yo

Re: Logging user activity

2022-02-07 Thread Peter J. Holzer
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 th

Logging user activity

2022-02-07 Thread blessy carol
27;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. Thanks & Regards, Blessy. -- https://mail.python.org/mailman/listinfo/python-list

Re: Trouble propagating logging configuration

2021-09-04 Thread Peter J. Holzer
On 2021-09-02 09:06:53 +0200, Loris Bennett wrote: > Thanks Peter and Dieter for all the help. I have finally figured out > what my problem was. If in a module 'mylibs.mylib' I have > > import logging > > logger = logging.getLogger(__name__) > > and in

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

2021-09-03 Thread Barry
> 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 level of logging they want. However there is no >> easy m

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

2021-09-02 Thread Dieter Maurer
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. However there is no easy >method for pulling the named logging level names. > >Looking into the

Add a method to list the current named logging levels

2021-09-02 Thread Edward Spencer
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. However there is no easy method for pulling the named logging level names. Looking into the code, it would actually be incredibly easy to implement; in `logging

Re: Trouble propagating logging configuration

2021-09-02 Thread Loris Bennett
"Dieter Maurer" writes: > Loris Bennett wrote at 2021-9-1 13:48 +0200: >> ... >>Yes, but to quote from >>https://docs.python.org/3.6/howto/logging.html#logging-basic-tutorial: >> >> A good convention to use when naming loggers is to use a module-

Re: Trouble propagating logging configuration

2021-09-01 Thread Dieter Maurer
Loris Bennett wrote at 2021-9-1 13:48 +0200: > ... >Yes, but to quote from >https://docs.python.org/3.6/howto/logging.html#logging-basic-tutorial: > > A good convention to use when naming loggers is to use a module-level > logger, in each module which uses logging

Re: Trouble propagating logging configuration

2021-09-01 Thread Peter Otten
On 01/09/2021 13:48, Loris Bennett wrote: "Dieter Maurer" writes: Loris Bennett wrote at 2021-8-31 15:25 +0200: I am having difficulty getting the my logging configuration passed on to imported modules. My initial structure was as follows: $ tree blorp/ blorp/

Re: Trouble propagating logging configuration

2021-09-01 Thread Loris Bennett
"Dieter Maurer" writes: > Loris Bennett wrote at 2021-8-31 15:25 +0200: >>I am having difficulty getting the my logging configuration passed on >>to imported modules. >> >>My initial structure was as follows: >> >> $ tree blorp/

Re: Trouble propagating logging configuration

2021-08-31 Thread Dieter Maurer
Loris Bennett wrote at 2021-8-31 15:25 +0200: >I am having difficulty getting the my logging configuration passed on >to imported modules. > >My initial structure was as follows: > > $ tree blorp/ > blorp/ > |-- blorp > | |-- __init__.py > | |-- bar.py >

Re: Trouble propagating logging configuration

2021-08-31 Thread Loris Bennett
"Loris Bennett" writes: > Hi, > > I am having difficulty getting the my logging configuration passed on > to imported modules. > > My initial structure was as follows: > > $ tree blorp/ > blorp/ > |-- blorp > | |-- __init__.py > | |--

Trouble propagating logging configuration

2021-08-31 Thread Loris Bennett
Hi, I am having difficulty getting the my logging configuration passed on to imported modules. My initial structure was as follows: $ tree blorp/ blorp/ |-- blorp | |-- __init__.py | |-- bar.py | |-- foo.py | `-- main.py `-- pyproject.toml whereby the logging

Re: How to implement logging for an imported module?

2021-03-15 Thread Peter Otten
On 15/03/2021 09:47, Robert Latest via Python-list wrote: Richard Damon wrote: On 3/8/21 4:16 AM, Robert Latest via Python-list wrote: Joseph L. Casale wrote: I couldn't find any information on how to implement logging in a library that doesn't know the name of the application th

Re: How to implement logging for an imported module?

2021-03-15 Thread Robert Latest via Python-list
Richard Damon wrote: > On 3/8/21 4:16 AM, Robert Latest via Python-list wrote: >> Joseph L. Casale wrote: >>>> I couldn't find any information on how to implement logging in a library >>>> that doesn't know the name of the application that uses it. H

Re: How to implement logging for an imported module?

2021-03-08 Thread Richard Damon
On 3/8/21 4:16 AM, Robert Latest via Python-list wrote: > Joseph L. Casale wrote: >>> I couldn't find any information on how to implement logging in a library >>> that >>> doesn't know the name of the application that uses it. How is that done? >> Th

Re: How to implement logging for an imported module?

2021-03-08 Thread Robert Latest via Python-list
Joseph L. Casale wrote: >> I couldn't find any information on how to implement logging in a library that >> doesn't know the name of the application that uses it. How is that done? > > That's not how it works, it is the opposite. You need to know the name of its &g

Re: How to implement logging for an imported module?

2021-03-07 Thread Pankaj Jangid
"Joseph L. Casale" writes: >> I couldn't find any information on how to implement logging in a >> library that doesn't know the name of the application that uses >> it. How is that done? > Create (get) a root logger (you don't have to use it) a

RE: How to implement logging for an imported module?

2021-03-07 Thread Joseph L. Casale
> I couldn't find any information on how to implement logging in a library that > doesn't know the name of the application that uses it. How is that done? Hello, That's not how it works, it is the opposite. You need to know the name of its logger, and since you imported it

  1   2   3   4   5   6   7   8   9   10   >