Init basesystem source codes.
[staging/basesystem.git] / systemservice / logger_service / server / include / ss_logger_cfg.h
1 /*
2  * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 ///////////////////////////////////////////////////////////////////////////////
18 /// \ingroup  tag_SS_LoggerService
19 /// \brief    Provide support for SS Logger module configuration.
20 ///
21 ///////////////////////////////////////////////////////////////////////////////
22 #ifndef LOGGER_SERVICE_SERVER_INCLUDE_SS_LOGGER_CFG_H_
23 #define LOGGER_SERVICE_SERVER_INCLUDE_SS_LOGGER_CFG_H_
24
25 ///////////////////////////////////////////////////////////////////////////////
26 // INCLUDES
27 ///////////////////////////////////////////////////////////////////////////////
28
29 #include <native_service/frameworkunified_types.h>
30 #include <native_service/ns_config_parser_if.h>
31 #include <native_service/ns_logger_if.h>
32 #include <system_service/ss_templates.h>
33 #include <system_service/ss_logger_service.h>
34 #include <system_service/ss_logger_service_local.h>
35 #include <string>
36 #include <vector>
37 #include "loggerservicedebug_loggerservicelog.h"
38
39 ///////////////////////////////////////////////////////////////////////////////
40 // CONFIGURATION CLASS DEFINITION
41 ///////////////////////////////////////////////////////////////////////////////
42 /*Default values for the storage thread*/
43 #define ERROR_EVENT_STORAGE_QUEUE_NAME  "/SSLoggerStrage"
44 #define ERROR_EVENT_STORAGE_PRIORITY    (UI_8)30
45 #define ERROR_EVENT_STORAGE_SLEEP_TIME  (useconds_t)50000
46 #define ERROR_EVENT_STORAGE_SLEEP_AFTER (UI_8)5
47
48 #if ENABLE_PRODUCTION_BUILD == 1
49 #define SS_LOGGER_DEFAULT_VALUE eDeactivate
50 #else
51 #define SS_LOGGER_DEFAULT_VALUE eActivate
52 #endif
53
54 #define LOGGERSERVICELOG_EMMC_COUNTER_MAX 99999u
55
56 struct SLoggerStorageInfo {
57   SLoggerStorageInfo()
58       : Name(ERROR_EVENT_STORAGE_QUEUE_NAME),
59         Priority(ERROR_EVENT_STORAGE_PRIORITY),
60         Timeout(ERROR_EVENT_STORAGE_SLEEP_TIME),
61         TimeoutAfter(ERROR_EVENT_STORAGE_SLEEP_AFTER) {  // LCOV_EXCL_BR_LINE 11:Unexpected branch
62   }
63   std::string Name;
64   SI_32 Priority;
65   SI_32 Timeout;
66   SI_32 TimeoutAfter;
67 };
68
69 enum EInsertEventType {
70   eInsertEventEELStorage,
71   eInsertEventEELActive,
72   eInsertEventLoggerserviceEmmcLogs,
73   eInsertEventInvalid
74 };
75
76 struct ExternalLogInfo {
77   std::string dirname;
78   std::string path;
79   BOOL remove;
80 };
81
82 struct ExternalLogList {
83   SI_32 num;
84   SI_32 max;
85   ExternalLogInfo* p_info;
86 };
87
88 class CLoggerCfg {
89  public:
90   CLoggerCfg(void);
91   ~CLoggerCfg(void);
92
93   EFrameworkunifiedStatus Initialize(HANDLE f_hApp);
94
95   EFrameworkunifiedStatus Load(const std::string &f_filePathAndName);
96   EFrameworkunifiedStatus Validate(void);
97   void Print(void);
98
99   EFrameworkunifiedStatus SetLoggingParams(HANDLE f_hApp,
100                               STLoggerSetParams f_stLoggerSetParams);
101
102   EFrameworkunifiedStatus SetUDPLogging(HANDLE f_hApp, const ELOGGER_STAT f_eUDPLoggingStatus);
103
104   EFrameworkunifiedStatus PersistLoggingParam(HANDLE f_hApp);
105   std::string getEmmcOutputPath(void);
106   std::string getEmmcOutputNaviLogPath(void);
107   std::string getUsb0MountPath(void);
108   std::string getUsb1MountPath(void);
109   std::string getSdMountPath(void);
110   std::string getDeviceName(void);
111   void setUsb0MountPath(std::string &f_deviceMountpath);  // NOLINT (runtime/references)
112   EFrameworkunifiedStatus GetUserInvokedDestination(std::string &f_dest);  // NOLINT (runtime/references)
113
114   EFrameworkunifiedStatus GetEmmcDestination(std::string &f_dest);  // NOLINT (runtime/references)
115   EFrameworkunifiedStatus GetEmmcNaviLogDestination(std::string &f_dest);  // NOLINT (runtime/references)
116
117   UI_32 GetUserInvokedCounter(void);
118   EFrameworkunifiedStatus GetIncrementAndPersistUserInvokedCounter(HANDLE f_hApp,
119                                                       UI_32 &f_counter);  // NOLINT (runtime/references)
120
121   EFrameworkunifiedStatus GetAndIncrementEmmcCounter(UI_32 &f_counter);  // NOLINT (runtime/references)
122   EFrameworkunifiedStatus RefreshEmmcCounter(UI_32 &f_counter) const;  // NOLINT (runtime/references)
123
124   void ResetEmmcCounter(void);
125
126   SI_32 m_logMaxFileSize;
127   UI_32 m_logMask[ZONE_MASK_ARRAY_ELTS];
128   SI_32 m_performanceLogMaxFileSize;
129   SI_32 m_emmcOutputMax;
130   SI_32 m_emmcOutputErrMax;
131   SI_32 m_emmcOutputGrpRelaunchMax;
132   SI_32 m_emmcOutputNaviLogMax;
133   SI_32 m_emmcOutputNaviLogNmlMax;
134   SI_32 m_emmcOutputNaviLogErrMax;
135   ExternalLogList m_ExternalLogList;
136
137   std::string m_emmcOutputPath;
138   std::string m_emmcOutputNaviLogPath;
139   std::string m_usb0MountPath;
140   std::string m_usb1MountPath;
141   std::string m_sdMountPath;
142
143   EDEV_TYPE GetConnectedDevice(std::string f_devPath);
144   EInsertEventType GetInsertEventType(std::string f_relPath);
145
146   std::string GetEELActivateRelPath(void);
147   std::string GetDebugFolderContentRelPath(void);
148   std::string GetEELExportRelPath(void);
149
150   BOOL IsUDPLoggingEnabled(void);
151   void AddLoggingParamCB(CbFuncPtr f_fp);
152
153   EFrameworkunifiedStatus GetLoggerStorageInfo(SLoggerStorageInfo &f_info);  // NOLINT (runtime/references)
154   BOOL IsLoggingEnabled(void);
155   EFrameworkunifiedStatus EelActivateLogging(HANDLE f_hApp);
156   ExternalLogList GetExternalLogList(void);
157
158  private:
159   void UpdateLoggingStatus(void);
160   std::vector<CbFuncPtr> m_LoggingCallBack;
161   void GetHighestEmmcCounterValue(UI_32 &f_counter);  // NOLINT (runtime/references)
162
163   EDEV_TYPE m_eDevType;
164   UI_32 m_UserInvokedLoggingNumber;
165   UI_32 m_EmmcCounter;
166   ELOGGER_STAT m_eLoggerUDPLoggingStatus;
167   BOOL m_udpEnvFlag;
168   ELOGGER_STAT m_eLoggerStatus;
169
170   std::string m_EELStorageRelPath;
171
172   std::string m_EELActivateRelPath;
173
174   std::string m_LoggerserviceEmmcLogsRelPath;
175
176   EFrameworkunifiedStatus SetandPersistLoggingParams(HANDLE f_hApp,
177                                         STLoggerSetAllParams f_Params,
178                                         BOOL f_InitCall);
179   SLoggerStorageInfo m_loggerStorageInfo;
180
181   void RemoveCarriageReturn(std::string &f_str);  // NOLINT (runtime/references)
182 };
183
184 #endif  // LOGGER_SERVICE_SERVER_INCLUDE_SS_LOGGER_CFG_H_
185