Skip to content

Commit

Permalink
Make CommonLogger non-singleton
Browse files Browse the repository at this point in the history
  • Loading branch information
cherylking committed Jan 18, 2024
1 parent 982df5e commit 57e398a
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ abstract class AbstractServerTask extends AbstractLibertyTask {
if (serverConfigFile != null && serverConfigFile.exists()) {
try {
Map<String,String> props = combinedBootstrapProperties == null ? convertPropertiesToMap(server.bootstrapProperties) : combinedBootstrapProperties;
getServerConfigDocument(CommonLogger.getInstance(project), serverConfigFile, server.configDirectory, server.bootstrapPropertiesFile, props, server.serverEnvFile,
getServerConfigDocument(new CommonLogger(project), serverConfigFile, server.configDirectory, server.bootstrapPropertiesFile, props, server.serverEnvFile,
false, getLibertyDirectoryPropertyFiles(null));
if (scd != null && isLocationFound( scd.getLocations(), fileName)) {
logger.debug("Application configuration is found in server.xml : " + fileName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -682,7 +682,7 @@ class DeployTask extends AbstractServerTask {
File serverXML = new File(getServerDir(project).getCanonicalPath(), "server.xml")

try {
scd = ServerConfigDocument.getInstance(CommonLogger.getInstance(project), serverXML, server.configDirectory,
scd = getServerConfigDocument(new CommonLogger(project), serverXML, server.configDirectory,
server.bootstrapPropertiesFile, combinedBootstrapProperties, server.serverEnvFile, false, getLibertyDirectoryPropertyFiles(null))

//appName will be set to a name derived from appFile if no name can be found.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class StartTask extends AbstractServerTask {
if (serverConfigFile != null && serverConfigFile.exists()) {
try {
Map<String,String> props = combinedBootstrapProperties == null ? convertPropertiesToMap(server.bootstrapProperties) : combinedBootstrapProperties;
getServerConfigDocument(CommonLogger.getInstance(project), serverConfigFile, server.configDirectory, server.bootstrapPropertiesFile, props, server.serverEnvFile,
getServerConfigDocument(new CommonLogger(project), serverConfigFile, server.configDirectory, server.bootstrapPropertiesFile, props, server.serverEnvFile,
false, getLibertyDirectoryPropertyFiles(null));
if (scd != null) {
appNames = scd.getNames()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import org.gradle.api.logging.LogLevel
import io.openliberty.tools.ant.ServerTask
import io.openliberty.tools.common.plugins.config.ServerConfigDocument

import io.openliberty.tools.gradle.utils.CommonLogger

class UndeployTask extends AbstractServerTask {

private static final String STOP_APP_MESSAGE_CODE_REG = "CWWKZ0009I.*"
Expand Down Expand Up @@ -77,7 +79,7 @@ class UndeployTask extends AbstractServerTask {
File serverXML = new File(getServerDir(project).getCanonicalPath(), "server.xml")

try {
getServerConfigDocument(CommonLogger.getInstance(project), serverXML, server.configDirectory,
getServerConfigDocument(new CommonLogger(project), serverXML, server.configDirectory,
server.bootstrapPropertiesFile, combinedBootstrapProperties, server.serverEnvFile, false, getLibertyDirectoryPropertyFiles(null))

//appName will be set to a name derived from appFile if no name can be found.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* (C) Copyright IBM Corporation 2019, 2020.
* (C) Copyright IBM Corporation 2019, 2024.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -21,24 +21,12 @@ import org.gradle.api.Project

public class CommonLogger implements CommonLoggerI {

private static CommonLogger logger = null
private static Project project
private Project project

CommonLogger(Project project) {
public CommonLogger(Project project) {
this.project = project
}

public static init(Project project) {
logger = new CommonLogger(project)
}

public static CommonLogger getInstance(Project project) {
if (logger == null) {
CommonLogger.init(project)
}
return logger
}

@Override
public void debug(String msg) {
project.getLogger().debug(msg)
Expand Down

0 comments on commit 57e398a

Please sign in to comment.