LCOV - code coverage report
Current view: top level - serverManager/common/source - Utils.cpp (source / functions) Coverage Total Hit
Test: coverage.info Lines: 95.6 % 45 43
Test Date: 2025-03-21 11:02:39 Functions: 100.0 % 3 3

            Line data    Source code
       1              : /*
       2              :  * If not stated otherwise in this file or this component's LICENSE file the
       3              :  * following copyright and licenses apply:
       4              :  *
       5              :  * Copyright 2022 Sky UK
       6              :  *
       7              :  * Licensed under the Apache License, Version 2.0 (the "License");
       8              :  * you may not use this file except in compliance with the License.
       9              :  * You may obtain a copy of the License at
      10              :  *
      11              :  * http://www.apache.org/licenses/LICENSE-2.0
      12              :  *
      13              :  * Unless required by applicable law or agreed to in writing, software
      14              :  * distributed under the License is distributed on an "AS IS" BASIS,
      15              :  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      16              :  * See the License for the specific language governing permissions and
      17              :  * limitations under the License.
      18              :  */
      19              : 
      20              : #include "Utils.h"
      21              : 
      22              : namespace rialto::servermanager::common
      23              : {
      24           83 : const char *toString(const firebolt::rialto::common::SessionServerState &state)
      25              : {
      26           83 :     switch (state)
      27              :     {
      28           22 :     case firebolt::rialto::common::SessionServerState::UNINITIALIZED:
      29           22 :         return "Uninitialized";
      30           32 :     case firebolt::rialto::common::SessionServerState::INACTIVE:
      31           32 :         return "Inactive";
      32            7 :     case firebolt::rialto::common::SessionServerState::ACTIVE:
      33            7 :         return "Active";
      34           12 :     case firebolt::rialto::common::SessionServerState::NOT_RUNNING:
      35           12 :         return "NotRunning";
      36           10 :     case firebolt::rialto::common::SessionServerState::ERROR:
      37           10 :         return "Error";
      38              :     }
      39            0 :     return "Unknown";
      40              : }
      41              : 
      42           23 : RIALTO_DEBUG_LEVEL convert(const service::LoggingLevel &loggingLevel)
      43              : {
      44           23 :     switch (loggingLevel)
      45              :     {
      46            4 :     case service::LoggingLevel::FATAL:
      47              :     {
      48            4 :         return RIALTO_DEBUG_LEVEL_FATAL;
      49              :     }
      50            4 :     case service::LoggingLevel::ERROR:
      51              :     {
      52            4 :         return RIALTO_DEBUG_LEVEL(RIALTO_DEBUG_LEVEL_FATAL | RIALTO_DEBUG_LEVEL_ERROR);
      53              :     }
      54            4 :     case service::LoggingLevel::WARNING:
      55              :     {
      56            4 :         return RIALTO_DEBUG_LEVEL(RIALTO_DEBUG_LEVEL_FATAL | RIALTO_DEBUG_LEVEL_ERROR | RIALTO_DEBUG_LEVEL_WARNING);
      57              :     }
      58            4 :     case service::LoggingLevel::MILESTONE:
      59              :     {
      60              :         return RIALTO_DEBUG_LEVEL(RIALTO_DEBUG_LEVEL_FATAL | RIALTO_DEBUG_LEVEL_ERROR | RIALTO_DEBUG_LEVEL_WARNING |
      61            4 :                                   RIALTO_DEBUG_LEVEL_MILESTONE);
      62              :     }
      63            4 :     case service::LoggingLevel::INFO:
      64              :     {
      65              :         return RIALTO_DEBUG_LEVEL(RIALTO_DEBUG_LEVEL_FATAL | RIALTO_DEBUG_LEVEL_ERROR | RIALTO_DEBUG_LEVEL_WARNING |
      66            4 :                                   RIALTO_DEBUG_LEVEL_MILESTONE | RIALTO_DEBUG_LEVEL_INFO);
      67              :     }
      68            2 :     case service::LoggingLevel::DEBUG:
      69              :     {
      70              :         return RIALTO_DEBUG_LEVEL(RIALTO_DEBUG_LEVEL_FATAL | RIALTO_DEBUG_LEVEL_ERROR | RIALTO_DEBUG_LEVEL_WARNING |
      71            2 :                                   RIALTO_DEBUG_LEVEL_MILESTONE | RIALTO_DEBUG_LEVEL_INFO | RIALTO_DEBUG_LEVEL_DEBUG);
      72              :     }
      73            1 :     case service::LoggingLevel::DEFAULT:
      74              :     case service::LoggingLevel::UNCHANGED:
      75              :     {
      76            1 :         return RIALTO_DEBUG_LEVEL_DEFAULT;
      77              :     }
      78              :     }
      79            0 :     return RIALTO_DEBUG_LEVEL_DEFAULT;
      80              : }
      81              : 
      82            3 : void setLocalLogLevels(const service::LoggingLevels &logLevels)
      83              : {
      84            3 :     if (logLevels.defaultLoggingLevel != service::LoggingLevel::UNCHANGED)
      85              :     {
      86            3 :         firebolt::rialto::logging::setLogLevels(RIALTO_COMPONENT_DEFAULT, convert(logLevels.defaultLoggingLevel));
      87              :     }
      88            3 :     if (logLevels.clientLoggingLevel != service::LoggingLevel::UNCHANGED)
      89              :     {
      90            3 :         firebolt::rialto::logging::setLogLevels(RIALTO_COMPONENT_CLIENT, convert(logLevels.clientLoggingLevel));
      91              :     }
      92            3 :     if (logLevels.sessionServerLoggingLevel != service::LoggingLevel::UNCHANGED)
      93              :     {
      94            3 :         firebolt::rialto::logging::setLogLevels(RIALTO_COMPONENT_SERVER, convert(logLevels.sessionServerLoggingLevel));
      95              :     }
      96            3 :     if (logLevels.ipcLoggingLevel != service::LoggingLevel::UNCHANGED)
      97              :     {
      98            3 :         firebolt::rialto::logging::setLogLevels(RIALTO_COMPONENT_IPC, convert(logLevels.ipcLoggingLevel));
      99              :     }
     100            3 :     if (logLevels.serverManagerLoggingLevel != service::LoggingLevel::UNCHANGED)
     101              :     {
     102            3 :         firebolt::rialto::logging::setLogLevels(RIALTO_COMPONENT_SERVER_MANAGER,
     103            3 :                                                 convert(logLevels.serverManagerLoggingLevel));
     104              :     }
     105            3 :     if (logLevels.commonLoggingLevel != service::LoggingLevel::UNCHANGED)
     106              :     {
     107            1 :         firebolt::rialto::logging::setLogLevels(RIALTO_COMPONENT_COMMON, convert(logLevels.commonLoggingLevel));
     108              :     }
     109            3 : }
     110              : } // namespace rialto::servermanager::common
        

Generated by: LCOV version 2.0-1