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

inconsistent behaviour when using colorlog feature of cement 2.6 #314

Closed
rjdp opened this Issue Jun 11, 2015 · 10 comments

Comments

Projects
None yet
3 participants
@rjdp
Contributor

rjdp commented Jun 11, 2015

when using colorlog(cement2.6) log messages are not written to the 'log file'(mentioned in the config) when 'level' is set to 'debug' but when level is set to other than 'debug' , messages are written to log file as expected .

@derks

This comment has been minimized.

Show comment
Hide comment
@derks

derks Jun 11, 2015

Member

@rjdp thanks for the report. Will look at this today.

Member

derks commented Jun 11, 2015

@rjdp thanks for the report. Will look at this today.

@derks derks added this to the 2.7.2 Development milestone Jun 11, 2015

@derks derks self-assigned this Jun 11, 2015

@rjdp

This comment has been minimized.

Show comment
Hide comment
@rjdp

rjdp Jun 12, 2015

Contributor

@derks ... also in cases where it(colorlog) does write to log file , the log entries don't have the color info / the log messages aren't color coded .

Contributor

rjdp commented Jun 12, 2015

@derks ... also in cases where it(colorlog) does write to log file , the log entries don't have the color info / the log messages aren't color coded .

@derks

This comment has been minimized.

Show comment
Hide comment
@derks

derks Jun 12, 2015

Member

@rjdp sorry I didn't get to this yesterday, but will be checking it out now. Not embedding color codes in the log files was by design, as I did not think that would be anyones preference. That said, I'll make sure that bit is configurable so that you can enable it if you wish.

Member

derks commented Jun 12, 2015

@rjdp sorry I didn't get to this yesterday, but will be checking it out now. Not embedding color codes in the log files was by design, as I did not think that would be anyones preference. That said, I'll make sure that bit is configurable so that you can enable it if you wish.

@derks

This comment has been minimized.

Show comment
Hide comment
@derks

derks Jun 12, 2015

Member

Confirmed that debug logging is broken in colorlog only when file logging is enabled (console logging works fine):

2015-06-12 12:40:09,473 (DEBUG) myapp : logging initialized for 'myapp' using ColorLogHandler
--- Logging error ---
Traceback (most recent call last):
  File "/usr/local/Cellar/python3/3.4.3/Frameworks/Python.framework/Versions/3.4/lib/python3.4/logging/__init__.py", line 978, in emit
    msg = self.format(record)
  File "/usr/local/Cellar/python3/3.4.3/Frameworks/Python.framework/Versions/3.4/lib/python3.4/logging/__init__.py", line 828, in format
    return fmt.format(record)
  File "/usr/local/Cellar/python3/3.4.3/Frameworks/Python.framework/Versions/3.4/lib/python3.4/logging/__init__.py", line 568, in format
    s = self.formatMessage(record)
  File "/usr/local/Cellar/python3/3.4.3/Frameworks/Python.framework/Versions/3.4/lib/python3.4/logging/__init__.py", line 537, in formatMessage
    return self._style.format(record)
  File "/usr/local/Cellar/python3/3.4.3/Frameworks/Python.framework/Versions/3.4/lib/python3.4/logging/__init__.py", line 381, in format
    return self._fmt % record.__dict__
KeyError: 'log_color'
Call stack:
  File "myapp.py", line 40, in <module>
    with MyApp() as app:
  File "/Users/derks/Development/cement/cement/core/foundation.py", line 772, in __enter__
    self.setup()
  File "/Users/derks/Development/cement/cement/core/foundation.py", line 744, in setup
    self._setup_log_handler()
  File "/Users/derks/Development/cement/cement/core/foundation.py", line 1092, in _setup_log_handler
    self.log = self._resolve_handler('log', self._meta.log_handler)
  File "/Users/derks/Development/cement/cement/core/foundation.py", line 1009, in _resolve_handler
    han._setup(self)
  File "/Users/derks/Development/cement/cement/ext/ext_logging.py", line 128, in _setup
    (self._meta.namespace, self.__class__.__name__))
  File "/Users/derks/Development/cement/cement/ext/ext_logging.py", line 311, in debug
    self.backend.debug(msg, **kwargs)
Message: "logging initialized for 'myapp' using ColorLogHandler"
Arguments: ()
Member

derks commented Jun 12, 2015

Confirmed that debug logging is broken in colorlog only when file logging is enabled (console logging works fine):

2015-06-12 12:40:09,473 (DEBUG) myapp : logging initialized for 'myapp' using ColorLogHandler
--- Logging error ---
Traceback (most recent call last):
  File "/usr/local/Cellar/python3/3.4.3/Frameworks/Python.framework/Versions/3.4/lib/python3.4/logging/__init__.py", line 978, in emit
    msg = self.format(record)
  File "/usr/local/Cellar/python3/3.4.3/Frameworks/Python.framework/Versions/3.4/lib/python3.4/logging/__init__.py", line 828, in format
    return fmt.format(record)
  File "/usr/local/Cellar/python3/3.4.3/Frameworks/Python.framework/Versions/3.4/lib/python3.4/logging/__init__.py", line 568, in format
    s = self.formatMessage(record)
  File "/usr/local/Cellar/python3/3.4.3/Frameworks/Python.framework/Versions/3.4/lib/python3.4/logging/__init__.py", line 537, in formatMessage
    return self._style.format(record)
  File "/usr/local/Cellar/python3/3.4.3/Frameworks/Python.framework/Versions/3.4/lib/python3.4/logging/__init__.py", line 381, in format
    return self._fmt % record.__dict__
KeyError: 'log_color'
Call stack:
  File "myapp.py", line 40, in <module>
    with MyApp() as app:
  File "/Users/derks/Development/cement/cement/core/foundation.py", line 772, in __enter__
    self.setup()
  File "/Users/derks/Development/cement/cement/core/foundation.py", line 744, in setup
    self._setup_log_handler()
  File "/Users/derks/Development/cement/cement/core/foundation.py", line 1092, in _setup_log_handler
    self.log = self._resolve_handler('log', self._meta.log_handler)
  File "/Users/derks/Development/cement/cement/core/foundation.py", line 1009, in _resolve_handler
    han._setup(self)
  File "/Users/derks/Development/cement/cement/ext/ext_logging.py", line 128, in _setup
    (self._meta.namespace, self.__class__.__name__))
  File "/Users/derks/Development/cement/cement/ext/ext_logging.py", line 311, in debug
    self.backend.debug(msg, **kwargs)
Message: "logging initialized for 'myapp' using ColorLogHandler"
Arguments: ()

derks added a commit that referenced this issue Jun 12, 2015

derks added a commit that referenced this issue Jun 12, 2015

derks added a commit that referenced this issue Jun 12, 2015

derks added a commit that referenced this issue Jun 12, 2015

@derks

This comment has been minimized.

Show comment
Hide comment
@derks

derks Jun 12, 2015

Member

This is resolved in master and stable/2.6.x branches. Will push out Cement 2.6.2 Stable relatively soon. The default for log files is to not colorize them, however you can override this behavior with the meta option colorize_log_files = True. For example:

from cement.core.foundation import CementApp
from cement.ext.ext_colorlog import ColorLogHandler

class MyApp(CementApp):
    class Meta:
        label = 'myapp'
        extensions = ['colorlog']
        log_handler = ColorLogHandler(colorize_log_files=True)

Please let me know if you see any other issues, and thanks for helping make Cement better!

Member

derks commented Jun 12, 2015

This is resolved in master and stable/2.6.x branches. Will push out Cement 2.6.2 Stable relatively soon. The default for log files is to not colorize them, however you can override this behavior with the meta option colorize_log_files = True. For example:

from cement.core.foundation import CementApp
from cement.ext.ext_colorlog import ColorLogHandler

class MyApp(CementApp):
    class Meta:
        label = 'myapp'
        extensions = ['colorlog']
        log_handler = ColorLogHandler(colorize_log_files=True)

Please let me know if you see any other issues, and thanks for helping make Cement better!

@rjdp

This comment has been minimized.

Show comment
Hide comment
@rjdp

rjdp Jun 12, 2015

Contributor

thanks !

Contributor

rjdp commented Jun 12, 2015

thanks !

@derks derks closed this Jun 12, 2015

@derks derks reopened this Jun 14, 2015

@derks

This comment has been minimized.

Show comment
Hide comment
@derks

derks Jun 14, 2015

Member

Note to self: Extension should support colorize_file_log and colorize_console_log via the config section [log.colorlog] as that is a per-user preference, and shouldn't be hard-coded by the app developer in Meta.

Member

derks commented Jun 14, 2015

Note to self: Extension should support colorize_file_log and colorize_console_log via the config section [log.colorlog] as that is a per-user preference, and shouldn't be hard-coded by the app developer in Meta.

@harshadyeola

This comment has been minimized.

Show comment
Hide comment
@harshadyeola

harshadyeola Jun 15, 2015

@derks
May i know the release time for this fix?

harshadyeola commented Jun 15, 2015

@derks
May i know the release time for this fix?

@derks

This comment has been minimized.

Show comment
Hide comment
@derks

derks Jun 15, 2015

Member

Will plan on getting Cement 2.6.2 out this week.

Member

derks commented Jun 15, 2015

Will plan on getting Cement 2.6.2 out this week.

derks added a commit that referenced this issue Jun 22, 2015

derks added a commit that referenced this issue Jun 22, 2015

@derks derks closed this Jun 22, 2015

@derks

This comment has been minimized.

Show comment
Hide comment
@derks

derks Jun 22, 2015

Member

@harshadyeola just release Cement 2.6.2, which includes this fix.

Member

derks commented Jun 22, 2015

@harshadyeola just release Cement 2.6.2, which includes this fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment