RDK Documentation (Open Sourced RDK Components)
librmh_globals.c
1 /*
2  * If not stated otherwise in this file or this component's Licenses.txt file the
3  * following copyright and licenses apply:
4  *
5  * Copyright 2016 RDK Management
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 <stdarg.h>
21 #include "librmh.h"
22 #include "rdk_moca_hal.h"
23 
24 __attribute__((visibility("hidden"))) RMH_APIList hRMHGeneric_APIList;
25 __attribute__((visibility("hidden"))) RMH_APIList hRMHGeneric_SoCUnimplementedAPIList;
26 __attribute__((visibility("hidden"))) RMH_APITagList hRMHGeneric_APITags;
27 
28 void RMH_Print(const RMH_Handle handle, const RMH_LogLevel level, const char *filename, const uint32_t lineNumber, const char *format, ...) {
29  va_list args;
30  va_start(args, format);
31  if (handle && handle->localLogToFile) {
32  vfprintf(handle->localLogToFile, format, args);
33  }
34  else if (handle && handle->printBuf && handle->eventCB && ((handle->eventNotifyBitMask & RMH_EVENT_API_PRINT) == RMH_EVENT_API_PRINT)) {
35  RMH_EventData eventData;
36  vsnprintf(handle->printBuf, RMH_MAX_PRINT_LINE_SIZE, format, args);
37  eventData.RMH_EVENT_API_PRINT.logLevel=level;
38  eventData.RMH_EVENT_API_PRINT.logMsg=(const char *)handle->printBuf;
39  handle->eventCB(RMH_EVENT_API_PRINT, &eventData, handle->eventCBUserContext);
40  }
41  else {
42  vprintf(format, args);
43  }
44  va_end(args);
45 }
RMH_APITagList
Definition: rmh_type.h:240
RMH
Definition: librmh.h:57
RMH_EventData
Definition: rmh_type.h:157
RMH_APIList
Definition: rmh_type.h:234