[ARTEMIS-1293] Log messages without prefixed id code in artemis-commons
This commit is contained in:
parent
e513f0e688
commit
28087ad4af
|
@ -84,7 +84,7 @@ public class NetworkHealthCheck extends ActiveMQScheduledComponent {
|
|||
netToUse = null;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.warn(e.getMessage(), e);
|
||||
ActiveMQUtilLogger.LOGGER.failedToSetNIC(e, nicName == null ? " " : nicName);
|
||||
netToUse = null;
|
||||
}
|
||||
|
||||
|
@ -126,7 +126,7 @@ public class NetworkHealthCheck extends ActiveMQScheduledComponent {
|
|||
try {
|
||||
this.addAddress(InetAddress.getByName(address.trim()));
|
||||
} catch (Exception e) {
|
||||
logger.warn(e.getMessage(), e);
|
||||
ActiveMQUtilLogger.LOGGER.failedToParseAddressList(e, addressList);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -144,7 +144,7 @@ public class NetworkHealthCheck extends ActiveMQScheduledComponent {
|
|||
try {
|
||||
this.addURL(new URL(address.trim()));
|
||||
} catch (Exception e) {
|
||||
logger.warn(e.getMessage(), e);
|
||||
ActiveMQUtilLogger.LOGGER.failedToParseUrlList(e, addressList);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -203,7 +203,7 @@ public class NetworkHealthCheck extends ActiveMQScheduledComponent {
|
|||
|
||||
public NetworkHealthCheck addAddress(InetAddress address) {
|
||||
if (!check(address)) {
|
||||
logger.warn("Ping Address " + address + " wasn't reacheable");
|
||||
ActiveMQUtilLogger.LOGGER.addressWasntReacheable(address.toString());
|
||||
}
|
||||
|
||||
if (!ignoreLoopback && address.isLoopbackAddress()) {
|
||||
|
@ -227,7 +227,7 @@ public class NetworkHealthCheck extends ActiveMQScheduledComponent {
|
|||
|
||||
public NetworkHealthCheck addURL(URL url) {
|
||||
if (!check(url)) {
|
||||
logger.warn("Ping url " + url + " wasn't reacheable");
|
||||
ActiveMQUtilLogger.LOGGER.urlWasntReacheable(url.toString());
|
||||
}
|
||||
urls.add(url);
|
||||
checkStart();
|
||||
|
@ -276,10 +276,10 @@ public class NetworkHealthCheck extends ActiveMQScheduledComponent {
|
|||
for (ActiveMQComponent component : componentList) {
|
||||
if (!component.isStarted()) {
|
||||
try {
|
||||
logger.info("Network is healthy, starting service " + component);
|
||||
ActiveMQUtilLogger.LOGGER.startingService(component.toString());
|
||||
component.start();
|
||||
} catch (Exception e) {
|
||||
logger.warn("Error starting component " + component, e);
|
||||
ActiveMQUtilLogger.LOGGER.errorStartingComponent(e, component.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -287,10 +287,10 @@ public class NetworkHealthCheck extends ActiveMQScheduledComponent {
|
|||
for (ActiveMQComponent component : componentList) {
|
||||
if (component.isStarted()) {
|
||||
try {
|
||||
logger.info("Network is unhealthy, stopping service " + component);
|
||||
ActiveMQUtilLogger.LOGGER.stoppingService(component.toString());
|
||||
component.stop();
|
||||
} catch (Exception e) {
|
||||
logger.warn("Error stopping component " + component, e);
|
||||
ActiveMQUtilLogger.LOGGER.errorStoppingComponent(e, component.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -332,7 +332,7 @@ public class NetworkHealthCheck extends ActiveMQScheduledComponent {
|
|||
return purePing(address);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.warn(e.getMessage(), e);
|
||||
ActiveMQUtilLogger.LOGGER.failedToCheckAddress(e, address == null ? " " : address.toString());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -378,7 +378,7 @@ public class NetworkHealthCheck extends ActiveMQScheduledComponent {
|
|||
String inputLine;
|
||||
while ((inputLine = reader.readLine()) != null) {
|
||||
if (error) {
|
||||
logger.warn(inputLine);
|
||||
ActiveMQUtilLogger.LOGGER.failedToReadFromStream(inputLine == null ? " " : inputLine);
|
||||
} else {
|
||||
logger.trace(inputLine);
|
||||
}
|
||||
|
@ -395,7 +395,7 @@ public class NetworkHealthCheck extends ActiveMQScheduledComponent {
|
|||
is.close();
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
logger.warn(e.getMessage(), e);
|
||||
ActiveMQUtilLogger.LOGGER.failedToCheckURL(e, url == null ? " " : url.toString());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ package org.apache.activemq.artemis.logs;
|
|||
|
||||
import org.jboss.logging.BasicLogger;
|
||||
import org.jboss.logging.Logger;
|
||||
import org.jboss.logging.annotations.Cause;
|
||||
import org.jboss.logging.annotations.LogMessage;
|
||||
import org.jboss.logging.annotations.Message;
|
||||
import org.jboss.logging.annotations.MessageLogger;
|
||||
|
@ -44,6 +45,16 @@ public interface ActiveMQUtilLogger extends BasicLogger {
|
|||
*/
|
||||
ActiveMQUtilLogger LOGGER = Logger.getMessageLogger(ActiveMQUtilLogger.class, ActiveMQUtilLogger.class.getPackage().getName());
|
||||
|
||||
@LogMessage(level = Logger.Level.INFO)
|
||||
@Message(id = 201000, value = "Network is healthy, starting service {0}",
|
||||
format = Message.Format.MESSAGE_FORMAT)
|
||||
void startingService(String component);
|
||||
|
||||
@LogMessage(level = Logger.Level.INFO)
|
||||
@Message(id = 201001, value = "Network is unhealthy, stopping service {0}",
|
||||
format = Message.Format.MESSAGE_FORMAT)
|
||||
void stoppingService(String component);
|
||||
|
||||
@LogMessage(level = Logger.Level.WARN)
|
||||
@Message(id = 202000, value = "Missing privileges to set Thread Context Class Loader on Thread Factory. Using current Thread Context Class Loader",
|
||||
format = Message.Format.MESSAGE_FORMAT)
|
||||
|
@ -53,4 +64,79 @@ public interface ActiveMQUtilLogger extends BasicLogger {
|
|||
@Message(id = 202001, value = "{0} is a loopback address and will be discarded.",
|
||||
format = Message.Format.MESSAGE_FORMAT)
|
||||
void addressloopback(String address);
|
||||
|
||||
@LogMessage(level = Logger.Level.WARN)
|
||||
@Message(id = 202002, value = "Ping Address {0} wasn't reacheable.",
|
||||
format = Message.Format.MESSAGE_FORMAT)
|
||||
void addressWasntReacheable(String address);
|
||||
|
||||
@LogMessage(level = Logger.Level.WARN)
|
||||
@Message(id = 202003, value = "Ping Url {0} wasn't reacheable.",
|
||||
format = Message.Format.MESSAGE_FORMAT)
|
||||
void urlWasntReacheable(String url);
|
||||
|
||||
@LogMessage(level = Logger.Level.WARN)
|
||||
@Message(id = 202004, value = "Error starting component {0} ",
|
||||
format = Message.Format.MESSAGE_FORMAT)
|
||||
void errorStartingComponent(@Cause Exception e, String component);
|
||||
|
||||
@LogMessage(level = Logger.Level.WARN)
|
||||
@Message(id = 202005, value = "Error stopping component {0} ",
|
||||
format = Message.Format.MESSAGE_FORMAT)
|
||||
void errorStoppingComponent(@Cause Exception e, String component);
|
||||
|
||||
@LogMessage(level = Logger.Level.WARN)
|
||||
@Message(id = 202006, value = "Failed to check Url {0}.",
|
||||
format = Message.Format.MESSAGE_FORMAT)
|
||||
void failedToCheckURL(@Cause Exception e, String url);
|
||||
|
||||
@LogMessage(level = Logger.Level.WARN)
|
||||
@Message(id = 202007, value = "Failed to check Address {0}.",
|
||||
format = Message.Format.MESSAGE_FORMAT)
|
||||
void failedToCheckAddress(@Cause Exception e, String address);
|
||||
|
||||
@LogMessage(level = Logger.Level.WARN)
|
||||
@Message(id = 202008, value = "Failed to check Address list {0}.",
|
||||
format = Message.Format.MESSAGE_FORMAT)
|
||||
void failedToParseAddressList(@Cause Exception e, String addressList);
|
||||
|
||||
@LogMessage(level = Logger.Level.WARN)
|
||||
@Message(id = 202009, value = "Failed to check Url list {0}.",
|
||||
format = Message.Format.MESSAGE_FORMAT)
|
||||
void failedToParseUrlList(@Cause Exception e, String urlList);
|
||||
|
||||
@LogMessage(level = Logger.Level.WARN)
|
||||
@Message(id = 202010, value = "Failed to set NIC {0}.",
|
||||
format = Message.Format.MESSAGE_FORMAT)
|
||||
void failedToSetNIC(@Cause Exception e, String nic);
|
||||
|
||||
@LogMessage(level = Logger.Level.WARN)
|
||||
@Message(id = 202011, value = "Failed to read from stream {0}.",
|
||||
format = Message.Format.MESSAGE_FORMAT)
|
||||
void failedToReadFromStream(String stream);
|
||||
|
||||
@LogMessage(level = Logger.Level.WARN)
|
||||
@Message(id = 202012, value = "Object cannot be serialized.",
|
||||
format = Message.Format.MESSAGE_FORMAT)
|
||||
void failedToSerializeObject(@Cause Exception e);
|
||||
|
||||
@LogMessage(level = Logger.Level.WARN)
|
||||
@Message(id = 202013, value = "Unable to deserialize object.",
|
||||
format = Message.Format.MESSAGE_FORMAT)
|
||||
void failedToDeserializeObject(@Cause Exception e);
|
||||
|
||||
@LogMessage(level = Logger.Level.WARN)
|
||||
@Message(id = 202014, value = "Unable to encode byte array into Base64 notation.",
|
||||
format = Message.Format.MESSAGE_FORMAT)
|
||||
void failedToEncodeByteArrayToBase64Notation(@Cause Exception e);
|
||||
|
||||
@LogMessage(level = Logger.Level.WARN)
|
||||
@Message(id = 202015, value = "Failed to clean up file {0}",
|
||||
format = Message.Format.MESSAGE_FORMAT)
|
||||
void failedToCleanupFile(String file);
|
||||
|
||||
@LogMessage(level = Logger.Level.WARN)
|
||||
@Message(id = 202016, value = "Could not list files to clean up in {0}",
|
||||
format = Message.Format.MESSAGE_FORMAT)
|
||||
void failedListFilesToCleanup(String path);
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
*/
|
||||
package org.apache.activemq.artemis.utils;
|
||||
|
||||
import org.apache.activemq.artemis.logs.ActiveMQUtilLogger;
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
|
@ -543,7 +544,7 @@ public class Base64 {
|
|||
|
||||
oos.writeObject(serializableObject);
|
||||
} catch (java.io.IOException e) {
|
||||
logger.warn("Object cannot be serialized", e.getMessage(), e);
|
||||
ActiveMQUtilLogger.LOGGER.failedToSerializeObject(e);
|
||||
return null;
|
||||
} finally {
|
||||
try {
|
||||
|
@ -661,7 +662,7 @@ public class Base64 {
|
|||
gzos.write(source, off, len);
|
||||
gzos.close();
|
||||
} catch (java.io.IOException e) {
|
||||
logger.warn("Unable to encode byte array into Base64 notation", e.getMessage(), e);
|
||||
ActiveMQUtilLogger.LOGGER.failedToEncodeByteArrayToBase64Notation(e);
|
||||
return null;
|
||||
} finally {
|
||||
try {
|
||||
|
@ -950,7 +951,7 @@ public class Base64 {
|
|||
|
||||
obj = ois.readObject();
|
||||
} catch (java.io.IOException | java.lang.ClassNotFoundException e) {
|
||||
logger.warn("Unable to deserialize object", e.getMessage(), e);
|
||||
ActiveMQUtilLogger.LOGGER.failedToDeserializeObject(e);
|
||||
obj = null;
|
||||
} finally {
|
||||
try {
|
||||
|
|
|
@ -23,7 +23,7 @@ import java.nio.file.Files;
|
|||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
|
||||
import org.jboss.logging.Logger;
|
||||
import org.apache.activemq.artemis.logs.ActiveMQUtilLogger;
|
||||
|
||||
import static java.nio.file.attribute.PosixFilePermission.GROUP_EXECUTE;
|
||||
import static java.nio.file.attribute.PosixFilePermission.GROUP_READ;
|
||||
|
@ -36,8 +36,6 @@ import static java.nio.file.attribute.PosixFilePermission.OWNER_WRITE;
|
|||
|
||||
public class FileUtil {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(FileUtil.class);
|
||||
|
||||
public static void makeExec(File file) throws IOException {
|
||||
try {
|
||||
Files.setPosixFilePermissions(file.toPath(), new HashSet<>(Arrays.asList(OWNER_READ, OWNER_WRITE, OWNER_EXECUTE, GROUP_READ, GROUP_WRITE, GROUP_EXECUTE, OTHERS_READ, OTHERS_EXECUTE)));
|
||||
|
@ -61,12 +59,12 @@ public class FileUtil {
|
|||
}
|
||||
|
||||
if (files == null) {
|
||||
logger.warn("Could not list files to clean up in: " + directory.getAbsolutePath());
|
||||
ActiveMQUtilLogger.LOGGER.failedListFilesToCleanup(directory.getAbsolutePath());
|
||||
} else {
|
||||
for (String file : files) {
|
||||
File f = new File(directory, file);
|
||||
if (!deleteDirectory(f)) {
|
||||
logger.warn("Failed to clean up file: " + f.getAbsolutePath());
|
||||
ActiveMQUtilLogger.LOGGER.failedToCleanupFile(f.getAbsolutePath());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue