1 /* 2 * Copyright (c) 2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef MEDIA_DFX_H 17 #define MEDIA_DFX_H 18 19 #include <string> 20 #include <refbase.h> 21 #include "nocopyable.h" 22 #include "hisysevent.h" 23 24 namespace OHOS { 25 namespace Media { 26 class __attribute__((visibility("default"))) MediaEvent : public NoCopyable { 27 public: 28 MediaEvent() = default; 29 ~MediaEvent() = default; 30 bool CreateMsg(const char *format, ...) __attribute__((__format__(printf, 2, 3))); 31 void EventWrite(std::string eventName, OHOS::HiviewDFX::HiSysEvent::EventType type, 32 std::string module); 33 private: 34 std::string msg_; 35 }; 36 37 __attribute__((visibility("default"))) void BehaviorEventWrite(std::string status, std::string moudle); 38 __attribute__((visibility("default"))) void FaultEventWrite(std::string msg, std::string moudle); 39 40 class __attribute__((visibility("default"))) MediaTrace : public NoCopyable { 41 public: 42 explicit MediaTrace(const std::string &funcName); 43 static void TraceBegin(const std::string &funcName, int32_t taskId); 44 static void TraceEnd(const std::string &funcName, int32_t taskId); 45 static void CounterTrace(const std::string &varName, int32_t val); 46 ~MediaTrace(); 47 private: 48 bool isSync_ = false; 49 }; 50 } // namespace Media 51 } // namespace OHOS 52 #endif // MEDIA_DFX_H