Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #109474 > unrolled thread
| Started by | cl@isbd.net |
|---|---|
| First post | 2016-06-04 12:40 +0100 |
| Last post | 2016-06-04 13:14 +0100 |
| Articles | 3 — 2 participants |
Back to article view | Back to comp.lang.python
Is there any way to use the logging module adding nothing to a message cl@isbd.net - 2016-06-04 12:40 +0100
Re: Is there any way to use the logging module adding nothing to a message Ben Finney <ben+python@benfinney.id.au> - 2016-06-04 21:55 +1000
Re: Is there any way to use the logging module adding nothing to a message cl@isbd.net - 2016-06-04 13:14 +0100
| From | cl@isbd.net |
|---|---|
| Date | 2016-06-04 12:40 +0100 |
| Subject | Is there any way to use the logging module adding nothing to a message |
| Message-ID | <lara2d-s4v.ln1@esprimo.zbmc.eu> |
I want to use Python to handle the stdout logging that comes from
syncthing.
When you run syncthing it logs to stdout in a fairly standard format
with date, time, ERROR/WARNING/INFO etc. so I don't want to add these.
I just want to be able to write the log to a file with appropriate
rotation etc.
If I do:-
f = logging.handlers.RotatingFileHandler("/home/chris/tmp/mail.log", 'a', 1000000, 4)
f.setLevel(logging.DEBUG)
formatter = logging.Formatter('%(message)s')
f.setFormatter(formatter)
log.addHandler(f)
Will I get just the message with no extras added by the logging module?
--
Chris Green
·
[toc] | [next] | [standalone]
| From | Ben Finney <ben+python@benfinney.id.au> |
|---|---|
| Date | 2016-06-04 21:55 +1000 |
| Message-ID | <mailman.149.1465041358.1839.python-list@python.org> |
| In reply to | #109474 |
cl@isbd.net writes:
> If I do:-
>
> f = logging.handlers.RotatingFileHandler("/home/chris/tmp/mail.log", 'a', 1000000, 4)
> f.setLevel(logging.DEBUG)
> formatter = logging.Formatter('%(message)s')
> f.setFormatter(formatter)
> log.addHandler(f)
>
> Will I get just the message with no extras added by the logging module?
Yuo have the code, and presumably the system on which to test it. What's
the answer?
--
\ “I am too firm in my consciousness of the marvelous to be ever |
`\ fascinated by the mere supernatural …” —Joseph Conrad, _The |
_o__) Shadow-Line_ |
Ben Finney
[toc] | [prev] | [next] | [standalone]
| From | cl@isbd.net |
|---|---|
| Date | 2016-06-04 13:14 +0100 |
| Message-ID | <9ata2d-cb.ln1@esprimo.zbmc.eu> |
| In reply to | #109477 |
Ben Finney <ben+python@benfinney.id.au> wrote:
> cl@isbd.net writes:
>
> > If I do:-
> >
> > f = logging.handlers.RotatingFileHandler("/home/chris/tmp/mail.log", 'a', 1000000, 4)
> > f.setLevel(logging.DEBUG)
> > formatter = logging.Formatter('%(message)s')
> > f.setFormatter(formatter)
> > log.addHandler(f)
> >
> > Will I get just the message with no extras added by the logging module?
>
> Yuo have the code, and presumably the system on which to test it. What's
> the answer?
>
Very true, I thought the code was going to be much longer than that.
:-)
... and the answer is, yes, with the above I just get the message text
which is what I want.
--
Chris Green
·
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web