LCOV - code coverage report
Current view: top level - serverManager/common/source - Utils.cpp (source / functions) Coverage Total Hit
Test: coverage.info Lines: 95.7 % 47 45
Test Date: 2026-09-11 17:36:12 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          145 : const char *toString(const firebolt::rialto::common::SessionServerState &state)
      25              : {
      26          145 :     switch (state)
      27              :     {
      28           32 :     case firebolt::rialto::common::SessionServerState::UNINITIALIZED:
      29           32 :         return "Uninitialized";
      30           50 :     case firebolt::rialto::common::SessionServerState::INACTIVE:
      31           50 :         return "Inactive";
      32           10 :     case firebolt::rialto::common::SessionServerState::ACTIVE:
      33           10 :         return "Active";
      34           17 :     case firebolt::rialto::common::SessionServerState::NOT_RUNNING:
      35           17 :         return "NotRunning";
      36           11 :     case firebolt::rialto::common::SessionServerState::ERROR:
      37           11 :         return "Error";
      38           25 :     case firebolt::rialto::common::SessionServerState::SUSPENDED:
      39           25 :         return "Suspended";
      40              :     }
      41            0 :     return "Unknown";
      42              : }
      43              : 
      44           23 : RIALTO_DEBUG_LEVEL convert(const service::LoggingLevel &loggingLevel)
      45              : {
      46           23 :     switch (loggingLevel)
      47              :     {
      48            4 :     case service::LoggingLevel::FATAL:
      49              :     {
      50            4 :         return RIALTO_DEBUG_LEVEL_FATAL;
      51              :     }
      52            4 :     case service::LoggingLevel::ERROR:
      53              :     {
      54            4 :         return RIALTO_DEBUG_LEVEL(RIALTO_DEBUG_LEVEL_FATAL | RIALTO_DEBUG_LEVEL_ERROR);
      55              :     }
      56            4 :     case service::LoggingLevel::WARNING:
      57              :     {
      58            4 :         return RIALTO_DEBUG_LEVEL(RIALTO_DEBUG_LEVEL_FATAL | RIALTO_DEBUG_LEVEL_ERROR | RIALTO_DEBUG_LEVEL_WARNING);
      59              :     }
      60            4 :     case service::LoggingLevel::MILESTONE:
      61              :     {
      62              :         return RIALTO_DEBUG_LEVEL(RIALTO_DEBUG_LEVEL_FATAL | RIALTO_DEBUG_LEVEL_ERROR | RIALTO_DEBUG_LEVEL_WARNING |
      63            4 :                                   RIALTO_DEBUG_LEVEL_MILESTONE);
      64              :     }
      65            4 :     case service::LoggingLevel::INFO:
      66              :     {
      67              :         return RIALTO_DEBUG_LEVEL(RIALTO_DEBUG_LEVEL_FATAL | RIALTO_DEBUG_LEVEL_ERROR | RIALTO_DEBUG_LEVEL_WARNING |
      68            4 :                                   RIALTO_DEBUG_LEVEL_MILESTONE | RIALTO_DEBUG_LEVEL_INFO);
      69              :     }
      70            2 :     case service::LoggingLevel::DEBUG:
      71              :     {
      72              :         return RIALTO_DEBUG_LEVEL(RIALTO_DEBUG_LEVEL_FATAL | RIALTO_DEBUG_LEVEL_ERROR | RIALTO_DEBUG_LEVEL_WARNING |
      73            2 :                                   RIALTO_DEBUG_LEVEL_MILESTONE | RIALTO_DEBUG_LEVEL_INFO | RIALTO_DEBUG_LEVEL_DEBUG);
      74              :     }
      75            1 :     case service::LoggingLevel::DEFAULT:
      76              :     case service::LoggingLevel::UNCHANGED:
      77              :     {
      78            1 :         return RIALTO_DEBUG_LEVEL_DEFAULT;
      79              :     }
      80              :     }
      81            0 :     return RIALTO_DEBUG_LEVEL_DEFAULT;
      82              : }
      83              : 
      84            3 : void setLocalLogLevels(const service::LoggingLevels &logLevels)
      85              : {
      86            3 :     if (logLevels.defaultLoggingLevel != service::LoggingLevel::UNCHANGED)
      87              :     {
      88            3 :         firebolt::rialto::logging::setLogLevels(RIALTO_COMPONENT_DEFAULT, convert(logLevels.defaultLoggingLevel));
      89              :     }
      90            3 :     if (logLevels.clientLoggingLevel != service::LoggingLevel::UNCHANGED)
      91              :     {
      92            3 :         firebolt::rialto::logging::setLogLevels(RIALTO_COMPONENT_CLIENT, convert(logLevels.clientLoggingLevel));
      93              :     }
      94            3 :     if (logLevels.sessionServerLoggingLevel != service::LoggingLevel::UNCHANGED)
      95              :     {
      96            3 :         firebolt::rialto::logging::setLogLevels(RIALTO_COMPONENT_SERVER, convert(logLevels.sessionServerLoggingLevel));
      97              :     }
      98            3 :     if (logLevels.ipcLoggingLevel != service::LoggingLevel::UNCHANGED)
      99              :     {
     100            3 :         firebolt::rialto::logging::setLogLevels(RIALTO_COMPONENT_IPC, convert(logLevels.ipcLoggingLevel));
     101              :     }
     102            3 :     if (logLevels.serverManagerLoggingLevel != service::LoggingLevel::UNCHANGED)
     103              :     {
     104            3 :         firebolt::rialto::logging::setLogLevels(RIALTO_COMPONENT_SERVER_MANAGER,
     105            3 :                                                 convert(logLevels.serverManagerLoggingLevel));
     106              :     }
     107            3 :     if (logLevels.commonLoggingLevel != service::LoggingLevel::UNCHANGED)
     108              :     {
     109            1 :         firebolt::rialto::logging::setLogLevels(RIALTO_COMPONENT_COMMON, convert(logLevels.commonLoggingLevel));
     110              :     }
     111            3 : }
     112              : } // namespace rialto::servermanager::common
        

Generated by: LCOV version 2.0-1