From 7a2c23b3ad83eab0eed5b990c70a1603447d5ee5 Mon Sep 17 00:00:00 2001 From: "Singla, Rajiv (rs153v)" Date: Wed, 15 Aug 2018 11:46:10 -0400 Subject: Standalone TCA with EELF Logger Issue-ID: DCAEGEN2-633 Change-Id: I4da76b532021c0d6248455e7bd6e77f4614c35a7 Signed-off-by: Singla, Rajiv (rs153v) --- .../utils/eelf/logger/api/info/AppLogInfo.java | 101 ++++++++++++++++ .../utils/eelf/logger/api/info/CodeLogInfo.java | 55 +++++++++ .../eelf/logger/api/info/CustomFieldsLogInfo.java | 62 ++++++++++ .../utils/eelf/logger/api/info/ErrorLogInfo.java | 76 ++++++++++++ .../dcae/utils/eelf/logger/api/info/LogInfo.java | 30 +++++ .../eelf/logger/api/info/LogLevelCategory.java | 36 ++++++ .../utils/eelf/logger/api/info/MessageLogInfo.java | 62 ++++++++++ .../utils/eelf/logger/api/info/MiscLogInfo.java | 45 +++++++ .../eelf/logger/api/info/NagiosAlertLevel.java | 52 +++++++++ .../eelf/logger/api/info/RequestIdLogInfo.java | 44 +++++++ .../eelf/logger/api/info/RequestStatusCode.java | 32 +++++ .../eelf/logger/api/info/RequestTimingLogInfo.java | 64 ++++++++++ .../eelf/logger/api/info/ResponseLogInfo.java | 81 +++++++++++++ .../utils/eelf/logger/api/info/ServiceLogInfo.java | 61 ++++++++++ .../eelf/logger/api/info/TargetServiceLogInfo.java | 54 +++++++++ .../utils/eelf/logger/api/info/package-info.java | 28 +++++ .../dcae/utils/eelf/logger/api/log/AuditLog.java | 130 +++++++++++++++++++++ .../dcae/utils/eelf/logger/api/log/DebugLog.java | 76 ++++++++++++ .../utils/eelf/logger/api/log/EELFLogFactory.java | 85 ++++++++++++++ .../dcae/utils/eelf/logger/api/log/EELFLogger.java | 67 +++++++++++ .../eelf/logger/api/log/EELFLoggerContext.java | 56 +++++++++ .../dcae/utils/eelf/logger/api/log/ErrorLog.java | 93 +++++++++++++++ .../dcae/utils/eelf/logger/api/log/MetricLog.java | 130 +++++++++++++++++++++ .../utils/eelf/logger/api/log/package-info.java | 23 ++++ .../utils/eelf/logger/api/noop/NoOpAuditLog.java | 90 ++++++++++++++ .../utils/eelf/logger/api/noop/NoOpDebugLog.java | 56 +++++++++ .../utils/eelf/logger/api/noop/NoOpEELFLogger.java | 77 ++++++++++++ .../utils/eelf/logger/api/noop/NoOpErrorLog.java | 68 +++++++++++ .../utils/eelf/logger/api/noop/NoOpMetricLog.java | 89 ++++++++++++++ .../utils/eelf/logger/api/noop/package-info.java | 26 +++++ .../utils/eelf/logger/api/spec/AppLogSpec.java | 32 +++++ .../utils/eelf/logger/api/spec/AuditLogSpec.java | 42 +++++++ .../utils/eelf/logger/api/spec/DebugLogSpec.java | 34 ++++++ .../utils/eelf/logger/api/spec/ErrorLogSpec.java | 42 +++++++ .../utils/eelf/logger/api/spec/MetricLogSpec.java | 36 ++++++ .../eelf/logger/api/spec/OptionalLogSpec.java | 39 +++++++ .../utils/eelf/logger/api/spec/package-info.java | 28 +++++ 37 files changed, 2202 insertions(+) create mode 100644 eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/info/AppLogInfo.java create mode 100644 eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/info/CodeLogInfo.java create mode 100644 eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/info/CustomFieldsLogInfo.java create mode 100644 eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/info/ErrorLogInfo.java create mode 100644 eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/info/LogInfo.java create mode 100644 eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/info/LogLevelCategory.java create mode 100644 eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/info/MessageLogInfo.java create mode 100644 eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/info/MiscLogInfo.java create mode 100644 eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/info/NagiosAlertLevel.java create mode 100644 eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/info/RequestIdLogInfo.java create mode 100644 eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/info/RequestStatusCode.java create mode 100644 eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/info/RequestTimingLogInfo.java create mode 100644 eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/info/ResponseLogInfo.java create mode 100644 eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/info/ServiceLogInfo.java create mode 100644 eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/info/TargetServiceLogInfo.java create mode 100644 eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/info/package-info.java create mode 100644 eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/log/AuditLog.java create mode 100644 eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/log/DebugLog.java create mode 100644 eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/log/EELFLogFactory.java create mode 100644 eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/log/EELFLogger.java create mode 100644 eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/log/EELFLoggerContext.java create mode 100644 eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/log/ErrorLog.java create mode 100644 eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/log/MetricLog.java create mode 100644 eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/log/package-info.java create mode 100644 eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/noop/NoOpAuditLog.java create mode 100644 eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/noop/NoOpDebugLog.java create mode 100644 eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/noop/NoOpEELFLogger.java create mode 100644 eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/noop/NoOpErrorLog.java create mode 100644 eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/noop/NoOpMetricLog.java create mode 100644 eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/noop/package-info.java create mode 100644 eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/spec/AppLogSpec.java create mode 100644 eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/spec/AuditLogSpec.java create mode 100644 eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/spec/DebugLogSpec.java create mode 100644 eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/spec/ErrorLogSpec.java create mode 100644 eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/spec/MetricLogSpec.java create mode 100644 eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/spec/OptionalLogSpec.java create mode 100644 eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/spec/package-info.java (limited to 'eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils') diff --git a/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/info/AppLogInfo.java b/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/info/AppLogInfo.java new file mode 100644 index 0000000..bdce8d1 --- /dev/null +++ b/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/info/AppLogInfo.java @@ -0,0 +1,101 @@ +/* + * ================================================================================ + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + * + */ + +package org.onap.dcae.utils.eelf.logger.api.info; + +/** + * Captures information about application which is doing the logging. All app log fields must remain same for + * the whole duration of the application once its instance is created. + * + * @author Rajiv Singla + */ +public interface AppLogInfo extends LogInfo { + + /** + * Required field contains UUID which identifies this service instance inside an inventory management system + * (e.g. A&AI) to reference/manage this service as a unit + * + * @return remote VM Name or service the request is acting upon. + */ + String getServiceInstanceID(); + + /** + * Required field contains a universally unique identifier used to differentiate between multiple instances of + * the same (named), log writing service/application. Its value is set at instance creation time (and read by it, + * e.g. at start/initialization time from the environment). This value should be picked up by the component + * instance from its configuration file and subsequently used to enable differentiating log records created by + * multiple, locally load balanced EELF component or sub component instances that are otherwise identically + * configured. + * + * @return instance UUID + */ + String getInstanceUUID(); + + /** + * Optional field contains VM Name where app is deployed. + * DCAE sub components should populate this field but it can be empty if + * determined that its value can be added by the log files collecting agent itself (e.g. Splunk). + *

+ * Example: host.vm.name.com + *

+ * + * @return virtual server name + */ + String getVirtualServerName(); + + /** + * Optional field contains the logging component host server’s IP address. + *

+ * Example: 127.0.0.100 + *

+ * + * @return server ip address + */ + String getServerIPAddress(); + + /** + * Required field for VM's fully qualified domain name or hosting machine fully qualified domain name. + *

+ * Example: host.fqdn.com + *

+ * + * @return server host fully qualified domain name + */ + String getServerFQDN(); + + + /** + * Contains default values for {@link AppLogInfo} + */ + interface Defaults { + + String DEFAULT_SERVICE_INSTANCE_ID = "UNKNOWN_INSTANCE_ID"; + + String DEFAULT_INSTANCE_UUID = ""; + + String DEFAULT_VIRTUAL_SERVER_NAME = ""; + + String DEFAULT_SERVER_IP_ADDRESS = "UNKNOWN_IP_ADDRESS"; + + String DEFAULT_SERVER_FQDN = "UNKNOWN_SERVER_FQDN"; + + } + + +} diff --git a/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/info/CodeLogInfo.java b/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/info/CodeLogInfo.java new file mode 100644 index 0000000..bea195d --- /dev/null +++ b/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/info/CodeLogInfo.java @@ -0,0 +1,55 @@ +/* + * ================================================================================ + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + * + */ + +package org.onap.dcae.utils.eelf.logger.api.info; + +/** + * Capture field required to log details about code which is generating the log message. + *

+ * NOTE: When using a logging framework(e.g. logback) implementation these fields may be automatically deduced - so + * settings these fields is not required by the application and even if application sets these fields the logging + * framework may ignore it + * + *

+ * + * @author Rajiv Singla + */ +public interface CodeLogInfo extends LogInfo { + + + /** + * Optional field used if wanting to trace processing of a request over a number of sub-components of a single EELF + * component. It should be preceded by a log record that establishes its chaining back to the corresponding + * requestID. + * + * @return thread ID used to trace processing of request over number of sub-components of single EELF Component. + */ + String getThreadId(); + + + /** + * Optional field: If available for OO programing languages that support this concept. This is the name of the + * class that has caused the log record to be created. + * + * @return name of the class that has the caused the log record to be created + */ + String getClassName(); + + +} diff --git a/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/info/CustomFieldsLogInfo.java b/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/info/CustomFieldsLogInfo.java new file mode 100644 index 0000000..634afa6 --- /dev/null +++ b/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/info/CustomFieldsLogInfo.java @@ -0,0 +1,62 @@ +/* + * ================================================================================ + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + * + */ + +package org.onap.dcae.utils.eelf.logger.api.info; + +/** + * Captures fields required to log Custom fields + * + * @author Rajiv Singla + */ +public interface CustomFieldsLogInfo extends LogInfo { + + /** + * Optional field that can be used by developers to include additional application-specific + * information to support operations and troubleshooting of the system. + * + * @return additional application-specific information to support operations and troubleshooting of the system. + */ + String getCustomField1(); + + /** + * Optional field that can be used by developers to include additional application-specific + * information to support operations and troubleshooting of the system. + * + * @return additional application-specific information to support operations and troubleshooting of the system. + */ + String getCustomField2(); + + /** + * Optional field that can be used by developers to include additional application-specific + * information to support operations and troubleshooting of the system. + * + * @return additional application-specific information to support operations and troubleshooting of the system. + */ + String getCustomField3(); + + /** + * Optional field that can be used by developers to include additional application-specific + * information to support operations and troubleshooting of the system. + * + * @return additional application-specific information to support operations and troubleshooting of the system. + */ + String getCustomField4(); + + +} diff --git a/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/info/ErrorLogInfo.java b/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/info/ErrorLogInfo.java new file mode 100644 index 0000000..876037c --- /dev/null +++ b/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/info/ErrorLogInfo.java @@ -0,0 +1,76 @@ +/* + * ================================================================================ + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + * + */ + +package org.onap.dcae.utils.eelf.logger.api.info; + +/** + * Captures fields required to log error related information + * + * @author Rajiv Singla + */ +public interface ErrorLogInfo extends LogInfo { + + + /** + * Required field contains an error code representing the error condition. The codes can be chose by + * the logging application but they should adhere to the guidelines embodied in the table below: + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Error typeNotes
100Permission errors
200Availability errors/Timeouts
300Data errors
400Schema errors
500Business process errors
900Unknown Errors
+ * + * @return error Code + */ + Integer getErrorCode(); + + + /** + * Required field contains a human readable description of the error condition. + * + * @return human readable description of the error condition + */ + String getErrorDescription(); + +} diff --git a/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/info/LogInfo.java b/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/info/LogInfo.java new file mode 100644 index 0000000..4a3680f --- /dev/null +++ b/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/info/LogInfo.java @@ -0,0 +1,30 @@ +/* + * ================================================================================ + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + * + */ + +package org.onap.dcae.utils.eelf.logger.api.info; + +import java.io.Serializable; + +/** + * Marker interface for all EELF Logging Information Components + * + * @author Rajiv Singla + */ +public interface LogInfo extends Serializable { +} diff --git a/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/info/LogLevelCategory.java b/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/info/LogLevelCategory.java new file mode 100644 index 0000000..665a280 --- /dev/null +++ b/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/info/LogLevelCategory.java @@ -0,0 +1,36 @@ +/* + * ================================================================================ + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + * + */ + +package org.onap.dcae.utils.eelf.logger.api.info; + +/** + * Captures various logging levels. + * NOTE: Enum ordered signifies low to high log level severity + * + * @author Rajiv Singla + */ +public enum LogLevelCategory implements LogInfo { + + DEBUG, + INFO, + WARN, + ERROR, + FATAL; + +} diff --git a/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/info/MessageLogInfo.java b/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/info/MessageLogInfo.java new file mode 100644 index 0000000..cd53ccf --- /dev/null +++ b/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/info/MessageLogInfo.java @@ -0,0 +1,62 @@ +/* + * ================================================================================ + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + * + */ + +package org.onap.dcae.utils.eelf.logger.api.info; + +import java.util.Date; + +/** + * Captures fields required for message level logging. These fields are mostly derived fields. For example: creation + * timestamp can be auto generated based on system time, {@link RequestStatusCode} and {@link NagiosAlertLevel} can be + * derived based on {@link LogLevelCategory} + * + * @author Rajiv Singla + */ +public interface MessageLogInfo extends LogInfo { + + + /** + * Required field to capture when the message was created + * The value should be represented in UTC and formatted according to ISO 8601. + *

+ * Example: 2015-06-03T13:21:58+00:00 + *

+ * + * @return message creation creationTimestamp + */ + Date getCreationTimestamp(); + + /** + * Required field contains a value of COMPLETE or ERROR to indicate high level success or failure of the + * request related activities. + * + * @return value to indicate high level success or failure of the request related activities + */ + RequestStatusCode getStatusCode(); + + + /** + * Optional field for Nagios monitoring/alerting severity code + * + * @return nagios monitoring/alerting severity code + */ + NagiosAlertLevel getAlertSeverity(); + + +} diff --git a/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/info/MiscLogInfo.java b/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/info/MiscLogInfo.java new file mode 100644 index 0000000..bf1e451 --- /dev/null +++ b/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/info/MiscLogInfo.java @@ -0,0 +1,45 @@ +/* + * ================================================================================ + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + * + */ + +package org.onap.dcae.utils.eelf.logger.api.info; + +/** + * Captures optional / deprecated fields that can be populated as per EELF Logging Requirements + * + * @author Rajiv Singla + */ +public interface MiscLogInfo extends LogInfo { + + /** + * Optional field that can can be used to capture the flow of a transaction through the system by + * indicating the components and operations involved in processed. If present, it can be denoted by a comma + * separated list of components and applications. + * + * @return list of comma separated components and operations involved in processing + */ + String getProcessId(); + + /** + * This field is deprecated and should be left empty. + * + * @return deprecated field value - should be empty + */ + String getUnused(); + +} diff --git a/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/info/NagiosAlertLevel.java b/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/info/NagiosAlertLevel.java new file mode 100644 index 0000000..3da5fc3 --- /dev/null +++ b/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/info/NagiosAlertLevel.java @@ -0,0 +1,52 @@ +/* + * ================================================================================ + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + * + */ + +package org.onap.dcae.utils.eelf.logger.api.info; + +/** + * Enum for Nagios monitoring/alerting codes as per table below. + *

+ * + * + * + * + * + * + *
Return CodeService StateHost State
0OKUP
1WARNINGUP or DOWN/UNREACHABLE*
2CRITICALDOWN/UNREACHABLE
3UNKNOWNDOWN/UNREACHABLE
+ * + * @author Rajiv Singla + */ +public enum NagiosAlertLevel implements LogInfo { + + OK("0"), + WARNING("1"), + CRITICAL("2"), + UNKNOWN("3"); + + private String severityCode; + + NagiosAlertLevel(final String severityCode) { + this.severityCode = severityCode; + } + + public String getSeverityCode() { + return severityCode; + } + +} diff --git a/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/info/RequestIdLogInfo.java b/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/info/RequestIdLogInfo.java new file mode 100644 index 0000000..68d5a17 --- /dev/null +++ b/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/info/RequestIdLogInfo.java @@ -0,0 +1,44 @@ +/* + * ================================================================================ + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + * + */ + +package org.onap.dcae.utils.eelf.logger.api.info; + +/** + * Captures fields required for logging request information + * + * @author Rajiv Singla + */ +public interface RequestIdLogInfo extends LogInfo { + + /** + * Required field containing requestID which uniquely that identifies a single transaction request within the EELF + * platform. Its value is conforms to RFC4122 UUID. The requestID value is passed using a REST API from one + * EELF component to another via HTTP Headers named X-RequestID + *

+ * 724229c0-9945-11e5-bcde-0002a5d5c51b:1234 + *

+ * If receiving a composite requestID value, e.g. something of the form UUID-1:UUID-2, the receiving component + * should only use the UUID-1 portion (i.e. remove the “:” and any trailing suffix, e.g. UUID-2) as the requestID + * field value for its log files. + * + * @return requestID which uniquely that identifies a single transaction request within the EELF + */ + String getRequestId(); + +} diff --git a/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/info/RequestStatusCode.java b/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/info/RequestStatusCode.java new file mode 100644 index 0000000..b022b80 --- /dev/null +++ b/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/info/RequestStatusCode.java @@ -0,0 +1,32 @@ +/* + * ================================================================================ + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + * + */ + +package org.onap.dcae.utils.eelf.logger.api.info; + +/** + * Enum to indicate high level success or failure of the request related activities + * + * @author Rajiv Singla + */ +public enum RequestStatusCode { + + ERROR, + COMPLETE; + +} diff --git a/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/info/RequestTimingLogInfo.java b/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/info/RequestTimingLogInfo.java new file mode 100644 index 0000000..7448e69 --- /dev/null +++ b/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/info/RequestTimingLogInfo.java @@ -0,0 +1,64 @@ +/* + * ================================================================================ + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + * + */ + +package org.onap.dcae.utils.eelf.logger.api.info; + +import java.util.Date; + +/** + * Captures Logging fields required for request timing related information + * + * @author Rajiv Singla + */ +public interface RequestTimingLogInfo extends LogInfo { + + /** + * Required field containing creationTimestamp when the request processing started. + * The value should be represented in UTC and formatted according to ISO 8601. + *

+ * Example: 2015-06-03T13:21:58+00:00 + *

+ * + * @return request activity begin creationTimestamp + */ + Date getBeginTimestamp(); + + + /** + * Required field containing creationTimestamp when the request processed stopped. + * The value should be represented in UTC and formatted according to ISO 8601. + *

+ * Example: 2015-06-03T13:21:58+00:00 + *

+ * + * @return request activity end creationTimestamp + */ + Date getEndTimestamp(); + + + /** + * Required field contains the elapsed time to complete processing of an API call or transaction request (e.g., + * processing of a message that was received). This value should be the difference between EndTimestamp and + * BeginTimestamp fields and should be expressed in milliseconds. + * + * @return request processing elapsed time in milliseconds + */ + Long getElapsedTime(); + +} diff --git a/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/info/ResponseLogInfo.java b/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/info/ResponseLogInfo.java new file mode 100644 index 0000000..1929e7f --- /dev/null +++ b/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/info/ResponseLogInfo.java @@ -0,0 +1,81 @@ +/* + * ================================================================================ + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + * + */ + +package org.onap.dcae.utils.eelf.logger.api.info; + +/** + * Captures field required for logging Response information + * + * @author Rajiv Singla + */ +public interface ResponseLogInfo extends LogInfo { + + /** + * Required field contains application-specific response codes. While error codes are + * application-specific, they + * should conform categories mentioned in table below in order to provide consistency + *

+ * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Error typeNotes
0Success
100Permission errors
200Availability errors/Timeouts
300Data errors
400Schema errors
500Business process errors
900Unknown Errors
+ * + * @return application-specific error code + */ + Integer getResponseCode(); + + + /** + * Required field contains a human readable description of the {@link #getResponseCode()}. + * + * @return human readable description of the response code + */ + String getResponseDescription(); + +} diff --git a/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/info/ServiceLogInfo.java b/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/info/ServiceLogInfo.java new file mode 100644 index 0000000..0287cef --- /dev/null +++ b/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/info/ServiceLogInfo.java @@ -0,0 +1,61 @@ +/* + * ================================================================================ + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + * + */ + +package org.onap.dcae.utils.eelf.logger.api.info; + +/** + * Captures information about logging fields for application acting as service and handling requests from other + * applications + * + * @author Rajiv Singla + */ +public interface ServiceLogInfo extends LogInfo { + + /** + * Required field contains the developer given name of the ecomp component's exposed api (~='method', function') + * invoked. For example if the application is exposing a REST interface and exposing runtime metrics then the + * service name can be: appName-getMetrics + * + * @return name of the API invoked by the application + */ + String getServiceName(); + + + /** + * Optional field contains the name of the client or user invoking the service. + * It may be an application, user name or mech id. + * + * @return name of the client or user invoking the API if known + */ + String getPartnerName(); + + + /** + * Optional field contains requesting remote client application’s IP address. Use UNKNOWN or an empty string if not + * available. + * + * @return remote client application’s IP address + */ + String getClientIPAddress(); + + +} + + + diff --git a/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/info/TargetServiceLogInfo.java b/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/info/TargetServiceLogInfo.java new file mode 100644 index 0000000..d9b1f98 --- /dev/null +++ b/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/info/TargetServiceLogInfo.java @@ -0,0 +1,54 @@ +/* + * ================================================================================ + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + * + */ + +package org.onap.dcae.utils.eelf.logger.api.info; + +/** + * Captures fields for logging application which is calling an external/target service + * + * @author Rajiv Singla + */ +public interface TargetServiceLogInfo extends LogInfo { + + /** + * Required field containing name of EELF component/sub component or non-EELF entity which is invoked by the + * logging application + * + * @return target entity name which is invoked by the logging application + */ + String getTargetEntity(); + + + /** + * Required field containing name of External API/operation activities invoked on {@link #getTargetEntity()} + * + * @return target service name invoked by the logging application + */ + String getTargetServiceName(); + + + /** + * Optional field containing target VNF or VM being acted upon by the logging application. This field contains the + * virtual entity that is the target of the action for example the FQDN of the target virtual entity + * + * @return target Virtual Entity + */ + String getTargetVirtualEntity(); + +} diff --git a/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/info/package-info.java b/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/info/package-info.java new file mode 100644 index 0000000..45bddd1 --- /dev/null +++ b/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/info/package-info.java @@ -0,0 +1,28 @@ +/* + * ================================================================================ + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + * + */ + +/** + * Captures EELF logging information about various types. + *

+ * The logging information is segregated into various information different types as to their relevance in particular + * cases. + * + * @author Rajiv Singla + */ +package org.onap.dcae.utils.eelf.logger.api.info; diff --git a/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/log/AuditLog.java b/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/log/AuditLog.java new file mode 100644 index 0000000..952176e --- /dev/null +++ b/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/log/AuditLog.java @@ -0,0 +1,130 @@ +/* + * ================================================================================ + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + * + */ + +package org.onap.dcae.utils.eelf.logger.api.log; + + +import org.onap.dcae.utils.eelf.logger.api.info.LogLevelCategory; +import org.onap.dcae.utils.eelf.logger.api.spec.AuditLogSpec; +import org.onap.dcae.utils.eelf.logger.api.spec.OptionalLogSpec; + +/** + * Audit Log captures all log levels supported by audit specifications + * + * @author Rajiv Singla + */ +public interface AuditLog { + + /** + * Logs audit message with provided {@link LogLevelCategory} + * + * @param logLevelCategory log level category + * @param message log message + * @param auditLogSpec audit log spec + * @param optionalLogSpec optional log spec + * @param args argument values for log message interpolation + */ + void log(LogLevelCategory logLevelCategory, String message, AuditLogSpec auditLogSpec, + OptionalLogSpec optionalLogSpec, String... args); + + /** + * Logs audit message with provided {@link LogLevelCategory} and with default {@link OptionalLogSpec} + * + * @param logLevelCategory log level category + * @param message log message + * @param auditLogSpec audit log spec + * @param args argument values for log message interpolation + */ + void log(LogLevelCategory logLevelCategory, String message, AuditLogSpec auditLogSpec, String... args); + + + /** + * Logs audit message with provided INFO {@link LogLevelCategory} + * + * @param message log message + * @param auditLogSpec audit log spec + * @param args argument values for log message interpolation + */ + void info(String message, AuditLogSpec auditLogSpec, OptionalLogSpec optionalLogSpec, String... args); + + /** + * Logs audit message with provided INFO {@link LogLevelCategory} and with default {@link OptionalLogSpec} + * + * @param message log message + * @param auditLogSpec audit log spec + * @param args argument values for log message interpolation + */ + void info(String message, AuditLogSpec auditLogSpec, String... args); + + + /** + * Logs audit message with provided WARN {@link LogLevelCategory} + * + * @param message log message + * @param auditLogSpec audit log spec + * @param args argument values for log message interpolation + */ + void warn(String message, AuditLogSpec auditLogSpec, OptionalLogSpec optionalLogSpec, String... args); + + /** + * Logs audit message with provided WARN {@link LogLevelCategory} and with default {@link OptionalLogSpec} + * + * @param message log message + * @param auditLogSpec audit log spec + * @param args argument values for log message interpolation + */ + void warn(String message, AuditLogSpec auditLogSpec, String... args); + + /** + * Logs audit message with provided ERROR {@link LogLevelCategory} + * + * @param message log message + * @param auditLogSpec audit log spec + * @param args argument values for log message interpolation + */ + void error(String message, AuditLogSpec auditLogSpec, OptionalLogSpec optionalLogSpec, String... args); + + /** + * Logs audit message with provided ERROR {@link LogLevelCategory} and with default {@link OptionalLogSpec} + * + * @param message log message + * @param auditLogSpec audit log spec + * @param args argument values for log message interpolation + */ + void error(String message, AuditLogSpec auditLogSpec, String... args); + + /** + * Logs audit message with provided FATAL {@link LogLevelCategory} + * + * @param message log message + * @param auditLogSpec audit log spec + * @param args argument values for log message interpolation + */ + void fatal(String message, AuditLogSpec auditLogSpec, OptionalLogSpec optionalLogSpec, String... args); + + /** + * Logs audit message with provided FATAL {@link LogLevelCategory} and with default {@link OptionalLogSpec} + * + * @param message log message + * @param auditLogSpec audit log spec + * @param args argument values for log message interpolation + */ + void fatal(String message, AuditLogSpec auditLogSpec, String... args); + +} diff --git a/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/log/DebugLog.java b/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/log/DebugLog.java new file mode 100644 index 0000000..98a0921 --- /dev/null +++ b/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/log/DebugLog.java @@ -0,0 +1,76 @@ +/* + * ================================================================================ + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + * + */ + +package org.onap.dcae.utils.eelf.logger.api.log; + +import org.onap.dcae.utils.eelf.logger.api.info.LogLevelCategory; +import org.onap.dcae.utils.eelf.logger.api.spec.DebugLogSpec; +import org.onap.dcae.utils.eelf.logger.api.spec.OptionalLogSpec; + +/** + * Debug Log captures all log levels supported by debug specifications. + *

+ * NOTE: DEBUG Log is optional as per EELF Specifications + * + * @author Rajiv Singla + */ +public interface DebugLog { + + /** + * Logs debug message with provided {@link LogLevelCategory} + * + * @param logLevelCategory log level category + * @param message log message + * @param debugLogSpec debug log spec + * @param optionalLogSpec optional log spec + * @param args argument values for log message interpolation + */ + void log(LogLevelCategory logLevelCategory, String message, DebugLogSpec debugLogSpec, + OptionalLogSpec optionalLogSpec, String... args); + + /** + * Logs debug message with provided {@link LogLevelCategory} and with default {@link OptionalLogSpec} + * + * @param logLevelCategory log level category + * @param message log message + * @param debugLogSpec debug log spec + * @param args argument values for log message interpolation + */ + void log(LogLevelCategory logLevelCategory, String message, DebugLogSpec debugLogSpec, String... args); + + + /** + * Logs debug message with provided DEBUG {@link LogLevelCategory} + * + * @param message log message + * @param debugLogSpec debug log spec + * @param args argument values for log message interpolation + */ + void debug(String message, DebugLogSpec debugLogSpec, OptionalLogSpec optionalLogSpec, String... args); + + /** + * Logs debug message with provided DEBUG {@link LogLevelCategory} and with default {@link OptionalLogSpec} + * + * @param message log message + * @param debugLogSpec debug log spec + * @param args argument values for log message interpolation + */ + void debug(String message, DebugLogSpec debugLogSpec, String... args); + +} diff --git a/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/log/EELFLogFactory.java b/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/log/EELFLogFactory.java new file mode 100644 index 0000000..2cfb2ec --- /dev/null +++ b/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/log/EELFLogFactory.java @@ -0,0 +1,85 @@ +/* + * ================================================================================ + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + * + */ + +package org.onap.dcae.utils.eelf.logger.api.log; + + +import org.onap.dcae.utils.eelf.logger.api.noop.NoOpEELFLogger; + +import java.lang.reflect.InvocationTargetException; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.ServiceLoader; +import java.util.WeakHashMap; + +/** + * EELF Log Factory uses {@link ServiceLoader} to load implementations of {@link EELFLogger} in application + * classpath. If no EELF Logging implementations are found - eelf logging is disabled and {@link NoOpEELFLogger} + * is used. + * + * @author Rajiv Singla + */ +public class EELFLogFactory { + + private static final ServiceLoader SERVICE_LOADER = ServiceLoader.load(EELFLogger.class); + private static final Map, EELFLogger> LOGGER_CACHE = new WeakHashMap<>(64); + + private static List loggerImplementations = new LinkedList<>(); + + static { + + for (EELFLogger loggerImplementation : SERVICE_LOADER) { + loggerImplementations.add(loggerImplementation); + } + + if (loggerImplementations.isEmpty()) { + System.err.println( + "EELF LOGGING ERROR: Unable to find any EELF Logger Implementations in the classpath."); + System.err.println("=============EELF LOGGING IS DISABLED================"); + loggerImplementations.add(NoOpEELFLogger.getInstance()); + } + + } + + private EELFLogFactory() { + // private constructor + } + + public static EELFLogger getLogger(Class clazz) { + + if (LOGGER_CACHE.get(clazz) != null) { + return LOGGER_CACHE.get(clazz); + } + + EELFLogger EELFLogger = null; + try { + EELFLogger = loggerImplementations.get(0).getClass().getConstructor(Class.class) + .newInstance(clazz); + return EELFLogger; + + } catch ( + InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException e) { + throw new IllegalStateException("Error while Creating EELF Logger", e); + } + + } + + +} diff --git a/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/log/EELFLogger.java b/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/log/EELFLogger.java new file mode 100644 index 0000000..500d814 --- /dev/null +++ b/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/log/EELFLogger.java @@ -0,0 +1,67 @@ +/* + * ================================================================================ + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + * + */ + +package org.onap.dcae.utils.eelf.logger.api.log; + +/** + * EELF Logger is main abstraction which applications use to log EELF Compliant log messages + * + * @author Rajiv Singla + */ +public interface EELFLogger { + + /** + * Provides Audit Log + * + * @return Audit log + */ + AuditLog auditLog(); + + + /** + * Provides Metric Log + * + * @return metric log + */ + MetricLog metricLog(); + + /** + * Provides Error Log + * + * @return error log + */ + ErrorLog errorLog(); + + + /** + * Provides Debug Log + * + * @return debug log + */ + DebugLog debugLog(); + + /** + * Provides logging context + * + * @return logging context + */ + EELFLoggerContext loggingContext(); + + +} diff --git a/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/log/EELFLoggerContext.java b/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/log/EELFLoggerContext.java new file mode 100644 index 0000000..5910da5 --- /dev/null +++ b/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/log/EELFLoggerContext.java @@ -0,0 +1,56 @@ +/* + * ================================================================================ + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + * + */ + +package org.onap.dcae.utils.eelf.logger.api.log; + + +import org.onap.dcae.utils.eelf.logger.api.spec.AppLogSpec; + +/** + * EELF Logger Context contains fields are set during application creation time and are fixed for the entire + * duration of the application lifetime + * + * @author Rajiv Singla + */ +public interface EELFLoggerContext { + + /** + * Returns App Log Spec + * + * @return current app log spec + */ + AppLogSpec getAppLogSpec(); + + + /** + * Sets new App Log Spec + * + * @param appLogSpec new app log spec + */ + void setAppLogSpec(AppLogSpec appLogSpec); + + + /** + * Returns true if logging context is already initialized + * + * @return true if logger context is already initialized + */ + boolean isInitialized(); + +} diff --git a/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/log/ErrorLog.java b/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/log/ErrorLog.java new file mode 100644 index 0000000..6b27755 --- /dev/null +++ b/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/log/ErrorLog.java @@ -0,0 +1,93 @@ +/* + * ================================================================================ + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + * + */ + +package org.onap.dcae.utils.eelf.logger.api.log; + + +import org.onap.dcae.utils.eelf.logger.api.info.LogLevelCategory; +import org.onap.dcae.utils.eelf.logger.api.spec.ErrorLogSpec; +import org.onap.dcae.utils.eelf.logger.api.spec.OptionalLogSpec; + +/** + * @author Rajiv Singla + */ +public interface ErrorLog { + + /** + * Logs error message with provided {@link LogLevelCategory} + * + * @param logLevelCategory log level category + * @param message log message + * @param errorLogSpec error log spec + * @param optionalLogSpec optional log spec + * @param args argument values for log message interpolation + */ + void log(LogLevelCategory logLevelCategory, String message, ErrorLogSpec errorLogSpec, + OptionalLogSpec optionalLogSpec, String... args); + + /** + * Logs error message with provided {@link LogLevelCategory} and with default {@link OptionalLogSpec} + * + * @param logLevelCategory log level category + * @param message log message + * @param errorLogSpec error log spec + * @param args argument values for log message interpolation + */ + void log(LogLevelCategory logLevelCategory, String message, ErrorLogSpec errorLogSpec, String... args); + + + /** + * Logs error message with ERROR {@link LogLevelCategory} + * + * @param message log message + * @param errorLogSpec error log spec + * @param args argument values for log message interpolation + */ + void error(String message, ErrorLogSpec errorLogSpec, OptionalLogSpec optionalLogSpec, String... args); + + /** + * Logs error message with ERROR {@link LogLevelCategory} and with default {@link OptionalLogSpec} + * + * @param message log message + * @param errorLogSpec error log spec + * @param args argument values for log message interpolation + */ + void error(String message, ErrorLogSpec errorLogSpec, String... args); + + + /** + * Logs error message with WARN {@link LogLevelCategory} + * + * @param message log message + * @param errorLogSpec error log spec + * @param args argument values for log message interpolation + */ + void warn(String message, ErrorLogSpec errorLogSpec, OptionalLogSpec optionalLogSpec, String... args); + + /** + * Logs error message with WARN {@link LogLevelCategory} and with default {@link OptionalLogSpec} + * + * @param message log message + * @param errorLogSpec error log spec + * @param args argument values for log message interpolation + */ + void warn(String message, ErrorLogSpec errorLogSpec, String... args); + + +} diff --git a/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/log/MetricLog.java b/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/log/MetricLog.java new file mode 100644 index 0000000..ebc33ca --- /dev/null +++ b/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/log/MetricLog.java @@ -0,0 +1,130 @@ +/* + * ================================================================================ + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + * + */ + +package org.onap.dcae.utils.eelf.logger.api.log; + + +import org.onap.dcae.utils.eelf.logger.api.info.LogLevelCategory; +import org.onap.dcae.utils.eelf.logger.api.spec.MetricLogSpec; +import org.onap.dcae.utils.eelf.logger.api.spec.OptionalLogSpec; + +/** + * Metric Log captures all log levels supported by metric specifications + * + * @author Rajiv Singla + */ +public interface MetricLog { + + /** + * Logs metric message with provided {@link LogLevelCategory} + * + * @param logLevelCategory log level category + * @param message log message + * @param metricLogSpec metric log spec + * @param optionalLogSpec optional log spec + * @param args argument values for log message interpolation + */ + void log(LogLevelCategory logLevelCategory, String message, MetricLogSpec metricLogSpec, + OptionalLogSpec optionalLogSpec, String... args); + + /** + * Logs metric message with provided {@link LogLevelCategory} and with default {@link OptionalLogSpec} + * + * @param logLevelCategory log level category + * @param message log message + * @param metricLogSpec metric log spec + * @param args argument values for log message interpolation + */ + void log(LogLevelCategory logLevelCategory, String message, MetricLogSpec metricLogSpec, String... args); + + + /** + * Logs metric message with provided INFO {@link LogLevelCategory} + * + * @param message log message + * @param metricLogSpec metric log spec + * @param args argument values for log message interpolation + */ + void info(String message, MetricLogSpec metricLogSpec, OptionalLogSpec optionalLogSpec, String... args); + + /** + * Logs metric message with provided INFO {@link LogLevelCategory} and with default {@link OptionalLogSpec} + * + * @param message log message + * @param metricLogSpec metric log spec + * @param args argument values for log message interpolation + */ + void info(String message, MetricLogSpec metricLogSpec, String... args); + + + /** + * Logs metric message with provided WARN {@link LogLevelCategory} + * + * @param message log message + * @param metricLogSpec metric log spec + * @param args argument values for log message interpolation + */ + void warn(String message, MetricLogSpec metricLogSpec, OptionalLogSpec optionalLogSpec, String... args); + + /** + * Logs metric message with provided WARN {@link LogLevelCategory} and with default {@link OptionalLogSpec} + * + * @param message log message + * @param metricLogSpec metric log spec + * @param args argument values for log message interpolation + */ + void warn(String message, MetricLogSpec metricLogSpec, String... args); + + /** + * Logs metric message with provided ERROR {@link LogLevelCategory} + * + * @param message log message + * @param metricLogSpec metric log spec + * @param args argument values for log message interpolation + */ + void error(String message, MetricLogSpec metricLogSpec, OptionalLogSpec optionalLogSpec, String... args); + + /** + * Logs metric message with provided ERROR {@link LogLevelCategory} and with default {@link OptionalLogSpec} + * + * @param message log message + * @param metricLogSpec metric log spec + * @param args argument values for log message interpolation + */ + void error(String message, MetricLogSpec metricLogSpec, String... args); + + /** + * Logs metric message with provided FATAL {@link LogLevelCategory} + * + * @param message log message + * @param metricLogSpec metric log spec + * @param args argument values for log message interpolation + */ + void fatal(String message, MetricLogSpec metricLogSpec, OptionalLogSpec optionalLogSpec, String... args); + + /** + * Logs metric message with provided FATAL {@link LogLevelCategory} and with default {@link OptionalLogSpec} + * + * @param message log message + * @param metricLogSpec metric log spec + * @param args argument values for log message interpolation + */ + void fatal(String message, MetricLogSpec metricLogSpec, String... args); + +} diff --git a/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/log/package-info.java b/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/log/package-info.java new file mode 100644 index 0000000..e24ccc9 --- /dev/null +++ b/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/log/package-info.java @@ -0,0 +1,23 @@ +/* + * ================================================================================ + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + * + */ + +/** + * Contains Logging API contracts for various EELF Logs (e.g. Audit, Metric, Error, Debug etc) + */ +package org.onap.dcae.utils.eelf.logger.api.log; diff --git a/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/noop/NoOpAuditLog.java b/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/noop/NoOpAuditLog.java new file mode 100644 index 0000000..6c1c583 --- /dev/null +++ b/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/noop/NoOpAuditLog.java @@ -0,0 +1,90 @@ +/* + * ================================================================================ + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + * + */ + +package org.onap.dcae.utils.eelf.logger.api.noop; + + +import org.onap.dcae.utils.eelf.logger.api.info.LogLevelCategory; +import org.onap.dcae.utils.eelf.logger.api.log.AuditLog; +import org.onap.dcae.utils.eelf.logger.api.spec.AuditLogSpec; +import org.onap.dcae.utils.eelf.logger.api.spec.OptionalLogSpec; + +/** + * A no operation implementation of AuditLog + * + * @author Rajiv Singla + */ +public class NoOpAuditLog implements AuditLog { + + @Override + public void log(final LogLevelCategory logLevelCategory, final String message, final AuditLogSpec auditLogSpec, + final OptionalLogSpec optionalLogSpec, final String... args) { + // no operation + } + + @Override + public void log(final LogLevelCategory logLevelCategory, final String message, final AuditLogSpec auditLogSpec, + final String... args) { + // no operation + } + + @Override + public void info(final String message, final AuditLogSpec auditLogSpec, final OptionalLogSpec optionalLogSpec, + final String... args) { + // no operation + } + + @Override + public void info(final String message, final AuditLogSpec auditLogSpec, final String... args) { + // no operation + } + + @Override + public void warn(final String message, final AuditLogSpec auditLogSpec, final OptionalLogSpec optionalLogSpec, + final String... args) { + // no operation + } + + @Override + public void warn(final String message, final AuditLogSpec auditLogSpec, final String... args) { + // no operation + } + + @Override + public void error(final String message, final AuditLogSpec auditLogSpec, final OptionalLogSpec optionalLogSpec, + final String... args) { + // no operation + } + + @Override + public void error(final String message, final AuditLogSpec auditLogSpec, final String... args) { + // no operation + } + + @Override + public void fatal(final String message, final AuditLogSpec auditLogSpec, final OptionalLogSpec optionalLogSpec, + final String... args) { + // no operation + } + + @Override + public void fatal(final String message, final AuditLogSpec auditLogSpec, final String... args) { + // no operation + } +} diff --git a/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/noop/NoOpDebugLog.java b/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/noop/NoOpDebugLog.java new file mode 100644 index 0000000..dd36b52 --- /dev/null +++ b/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/noop/NoOpDebugLog.java @@ -0,0 +1,56 @@ +/* + * ================================================================================ + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + * + */ + +package org.onap.dcae.utils.eelf.logger.api.noop; + + +import org.onap.dcae.utils.eelf.logger.api.info.LogLevelCategory; +import org.onap.dcae.utils.eelf.logger.api.log.DebugLog; +import org.onap.dcae.utils.eelf.logger.api.spec.DebugLogSpec; +import org.onap.dcae.utils.eelf.logger.api.spec.OptionalLogSpec; + +/** + * A no operation implementation of Debug Log + * + * @author Rajiv Singla + */ +public class NoOpDebugLog implements DebugLog { + @Override + public void log(final LogLevelCategory logLevelCategory, final String message, final DebugLogSpec debugLogSpec, + final OptionalLogSpec optionalLogSpec, final String... args) { + // no operation + } + + @Override + public void log(final LogLevelCategory logLevelCategory, final String message, final DebugLogSpec debugLogSpec, + final String... args) { + // no operation + } + + @Override + public void debug(final String message, final DebugLogSpec debugLogSpec, final OptionalLogSpec optionalLogSpec, + final String... args) { + // no operation + } + + @Override + public void debug(final String message, final DebugLogSpec debugLogSpec, final String... args) { + // no operation + } +} diff --git a/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/noop/NoOpEELFLogger.java b/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/noop/NoOpEELFLogger.java new file mode 100644 index 0000000..c761ba1 --- /dev/null +++ b/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/noop/NoOpEELFLogger.java @@ -0,0 +1,77 @@ +/* + * ================================================================================ + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + * + */ + +package org.onap.dcae.utils.eelf.logger.api.noop; + + +import org.onap.dcae.utils.eelf.logger.api.log.AuditLog; +import org.onap.dcae.utils.eelf.logger.api.log.DebugLog; +import org.onap.dcae.utils.eelf.logger.api.log.EELFLogger; +import org.onap.dcae.utils.eelf.logger.api.log.EELFLoggerContext; +import org.onap.dcae.utils.eelf.logger.api.log.ErrorLog; +import org.onap.dcae.utils.eelf.logger.api.log.MetricLog; + +/** + * A no operation implementation of {@link EELFLogger} + * + * @author Rajiv Singla + */ +public class NoOpEELFLogger implements EELFLogger { + + private static final AuditLog NO_OP_AUDIT_LOG = new NoOpAuditLog(); + private static final MetricLog NO_OP_METRIC_LOG = new NoOpMetricLog(); + private static final ErrorLog NO_OP_ERROR_LOG = new NoOpErrorLog(); + private static final DebugLog NO_OP_DEBUG_LOG = new NoOpDebugLog(); + + private static final NoOpEELFLogger NO_OP_EELF_LOGGER = new NoOpEELFLogger(); + + private NoOpEELFLogger() { + // private constructor + } + + public static NoOpEELFLogger getInstance() { + return NO_OP_EELF_LOGGER; + } + + @Override + public AuditLog auditLog() { + return NO_OP_AUDIT_LOG; + } + + @Override + public MetricLog metricLog() { + return NO_OP_METRIC_LOG; + } + + @Override + public ErrorLog errorLog() { + return NO_OP_ERROR_LOG; + } + + @Override + public DebugLog debugLog() { + return NO_OP_DEBUG_LOG; + } + + @Override + public EELFLoggerContext loggingContext() { + return null; + } + +} diff --git a/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/noop/NoOpErrorLog.java b/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/noop/NoOpErrorLog.java new file mode 100644 index 0000000..c1b4e13 --- /dev/null +++ b/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/noop/NoOpErrorLog.java @@ -0,0 +1,68 @@ +/* + * ================================================================================ + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + * + */ + +package org.onap.dcae.utils.eelf.logger.api.noop; + + +import org.onap.dcae.utils.eelf.logger.api.info.LogLevelCategory; +import org.onap.dcae.utils.eelf.logger.api.log.ErrorLog; +import org.onap.dcae.utils.eelf.logger.api.spec.ErrorLogSpec; +import org.onap.dcae.utils.eelf.logger.api.spec.OptionalLogSpec; + +/** + * A no operation implementation of Error Log + * + * @author Rajiv Singla + */ +public class NoOpErrorLog implements ErrorLog { + + @Override + public void log(final LogLevelCategory logLevelCategory, final String message, final ErrorLogSpec errorLogSpec, + final OptionalLogSpec optionalLogSpec, final String... args) { + // no operation + } + + @Override + public void log(final LogLevelCategory logLevelCategory, final String message, final ErrorLogSpec errorLogSpec, + final String... args) { + // no operation + } + + @Override + public void error(final String message, final ErrorLogSpec errorLogSpec, final OptionalLogSpec optionalLogSpec, + final String... args) { + // no operation + } + + @Override + public void error(final String message, final ErrorLogSpec errorLogSpec, final String... args) { + // no operation + } + + @Override + public void warn(final String message, final ErrorLogSpec errorLogSpec, final OptionalLogSpec optionalLogSpec, + final String... args) { + // no operation + } + + @Override + public void warn(final String message, final ErrorLogSpec errorLogSpec, final String... args) { + // no operation + } +} diff --git a/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/noop/NoOpMetricLog.java b/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/noop/NoOpMetricLog.java new file mode 100644 index 0000000..1c67862 --- /dev/null +++ b/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/noop/NoOpMetricLog.java @@ -0,0 +1,89 @@ +/* + * ================================================================================ + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + * + */ + +package org.onap.dcae.utils.eelf.logger.api.noop; + + +import org.onap.dcae.utils.eelf.logger.api.info.LogLevelCategory; +import org.onap.dcae.utils.eelf.logger.api.log.MetricLog; +import org.onap.dcae.utils.eelf.logger.api.spec.MetricLogSpec; +import org.onap.dcae.utils.eelf.logger.api.spec.OptionalLogSpec; + +/** + * A no operation implementation of Metric Log + * + * @author Rajiv Singla + */ +public class NoOpMetricLog implements MetricLog { + @Override + public void log(final LogLevelCategory logLevelCategory, final String message, final MetricLogSpec metricLogSpec, + final OptionalLogSpec optionalLogSpec, final String... args) { + // no operation + } + + @Override + public void log(final LogLevelCategory logLevelCategory, final String message, final MetricLogSpec metricLogSpec, + final String... args) { + // no operation + } + + @Override + public void info(final String message, final MetricLogSpec metricLogSpec, final OptionalLogSpec optionalLogSpec, + final String... args) { + // no operation + } + + @Override + public void info(final String message, final MetricLogSpec metricLogSpec, final String... args) { + // no operation + } + + @Override + public void warn(final String message, final MetricLogSpec metricLogSpec, final OptionalLogSpec optionalLogSpec, + final String... args) { + // no operation + } + + @Override + public void warn(final String message, final MetricLogSpec metricLogSpec, final String... args) { + // no operation + } + + @Override + public void error(final String message, final MetricLogSpec metricLogSpec, final OptionalLogSpec optionalLogSpec, + final String... args) { + // no operation + } + + @Override + public void error(final String message, final MetricLogSpec metricLogSpec, final String... args) { + // no operation + } + + @Override + public void fatal(final String message, final MetricLogSpec metricLogSpec, final OptionalLogSpec optionalLogSpec, + final String... args) { + // no operation + } + + @Override + public void fatal(final String message, final MetricLogSpec metricLogSpec, final String... args) { + // no operation + } +} diff --git a/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/noop/package-info.java b/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/noop/package-info.java new file mode 100644 index 0000000..f7ed917 --- /dev/null +++ b/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/noop/package-info.java @@ -0,0 +1,26 @@ +/* + * ================================================================================ + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + * + */ + +/** + * Contains no operation implementation of EELF Logging API. Generally used as a fallback when no EELF Logging + * implementation is detected in the application classpath + * + * @author Rajiv Singla + */ +package org.onap.dcae.utils.eelf.logger.api.noop; diff --git a/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/spec/AppLogSpec.java b/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/spec/AppLogSpec.java new file mode 100644 index 0000000..83643fb --- /dev/null +++ b/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/spec/AppLogSpec.java @@ -0,0 +1,32 @@ +/* + * ================================================================================ + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + * + */ + +package org.onap.dcae.utils.eelf.logger.api.spec; + + +import org.onap.dcae.utils.eelf.logger.api.info.AppLogInfo; + +/** + * App Log spec captures fields which are fixed for the duration of application once its instance is created. They + * should be populated for all specifications regardless of if they are relevant to that specification + * + * @author Rajiv Singla + */ +public interface AppLogSpec extends AppLogInfo { +} diff --git a/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/spec/AuditLogSpec.java b/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/spec/AuditLogSpec.java new file mode 100644 index 0000000..46360b1 --- /dev/null +++ b/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/spec/AuditLogSpec.java @@ -0,0 +1,42 @@ +/* + * ================================================================================ + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + * + */ + +package org.onap.dcae.utils.eelf.logger.api.spec; + + +import org.onap.dcae.utils.eelf.logger.api.info.RequestIdLogInfo; +import org.onap.dcae.utils.eelf.logger.api.info.RequestTimingLogInfo; +import org.onap.dcae.utils.eelf.logger.api.info.ResponseLogInfo; +import org.onap.dcae.utils.eelf.logger.api.info.ServiceLogInfo; + +/** + * Captures fields required for EELF Audit Log Specification. + * + * @author Rajiv Singla + */ +public interface AuditLogSpec extends + // request id must be preset for all log specifications + RequestIdLogInfo, + // duration related fields + RequestTimingLogInfo, + // app acting as a service fields + ServiceLogInfo, ResponseLogInfo { + + +} diff --git a/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/spec/DebugLogSpec.java b/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/spec/DebugLogSpec.java new file mode 100644 index 0000000..ac4bd64 --- /dev/null +++ b/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/spec/DebugLogSpec.java @@ -0,0 +1,34 @@ +/* + * ================================================================================ + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + * + */ + +package org.onap.dcae.utils.eelf.logger.api.spec; + + +import org.onap.dcae.utils.eelf.logger.api.info.RequestIdLogInfo; + +/** + * Captures fields required for EELF Debug Log Specification. + * NOTE: As per specification debug log is optional + * + * @author Rajiv Singla + */ +public interface DebugLogSpec extends + // request id must be preset for all log specifications + RequestIdLogInfo { +} diff --git a/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/spec/ErrorLogSpec.java b/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/spec/ErrorLogSpec.java new file mode 100644 index 0000000..455f433 --- /dev/null +++ b/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/spec/ErrorLogSpec.java @@ -0,0 +1,42 @@ +/* + * ================================================================================ + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + * + */ + +package org.onap.dcae.utils.eelf.logger.api.spec; + + +import org.onap.dcae.utils.eelf.logger.api.info.ErrorLogInfo; +import org.onap.dcae.utils.eelf.logger.api.info.RequestIdLogInfo; +import org.onap.dcae.utils.eelf.logger.api.info.ServiceLogInfo; +import org.onap.dcae.utils.eelf.logger.api.info.TargetServiceLogInfo; + +/** + * Captures fields required for EELF Error Log Specification + * + * @author Rajiv Singla + */ +public interface ErrorLogSpec extends + // request id must be preset for all log specifications + RequestIdLogInfo, + // app acting as a service fields + ServiceLogInfo, + // app calling external service fields + TargetServiceLogInfo, + // error details fields + ErrorLogInfo { +} diff --git a/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/spec/MetricLogSpec.java b/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/spec/MetricLogSpec.java new file mode 100644 index 0000000..5b5f698 --- /dev/null +++ b/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/spec/MetricLogSpec.java @@ -0,0 +1,36 @@ +/* + * ================================================================================ + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + * + */ + +package org.onap.dcae.utils.eelf.logger.api.spec; + + +import org.onap.dcae.utils.eelf.logger.api.info.TargetServiceLogInfo; + +/** + * Captures fields required for EELF Metric Log Specification. + * + * @author Rajiv Singla + */ +public interface MetricLogSpec extends + // Audit log spec + AuditLogSpec, + // App calling external service fields + TargetServiceLogInfo { + +} diff --git a/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/spec/OptionalLogSpec.java b/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/spec/OptionalLogSpec.java new file mode 100644 index 0000000..dac08ab --- /dev/null +++ b/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/spec/OptionalLogSpec.java @@ -0,0 +1,39 @@ +/* + * ================================================================================ + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + * + */ + +package org.onap.dcae.utils.eelf.logger.api.spec; + +import org.onap.dcae.utils.eelf.logger.api.info.CodeLogInfo; +import org.onap.dcae.utils.eelf.logger.api.info.CustomFieldsLogInfo; +import org.onap.dcae.utils.eelf.logger.api.info.MessageLogInfo; +import org.onap.dcae.utils.eelf.logger.api.info.MiscLogInfo; + +/** + * Captures fields which are optional or derived from other fields + * + * @author Rajiv Singla + */ +public interface OptionalLogSpec extends + // message fields are mostly auto generated or can be derived from other fields + MessageLogInfo, + // Code log info can be derived by the underlying logging framework or provided optionally by the app + CodeLogInfo, + // custom and misc log info are mostly optional + CustomFieldsLogInfo, MiscLogInfo { +} diff --git a/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/spec/package-info.java b/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/spec/package-info.java new file mode 100644 index 0000000..b4c1df8 --- /dev/null +++ b/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/spec/package-info.java @@ -0,0 +1,28 @@ +/* + * ================================================================================ + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + * + */ + +/** + * Contains various EELF Logging Specifications. + *

+ * Some specifications are fixed for the whole duration of the + * application, some specification are either optional or derived and some are required for particular EELF Logging + * specification. These logging specification are composed of various logging information in + * {@link org.onap.dcae.utils.eelf.logger.api.info} package + */ +package org.onap.dcae.utils.eelf.logger.api.spec; -- cgit 1.2.3-korg