122c0b7e4Sopenharmony_ci/* 222c0b7e4Sopenharmony_ci * Copyright (c) 2022 Huawei Device Co., Ltd. 322c0b7e4Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 422c0b7e4Sopenharmony_ci * you may not use this file except in compliance with the License. 522c0b7e4Sopenharmony_ci * You may obtain a copy of the License at 622c0b7e4Sopenharmony_ci * 722c0b7e4Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 822c0b7e4Sopenharmony_ci * 922c0b7e4Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 1022c0b7e4Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 1122c0b7e4Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1222c0b7e4Sopenharmony_ci * See the License for the specific language governing permissions and 1322c0b7e4Sopenharmony_ci * limitations under the License. 1422c0b7e4Sopenharmony_ci */ 1522c0b7e4Sopenharmony_ci 1622c0b7e4Sopenharmony_ci#include "bundle_active_log.h" 1722c0b7e4Sopenharmony_ci 1822c0b7e4Sopenharmony_cinamespace OHOS { 1922c0b7e4Sopenharmony_cinamespace DeviceUsageStats { 2022c0b7e4Sopenharmony_ciBundleActiveLogLevel BundleActiveLog::logLevel_ = {BundleActiveLogLevel::DEBUG}; 2122c0b7e4Sopenharmony_cibool BundleActiveLog::JudgeValidLevel(const BundleActiveLogLevel &level) 2222c0b7e4Sopenharmony_ci{ 2322c0b7e4Sopenharmony_ci const BundleActiveLogLevel &currLevel = BundleActiveLog::GetLogLevel(); 2422c0b7e4Sopenharmony_ci if (level < currLevel) { 2522c0b7e4Sopenharmony_ci return false; 2622c0b7e4Sopenharmony_ci } 2722c0b7e4Sopenharmony_ci return true; 2822c0b7e4Sopenharmony_ci} 2922c0b7e4Sopenharmony_ci 3022c0b7e4Sopenharmony_cistd::string BundleActiveLog::GetCurrFileName(const char *str) 3122c0b7e4Sopenharmony_ci{ 3222c0b7e4Sopenharmony_ci if (!str) { 3322c0b7e4Sopenharmony_ci return std::string(); 3422c0b7e4Sopenharmony_ci } 3522c0b7e4Sopenharmony_ci std::string fullPath(str); 3622c0b7e4Sopenharmony_ci size_t pos = fullPath.find_last_of("/"); 3722c0b7e4Sopenharmony_ci if (pos == std::string::npos) { 3822c0b7e4Sopenharmony_ci return std::string(); 3922c0b7e4Sopenharmony_ci } 4022c0b7e4Sopenharmony_ci return fullPath.substr(pos + 1); 4122c0b7e4Sopenharmony_ci} 4222c0b7e4Sopenharmony_ci} // namespace DeviceUsageStats 4322c0b7e4Sopenharmony_ci} // namespace OHOS 4422c0b7e4Sopenharmony_ci 45