generator icon indicating copy to clipboard operation
generator copied to clipboard

why Log missing info method ?

Open WestFarmer opened this issue 2 years ago • 4 comments

package org.mybatis.generator.logging;

public interface Log {

    boolean isDebugEnabled();

    void error(String s, Throwable e);

    void error(String s);

    void debug(String s);

    void warn(String s);
}

Is this reasonable ? for what purpose to have no info ?

WestFarmer avatar May 17 '22 08:05 WestFarmer

There's no real reason except that it wouldn't be used anywhere. Adding it would lower code coverage.

jeffgbutler avatar May 17 '22 10:05 jeffgbutler

@jeffgbutler I developed some generator plugins, I belive it's useful to output some informative message when running.

WestFarmer avatar May 17 '22 12:05 WestFarmer

also, I think the maven log imeplementation can be refactored a little bit. use case: for plugin development, I want to set different log level for my plugin only, with current maven log implementation, it's not possible.

package org.mybatis.generator.maven;

import org.apache.maven.plugin.Mojo;
import org.mybatis.generator.logging.AbstractLogFactory;
import org.mybatis.generator.logging.Log;

public class MavenLogFactory implements AbstractLogFactory {

    private final MavenLogImpl logImplementation;

    MavenLogFactory(Mojo mojo) {
        logImplementation = new MavenLogImpl(mojo.getLog());
    }

    public Log getLog(Class<?> aClass) {
        return logImplementation;
    }
}

the aClass is ignored, so for plugin within packge com.xxx.mbg.plugins, maven argument won't take effect:

-Dorg.slf4j.simpleLogger.log.com.xxx.mbg.plugins=debug

while this one will work:

-Dorg.slf4j.simpleLogger.log.org.mybatis.generator=debug

but it results extra debug logs comes from mybatis generator...

WestFarmer avatar May 17 '22 12:05 WestFarmer

I'm open to adding an info level to the logging infrastructure.

The maven log thing is probably more complex, but I haven't looked seriously at Maven logging for several years. If you have any ideas about how to make such a change please let us know.

jeffgbutler avatar May 17 '22 13:05 jeffgbutler