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

Implicit logger #213

Closed
mottosso opened this issue Jul 31, 2015 · 0 comments
Closed

Implicit logger #213

mottosso opened this issue Jul 31, 2015 · 0 comments

Comments

@mottosso
Copy link
Member

Goal

Eliminate the need for @pyblish.api.log.

Currently, a logger is implicitly included in every plug-in, as per it's superclass. But what the superclass can't know is the name of your plug-in. The name is present in every log record, and in the vast landscape of hundreds or thousands of records it can be helpful to be able to distinguish between where a particular record originated from.

For example, this plug-in.

import pyblish.api

class MyPlugin(pyblish.api.Plugin):
    def process(self):
        self.log.info("Hello world")

Outputs..

# pyblish.pyblish.plugin.Plugin : Hello world # 

When you decorate your class with a logger, the decoration mechanism look up the name of your plug-in at run-time and append it to its records.

import pyblish.api

@pyblish.api.log
class MyPlugin(pyblish.api.Plugin):
    def process(self):
        self.log.info("Hello world")

# pyblish.__main__.MyPlugin: Hello world #

Implementation

Apply a logger in a similar fashion, instead relying on meta-programming, similar to how plug-ins are currently evaluated to be pre-1.1 (i.e. using process_instance in favour of just process).

The logger will be applied implicitly, along with the name given when subclassing, eliminating the need to manually decorate any classes.

mottosso added a commit to mottosso/pyblish-base that referenced this issue Jul 31, 2015
mottosso added a commit to mottosso/pyblish-base that referenced this issue Aug 4, 2015
In compliance with the recent support for @log-less plug-ins (pyblish#213)
@mottosso mottosso mentioned this issue Aug 4, 2015
@mottosso mottosso closed this as completed Aug 6, 2015
mottosso referenced this issue in tokejepsen/pyblish-hiero Aug 6, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant