[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;
|
netToUse = null;
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.warn(e.getMessage(), e);
|
ActiveMQUtilLogger.LOGGER.failedToSetNIC(e, nicName == null ? " " : nicName);
|
||||||
netToUse = null;
|
netToUse = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -126,7 +126,7 @@ public class NetworkHealthCheck extends ActiveMQScheduledComponent {
|
||||||
try {
|
try {
|
||||||
this.addAddress(InetAddress.getByName(address.trim()));
|
this.addAddress(InetAddress.getByName(address.trim()));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.warn(e.getMessage(), e);
|
ActiveMQUtilLogger.LOGGER.failedToParseAddressList(e, addressList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -144,7 +144,7 @@ public class NetworkHealthCheck extends ActiveMQScheduledComponent {
|
||||||
try {
|
try {
|
||||||
this.addURL(new URL(address.trim()));
|
this.addURL(new URL(address.trim()));
|
||||||
} catch (Exception e) {
|
} 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) {
|
public NetworkHealthCheck addAddress(InetAddress address) {
|
||||||
if (!check(address)) {
|
if (!check(address)) {
|
||||||
logger.warn("Ping Address " + address + " wasn't reacheable");
|
ActiveMQUtilLogger.LOGGER.addressWasntReacheable(address.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ignoreLoopback && address.isLoopbackAddress()) {
|
if (!ignoreLoopback && address.isLoopbackAddress()) {
|
||||||
|
@ -227,7 +227,7 @@ public class NetworkHealthCheck extends ActiveMQScheduledComponent {
|
||||||
|
|
||||||
public NetworkHealthCheck addURL(URL url) {
|
public NetworkHealthCheck addURL(URL url) {
|
||||||
if (!check(url)) {
|
if (!check(url)) {
|
||||||
logger.warn("Ping url " + url + " wasn't reacheable");
|
ActiveMQUtilLogger.LOGGER.urlWasntReacheable(url.toString());
|
||||||
}
|
}
|
||||||
urls.add(url);
|
urls.add(url);
|
||||||
checkStart();
|
checkStart();
|
||||||
|
@ -276,10 +276,10 @@ public class NetworkHealthCheck extends ActiveMQScheduledComponent {
|
||||||
for (ActiveMQComponent component : componentList) {
|
for (ActiveMQComponent component : componentList) {
|
||||||
if (!component.isStarted()) {
|
if (!component.isStarted()) {
|
||||||
try {
|
try {
|
||||||
logger.info("Network is healthy, starting service " + component);
|
ActiveMQUtilLogger.LOGGER.startingService(component.toString());
|
||||||
component.start();
|
component.start();
|
||||||
} catch (Exception e) {
|
} 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) {
|
for (ActiveMQComponent component : componentList) {
|
||||||
if (component.isStarted()) {
|
if (component.isStarted()) {
|
||||||
try {
|
try {
|
||||||
logger.info("Network is unhealthy, stopping service " + component);
|
ActiveMQUtilLogger.LOGGER.stoppingService(component.toString());
|
||||||
component.stop();
|
component.stop();
|
||||||
} catch (Exception e) {
|
} 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);
|
return purePing(address);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.warn(e.getMessage(), e);
|
ActiveMQUtilLogger.LOGGER.failedToCheckAddress(e, address == null ? " " : address.toString());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -378,7 +378,7 @@ public class NetworkHealthCheck extends ActiveMQScheduledComponent {
|
||||||
String inputLine;
|
String inputLine;
|
||||||
while ((inputLine = reader.readLine()) != null) {
|
while ((inputLine = reader.readLine()) != null) {
|
||||||
if (error) {
|
if (error) {
|
||||||
logger.warn(inputLine);
|
ActiveMQUtilLogger.LOGGER.failedToReadFromStream(inputLine == null ? " " : inputLine);
|
||||||
} else {
|
} else {
|
||||||
logger.trace(inputLine);
|
logger.trace(inputLine);
|
||||||
}
|
}
|
||||||
|
@ -395,7 +395,7 @@ public class NetworkHealthCheck extends ActiveMQScheduledComponent {
|
||||||
is.close();
|
is.close();
|
||||||
return true;
|
return true;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.warn(e.getMessage(), e);
|
ActiveMQUtilLogger.LOGGER.failedToCheckURL(e, url == null ? " " : url.toString());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@ package org.apache.activemq.artemis.logs;
|
||||||
|
|
||||||
import org.jboss.logging.BasicLogger;
|
import org.jboss.logging.BasicLogger;
|
||||||
import org.jboss.logging.Logger;
|
import org.jboss.logging.Logger;
|
||||||
|
import org.jboss.logging.annotations.Cause;
|
||||||
import org.jboss.logging.annotations.LogMessage;
|
import org.jboss.logging.annotations.LogMessage;
|
||||||
import org.jboss.logging.annotations.Message;
|
import org.jboss.logging.annotations.Message;
|
||||||
import org.jboss.logging.annotations.MessageLogger;
|
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());
|
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)
|
@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",
|
@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)
|
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.",
|
@Message(id = 202001, value = "{0} is a loopback address and will be discarded.",
|
||||||
format = Message.Format.MESSAGE_FORMAT)
|
format = Message.Format.MESSAGE_FORMAT)
|
||||||
void addressloopback(String address);
|
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;
|
package org.apache.activemq.artemis.utils;
|
||||||
|
|
||||||
|
import org.apache.activemq.artemis.logs.ActiveMQUtilLogger;
|
||||||
import org.jboss.logging.Logger;
|
import org.jboss.logging.Logger;
|
||||||
|
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
|
@ -543,7 +544,7 @@ public class Base64 {
|
||||||
|
|
||||||
oos.writeObject(serializableObject);
|
oos.writeObject(serializableObject);
|
||||||
} catch (java.io.IOException e) {
|
} catch (java.io.IOException e) {
|
||||||
logger.warn("Object cannot be serialized", e.getMessage(), e);
|
ActiveMQUtilLogger.LOGGER.failedToSerializeObject(e);
|
||||||
return null;
|
return null;
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
try {
|
||||||
|
@ -661,7 +662,7 @@ public class Base64 {
|
||||||
gzos.write(source, off, len);
|
gzos.write(source, off, len);
|
||||||
gzos.close();
|
gzos.close();
|
||||||
} catch (java.io.IOException e) {
|
} catch (java.io.IOException e) {
|
||||||
logger.warn("Unable to encode byte array into Base64 notation", e.getMessage(), e);
|
ActiveMQUtilLogger.LOGGER.failedToEncodeByteArrayToBase64Notation(e);
|
||||||
return null;
|
return null;
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
try {
|
||||||
|
@ -950,7 +951,7 @@ public class Base64 {
|
||||||
|
|
||||||
obj = ois.readObject();
|
obj = ois.readObject();
|
||||||
} catch (java.io.IOException | java.lang.ClassNotFoundException e) {
|
} catch (java.io.IOException | java.lang.ClassNotFoundException e) {
|
||||||
logger.warn("Unable to deserialize object", e.getMessage(), e);
|
ActiveMQUtilLogger.LOGGER.failedToDeserializeObject(e);
|
||||||
obj = null;
|
obj = null;
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -23,7 +23,7 @@ import java.nio.file.Files;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashSet;
|
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_EXECUTE;
|
||||||
import static java.nio.file.attribute.PosixFilePermission.GROUP_READ;
|
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 {
|
public class FileUtil {
|
||||||
|
|
||||||
private static final Logger logger = Logger.getLogger(FileUtil.class);
|
|
||||||
|
|
||||||
public static void makeExec(File file) throws IOException {
|
public static void makeExec(File file) throws IOException {
|
||||||
try {
|
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)));
|
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) {
|
if (files == null) {
|
||||||
logger.warn("Could not list files to clean up in: " + directory.getAbsolutePath());
|
ActiveMQUtilLogger.LOGGER.failedListFilesToCleanup(directory.getAbsolutePath());
|
||||||
} else {
|
} else {
|
||||||
for (String file : files) {
|
for (String file : files) {
|
||||||
File f = new File(directory, file);
|
File f = new File(directory, file);
|
||||||
if (!deleteDirectory(f)) {
|
if (!deleteDirectory(f)) {
|
||||||
logger.warn("Failed to clean up file: " + f.getAbsolutePath());
|
ActiveMQUtilLogger.LOGGER.failedToCleanupFile(f.getAbsolutePath());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue