There are two logger files in iotivity.
These are 'resource/csdk/logger' and
'resource/csdk/connectivity/common/logger'.
since 'resource/csdk/connectivity/common/logger' is using in only CA.
it is better to integrate with 'resource/csdk/logger'
so only 'resource/csdk/logger' will be used after that.
ps. oc_* logger name will be replaced with oic_* name
through other Change
Change-Id: I195b6d9e8066bcc87c0a9ea50a3bf335e3b7340a
Signed-off-by: jihwan.seo <jihwan.seo@samsung.com>
Signed-off-by: koushik.girijala <g.koushik@samsung.com>
Signed-off-by: jihwan.seo <jihwan.seo@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/4623
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Jon A. Cruz <jonc@osg.samsung.com>
target_os = env.get('TARGET_OS')
src_dir = env.get('SRC_DIR')
+if target_os not in ['tizen']:
+ # Build liblogger
+ SConscript('csdk/logger/SConscript')
+
if target_os not in ['arduino', 'darwin', 'ios', 'android']:
env.AppendUnique(LIBS=['rt'])
'security/include/internal',
])
-liboctbstack_env.AppendUnique(LIBS = ['ocsrm'])
-
if target_os not in ['arduino', 'windows', 'winrt']:
liboctbstack_env.AppendUnique(CPPDEFINES = ['WITH_POSIX'])
liboctbstack_env.AppendUnique(CFLAGS = ['-std=c99'])
liboctbstack_env.AppendUnique(LIBS = ['ra_xmpp'])
liboctbstack_env.AppendUnique(LIBS = ['coap', 'm'])
+liboctbstack_env.PrependUnique(LIBS = ['ocsrm'])
if target_os in ['tizen', 'linux']:
liboctbstack_env.ParseConfig("pkg-config --cflags --libs uuid")
OCTBSTACK_SRC + 'ocserverrequest.c',
OCTBSTACK_SRC + 'occollection.c',
OCTBSTACK_SRC + 'oicgroup.c',
- 'logger/src/logger.c',
OCTBSTACK_SRC + "rdpayload.c"
]
cp -R ./extlibs/timer/ $sourcedir/tmp/con/extlibs/
mkdir -p $sourcedir/tmp/con/c_common
cp -R ./resource/c_common/* $sourcedir/tmp/con/c_common/
+cp -R ./resource/csdk/logger/include/* $sourcedir/tmp/con/common/inc/
# copy dependency RPMs and conf files for tizen build
cp ./tools/tizen/*.rpm $sourcedir/tmp
print "Reading common folder script"
ca_os = env.get('TARGET_OS')
-
+src_dir = env.get('SRC_DIR')
root_dir = './../'
env.AppendUnique(CPPPATH = [
'common/inc/',
+ src_dir + '/resource/csdk/logger/include/',
])
-temp = env['CPPPATH']
-header = ' '
-for item in temp:
- header = header + ' -I' + item
-
######################################################################
# Source files and Target(s)
######################################################################
ca_common_src_path + 'caremotehandler.c'
]
-if ca_os == 'arduino':
- env.Command(env.get('BUILD_DIR') + 'logger.c.o', None, '$CXX -o ' + env.get('BUILD_DIR') + 'logger.c.o' + ' $LINKFLAGS $CCFLAGS $CXXFLAGS ' + '-I' + Dir('.').srcnode().path + '/inc' + header + ' ' + Dir('.').srcnode().path + '/src/logger.c')
- logger_src = [
- env.get('BUILD_DIR') + 'logger.c.o',
- ]
-else:
- logger_src = [
- ca_common_src_path + 'logger.c',
- ca_common_src_path + 'oic_logger.c',
- ca_common_src_path + 'oic_console_logger.c'
- ]
-
if env['POSIX_SUPPORTED']:
platform_src = [
ca_common_src_path + 'cathreadpool_pthreads.c',
env.AppendUnique(CA_SRC = ca_common_src)
-env.AppendUnique(CA_SRC = logger_src)
env.AppendUnique(CA_SRC = platform_src)
+++ /dev/null
-//******************************************************************
-//
-// Copyright 2014 Intel Mobile Communications GmbH All Rights Reserved.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-
-#ifndef U_LOGGER_H_
-#define U_LOGGER_H_
-
-#include <stdint.h>
-#include <stdio.h>
-#include <stdarg.h>
-#include "oic_logger.h"
-#include "oic_console_logger.h"
-
-#ifdef __ANDROID__
-#include <android/log.h>
-#elif defined(__TIZEN__)
-#include <dlog.h>
-#elif defined ARDUINO
-#include "Arduino.h"
-#include "avr/pgmspace.h"
-#endif
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-// Use the PCF macro to wrap strings stored in FLASH on the Arduino
-// Example: OC_LOG(INFO, TAG, PCF("Entering function"));
-#ifdef ARDUINO
-
-#ifdef __cplusplus
-#define PCF(str) ((PROGMEM const char *)(F(str)))
-#else
-#define PCF(str) ((PROGMEM const char *)(PSTR(str)))
-#endif //__cplusplus
-
-#else
-#define PCF(str) str
-#endif //ARDUINO
-
-// Max buffer size used in variable argument log function
-#define MAX_LOG_V_BUFFER_SIZE (256)
-
-// Log levels
-#ifdef __TIZEN__
-typedef enum {
- DEBUG = DLOG_DEBUG,
- INFO = DLOG_INFO,
- WARNING = DLOG_WARN,
- ERROR = DLOG_ERROR,
- FATAL = DLOG_ERROR
-} LogLevel;
-#else
-typedef enum
-{
- DEBUG = 0, INFO, WARNING, ERROR, FATAL
-} LogLevel;
-#endif
-
-#ifdef __TIZEN__
-#define OC_LOG(level,tag,mes) LOG_(LOG_ID_MAIN, level, tag, mes)
-#define OC_LOG_V(level,tag,fmt,args...) LOG_(LOG_ID_MAIN, level, tag, fmt,##args)
-#define OC_LOG_BUFFER(level, tag, buffer, bufferSize)
-#endif
-
-#ifdef __TIZEN__
-#define OICLog(level,tag,mes) LOG(level,tag,mes)
-#define OICLogv(level,tag,fmt,args...) LOG(level,tag,fmt,##args)
-#elif defined(ANDROID) || defined(__linux__) || defined(__APPLE__)
-/**
- * Configure logger to use a context that defines a custom logger function
- *
- * @param ctx - pointer to oc_log_ctx_t struct that defines custom logging functions
- */
-void OICLogConfig(oic_log_ctx_t *ctx);
-
-/**
- * Initialize the logger. Optional on Android and Linux. Configures serial port on Arduino
- */
-void OICLogInit();
-
-/**
- * Called to Free dyamically allocated resources used with custom logging.
- * Not necessary if default logging is used
- *
- */
-void OICLogShutdown();
-
-/**
- * Output a log string with the specified priority level.
- * Only defined for Linux and Android
- *
- * @param level - DEBUG, INFO, WARNING, ERROR, FATAL
- * @param tag - Module name
- * @param logStr - log string
- */
-void OICLog(LogLevel level, const char *tag, const char *logStr);
-
-/**
- * Output a variable argument list log string with the specified priority level.
- * Only defined for Linux and Android
- *
- * @param level - DEBUG, INFO, WARNING, ERROR, FATAL
- * @param tag - Module name
- * @param format - variadic log string
- */
-void OICLogv(LogLevel level, const char *tag, const char *format, ...)
-#if defined(__GNUC__)
- __attribute__ ((format(printf, 3, 4)))
-#endif
-;
-
-/**
- * Output the contents of the specified buffer (in hex) with the specified priority level.
- *
- * @param level - DEBUG, INFO, WARNING, ERROR, FATAL
- * @param tag - Module name
- * @param buffer - pointer to buffer of bytes
- * @param bufferSize - max number of byte in buffer
- */
-void OICLogBuffer(LogLevel level, const char *tag, const uint8_t *buffer, uint16_t bufferSize);
-#else // For arduino platforms
-/**
- * Initialize the serial logger for Arduino
- * Only defined for Arduino
- */
-void OICLogInit();
-
-/**
- * Output a log string with the specified priority level.
- * Only defined for Arduino. Uses PROGMEM strings
- *
- * @param level - DEBUG, INFO, WARNING, ERROR, FATAL
- * @param tag - Module name
- * @param logStr - log string
- */
-void OICLog(LogLevel level, PROGMEM const char *tag, const int16_t lineNum,
- PROGMEM const char *logStr);
-
-/**
- * Output the contents of the specified buffer (in hex) with the specified priority level.
- *
- * @param level - DEBUG, INFO, WARNING, ERROR, FATAL
- * @param tag - Module name
- * @param buffer - pointer to buffer of bytes
- * @param bufferSize - max number of byte in buffer
- */
-void OICLogBuffer(LogLevel level, const char *tag, const uint8_t *buffer, uint16_t bufferSize);
-
-/**
- * Output a variable argument list log string with the specified priority level.
- *
- * @param level - DEBUG, INFO, WARNING, ERROR, FATAL
- * @param tag - Module name
- * @param format - variadic log string
- */
-void OICLogv(LogLevel level, PROGMEM const char *tag, const int16_t lineNum,
- PROGMEM const char *format, ...)
-#if defined(__GNUC__)
- __attribute__ ((format(printf, 4, 5)))
-#endif
-;
-#endif
-
-#ifdef TB_LOG
-
-#ifdef __TIZEN__
-#define OIC_LOG(level,tag,mes) LOG_(LOG_ID_MAIN, level, tag, mes)
-#define OIC_LOG_V(level,tag,fmt,args...) LOG_(LOG_ID_MAIN, level, tag, fmt,##args)
-#define OIC_LOG_BUFFER(level, tag, buffer, bufferSize)
-#else // These macros are defined for Linux, Android, and Arduino
-#define OIC_LOG_INIT() OICLogInit()
-
-#ifdef ARDUINO
-#define OIC_LOG_CONFIG(ctx)
-#define OIC_LOG_SHUTDOWN()
-#define OIC_LOG(level, tag, logStr) OICLog((level), PCF(tag), __LINE__, PCF(logStr))
-#define OIC_LOG_V(level, tag, ...)
-// To enable OIC_LOG_V, uncomment the below
-//#define OIC_LOG_V(level, tag, format, ...) OICLogv((level), PCF(tag), __LINE__, PCF(format), __VA_ARGS__)
-#define OIC_LOG_BUFFER(level, tag, buffer, bufferSize)\
- OICLogBuffer((level), PCF(tag), (buffer), (bufferSize))
-#else
-#define OIC_LOG_CONFIG(ctx) OICLogConfig((ctx))
-#define OIC_LOG_SHUTDOWN() OICLogShutdown()
-#define OIC_LOG(level, tag, logStr) OICLog((level), (tag), (logStr))
-#define OIC_LOG_V(level, tag, ...) OICLogv((level), (tag), __VA_ARGS__)
-#define OIC_LOG_BUFFER(level, tag, buffer, bufferSize)\
- OICLogBuffer((level), tag, (buffer), (bufferSize))
-#endif //ARDUINO
-#endif //__TIZEN__
-#else //TB_LOG
-
-#define OIC_LOG_CONFIG(ctx)
-#define OIC_LOG_SHUTDOWN()
-#define OIC_LOG(level, tag, logStr)
-#define OIC_LOG_V(level, tag, ...)
-#define OIC_LOG_BUFFER(level, tag, buffer, bufferSize)
-#define OIC_LOG_INIT()
-
-#endif // TB_LOG
-
-
-#ifdef __cplusplus
-}
-#endif // __cplusplus
-#endif /* U_LOGGER_H_ */
+++ /dev/null
-//******************************************************************
-//
-// Copyright 2014 Intel Mobile Communications GmbH All Rights Reserved.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-
-#ifndef OIC_CONSOLE_LOGGER_
-#define OIC_CONSOLE_LOGGER_
-
-#include "oic_logger_types.h"
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-oic_log_ctx_t *oic_make_console_logger();
-
-int oic_console_logger_init(oic_log_ctx_t *ctx, void *world);
-void oic_console_logger_destroy(oic_log_ctx_t *ctx);
-void oic_console_logger_flush(oic_log_ctx_t *ctx);
-void oic_console_logger_set_level(oic_log_ctx_t *ctx, const int level);
-size_t oic_console_logger_write(oic_log_ctx_t *ctx, const int level, const char *msg);
-int oic_console_logger_set_module(oic_log_ctx_t *ctx, const char *module_name);
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
-
-#endif /* OIC_CONSOLE_LOGGER_ */
-
+++ /dev/null
-//******************************************************************
-//
-// Copyright 2014 Intel Mobile Communications GmbH All Rights Reserved.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-
-#ifndef OIC_LOGGER_H_
-#define OIC_LOGGER_H_
-
-#include "oic_logger_types.h"
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-/* Basic interface: */
-oic_log_ctx_t *oic_log_make_ctx(void *world, const oic_log_level level, oic_log_init_t init,
- oic_log_destroy_t destroy, oic_log_flush_t flush,
- oic_log_set_level_t set_level,oic_log_write_level_t write_level,
- oic_log_set_module_t set_module);
-
-void oic_log_destroy(oic_log_ctx_t *ctx);
-
-void oic_log_flush(oic_log_ctx_t *ctx);
-void oic_log_set_level(oic_log_ctx_t *ctx, const oic_log_level ll);
-size_t oic_log_write(oic_log_ctx_t *ctx, const char *msg);
-size_t oic_log_write_level(oic_log_ctx_t *ctx, const oic_log_level ll, const char *msg);
-int oic_log_set_module(oic_log_ctx_t *ctx, const char *module_name);
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
-
-#endif /* OIC_LOGGER_H_ */
-
+++ /dev/null
-//******************************************************************
-//
-// Copyright 2014 Intel Mobile Communications GmbH All Rights Reserved.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-
-#ifndef OIC_LOGGER_TYPES_H_
-#define OIC_LOGGER_TYPES_H_
-
-#include <stddef.h>
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-typedef enum
-{
- __OIC_LOG_MIN__ = -1,
- OIC_LOG_ALL = 0,
- OIC_LOG_FATAL,
- OIC_LOG_ERROR,
- OIC_LOG_WARNING,
- OIC_LOG_INFO,
- OIC_LOG_DEBUG,
- OIC_LOG_DISABLED,
- __OIC_LOG_MAX__
-} oic_log_level;
-
-typedef struct _oic_log_ctx
-{
- void *ctx;
-
- oic_log_level log_level;
-
- char *module_name;
-
- /* Required interface: */
- int (*init)(struct _oic_log_ctx *, void *);
- void (*destroy)(struct _oic_log_ctx *);
- void (*flush)(struct _oic_log_ctx *);
- void (*set_level)(struct _oic_log_ctx *, const int);
- size_t (*write_level)(struct _oic_log_ctx *, const int, const char *);
- int (*set_module)(struct _oic_log_ctx *, const char *);
-
- /* Optional interface (if one is implemented, all must be implemented): */
- int (*lock)(struct _oic_log_ctx *);
- int (*unlock)(struct _oic_log_ctx *);
- int (*try_lock)(struct _oic_log_ctx *);
- int (*locked_destroy)(struct _oic_log_ctx *);
-
-} oic_log_ctx_t;
-
-/* Notice that these are all passed the /top level/ ctx-- it's "public" with respect to
- these functions, they have full access to fiddle with the structure all they want (but,
- generally should avoid doing that); I could certainly be convinced to go the other direction,
- and have most functions only take the inner context: */
-typedef int (*oic_log_init_t)(oic_log_ctx_t *, void *);
-typedef void (*oic_log_destroy_t)(oic_log_ctx_t *);
-typedef void (*oic_log_flush_t)(oic_log_ctx_t *);
-typedef void (*oic_log_set_level_t)(oic_log_ctx_t *, const int);
-typedef size_t (*oic_log_write_level_t)(oic_log_ctx_t *, const int, const char *);
-typedef int (*oic_log_set_module_t)(oic_log_ctx_t *, const char *);
-typedef int (*oic_log_lock_t)(oic_log_ctx_t *);
-typedef int (*oic_log_unlock_t)(oic_log_ctx_t *);
-typedef int (*oic_log_try_lock_t)(oic_log_ctx_t *);
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
-
-#endif /* OIC_LOGGER_TYPES_H_ */
-
+++ /dev/null
-//******************************************************************
-//
-// Copyright 2014 Intel Mobile Communications GmbH All Rights Reserved.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-
-// Defining _POSIX_C_SOURCE macro with 199309L (or greater) as value
-// causes header files to expose definitions
-// corresponding to the POSIX.1b, Real-time extensions
-// (IEEE Std 1003.1b-1993) specification
-//
-// For this specific file, see use of clock_gettime,
-// Refer to http://pubs.opengroup.org/stage7tc1/functions/clock_gettime.html
-// and to http://man7.org/linux/man-pages/man2/clock_gettime.2.html
-#ifndef _POSIX_C_SOURCE
-#define _POSIX_C_SOURCE 200809L
-#endif
-
-// Platform check can be extended to check and/or define more, or could be
-// moved into a config.h
-#if !defined(__ARDUINO__) && !defined(ARDUINO)
-#define HAVE_UNISTD_H 1
-#endif
-
-// Pull in _POSIX_TIMERS feature test macro to check for
-// clock_gettime() support.
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-
-// if we have unistd.h, we're a Unix system
-#include <time.h>
-#include <sys/time.h>
-#endif
-
-#include "logger.h"
-#include "string.h"
-#include "oic_logger.h"
-#include "oic_console_logger.h"
-
-#ifndef __TIZEN__
-static oic_log_ctx_t *logCtx = 0;
-
-#ifndef __ANDROID__
-static oic_log_level LEVEL_XTABLE[] =
-{ OIC_LOG_DEBUG, OIC_LOG_INFO, OIC_LOG_WARNING, OIC_LOG_ERROR, OIC_LOG_FATAL };
-#endif
-
-#endif
-
-static const uint16_t LINE_BUFFER_SIZE = (16 * 2) + 16 +
- 1; // Show 16 bytes, 2 chars/byte, spaces between bytes, null termination
-
-// Convert LogLevel to platform-specific severity level. Store in PROGMEM on Arduino
-#ifdef __ANDROID__
-#ifdef ADB_SHELL
-static const char *LEVEL[] =
-{ "DEBUG", "INFO", "WARNING", "ERROR", "FATAL"};
-
-#else
-static android_LogPriority LEVEL[] =
-{ ANDROID_LOG_DEBUG, ANDROID_LOG_INFO, ANDROID_LOG_WARN, ANDROID_LOG_ERROR, ANDROID_LOG_FATAL};
-#endif
-#elif defined (__linux__) || defined (__APPLE__)
-static const char *LEVEL[] __attribute__ ((unused)) =
-{ "DEBUG", "INFO", "WARNING", "ERROR", "FATAL"};
-#elif defined ARDUINO
-#include <stdarg.h>
-#include "Arduino.h"
-
-PROGMEM const char level0[] = "DEBUG";
-PROGMEM const char level1[] = "INFO";
-PROGMEM const char level2[] = "WARNING";
-PROGMEM const char level3[] = "ERROR";
-PROGMEM const char level4[] = "FATAL";
-
-PROGMEM const char *const LEVEL[] =
-{ level0, level1, level2, level3, level4};
-
-static void OICLogString(LogLevel level, PROGMEM const char *tag, PROGMEM const char *logStr);
-#ifdef ARDUINO_ARCH_AVR
-//Mega2560 and other 8-bit AVR microcontrollers
-#define GET_PROGMEM_BUFFER(buffer, addr) { strcpy_P(buffer, (char*)pgm_read_word(addr));}
-#elif defined ARDUINO_ARCH_SAM
-//Arduino Due and other 32-bit ARM micro-controllers
-#define GET_PROGMEM_BUFFER(buffer, addr) { strcpy_P(buffer, (char*)pgm_read_dword(addr));}
-#else
-#define GET_PROGMEM_BUFFER(buffer, addr) { buffer[0] = '\0';}
-#endif
-#endif // __ANDROID__
-
-#ifndef ARDUINO
-#ifndef __TIZEN__
-void OICLogConfig(oic_log_ctx_t *ctx)
-{
- logCtx = ctx;
-}
-
-void OICLogInit()
-{
-
-}
-
-void OICLogShutdown()
-{
-#if defined(__linux__) || defined(__APPLE__)
- if (logCtx && logCtx->destroy)
- {
- logCtx->destroy(logCtx);
- }
-#endif
-}
-
-/**
- * Output a log string with the specified priority level.
- * Only defined for Linux and Android
- *
- * @param level - DEBUG, INFO, WARNING, ERROR, FATAL
- * @param tag - Module name
- * @param logStr - log string
- */
-void OICLog(LogLevel level, const char *tag, const char *logStr)
-{
- if (!logStr || !tag)
- {
- return;
- }
-
-#ifdef __ANDROID__
-
-#ifdef ADB_SHELL
- printf("%s: %s: %s\n", LEVEL[level], tag, logStr);
-#else
- __android_log_write(LEVEL[level], tag, logStr);
-#endif
-
-#elif defined __linux__ || defined __APPLE__
- if (logCtx && logCtx->write_level)
- {
- logCtx->write_level(logCtx, LEVEL_XTABLE[level], logStr);
-
- }
- else
- {
- int min = 0;
- int sec = 0;
- int ms = 0;
-#if defined(_POSIX_TIMERS) && _POSIX_TIMERS > 0
- struct timespec when = { 0, 0 };
- clockid_t clk = CLOCK_REALTIME;
-#ifdef CLOCK_REALTIME_COARSE
- clk = CLOCK_REALTIME_COARSE;
-#endif
- if (!clock_gettime(clk, &when))
- {
- min = (when.tv_sec / 60) % 60;
- sec = when.tv_sec % 60;
- ms = when.tv_nsec / 1000000;
- }
-#else
- struct timeval now;
- if (!gettimeofday(&now, NULL))
- {
- min = (now.tv_sec / 60) % 60;
- sec = now.tv_sec % 60;
- ms = now.tv_usec * 1000;
- }
-#endif
- printf("%02d:%02d.%03d %s: %s: %s\n", min, sec, ms, LEVEL[level], tag, logStr);
- }
-#endif
-}
-
-/**
- * Output a variable argument list log string with the specified priority level.
- * Only defined for Linux and Android
- *
- * @param level - DEBUG, INFO, WARNING, ERROR, FATAL
- * @param tag - Module name
- * @param format - variadic log string
- */
-void OICLogv(LogLevel level, const char *tag, const char *format, ...)
-{
- if (!format || !tag)
- {
- return;
- }
- char buffer[MAX_LOG_V_BUFFER_SIZE] = {};
- va_list args;
- va_start(args, format);
- vsnprintf(buffer, sizeof buffer - 1, format, args);
- va_end(args);
- OICLog(level, tag, buffer);
-}
-
-/**
- * Output the contents of the specified buffer (in hex) with the specified priority level.
- *
- * @param level - DEBUG, INFO, WARNING, ERROR, FATAL
- * @param tag - Module name
- * @param buffer - pointer to buffer of bytes
- * @param bufferSize - max number of byte in buffer
- */
-void OICLogBuffer(LogLevel level, const char *tag, const uint8_t *buffer, uint16_t bufferSize)
-{
- if (!buffer || !tag || (bufferSize == 0))
- {
- return;
- }
-
- // I've got no idea why static initialization doesn't work here. It seems that the compiler
- // seems to think that this is a variable-sized object
- char lineBuffer[LINE_BUFFER_SIZE];
- memset(lineBuffer, 0, sizeof lineBuffer);
- int lineIndex = 0;
- int i;
- for (i = 0; i < bufferSize; i++)
- {
- // Format the buffer data into a line
- snprintf(&lineBuffer[lineIndex*3], sizeof(lineBuffer)-lineIndex*3, "%02X ", buffer[i]);
- lineIndex++;
- // Output 16 values per line
- if (((i + 1) % 16) == 0)
- {
- OICLog(level, tag, lineBuffer);
- memset(lineBuffer, 0, sizeof lineBuffer);
- lineIndex = 0;
- }
- }
- // Output last values in the line, if any
- if (bufferSize % 16)
- {
- OICLog(level, tag, lineBuffer);
- }
-}
-#endif //__TIZEN__
-#endif //ARDUINO
-#ifdef ARDUINO
-/**
- * Initialize the serial logger for Arduino
- * Only defined for Arduino
- */
-void OICLogInit()
-{
- Serial.begin(115200);
-}
-
-/**
- * Output a log string with the specified priority level.
- * Only defined for Arduino. Only uses PROGMEM strings
- * for the tag parameter
- *
- * @param level - DEBUG, INFO, WARNING, ERROR, FATAL
- * @param tag - Module name
- * @param logStr - log string
- */
- void OICLogString(LogLevel level, PROGMEM const char * tag,
- const char * logStr)
- {
- if (!logStr || !tag)
- {
- return;
- }
-
- char buffer[LINE_BUFFER_SIZE] = {};
- strcpy_P(buffer, (char*)pgm_read_word(&(LEVEL[level])));
- Serial.print(buffer);
-
- char c = NULL;
- Serial.print(F(": "));
- while ((c = pgm_read_byte(tag)))
- {
- Serial.write(c);
- tag++;
- }
- Serial.print(F(": "));
-
- Serial.println(logStr);
- }
-
-/**
- * Output the contents of the specified buffer (in hex) with the specified
- * priority level.
- *
- * @param level - DEBUG, INFO, WARNING, ERROR, FATAL
- * @param tag - Module name
- * @param buffer - pointer to buffer of bytes
- * @param bufferSize - max number of byte in buffer
- */
- void OICLogBuffer(LogLevel level, PROGMEM const char * tag,
- const uint8_t * buffer, uint16_t bufferSize)
- {
- if (!buffer || !tag || (bufferSize == 0))
- {
- return;
- }
-
- char lineBuffer[LINE_BUFFER_SIZE] = {0};
- uint8_t lineIndex = 0;
- for (uint8_t i = 0; i < bufferSize; i++)
- {
- // Format the buffer data into a line
- snprintf(&lineBuffer[lineIndex*3], sizeof(lineBuffer)-lineIndex*3, "%02X ", buffer[i]);
- lineIndex++;
- // Output 16 values per line
- if (((i+1)%16) == 0)
- {
- OICLogString(level, tag, lineBuffer);
- memset(lineBuffer, 0, sizeof lineBuffer);
- lineIndex = 0;
- }
- }
- // Output last values in the line, if any
- if (bufferSize % 16)
- {
- OICLogString(level, tag, lineBuffer);
- }
- }
-
-/**
- * Output a log string with the specified priority level.
- * Only defined for Arduino. Uses PROGMEM strings
- *
- * @param level - DEBUG, INFO, WARNING, ERROR, FATAL
- * @param tag - Module name
- * @param logStr - log string
- */
-void OICLog(LogLevel level, PROGMEM const char *tag, const int16_t lineNum,
- PROGMEM const char *logStr)
-{
- if (!logStr || !tag)
- {
- return;
- }
- char buffer[LINE_BUFFER_SIZE] = {0};
- GET_PROGMEM_BUFFER(buffer, &(LEVEL[level]));
- Serial.print(buffer);
- char c;
- Serial.print(F(": "));
- while ((c = pgm_read_byte(tag)))
- {
- Serial.write(c);
- tag++;
- }
- Serial.print(F(": "));
- Serial.print(lineNum);
- Serial.print(F(": "));
- while ((c = pgm_read_byte(logStr)))
- {
- Serial.write(c);
- logStr++;
- }
- Serial.println();
-}
-
-/**
- * Output a variable argument list log string with the specified priority level.
- * Only defined for Arduino as depicted below.
- *
- * @param level - DEBUG, INFO, WARNING, ERROR, FATAL
- * @param tag - Module name
- * @param format - variadic log string
- */
-void OICLogv(LogLevel level, PROGMEM const char *tag, const int16_t lineNum,
- PROGMEM const char *format, ...)
-{
- char buffer[LINE_BUFFER_SIZE];
- va_list ap;
- va_start(ap, format);
- GET_PROGMEM_BUFFER(buffer, &(LEVEL[level]));
- Serial.print(buffer);
-
- char c;
- Serial.print(F(": "));
- while ((c = pgm_read_byte(tag))) {
- Serial.write(c);
- tag++;
- }
- Serial.print(F(": "));
- Serial.print(lineNum);
- Serial.print(F(": "));
-
-#ifdef __AVR__
- vsnprintf_P(buffer, sizeof(buffer), format, ap);
-#else
- vsnprintf(buffer, sizeof(buffer), format, ap);
-#endif
- for (char *p = &buffer[0]; *p; p++)
- {
- // emulate cooked mode for newlines
- if (*p == '\n')
- {
- Serial.write('\r');
- }
- Serial.write(*p);
- }
- Serial.println();
- va_end(ap);
-}
-/**
- * Output a variable argument list log string with the specified priority level.
- * Only defined for Arduino as depicted below.
- *
- * @param level - DEBUG, INFO, WARNING, ERROR, FATAL
- * @param tag - Module name
- * @param format - variadic log string
- */
-void OICLogv(LogLevel level, const char *tag, const __FlashStringHelper *format, ...)
-{
- char buffer[LINE_BUFFER_SIZE];
- va_list ap;
- va_start(ap, format);
- // strcpy_P(buffer, (char*)pgm_read_word(&(LEVEL[level])));
- // Serial.print(buffer);
-
- Serial.print(LEVEL[level]);
- // char c;
- Serial.print(F(": "));
-
- /*while ((c = pgm_read_byte(tag))) {
- Serial.write(c);
- tag++;
- }*/
- Serial.print(tag);
- Serial.print(F(": "));
-
-#ifdef __AVR__
- vsnprintf_P(buffer, sizeof(buffer), (const char *)format, ap); // progmem for AVR
-#else
- vsnprintf(buffer, sizeof(buffer), (const char *)format, ap); // for the rest of the world
-#endif
- for (char *p = &buffer[0]; *p; p++)
- {
- // emulate cooked mode for newlines
- if (*p == '\n')
- {
- // Serial.write('\r');
- Serial.print('\r');
- }
- //Serial.write(*p);
- Serial.print(p);
- }
- Serial.println();
- va_end(ap);
-}
-
-#endif //ARDUINO
\ No newline at end of file
+++ /dev/null
-//******************************************************************
-//
-// Copyright 2014 Intel Mobile Communications GmbH All Rights Reserved.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-
-#include "oic_logger.h"
-#include "oic_console_logger.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-
-typedef struct
-{
- FILE *out;
-} oic_console_logger_ctx;
-
-oic_log_ctx_t *oic_make_console_logger()
-{
- return oic_log_make_ctx(NULL, OIC_LOG_ALL, oic_console_logger_init, oic_console_logger_destroy,
- oic_console_logger_flush, oic_console_logger_set_level,
- oic_console_logger_write,oic_console_logger_set_module);
-}
-
-int oic_console_logger_init(oic_log_ctx_t *ctx, void *world)
-{
- (void)world;
- oic_console_logger_ctx *my_ctx =
- (oic_console_logger_ctx *) malloc(sizeof(oic_console_logger_ctx));
-
- if (0 == my_ctx)
- return 0;
-
- my_ctx->out = stderr;
-
- ctx->ctx = (void *) my_ctx;
-
- return 1;
-}
-
-void oic_console_logger_destroy(oic_log_ctx_t *ctx)
-{
- oic_console_logger_ctx *lctx = (oic_console_logger_ctx *) ctx->ctx;
-
- fflush(lctx->out);
-
- free(lctx);
-}
-
-void oic_console_logger_flush(oic_log_ctx_t *ctx)
-{
- oic_console_logger_ctx *lctx = (oic_console_logger_ctx *) ctx->ctx;
-
- fflush(lctx->out);
-}
-
-void oic_console_logger_set_level(oic_log_ctx_t *ctx, const int level)
-{
- (void)ctx;
- (void)level;
- /* We don't have any special thing we need to do when a log level changes. */
- return;
-}
-
-size_t oic_console_logger_write(oic_log_ctx_t *ctx, const int level, const char *msg)
-{
- oic_console_logger_ctx *lctx = (oic_console_logger_ctx *) ctx->ctx;
-
- /* A "real" implementation might want to replace the loglevel with a mnemonic: */
-
- if (0 == ctx->module_name)
- return 1 + fprintf(lctx->out, "%d: %s\n", level, msg);
-
- return 1 + fprintf(lctx->out, "%d: [%s]: %s\n", level, ctx->module_name, msg);
-}
-
-int oic_console_logger_set_module(oic_log_ctx_t *ctx, const char *module_name)
-{
- (void)ctx;
- (void)module_name;
- /* We don't do anything special when the module name changes: */
- return 1;
-}
+++ /dev/null
-//******************************************************************
-//
-// Copyright 2014 Intel Mobile Communications GmbH All Rights Reserved.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-
-#include "oic_logger.h"
-#include "oic_string.h"
-
-#include <string.h>
-#include <stdlib.h>
-
-oic_log_ctx_t *oic_log_make_ctx(void *world, const oic_log_level level, oic_log_init_t init,
- oic_log_destroy_t destroy, oic_log_flush_t flush,
- oic_log_set_level_t set_level,oic_log_write_level_t write_level,
- oic_log_set_module_t set_module)
-{
- oic_log_ctx_t *log_ctx;
-
- if (0 == init || 0 == destroy || 0 == flush || 0 == set_level || 0 == write_level
- || 0 == set_module)
- return 0;
-
- if (__OIC_LOG_MIN__ > level || __OIC_LOG_MAX__ < level)
- return 0;
-
- log_ctx = (oic_log_ctx_t *) malloc(sizeof(oic_log_ctx_t));
-
- if (0 == log_ctx)
- return 0;
-
- log_ctx->ctx = 0; /* we'll get to this in a sec... */
- log_ctx->log_level = level;
- log_ctx->module_name = 0;
- log_ctx->init = init;
- log_ctx->destroy = destroy;
- log_ctx->flush = flush;
- log_ctx->set_level = set_level;
- log_ctx->set_module = set_module;
-
- log_ctx->write_level = write_level;
-
- if (0 == log_ctx->init(log_ctx, world))
- {
- free(log_ctx);
- return 0;
- }
-
- return log_ctx;
-}
-
-void oic_log_destroy(oic_log_ctx_t *ctx)
-{
- if (0 == ctx)
- return;
-
- ctx->destroy(ctx);
-
- if (0 != ctx->module_name)
- free(ctx->module_name);
-
- free(ctx);
-}
-
-int oic_log_init(oic_log_ctx_t *ctx, void *world)
-{
- if (0 == ctx)
- return 0;
-
- return ctx->init(ctx, world);
-}
-
-void oic_log_flush(oic_log_ctx_t *ctx)
-{
- if (0 == ctx)
- {
- return;
- }
- ctx->flush(ctx);
-}
-
-void oic_log_set_level(oic_log_ctx_t *ctx, const oic_log_level ll)
-{
- if (0 == ctx)
- {
- return;
- }
- ctx->set_level(ctx, ll);
-}
-
-size_t oic_log_write(oic_log_ctx_t *ctx, const char *msg)
-{
- if (0 == ctx)
- return 0;
-
- return oic_log_write_level(ctx, ctx->log_level, msg);
-}
-
-size_t oic_log_write_level(oic_log_ctx_t *ctx, const oic_log_level ll, const char *msg)
-{
- if (0 == ctx)
- return 0;
-
- ctx->log_level = ll;
-
- /* Notify: */
- return ctx->write_level(ctx, ll, msg);
-}
-
-int oic_log_set_module(oic_log_ctx_t *ctx, const char *module_name)
-{
- char *mn;
-
- if (0 == ctx)
- return 0;
-
- /* Swap pointers so that module data's not erased in the event of failure: */
- mn = OICStrdup(module_name);
- if (0 == mn)
- {
- if (0 != ctx->module_name)
- free(ctx->module_name);
- return 0;
- }
-
- if (0 != ctx->module_name)
- free(ctx->module_name);
-
- ctx->module_name = mn;
-
- /* Notify: */
- return ctx->set_module(ctx, ctx->module_name);
-}
-
-
secured = env.get('SECURED')
with_ra = env.get ('WITH_RA')
with_tcp = env.get('WITH_TCP')
+src_dir = env.get('SRC_DIR')
root_dir = os.pardir
ca_path = os.curdir
env.PrependUnique(CPPPATH = [ os.path.join(root_dir, 'api') ])
env.AppendUnique(CPPPATH = [ os.path.join(root_dir, 'inc'),
os.path.join(root_dir, 'lib/libcoap-4.1.1'),
+ os.path.join(src_dir, '/resource/csdk/logger/include/'),
os.path.join(root_dir, 'common/inc') ])
if ca_os not in ['arduino', 'windows', 'winrt']:
'adapter_util/caadapterutils.c')])
env.AppendUnique(CA_SRC = [os.path.join(ca_path,
'adapter_util/cafragmentation.c')])
+
if env.get('SECURED') == '1':
env.AppendUnique(CA_SRC = [os.path.join(ca_path,
'adapter_util/caadapternetdtls.c')])
env.AppendUnique(CPPPATH = [os.path.join(root_dir,
'external/inc')])
if env.get('DTLS_WITH_X509') == '1':
- src_dir = env.get('SRC_DIR')
env.AppendUnique(CPPPATH = [src_dir + '/resource/csdk/connectivity/inc/pkix'])
env.AppendUnique(CPPPATH = [src_dir + '/extlibs/tinydtls/ecc/'])
env.AppendUnique(CPPPATH = [src_dir + '/extlibs/tinydtls/sha2/'])
--- /dev/null
+Import('env')
+import os
+
+env.AppendUnique(CPPPATH = [os.path.join(Dir('.').abspath, './include')])
+
+if env.get('TARGET_OS') == 'tizen':
+ env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
+else:
+ env.AppendUnique(LIBPATH = [os.path.join(env.get('BUILD_DIR'), 'resource/csdk/logger/')])
+
+env.PrependUnique(LIBS = ['logger'])
+
+local_env = env.Clone()
+
+######################################################################
+# Source files and Targets
+######################################################################
+
+#TODO work-around: at the moment if an Arduino build is done the logger.c file
+# ends up using C++ such as for the arduino Time Library, Serial, etc.
+# Therefore we copy it to a .cpp name so it is compiled correctly.
+
+if env.get('TARGET_OS') in ['arduino']:
+ Command("./src/logger.cpp", "./src/logger.c", Copy("$TARGET", "$SOURCE"))
+ logger_src = ['./src/logger.cpp']
+else:
+ logger_src = ['./src/logger.c']
+
+loggerlib = local_env.StaticLibrary('logger', logger_src)
+local_env.InstallTarget(loggerlib, 'logger')
+
#include <stdint.h>
#include <stdio.h>
#include <stdarg.h>
-#include "oc_logger.h"
-#include "oc_console_logger.h"
+#include "logger_types.h"
#ifdef __ANDROID__
- #include <android/log.h>
+#include <android/log.h>
#elif defined(__TIZEN__)
#include <dlog.h>
-#elif defined ARDUINO
- #include "Arduino.h"
- #include <avr/pgmspace.h>
+#elif defined(ARDUINO)
+#include "Arduino.h"
+#include "avr/pgmspace.h"
#endif
#ifdef __cplusplus
-extern "C" {
+extern "C"
+{
#endif
// Use the PCF macro to wrap strings stored in FLASH on the Arduino
* @param bufferSize - max number of byte in buffer
*/
void OCLogBuffer(LogLevel level, const char * tag, const uint8_t * buffer, uint16_t bufferSize);
-#else
+#else // For arduino platforms
/**
* Initialize the serial logger for Arduino
* Only defined for Arduino
*
* @param level - DEBUG, INFO, WARNING, ERROR, FATAL
* @param tag - Module name
+ * @param lineNum- line Number
* @param logStr - log string
*/
- void OCLog(LogLevel level, PROGMEM const char * tag, PROGMEM const char * logStr);
+ void OCLog(LogLevel level, PROGMEM const char *tag, const int lineNum,
+ PROGMEM const char *logStr);
/**
* Output the contents of the specified buffer (in hex) with the specified priority level.
* @param buffer - pointer to buffer of bytes
* @param bufferSize - max number of byte in buffer
*/
- void OCLogBuffer(LogLevel level, PROGMEM const char * tag, const uint8_t * buffer, uint16_t bufferSize);
+ void OCLogBuffer(LogLevel level, const char *tag, const uint8_t *buffer, size_t bufferSize);
/**
* Output a variable argument list log string with the specified priority level.
*
* @param level - DEBUG, INFO, WARNING, ERROR, FATAL
* @param tag - Module name
+ * @param lineNum- line Number
* @param format - variadic log string
*/
- void OCLogv(LogLevel level, const char * tag, const char * format, ...)
+ void OCLogv(LogLevel level, PROGMEM const char *tag, const int lineNum,
+ PROGMEM const char *format, ...)
#if defined(__GNUC__)
- __attribute__ ((format(printf, 3, 4)))
+ __attribute__ ((format(printf, 4, 5)))
#endif
- ;
+;
#endif
#ifdef TB_LOG
+
#ifdef __TIZEN__
- #define OC_LOG(level,tag,mes) LOG_(LOG_ID_MAIN, level, tag, mes)
- #define OC_LOG_V(level,tag,fmt,args...) LOG_(LOG_ID_MAIN, level, tag, fmt,##args)
- #define OC_LOG_BUFFER(level, tag, buffer, bufferSize)
+
+#define OIC_LOG(level,tag,mes) LOG_(LOG_ID_MAIN, (level), (tag), mes)
+#define OIC_LOG_V(level,tag,fmt,args...) LOG_(LOG_ID_MAIN, level, tag, fmt, ##args)
+#define OIC_LOG_BUFFER(level, tag, buffer, bufferSize)
+
+#define OC_LOG(level,tag,mes) LOG_(LOG_ID_MAIN, (level), (tag), mes)
+#define OC_LOG_V(level,tag,fmt,args...) LOG_(LOG_ID_MAIN, (level), (tag), fmt, ##args)
+#define OC_LOG_BUFFER(level, tag, buffer, bufferSize)
+
#else // These macros are defined for Linux, Android, and Arduino
- #define OC_LOG_INIT() OCLogInit()
- #define OC_LOG_BUFFER(level, tag, buffer, bufferSize) OCLogBuffer((level), PCF(tag), (buffer), (bufferSize))
-
- #ifdef ARDUINO
- #define OC_LOG_CONFIG(ctx)
- #define OC_LOG_SHUTDOWN()
- #define OC_LOG(level, tag, logStr) OCLog((level), PCF(tag), PCF(logStr))
- // Use full namespace for logInit to avoid function name collision
- #define OC_LOG_INIT() OCLogInit()
- // Don't define variable argument log function for Arduino
- #define OC_LOG_V(level, tag, format, ...) OCLogv((level), PCF(tag), PCF(format), __VA_ARGS__)
- #else
- #define OC_LOG_CONFIG(ctx) OCLogConfig((ctx))
- #define OC_LOG(level, tag, logStr) OCLog((level), (tag), (logStr))
- #define OC_LOG_SHUTDOWN() OCLogShutdown()
- // Define variable argument log function for Linux and Android
- #define OC_LOG_V(level, tag, ...) OCLogv((level), (tag), __VA_ARGS__)
- #endif
-#endif
+
+#define OC_LOG_INIT() OCLogInit()
+#define OIC_LOG_INIT() OCLogInit()
+
+#ifdef ARDUINO
+
+#define OC_LOG_BUFFER(level, tag, buffer, bufferSize) OCLogBuffer((level), PCF(tag), (buffer), (bufferSize))
+#define OIC_LOG_BUFFER(level, tag, buffer, bufferSize) OCLogBuffer((level), PCF(tag), (buffer), (bufferSize))
+#define OC_LOG_CONFIG(ctx)
+#define OC_LOG_SHUTDOWN()
+#define OC_LOG(level, tag, logStr) OCLog((level), PCF(tag), __LINE__, PCF(logStr))
+// Don't define variable argument log function for Arduino
+#define OC_LOG_V(level, tag, format, ...) OCLogv((level), PCF(tag), __LINE__, PCF(format),__VA_ARGS__)
+
+#define OIC_LOG_CONFIG(ctx)
+#define OIC_LOG_SHUTDOWN()
+#define OIC_LOG(level, tag, logStr) OCLog((level), PCF(tag), __LINE__, PCF(logStr))
+#define OIC_LOG_V(level, tag, ...)
+
#else
- #define OC_LOG_CONFIG(ctx)
- #define OC_LOG_SHUTDOWN()
- #define OC_LOG(level, tag, logStr)
- #define OC_LOG_V(level, tag, ...)
- #define OC_LOG_BUFFER(level, tag, buffer, bufferSize)
- #define OC_LOG_INIT()
+
+#define OC_LOG_BUFFER(level, tag, buffer, bufferSize) OCLogBuffer((level), (tag), (buffer), (bufferSize))
+#define OIC_LOG_BUFFER(level, tag, buffer, bufferSize) OCLogBuffer((level), (tag), (buffer), (bufferSize))
+#define OC_LOG_CONFIG(ctx) OCLogConfig((ctx))
+#define OC_LOG_SHUTDOWN() OCLogShutdown()
+#define OC_LOG(level, tag, logStr) OCLog((level), (tag), (logStr))
+// Define variable argument log function for Linux and Android
+#define OC_LOG_V(level, tag, ...) OCLogv((level), (tag), __VA_ARGS__)
+
+#define OIC_LOG_CONFIG(ctx) OCLogConfig((ctx))
+#define OIC_LOG_SHUTDOWN() OCLogShutdown()
+#define OIC_LOG(level, tag, logStr) OCLog((level), (tag), (logStr))
+// Define variable argument log function for Linux and Android
+#define OIC_LOG_V(level, tag, ...) OCLogv((level), (tag), __VA_ARGS__)
+
+#endif //ARDUINO
+#endif //__TIZEN__
+
+#else //TB_LOG
+
+#define OC_LOG_CONFIG(ctx)
+#define OC_LOG_SHUTDOWN()
+#define OC_LOG(level, tag, logStr)
+#define OC_LOG_V(level, tag, ...)
+#define OC_LOG_BUFFER(level, tag, buffer, bufferSize)
+#define OC_LOG_INIT()
+
+#define OIC_LOG_CONFIG(ctx)
+#define OIC_LOG_SHUTDOWN()
+#define OIC_LOG(level, tag, logStr)
+#define OIC_LOG_V(level, tag, ...)
+#define OIC_LOG_BUFFER(level, tag, buffer, bufferSize)
+#define OIC_LOG_INIT()
#endif
#ifdef __cplusplus
--- /dev/null
+//******************************************************************
+//
+// Copyright 2014 Intel Mobile Communications GmbH All Rights Reserved.
+//
+//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+
+#ifndef OC_LOGGER_TYPES_H_
+#define OC_LOGGER_TYPES_H_
+
+#include <stddef.h>
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+typedef enum
+{
+ OC_LOG_MIN_VAL__ = -1,
+ OC_LOG_ALL = 0,
+ OC_LOG_FATAL,
+ OC_LOG_ERROR,
+ OC_LOG_WARNING,
+ OC_LOG_INFO,
+ OC_LOG_DEBUG,
+ OC_LOG_DISABLED,
+ OC_LOG_MAX_VAL__
+} oc_log_level;
+
+typedef struct _oc_log_ctx
+{
+ void* ctx;
+
+ oc_log_level log_level;
+
+ char* module_name;
+
+ /* Required interface: */
+ int (*init) (struct _oc_log_ctx *, void *);
+ void (*destroy) (struct _oc_log_ctx *);
+ void (*flush) (struct _oc_log_ctx *);
+ void (*set_level) (struct _oc_log_ctx *, const int);
+ size_t (*write_level) (struct _oc_log_ctx *, const int, const char *);
+ int (*set_module) (struct _oc_log_ctx *, const char *);
+
+ /* Optional interface (if one is implemented, all must be implemented): */
+ int (*lock) (struct _oc_log_ctx *);
+ int (*unlock) (struct _oc_log_ctx *);
+ int (*try_lock) (struct _oc_log_ctx *);
+ int (*locked_destroy) (struct _oc_log_ctx *);
+} oc_log_ctx_t;
+
+/* Notice that these are all passed the /top level/ ctx-- it's "public" with respect to
+these functions, they have full access to fiddle with the structure all they want (but,
+generally should avoid doing that); I could certainly be convinced to go the other direction,
+and have most functions only take the inner context: */
+typedef int (*oc_log_init_t) (oc_log_ctx_t *, void *);
+typedef void (*oc_log_destroy_t) (oc_log_ctx_t *);
+typedef void (*oc_log_flush_t) (oc_log_ctx_t *);
+typedef void (*oc_log_set_level_t) (oc_log_ctx_t *, const int);
+typedef size_t (*oc_log_write_level_t) (oc_log_ctx_t *, const int, const char *);
+typedef int (*oc_log_set_module_t) (oc_log_ctx_t *, const char *);
+typedef int (*oc_log_lock_t) (oc_log_ctx_t *);
+typedef int (*oc_log_unlock_t) (oc_log_ctx_t *);
+typedef int (*oc_log_try_lock_t) (oc_log_ctx_t *);
+
+#ifdef __cplusplus
+ } // extern "C"
+#endif
+
+#endif
+
#include "logger.h"
#include "string.h"
-#include "oc_logger.h"
-#include "oc_console_logger.h"
+#include "logger_types.h"
#ifndef __TIZEN__
static oc_log_ctx_t *logCtx = 0;
// Convert LogLevel to platform-specific severity level. Store in PROGMEM on Arduino
#ifdef __ANDROID__
- static android_LogPriority LEVEL[] = {ANDROID_LOG_DEBUG, ANDROID_LOG_INFO, ANDROID_LOG_WARN, ANDROID_LOG_ERROR, ANDROID_LOG_FATAL};
-#elif defined(__linux__) || defined(__APPLE__)
- static const char * LEVEL[] __attribute__ ((unused)) = {"DEBUG", "INFO", "WARNING", "ERROR", "FATAL"};
+#ifdef ADB_SHELL
+ static const char *LEVEL[] =
+ {"DEBUG", "INFO", "WARNING", "ERROR", "FATAL"};
+
+#else
+ static android_LogPriority LEVEL[] =
+ {ANDROID_LOG_DEBUG, ANDROID_LOG_INFO, ANDROID_LOG_WARN, ANDROID_LOG_ERROR, ANDROID_LOG_FATAL};
+#endif
+#elif defined (__linux__) || defined (__APPLE__)
+ static const char *LEVEL[] __attribute__ ((unused)) =
+ {"DEBUG", "INFO", "WARNING", "ERROR", "FATAL"};
#elif defined ARDUINO
- #include <stdarg.h>
+#include <stdarg.h>
+#include "Arduino.h"
PROGMEM const char level0[] = "DEBUG";
PROGMEM const char level1[] = "INFO";
#ifndef ARDUINO
#ifndef __TIZEN__
-void OCLogConfig(oc_log_ctx_t *ctx) {
+void OCLogConfig(oc_log_ctx_t *ctx)
+{
logCtx = ctx;
}
-void OCLogInit() {
+void OCLogInit()
+{
}
-void OCLogShutdown() {
+void OCLogShutdown()
+{
#if defined(__linux__) || defined(__APPLE__)
if (logCtx && logCtx->destroy)
{
* @param tag - Module name
* @param format - variadic log string
*/
-void OCLogv(LogLevel level, const char * tag, const char * format, ...) {
+void OCLogv(LogLevel level, const char * tag, const char * format, ...)
+{
if (!format || !tag) {
return;
}
OCLog(level, tag, buffer);
}
-static void osalGetTime(int *min,int *sec, int *ms)
-{
- if (min && sec && ms)
- {
-#if defined(_POSIX_TIMERS) && _POSIX_TIMERS > 0
- struct timespec when = { .tv_sec = 0 };
- clockid_t clk = CLOCK_REALTIME;
-#ifdef CLOCK_REALTIME_COARSE
- clk = CLOCK_REALTIME_COARSE;
-#endif
- if (!clock_gettime(clk, &when))
- {
- *min = (when.tv_sec / 60) % 60;
- *sec = when.tv_sec % 60;
- *ms = when.tv_nsec / 1000000;
- }
-#else
- struct timeval now;
- if (!gettimeofday(&now, NULL))
- {
- *min = (now.tv_sec / 60) % 60;
- *sec = now.tv_sec % 60;
- *ms = now.tv_usec * 1000;
- }
-#endif
- }
-}
-
/**
* Output a log string with the specified priority level.
* Only defined for Linux and Android
* @param tag - Module name
* @param logStr - log string
*/
-void OCLog(LogLevel level, const char * tag, const char * logStr) {
- if (!logStr || !tag) {
- return;
- }
-
-#ifdef __ANDROID__
- __android_log_write(LEVEL[level], tag, logStr);
-#elif defined(__linux__) || defined(__APPLE__)
- if (logCtx && logCtx->write_level)
+void OCLog(LogLevel level, const char * tag, const char * logStr)
+{
+ if (!logStr || !tag)
{
- logCtx->write_level(logCtx, LEVEL_XTABLE[level], logStr);
+ return;
}
- else
- {
- int min = 0;
- int sec = 0;
- int ms = 0;
- osalGetTime(&min,&sec,&ms);
- printf("%02d:%02d.%03d %s: %s: %s\n", min, sec, ms, LEVEL[level], tag, logStr);
- }
-#endif
-}
+ #ifdef __ANDROID__
+
+ #ifdef ADB_SHELL
+ printf("%s: %s: %s\n", LEVEL[level], tag, logStr);
+ #else
+ __android_log_write(LEVEL[level], tag, logStr);
+ #endif
+
+ #elif defined __linux__ || defined __APPLE__
+ if (logCtx && logCtx->write_level)
+ {
+ logCtx->write_level(logCtx, LEVEL_XTABLE[level], logStr);
+
+ }
+ else
+ {
+ int min = 0;
+ int sec = 0;
+ int ms = 0;
+ #if defined(_POSIX_TIMERS) && _POSIX_TIMERS > 0
+ struct timespec when = { .tv_sec = 0, .tv_nsec = 0 };
+ clockid_t clk = CLOCK_REALTIME;
+ #ifdef CLOCK_REALTIME_COARSE
+ clk = CLOCK_REALTIME_COARSE;
+ #endif
+ if (!clock_gettime(clk, &when))
+ {
+ min = (when.tv_sec / 60) % 60;
+ sec = when.tv_sec % 60;
+ ms = when.tv_nsec / 1000000;
+ }
+ #else
+ struct timeval now;
+ if (!gettimeofday(&now, NULL))
+ {
+ min = (now.tv_sec / 60) % 60;
+ sec = now.tv_sec % 60;
+ ms = now.tv_usec * 1000;
+ }
+ #endif
+ printf("%02d:%02d.%03d %s: %s: %s\n", min, sec, ms, LEVEL[level], tag, logStr);
+ }
+ #endif
+ }
/**
* Output the contents of the specified buffer (in hex) with the specified priority level.
* @param buffer - pointer to buffer of bytes
* @param bufferSize - max number of byte in buffer
*/
-void OCLogBuffer(LogLevel level, const char * tag, const uint8_t * buffer, uint16_t bufferSize) {
- if (!buffer || !tag || (bufferSize == 0)) {
+void OCLogBuffer(LogLevel level, const char * tag, const uint8_t * buffer, uint16_t bufferSize)
+{
+ if (!buffer || !tag || (bufferSize == 0))
+ {
return;
}
memset(lineBuffer, 0, sizeof lineBuffer);
int lineIndex = 0;
int i;
- for (i = 0; i < bufferSize; i++) {
+ for (i = 0; i < bufferSize; i++)
+ {
// Format the buffer data into a line
snprintf(&lineBuffer[lineIndex*3], sizeof(lineBuffer)-lineIndex*3, "%02X ", buffer[i]);
lineIndex++;
// Output 16 values per line
- if (((i+1)%16) == 0) {
+ if (((i+1)%16) == 0)
+ {
OCLog(level, tag, lineBuffer);
memset(lineBuffer, 0, sizeof lineBuffer);
lineIndex = 0;
}
}
// Output last values in the line, if any
- if (bufferSize % 16) {
+ if (bufferSize % 16)
+ {
OCLog(level, tag, lineBuffer);
}
}
#endif //__TIZEN__
-#else
- /**
- * Initialize the serial logger for Arduino
- * Only defined for Arduino
- */
- void OCLogInit() {
- Serial.begin(115200);
- }
-
- /**
- * Output a log string with the specified priority level.
- * Only defined for Arduino. Only uses PROGMEM strings
- * for the tag parameter
- *
- * @param level - DEBUG, INFO, WARNING, ERROR, FATAL
- * @param tag - Module name
- * @param logStr - log string
- */
- void OCLogString(LogLevel level, PROGMEM const char * tag, const char * logStr) {
- if (!logStr || !tag) {
- return;
- }
-
- char buffer[LINE_BUFFER_SIZE];
-
- GET_PROGMEM_BUFFER(buffer, &(LEVEL[level]));
- Serial.print(buffer);
-
- char c;
- Serial.print(F(": "));
- while ((c = pgm_read_byte(tag))) {
- Serial.write(c);
- tag++;
- }
- Serial.print(F(": "));
+#endif //ARDUINO
+#ifdef ARDUINO
+/**
+ * Initialize the serial logger for Arduino
+ * Only defined for Arduino
+ */
+void OCLogInit()
+{
+ Serial.begin(115200);
+}
- Serial.println(logStr);
+/**
+ * Output a log string with the specified priority level.
+ * Only defined for Arduino. Only uses PROGMEM strings
+ * for the tag parameter
+ *
+ * @param level - DEBUG, INFO, WARNING, ERROR, FATAL
+ * @param tag - Module name
+ * @param logStr - log string
+ */
+void OCLogString(LogLevel level, PROGMEM const char * tag, const char * logStr)
+{
+ if (!logStr || !tag)
+ {
+ return;
}
- /**
- * Output the contents of the specified buffer (in hex) with the specified priority level.
- *
- * @param level - DEBUG, INFO, WARNING, ERROR, FATAL
- * @param tag - Module name
- * @param buffer - pointer to buffer of bytes
- * @param bufferSize - max number of byte in buffer
- */
- void OCLogBuffer(LogLevel level, PROGMEM const char * tag, const uint8_t * buffer, uint16_t bufferSize) {
- if (!buffer || !tag || (bufferSize == 0)) {
- return;
- }
-
- char lineBuffer[LINE_BUFFER_SIZE] = {0};
- uint8_t lineIndex = 0;
- for (uint8_t i = 0; i < bufferSize; i++) {
- // Format the buffer data into a line
- snprintf(&lineBuffer[lineIndex*3], sizeof(lineBuffer)-lineIndex*3, "%02X ", buffer[i]);
- lineIndex++;
- // Output 16 values per line
- if (((i+1)%16) == 0) {
- OCLogString(level, tag, lineBuffer);
- memset(lineBuffer, 0, sizeof lineBuffer);
- lineIndex = 0;
- }
- }
- // Output last values in the line, if any
- if (bufferSize % 16) {
- OCLogString(level, tag, lineBuffer);
- }
- }
+ char buffer[LINE_BUFFER_SIZE];
- /**
- * Output a log string with the specified priority level.
- * Only defined for Arduino. Uses PROGMEM strings
- *
- * @param level - DEBUG, INFO, WARNING, ERROR, FATAL
- * @param tag - Module name
- * @param logStr - log string
- */
- void OCLog(LogLevel level, PROGMEM const char * tag, PROGMEM const char * logStr) {
- if (!logStr || !tag) {
- return;
- }
+ GET_PROGMEM_BUFFER(buffer, &(LEVEL[level]));
+ Serial.print(buffer);
- char buffer[LINE_BUFFER_SIZE];
+ char c;
+ Serial.print(F(": "));
+ while ((c = pgm_read_byte(tag)))
+ {
+ Serial.write(c);
+ tag++;
+ }
+ Serial.print(F(": "));
- GET_PROGMEM_BUFFER(buffer, &(LEVEL[level]));
- Serial.print(buffer);
+ Serial.println(logStr);
+}
- char c;
- Serial.print(F(": "));
- while ((c = pgm_read_byte(tag))) {
- Serial.write(c);
- tag++;
- }
- Serial.print(F(": "));
+/**
+ * Output the contents of the specified buffer (in hex) with the specified
+ * priority level.
+ *
+ * @param level - DEBUG, INFO, WARNING, ERROR, FATAL
+ * @param tag - Module name
+ * @param buffer - pointer to buffer of bytes
+ * @param bufferSize - max number of byte in buffer
+ */
+ void OCLogBuffer(LogLevel level, PROGMEM const char * tag,
+ const uint8_t * buffer, size_t bufferSize)
+ {
+ if (!buffer || !tag || (bufferSize == 0))
+ {
+ return;
+ }
+
+ char lineBuffer[LINE_BUFFER_SIZE] = {0};
+ uint8_t lineIndex = 0;
+ for (uint8_t i = 0; i < bufferSize; i++)
+ {
+ // Format the buffer data into a line
+ snprintf(&lineBuffer[lineIndex*3], sizeof(lineBuffer)-lineIndex*3, "%02X ", buffer[i]);
+ lineIndex++;
+ // Output 16 values per line
+ if (((i+1)%16) == 0)
+ {
+ OCLogString(level, tag, lineBuffer);
+ memset(lineBuffer, 0, sizeof lineBuffer);
+ lineIndex = 0;
+ }
+ }
+ // Output last values in the line, if any
+ if (bufferSize % 16)
+ {
+ OCLogString(level, tag, lineBuffer);
+ }
+ }
- while ((c = pgm_read_byte(logStr))) {
- Serial.write(c);
- logStr++;
- }
- Serial.println();
+/**
+ * Output a log string with the specified priority level.
+ * Only defined for Arduino. Uses PROGMEM strings
+ *
+ * @param level - DEBUG, INFO, WARNING, ERROR, FATAL
+ * @param tag - Module name
+ * @param logStr - log string
+ */
+void OCLog(LogLevel level, PROGMEM const char *tag, const int lineNum,
+ PROGMEM const char *logStr)
+{
+ if (!logStr || !tag)
+ {
+ return;
}
-
- /**
- * Output a variable argument list log string with the specified priority level.
- * Only defined for Arduino as depicted below.
- *
- * @param level - DEBUG, INFO, WARNING, ERROR, FATAL
- * @param tag - Module name
- * @param format - variadic log string
- */
- void OCLogv(LogLevel level, PROGMEM const char * tag, PROGMEM const char * format, ...)
+ char buffer[LINE_BUFFER_SIZE] = {0};
+ GET_PROGMEM_BUFFER(buffer, &(LEVEL[level]));
+ Serial.print(buffer);
+ char c;
+ Serial.print(F(": "));
+ while ((c = pgm_read_byte(tag)))
{
- char buffer[LINE_BUFFER_SIZE];
- va_list ap;
- va_start(ap, format);
-
- GET_PROGMEM_BUFFER(buffer, &(LEVEL[level]));
- Serial.print(buffer);
+ Serial.write(c);
+ tag++;
+ }
+ Serial.print(F(": "));
+ Serial.print(lineNum);
+ Serial.print(F(": "));
+ while ((c = pgm_read_byte(logStr)))
+ {
+ Serial.write(c);
+ logStr++;
+ }
+ Serial.println();
+}
- char c;
- Serial.print(F(": "));
+/**
+ * Output a variable argument list log string with the specified priority level.
+ * Only defined for Arduino as depicted below.
+ *
+ * @param level - DEBUG, INFO, WARNING, ERROR, FATAL
+ * @param tag - Module name
+ * @param format - variadic log string
+ */
+void OCLogv(LogLevel level, PROGMEM const char *tag, const int lineNum,
+ PROGMEM const char *format, ...)
+{
+ char buffer[LINE_BUFFER_SIZE];
+ va_list ap;
+ va_start(ap, format);
+ GET_PROGMEM_BUFFER(buffer, &(LEVEL[level]));
+ Serial.print(buffer);
+
+ char c;
+ Serial.print(F(": "));
+ while ((c = pgm_read_byte(tag)))
+ {
+ Serial.write(c);
+ tag++;
+ }
+ Serial.print(F(": "));
+ Serial.print(lineNum);
+ Serial.print(F(": "));
- while ((c = pgm_read_byte(tag))) {
- Serial.write(c);
- tag++;
+#ifdef __AVR__
+ vsnprintf_P(buffer, sizeof(buffer), format, ap);
+#else
+ vsnprintf(buffer, sizeof(buffer), format, ap);
+#endif
+ for (char *p = &buffer[0]; *p; p++)
+ {
+ // emulate cooked mode for newlines
+ if (*p == '\n')
+ {
+ Serial.write('\r');
}
- Serial.print(F(": "));
+ Serial.write(*p);
+ }
+ Serial.println();
+ va_end(ap);
+}
+/**
+ * Output a variable argument list log string with the specified priority level.
+ * Only defined for Arduino as depicted below.
+ *
+ * @param level - DEBUG, INFO, WARNING, ERROR, FATAL
+ * @param tag - Module name
+ * @param format - variadic log string
+ */
+void OCLogv(LogLevel level, const char *tag, const __FlashStringHelper *format, ...)
+{
+ char buffer[LINE_BUFFER_SIZE];
+ va_list ap;
+ va_start(ap, format);
+ // strcpy_P(buffer, (char*)pgm_read_word(&(LEVEL[level])));
+ // Serial.print(buffer);
+
+ Serial.print(LEVEL[level]);
+ // char c;
+ Serial.print(F(": "));
+
+ /*while ((c = pgm_read_byte(tag))) {
+ Serial.write(c);
+ tag++;
+ }*/
+ Serial.print(tag);
+ Serial.print(F(": "));
#ifdef __AVR__
- vsnprintf_P(buffer, sizeof(buffer), format, ap);
+ vsnprintf_P(buffer, sizeof(buffer), (const char *)format, ap); // progmem for AVR
#else
- vsnprintf(buffer, sizeof(buffer), format, ap);
+ vsnprintf(buffer, sizeof(buffer), (const char *)format, ap); // for the rest of the world
#endif
- for(char *p = &buffer[0]; *p; p++) // emulate cooked mode for newlines
+ for (char *p = &buffer[0]; *p; p++)
+ {
+ // emulate cooked mode for newlines
+ if (*p == '\n')
{
- if(*p == '\n')
- {
- Serial.write('\r');
- }
- Serial.write(*p);
+ // Serial.write('\r');
+ Serial.print('\r');
}
- Serial.println();
- va_end(ap);
+ //Serial.write(*p);
+ Serial.print(p);
}
+ Serial.println();
+ va_end(ap);
+}
-#endif
+#endif //ARDUINO
cp -rf %{ROOTDIR}/resource/csdk/stack/include/ocstackconfig.h* %{DEST_INC_DIR}/
cp -rf %{ROOTDIR}/resource/csdk/stack/include/octypes.h* %{DEST_INC_DIR}/
cp -rf %{ROOTDIR}/resource/csdk/logger/include/logger.h* %{DEST_INC_DIR}/
+cp -rf %{ROOTDIR}/resource/csdk/logger/include/logger_types.h* %{DEST_INC_DIR}/
cp resource/oc_logger/include/oc_logger.hpp %{DEST_INC_DIR}/
cp resource/oc_logger/include/oc_log_stream.hpp %{DEST_INC_DIR}/
cp resource/oc_logger/include/oc_logger.h %{DEST_INC_DIR}/
namespace Service
{
-void OIC_HOSTING_LOG(LogLevel level, const char * format, ...)
-{
- if (!format) return;
- char buffer[MAX_LOG_V_BUFFER_SIZE] = {};
- va_list args;
- va_start(args, format);
- vsnprintf(buffer, sizeof buffer - 1, format, args);
- va_end(args);
- OCLog(level, PCF("Hosting"), buffer);
-}
-
namespace
{
const auto sizeofHostingTag = strlen("/hosting");
#include "RCSResourceObject.h"
#include "RequestObject.h"
+#define OIC_HOSTING_LOG(level, fmt, args...) OIC_LOG_V((level), PCF("Hosting"), fmt, ##args)
+
namespace OIC
{
namespace Service
{
-void OIC_HOSTING_LOG(LogLevel level, const char * format, ...);
-
class HostingObject : public std::enable_shared_from_this<HostingObject>
{
private: