1/* 2 * Copyright (c) 2021-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// Autogenerated file -- DO NOT EDIT! 17 18static const char *GetComponentTag(Logger::Component component) 19{ 20% LoggerData.components.each do |c| 21 if (component == Logger::Component::<%= c.enum %>) { 22 return "<%= c.name %>"; 23 } 24% end 25 26 UNREACHABLE(); 27} 28 29static const char *GetLevelTag(Logger::Level level) 30{ 31% LoggerData.levels.each do |l| 32 if (level == Logger::Level::<%= l.enum %>) { 33 return "<%= l.tag %>"; 34 } 35% end 36 37 UNREACHABLE(); 38} 39 40/* static */ 41Logger::Level Logger::LevelFromString(std::string_view s) 42{ 43% LoggerData.levels.each do |l| 44 if (s == "<%= l.name %>") { 45 return panda::Logger::Level::<%= l.enum %>; 46 } 47% end 48 49 UNREACHABLE(); 50} 51 52/* static */ 53Logger::ComponentMask Logger::ComponentMaskFromString(std::string_view s) 54{ 55% LoggerData.components.each do |c| 56 if (s == "<%= c.name %>") { 57 return panda::Logger::ComponentMask().set(Logger::Component::<%= c.enum %>); 58 } 59% end 60 61 if (s == "all") { 62 return panda::LoggerComponentMaskAll; 63 } 64 65 UNREACHABLE(); 66} 67 68/* static */ 69std::string Logger::StringfromDfxComponent(LogDfxComponent dfx_component) 70{ 71 switch (dfx_component) { 72% LoggerData.dfx_components.each do |c| 73 case Logger::LogDfxComponent::<%= c.enum %>: 74 return "<%= c.name %>"; 75% end 76 default: 77 break; 78 } 79 UNREACHABLE(); 80} 81 82/* static */ 83bool Logger::IsInLevelList(std::string_view s) 84{ 85% LoggerData.levels.each do |l| 86 if (s == "<%= l.name %>") { 87 return true; 88 } 89% end 90 91 return false; 92} 93 94/* static */ 95bool Logger::IsInComponentList(std::string_view s) 96{ 97% LoggerData.components.each do |c| 98 if (s == "<%= c.name %>") { 99 return true; 100 } 101% end 102 103 if (s == "all") { 104 return true; 105 } 106 return false; 107} 108 109/* static */ 110uint32_t Logger::GetLevelNumber(Logger::Level level) 111{ 112 switch (level) { 113% LoggerData.levels.each do |l| 114 case Logger::Level::<%= l.enum %>: 115 return <%= l.value %>; 116% end 117 default: 118 break; 119 } 120 121 UNREACHABLE(); 122} 123