-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Colorized logging #2604
Closed
+186
−59
Closed
Colorized logging #2604
Changes from 3 commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
beea535
Initial logging changes
gurupras 8fc7dc6
Converted some more logger.log()s
gurupras f2b3aad
Merge branch 'logging' into colorized-logging
gurupras 2a4c95b
Tiny spacing fix
gurupras 53312b7
Fixed bug where old logging format was still in use
gurupras 17d23a6
Merge branch 'dev' of github.com:PokemonGoF/PokemonGo-Bot into colori…
gurupras 4dd21ba
Removed extraneous print as pointed out by @douglascamata
gurupras bdbabf2
Removed all lcd reference
gurupras 4ba146d
Addded some comments
gurupras 043801c
Removed logger.verbose()
gurupras 79050bb
Removed additional prints from event_manager.py
gurupras 9a550d3
Revert "Removed additional prints from event_manager.py"
gurupras 17ae46b
Removed some more code related to LCD that somehow got through the fi…
gurupras 79bf1b2
Renamed LogFormatter to ColorizedLogFormatter
gurupras 64ef6c4
Merge branch 'dev' into colorized-logging
gurupras 4176d7b
Merge branch 'dev' of github.com:PokemonGoF/PokemonGo-Bot into colori…
gurupras cbba16a
Merge branch 'dev' into colorized-logging
gurupras 6cb0192
Fixed logging system initialization
gurupras babffeb
Updated EventManager() function so it more closely reflects previous …
gurupras 681a7d1
Fixed whitespace that crept in while refactoring
gurupras 6baa70d
Removed some of the commas-without-colors
gurupras ba5ab09
Removed additional initialize() method that was added to EventHandler…
gurupras e724c06
Refactored comments and order of initialization of LoggingHandler's _…
gurupras 6c14602
Merge branch 'dev' of github.com:PokemonGoF/PokemonGo-Bot into colori…
gurupras 3fa43b9
Added import of unicode_literals from future to logger.py
gurupras File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,9 +26,10 @@ def __init__(self, *handlers): | |
self._handlers = handlers or [] | ||
|
||
def event_report(self): | ||
for event, parameters in self._registered_events.iteritems(): | ||
for event, (color, parameters) in self._registered_events.iteritems(): | ||
print '-'*80 | ||
print 'Event: {}'.format(event) | ||
print 'Color: {}'.format(color) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please, remove these prints. |
||
if parameters: | ||
print 'Parameters:' | ||
for parameter in parameters: | ||
|
@@ -37,8 +38,8 @@ def event_report(self): | |
def add_handler(self, event_handler): | ||
self._handlers.append(event_handler) | ||
|
||
def register_event(self, name, parameters=[]): | ||
self._registered_events[name] = parameters | ||
def register_event(self, name, color='white', parameters=[]): | ||
self._registered_events[name] = (color, parameters) | ||
|
||
def emit(self, event, sender=None, level='info', formatted='', data={}): | ||
if not sender: | ||
|
@@ -52,7 +53,7 @@ def emit(self, event, sender=None, level='info', formatted='', data={}): | |
raise EventNotRegisteredException("Event %s not registered..." % event) | ||
|
||
# verify params match event | ||
parameters = self._registered_events[event] | ||
color, parameters = self._registered_events[event] | ||
if parameters: | ||
for k, v in data.iteritems(): | ||
if k not in parameters: | ||
|
@@ -62,4 +63,4 @@ def emit(self, event, sender=None, level='info', formatted='', data={}): | |
|
||
# send off to the handlers | ||
for handler in self._handlers: | ||
handler.handle_event(event, sender, level, formatted_msg, data) | ||
handler.handle_event(event, sender, level, formatted_msg, data, color=color) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is still this print and the print above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think those were added by me. But sure, I'll remove them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh shit, my bad... don't remove those, here it's the event's report... they should be here