Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a simple notifier that prints stuff to the console. #2

Merged
merged 3 commits into from
Sep 2, 2016

Conversation

kbruegge
Copy link
Member

@kbruegge kbruegge commented Sep 1, 2016

I think it's a good idea to have the most simple example one can think of.
Also it can be used offline. Or without a phone. Or without an unimail thing.


class ConsoleNotifier(Notifier):
def notify(self, recipient, msg):
log.info('Message: {} For: {}'.format(msg.text, recipient))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should use the level of the Message, not just info?

if msg.level == logging.CRITICAL:
log.critical('Message: {} For: {}'.format(msg.text, recipient))
if msg.level == logging.ERROR:
log.error('Message: {} For: {}'.format(msg.text, recipient))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those level are only ints and people might define their own levels. You should maybe test for <= or >= in the proper order.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should just print it here. For simplicities sake?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah

@maxnoe
Copy link
Member

maxnoe commented Sep 2, 2016

Nice minimal example!

@maxnoe maxnoe merged commit 2c69f42 into master Sep 2, 2016
@maxnoe maxnoe deleted the console_notifier branch September 2, 2016 08:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants