Merge lp:~raharper/curtin/trunk.add-syslog-handler into lp:~curtin-dev/curtin/trunk

Proposed by Ryan Harper
Status: Work in progress
Proposed branch: lp:~raharper/curtin/trunk.add-syslog-handler
Merge into: lp:~curtin-dev/curtin/trunk
Diff against target: 64 lines (+16/-3)
1 file modified
curtin/log.py (+16/-3)
To merge this branch: bzr merge lp:~raharper/curtin/trunk.add-syslog-handler
Reviewer Review Type Date Requested Status
Scott Moser (community) Approve
Server Team CI bot continuous-integration Approve
Review via email: mp+330914@code.launchpad.net

Description of the change

Always log to syslog

Add a default syslog log handler and always enable.

To post a comment you must log in.
Revision history for this message
Server Team CI bot (server-team-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Scott Moser (smoser) wrote :

Adjust your comment to mention that we are now supporting multiple handlers at once (I think).
And then i approve.

Is there a way to disable the syslog logger? It doesnt look like it. I dont have a reason at the moment to suggest that it needs to be.

review: Approve
Revision history for this message
Ryan Harper (raharper) wrote :

On Tue, Nov 28, 2017 at 9:52 AM, Scott Moser <email address hidden>
wrote:

> Review: Approve
>
> Adjust your comment to mention that we are now supporting multiple
> handlers at once (I think).
> And then i approve.
>
> Is there a way to disable the syslog logger? It doesnt look like it. I
> dont have a reason at the moment to suggest that it needs to be.
>

I want to review it in light of the journal_report logger; I thought this
would have replaced it but the journal reporter was needed separately
and the syslog had some interesting side-effects w.r.t the reporting logger.

I'll mark this WIP

Ryan

>
>
> --
> https://code.launchpad.net/~raharper/curtin/trunk.add-
> syslog-handler/+merge/330914
> You are the owner of lp:~raharper/curtin/trunk.add-syslog-handler.
>

Unmerged revisions

527. By Ryan Harper

log: always write to syslog

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'curtin/log.py'
--- curtin/log.py 2015-08-12 20:58:05 +0000
+++ curtin/log.py 2017-09-18 14:50:41 +0000
@@ -16,6 +16,7 @@
16# along with Curtin. If not, see <http://www.gnu.org/licenses/>.16# along with Curtin. If not, see <http://www.gnu.org/licenses/>.
1717
18import logging18import logging
19import logging.handlers
1920
20# Logging items for easy access21# Logging items for easy access
21getLogger = logging.getLogger22getLogger = logging.getLogger
@@ -29,6 +30,9 @@
29DEBUG = logging.DEBUG30DEBUG = logging.DEBUG
30NOTSET = logging.NOTSET31NOTSET = logging.NOTSET
3132
33CURTIN_LOG_FMT = \
34 "[CURTIN] %(asctime)s - %(filename)s[%(levelname)s]: %(message)s"
35
3236
33class NullHandler(logging.Handler):37class NullHandler(logging.Handler):
34 def emit(self, record):38 def emit(self, record):
@@ -36,6 +40,9 @@
3640
3741
38def basicConfig(**kwargs):42def basicConfig(**kwargs):
43 # always log to syslog
44 syslog = logging.handlers.SysLogHandler(address='/dev/log')
45 handlers = [syslog]
39 # basically like logging.basicConfig but only output for our logger46 # basically like logging.basicConfig but only output for our logger
40 if kwargs.get('filename'):47 if kwargs.get('filename'):
41 handler = logging.FileHandler(filename=kwargs['filename'],48 handler = logging.FileHandler(filename=kwargs['filename'],
@@ -44,6 +51,7 @@
44 handler = logging.StreamHandler(stream=kwargs['stream'])51 handler = logging.StreamHandler(stream=kwargs['stream'])
45 else:52 else:
46 handler = NullHandler()53 handler = NullHandler()
54 handlers.append(handler)
4755
48 if 'verbosity' in kwargs:56 if 'verbosity' in kwargs:
49 level = ((logging.ERROR, logging.INFO, logging.DEBUG)57 level = ((logging.ERROR, logging.INFO, logging.DEBUG)
@@ -51,9 +59,11 @@
51 else:59 else:
52 level = kwargs.get('level', logging.NOTSET)60 level = kwargs.get('level', logging.NOTSET)
5361
54 handler.setFormatter(logging.Formatter(fmt=kwargs.get('format'),62 fmt = kwargs.get('format', CURTIN_LOG_FMT)
55 datefmt=kwargs.get('datefmt')))63 for handler in handlers:
56 handler.setLevel(level)64 handler.setFormatter(logging.Formatter(fmt=fmt,
65 datefmt=kwargs.get('datefmt')))
66 handler.setLevel(level)
5767
58 logging.getLogger().setLevel(level)68 logging.getLogger().setLevel(level)
5969
@@ -63,6 +73,9 @@
63 logger.setLevel(level)73 logger.setLevel(level)
64 logger.addHandler(handler)74 logger.addHandler(handler)
6575
76 for h in handlers:
77 logger.addHandler(h)
78
6679
67def _getLogger(name='curtin'):80def _getLogger(name='curtin'):
68 return logging.getLogger(name)81 return logging.getLogger(name)

Subscribers

People subscribed via source and target branches