Skip to content

Commit

Permalink
joelittlejohn#113 Create RuleLogger interface and implementations.
Browse files Browse the repository at this point in the history
  • Loading branch information
ddcruver committed Nov 5, 2019
1 parent 63db1db commit 8b65204
Show file tree
Hide file tree
Showing 4 changed files with 186 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/**
* Copyright © 2010-2017 Nokia
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.jsonschema2pojo.cli;

import org.jsonschema2pojo.RuleLogger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class CommandLineLogger implements RuleLogger {

private final Logger log = LoggerFactory.getLogger(Jsonschema2PojoCLI.class);

@Override
public void debug(String msg) {
log.debug(msg);
}

@Override
public void error(String msg) {
log.error(msg);
}

@Override
public void info(String msg) {
log.info(msg);
}

@Override
public void trace(String msg) {
log.trace(msg);
}

@Override
public void warn(String msg) {
log.warn(msg);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/**
* Copyright © 2010-2017 Nokia
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.jsonschema2pojo;

public interface RuleLogger {

void debug(String msg);

void error(String msg);

void info(String msg);

void trace(String msg);

void warn(String msg);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/**
* Copyright © 2010-2017 Nokia
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a
* copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations
* under the License.
*/
package org.jsonschema2pojo.gradle

import org.gradle.api.logging.Logger
import org.jsonschema2pojo.RuleLogger

class GradleRuleLogger implements RuleLogger {

Logger logger

GradleRuleLogger(Logger logger) {
super()
this.logger = logger
}

@Override
void debug(String msg) {
logger.debug(msg)
}

@Override
void error(String msg) {
logger.error(msg)
}

@Override
void info(String msg) {
logger.info(msg)
}

@Override
void trace(String msg) {
logger.trace(msg)
}

@Override
void warn(String msg) {
logger.warn(msg)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/**
* Copyright © 2010-2017 Nokia
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.jsonschema2pojo.maven;

import org.apache.maven.plugin.logging.Log;
import org.jsonschema2pojo.RuleLogger;

public class MojoRuleLogger implements RuleLogger {
private final Log log;

public MojoRuleLogger(Log log) {
super();
this.log = log;
}

@Override
public void debug(String msg) {
log.debug(msg);
}

@Override
public void error(String msg) {
log.error(msg);
}

@Override
public void info(String msg) {
log.info(msg);
}

@Override
public void trace(String msg) {
log.debug(msg); // No trace level for Mojo Logger
}

@Override
public void warn(String msg) {
log.warn(msg);
}
}

0 comments on commit 8b65204

Please sign in to comment.