-
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
Colorized logging #2604
Conversation
Added new logging levels and functions
Conflicts: pokemongo_bot/api_wrapper.py pokemongo_bot/cell_workers/catch_lured_pokemon.py pokemongo_bot/cell_workers/catch_visible_pokemon.py pokemongo_bot/cell_workers/collect_level_up_reward.py pokemongo_bot/cell_workers/evolve_pokemon.py pokemongo_bot/cell_workers/handle_soft_ban.py pokemongo_bot/cell_workers/incubate_eggs.py pokemongo_bot/cell_workers/move_to_fort.py pokemongo_bot/cell_workers/nickname_pokemon.py pokemongo_bot/cell_workers/pokemon_catch_worker.py pokemongo_bot/cell_workers/recycle_items.py pokemongo_bot/cell_workers/sleep_schedule.py pokemongo_bot/cell_workers/spin_fort.py pokemongo_bot/cell_workers/transfer_pokemon.py pokemongo_bot/health_record/bot_event.py pokemongo_bot/logger.py Changes to be committed: modified: pokecli.py modified: pokemongo_bot/__init__.py modified: pokemongo_bot/cell_workers/sleep_schedule.py modified: pokemongo_bot/event_handlers/logging_handler.py modified: pokemongo_bot/event_manager.py modified: pokemongo_bot/logger.py
@gurupras please, remember that this colors cannot be logged in files (and there will be options for the user to log every task, or a specific task, to a file), so we need to handle this. |
I see. I may have missed this, but all the code I found was only invoking |
Oh, my bad. You're talking about |
input option -V[erbose] -c[olor] |
This NEEDS to be implemented, actual gui is shit. |
Well, not necessarily. However, you're right. I would still like colorized logging available Let me know if this requires any additional work, I'll be happy to get it On Sun, Aug 7, 2016 at 6:00 AM, raulgbcr notifications@github.com wrote:
|
@raulgbcr if by actual GUI you meant the terminal, it's NOT supposed to be user friendly from the start. It's not a GUI, it's an application with logs. We have no GUI (: |
👎 (see my comments) @TheSavior please review this |
print '-'*80 | ||
print 'Event: {}'.format(event) | ||
print 'Color: {}'.format(color) |
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.
please, remove these prints.
@@ -29,7 +29,6 @@ def event_report(self): | |||
for event, (color, parameters) in self._registered_events.iteritems(): | |||
print '-'*80 | |||
print 'Event: {}'.format(event) |
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
@gurupras please put the event name print back, I forgot that code was inside the event report function. It should indeed be there. My bad. |
But you don't want the port print? or you want both back |
@gurupras port? which port? colour I meant? Color is not necessary. The event report is just to help web developers create new UIs |
oops..sorry not port..it was:
I quickly saw that 80 and for some reason commented thinking it was port |
How about using different types of logging functions (e.g. error, pokémon, item) to allow for more extensibility? If we would use one logging class, we could give it multiple functions to call. Then the function could use its own color and settings (possibly shared across the class). This would make it easier to add options in the future, for example to allow setting the color or to disable certain logging. A con is that we would have to specify a type in the code. @douglascamata: How much work would it be to have the events use different functions, according to a given event? And what do you thing about that kind of system? |
@BartKoppelmans When you receive an event, you know what type of event it is. Anything you could do with multiple functions you could do inside of the event handler. |
@TheSavior: Nice, so it would be possible to implement this? What do you think about it then? |
We want to avoid duplicating code and be as simple as possible for the requirements we have. Why would we need multiple functions? What is so special that cannot be handled dynamically in just one function? |
That is not in our requirements, at least yet. So don't need to bother thinking about it because we don't know if that will ever happen (and personally, I don't think it will). |
This would enable us to have different functions for each type of log, and thus allow us to have separate settings for these functions. We could say no to logging the incubator and yes to logging the rest, while keeping the caught pokémon green and the transfers red. This would make it easier to extend, without having to change the old code. The common code can still be written in one function, which is called to reduce redundancy. The biggest plus is the extensibility, as it would make it easier to add settings to the functions. Doing this dynamically would result in one method full of complex nesting and if-statements. |
Or a json array of events that we want to log |
@BartKoppelmans @gurupras I already have plans for this and it will keep everything as dynamic as it is right now. There will be configs in every task inheriting from |
@douglascamata I'm curious, share it as soon as you start! 😄 |
@BartKoppelmans I will when I do it, but i'm working on more important stuff and I'm a bit overloaded. |
@BartKoppelmans btw, can you solve merge conflicts, please? |
@douglascamata Sure, let me know if I can help with some things! And I'm sorry, but this is not my PR, otherwise I would!😅 Pinging @gurupras to resolve the merge conflicts. |
Great job, thank you very much! @gurupras |
Conflicts: pokemongo_bot/__init__.py
- Cleaned up code - No more initialization upon `import logging` - The event system's `LoggingHandler` class now initializes logging framework - Early console is handled by `logging.basicConfig(...)`
There were some events where the initialization ended with a trailing comma. A color was _supposed_ to be added here but wasn't due to not falling clearly under one of the color categories.
… class In python __init__ __is__ the initialization method. So use that instead.
…zed-logging Conflicts: pokemongo_bot/__init__.py
can someone help me, getting this errors on OSX with iterm app.
|
Oh boy. |
@gurupras logger.py needs to import unicode_literals from future, probably. |
trying now with the new commit... looks good right now |
Short Description: Updates to the (updated) logging system
Fixes:
Some of the colours may not be the same as they were in the earlier
logger.log
system. I can change these if you're very particular. Some of the LCD code has also crept in. I can get rid of these if they're no longer required.The commit in itself may have some redundant code in terms of functions that can be used like:
self.logger.red('message in red')
,...
I thought these might be useful for cases where a message doesn't necessarily fit into the usual logging levels like
CRITICAL
,ERROR
,WARNING
,INFO
,DEBUG