Standalone TCA with EELF Logger
[dcaegen2/analytics/tca-gen2.git] / eelf-logger / eelf-logger-logback-impl / src / main / java / org / onap / dcae / utils / eelf / logger / logback / EELFLoggerDefaults.java
1 /*
2  * ================================================================================
3  * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
4  * ================================================================================
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  * ============LICENSE_END=========================================================
17  *
18  */
19
20 package org.onap.dcae.utils.eelf.logger.logback;
21
22
23 import org.onap.dcae.utils.eelf.logger.api.info.LogInfo;
24 import org.onap.dcae.utils.eelf.logger.model.info.AppLogInfoImpl;
25 import org.onap.dcae.utils.eelf.logger.model.info.CustomFieldsLogInfoImpl;
26 import org.onap.dcae.utils.eelf.logger.model.info.ErrorLogInfoImpl;
27 import org.onap.dcae.utils.eelf.logger.model.info.MiscLogInfoImpl;
28 import org.onap.dcae.utils.eelf.logger.model.info.RequestTimingLogInfoImpl;
29 import org.onap.dcae.utils.eelf.logger.model.info.ResponseLogInfoImpl;
30 import org.onap.dcae.utils.eelf.logger.model.info.ServiceLogInfoImpl;
31 import org.onap.dcae.utils.eelf.logger.model.info.TargetServiceLogInfoImpl;
32 import org.onap.dcae.utils.eelf.logger.model.spec.OptionalLogSpecImpl;
33
34 import java.util.Date;
35
36 import static org.onap.dcae.utils.eelf.logger.logback.utils.LogUtils.createDefaultAppLogInfo;
37
38
39 /**
40  * This utility class various default implementations for EELF Logger. Users should use these default rather then
41  * creating their own {@link LogInfo} objects.
42  *
43  * @author Rajiv Singla
44  */
45 public class EELFLoggerDefaults {
46
47     private static final String UNKNOWN_FIELD_VALUE = "UNKNOWN";
48
49     // =============== APP LOG SPEC ======================//
50     /**
51      * Provides Default {@link AppLogInfoImpl}
52      */
53     public static final AppLogInfoImpl DEFAULT_APP_LOG_INFO = createDefaultAppLogInfo();
54
55
56     // =============== AUDIT LOG SPEC ===================== //
57
58     private static final String DEFAULT_PARTNER_NAME =
59             System.getProperty("user.name") != null ? System.getProperty("user.name") : UNKNOWN_FIELD_VALUE;
60
61     public static final ServiceLogInfoImpl DEFAULT_SERVICE_LOG_INFO =
62             new ServiceLogInfoImpl(UNKNOWN_FIELD_VALUE, DEFAULT_PARTNER_NAME, "");
63
64
65     public static final RequestTimingLogInfoImpl DEFAULT_REQUEST_TIMING_LOG_INFO =
66             new RequestTimingLogInfoImpl(new Date(), new Date(), null);
67
68
69     public static final ResponseLogInfoImpl DEFAULT_RESPONSE_LOG_INFO =
70             new ResponseLogInfoImpl(900, "UNDEFINED");
71
72
73     // =============== METRIC LOG SPEC ===================== //
74
75     public static final TargetServiceLogInfoImpl DEFAULT_TARGET_SERVICE_LOG_INFO =
76             new TargetServiceLogInfoImpl(UNKNOWN_FIELD_VALUE, UNKNOWN_FIELD_VALUE, UNKNOWN_FIELD_VALUE);
77
78     // =============== ERROR LOG SPEC ===================== //
79
80     public static final ErrorLogInfoImpl DEFAULT_ERROR_LOG_INFO =
81             new ErrorLogInfoImpl(900, "UNDEFINED ERROR");
82
83
84     // ============= OPTIONAL LOG SPEC =================== //
85
86     /**
87      * Provides Default {@link CustomFieldsLogInfoImpl}
88      */
89     public static final CustomFieldsLogInfoImpl DEFAULT_CUSTOM_FIELDS_LOG_INFO =
90             new CustomFieldsLogInfoImpl("", "", "", "");
91
92     /**
93      * Provides Default {@link MiscLogInfoImpl}
94      */
95     public static final MiscLogInfoImpl DEFAULT_MISC_LOG_INFO = new MiscLogInfoImpl("", "");
96
97
98     /**
99      * Provides Default {@link OptionalLogSpecImpl}
100      */
101     public static final OptionalLogSpecImpl DEFAULT_OPTIONAL_LOG_SPEC = new OptionalLogSpecImpl(null, null,
102             DEFAULT_CUSTOM_FIELDS_LOG_INFO, DEFAULT_MISC_LOG_INFO);
103
104
105 }