Skip to content

Commit

Permalink
Replace dfi_log_util.h by celix_err.h.
Browse files Browse the repository at this point in the history
  • Loading branch information
PengZheng committed Dec 13, 2023
1 parent 5393c2a commit 3e61888
Show file tree
Hide file tree
Showing 27 changed files with 88 additions and 342 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,6 @@
#include "celix_log_helper.h"
#include "pubsub_message_serialization_service.h"

static void dfi_log(void *handle, int level, const char *file, int line, const char *msg, ...) {
va_list ap;
celix_log_helper_t *log = handle;
char *logStr = NULL;
va_start(ap, msg);
vasprintf(&logStr, msg, ap);
va_end(ap);
celix_logHelper_log(log, level, "FILE:%s, LINE:%i, MSG:%s", file, line, logStr);
free(logStr);
}


static celix_status_t pubsub_jsonSerializationProvider_serialize(pubsub_serialization_entry_t* entry, const void* msg, struct iovec** output, size_t* outputIovLen) {
celix_status_t status = CELIX_SUCCESS;

Expand Down Expand Up @@ -108,7 +96,6 @@ static void pubsub_jsonSerializationProvider_freeDeserializeMsg(pubsub_serializa

pubsub_serialization_provider_t* pubsub_jsonSerializationProvider_create(celix_bundle_context_t* ctx) {
pubsub_serialization_provider_t* provider = pubsub_serializationProvider_create(ctx, "json", true, 0, pubsub_jsonSerializationProvider_serialize, pubsub_jsonSerializationProvider_freeSerializeMsg, pubsub_jsonSerializationProvider_deserialize, pubsub_jsonSerializationProvider_freeDeserializeMsg);
jsonSerializer_logSetup(dfi_log, pubsub_serializationProvider_getLogHelper(provider), 1);;
return provider;
}

Expand Down
12 changes: 0 additions & 12 deletions bundles/pubsub/pubsub_utils/gtest/src/PubSubMatchingTestSuite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,6 @@
#include "pubsub_endpoint.h"
#include "pubsub_message_serialization_marker.h"

static void stdLog(void*, int level, const char *file, int line, const char *msg, ...) {
va_list ap;
const char *levels[5] = {"NIL", "ERROR", "WARNING", "INFO", "DEBUG"};
fprintf(stderr, "%s: FILE:%s, LINE:%i, MSG:",levels[level], file, line);
va_start(ap, msg);
vfprintf(stderr, msg, ap);
fprintf(stderr, "\n");
va_end(ap);
}

class PubSubMatchingTestSuite : public ::testing::Test {
public:
PubSubMatchingTestSuite() {
Expand All @@ -54,8 +44,6 @@ class PubSubMatchingTestSuite : public ::testing::Test {
ctx = std::shared_ptr<celix_bundle_context_t>{ctxPtr, [](auto*){/*nop*/}};

bndId = celix_bundleContext_installBundle(ctx.get(), MATCHING_BUNDLE, true);

dynMessage_logSetup(stdLog, NULL, 1);
}

~PubSubMatchingTestSuite() override {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,6 @@
#include "celix_framework_factory.h"
#include "celix_constants.h"

static void stdLog(void*, int level, const char *file, int line, const char *msg, ...) {
va_list ap;
const char *levels[5] = {"NIL", "ERROR", "WARNING", "INFO", "DEBUG"};
fprintf(stderr, "%s: FILE:%s, LINE:%i, MSG:",levels[level], file, line);
va_start(ap, msg);
vfprintf(stderr, msg, ap);
fprintf(stderr, "\n");
va_end(ap);
}

class PubSubSerializationHandlerTestSuite : public ::testing::Test {
public:
PubSubSerializationHandlerTestSuite() {
Expand All @@ -50,8 +40,6 @@ class PubSubSerializationHandlerTestSuite : public ::testing::Test {
fw = std::shared_ptr<celix_framework_t>{fwPtr, [](auto* f) {celix_frameworkFactory_destroyFramework(f);}};
ctx = std::shared_ptr<celix_bundle_context_t>{ctxPtr, [](auto*){/*nop*/}};

dynMessage_logSetup(stdLog, NULL, 1);

msgSerSvc.handle = this;
msgSerSvc.serialize = [](void* handle, const void*, struct iovec**, size_t*) -> celix_status_t {
auto* suite = static_cast<PubSubSerializationHandlerTestSuite*>(handle);
Expand Down
16 changes: 0 additions & 16 deletions bundles/pubsub/pubsub_utils/src/pubsub_serialization_provider.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,18 +81,6 @@ struct pubsub_serialization_provider {
celix_array_list_t *serializationSvcEntries; //key = pubsub_serialization_entry;
};

static void dfi_log(void *handle, int level, const char *file, int line, const char *msg, ...) {
(void)level;
va_list ap;
pubsub_serialization_provider_t *provider = handle;
char *logStr = NULL;
va_start(ap, msg);
vasprintf(&logStr, msg, ap);
va_end(ap);
celix_logHelper_log(provider->logHelper, CELIX_LOG_LEVEL_WARNING, "FILE:%s, LINE:%i, MSG:%s", file, line, logStr);
free(logStr);
}

static descriptor_type_e getDescriptorType(const char* filename) {
if (strstr(filename, ".descriptor")) {
return FIT_DESCRIPTOR;
Expand Down Expand Up @@ -610,10 +598,6 @@ pubsub_serialization_provider_t *pubsub_serializationProvider_create(
provider->freeDeserializeMsg = freeDeserializeMsg;
provider->logHelper = celix_logHelper_create(ctx, "celix_pubsub_serialization_provider");

dynFunction_logSetup(dfi_log, provider, 1);
dynType_logSetup(dfi_log, provider, 1);
dynCommon_logSetup(dfi_log, provider, 1);

{
//Start bundle tracker and register pubsub_message_serialization services
celix_bundle_tracking_options_t opts = CELIX_EMPTY_BUNDLE_TRACKING_OPTIONS;
Expand Down
14 changes: 0 additions & 14 deletions libs/dfi/gtest/src/dyn_closure_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,6 @@ extern "C" {

static int g_count;

static void stdLog(void*, int level, const char *file, int line, const char *msg, ...) {
va_list ap;
const char *levels[5] = {"NIL", "ERROR", "WARNING", "INFO", "DEBUG"};
fprintf(stderr, "%s: FILE:%s, LINE:%i, MSG:",levels[level], file, line);
va_start(ap, msg);
vfprintf(stderr, msg, ap);
fprintf(stderr, "\n");
va_end(ap);
}

#define EXAMPLE1_DESCRIPTOR "example(III)I"
static void example1_binding(void*, void* args[], void *out) {
int32_t a = *((int32_t *)args[0]);
Expand Down Expand Up @@ -151,10 +141,6 @@ static void tests() {
class DynClosureTests : public ::testing::Test {
public:
DynClosureTests() {
int lvl = 1;
dynFunction_logSetup(stdLog, NULL, lvl);
dynType_logSetup(stdLog, NULL, lvl);
dynCommon_logSetup(stdLog, NULL, lvl);
g_count = 0;
}
~DynClosureTests() override {
Expand Down
16 changes: 0 additions & 16 deletions libs/dfi/gtest/src/dyn_function_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,35 +19,19 @@

#include "gtest/gtest.h"

#include <stdarg.h>
#include "dyn_example_functions.h"

#include "dyn_common.h"
#include "dyn_function.h"
#include <ffi.h>

static void stdLog(void*, int level, const char *file, int line, const char *msg, ...) {
va_list ap;
const char *levels[5] = {"NIL", "ERROR", "WARNING", "INFO", "DEBUG"};
fprintf(stderr, "%s: FILE:%s, LINE:%i, MSG:",levels[level], file, line);
va_start(ap, msg);
vfprintf(stderr, msg, ap);
fprintf(stderr, "\n");
va_end(ap);
}


#define INVALID_FUNC_DESCRIPTOR "example$[D)V"//$ is an invalid symbol, missing (
#define INVALID_FUNC_TYPE_DESCRIPTOR "example(H)A"//H and A are invalid types


class DynFunctionTests : public ::testing::Test {
public:
DynFunctionTests() {
int lvl = 1;
dynFunction_logSetup(stdLog, nullptr, lvl);
dynType_logSetup(stdLog, nullptr, lvl);
dynCommon_logSetup(stdLog, nullptr, lvl);
}
~DynFunctionTests() override = default;

Expand Down
15 changes: 0 additions & 15 deletions libs/dfi/gtest/src/dyn_interface_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,6 @@ extern "C" {
#include "fmemopen.h"
#endif

static void stdLog(void*, int level, const char *file, int line, const char *msg, ...) {
va_list ap;
const char *levels[5] = {"NIL", "ERROR", "WARNING", "INFO", "DEBUG"};
fprintf(stderr, "%s: FILE:%s, LINE:%i, MSG:",levels[level], file, line);
va_start(ap, msg);
vfprintf(stderr, msg, ap);
fprintf(stderr, "\n");
va_end(ap);
}

static void checkInterfaceVersion(dyn_interface_type* dynIntf, const char* v) {
int status;

Expand Down Expand Up @@ -197,11 +187,6 @@ extern "C" {
class DynInterfaceTests : public ::testing::Test {
public:
DynInterfaceTests() {
int level = 1;
dynCommon_logSetup(stdLog, NULL, level);
dynType_logSetup(stdLog, NULL, level);
dynFunction_logSetup(stdLog, NULL, level);
dynInterface_logSetup(stdLog, NULL, level);
}
~DynInterfaceTests() override {
}
Expand Down
14 changes: 0 additions & 14 deletions libs/dfi/gtest/src/dyn_message_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,6 @@ extern "C" {
#include "fmemopen.h"
#endif

static void stdLog(void*, int level, const char *file, int line, const char *msg, ...) {
va_list ap;
const char *levels[5] = {"NIL", "ERROR", "WARNING", "INFO", "DEBUG"};
fprintf(stderr, "%s: FILE:%s, LINE:%i, MSG:",levels[level], file, line);
va_start(ap, msg);
vfprintf(stderr, msg, ap);
fprintf(stderr, "\n");
va_end(ap);
}

static void checkMessageVersion(dyn_message_type* dynMsg, const char* v){
int status = 0;

Expand Down Expand Up @@ -229,10 +219,6 @@ static void msg_invalid(void) {
class DynMessageTests : public ::testing::Test {
public:
DynMessageTests() {
int level = 1;
dynCommon_logSetup(stdLog, NULL, level);
dynType_logSetup(stdLog, NULL, level);
dynMessage_logSetup(stdLog, NULL, level);
}
~DynMessageTests() override {
}
Expand Down
13 changes: 0 additions & 13 deletions libs/dfi/gtest/src/dyn_type_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,10 @@
#include "gtest/gtest.h"

extern "C" {
#include <stdarg.h>

#include "dyn_common.h"
#include "dyn_type.h"
#include "celix_err.h"

static void stdLog(void*, int level, const char *file, int line, const char *msg, ...) {
va_list ap;
const char *levels[5] = {"NIL", "ERROR", "WARNING", "INFO", "DEBUG"};
fprintf(stderr, "%s: FILE:%s, LINE:%i, MSG:",levels[level], file, line);
va_start(ap, msg);
vfprintf(stderr, msg, ap);
fprintf(stderr, "\n");
va_end(ap);
}

static void runTest(const char *descriptorStr, const char *exName) {
dyn_type *type;
type = NULL;
Expand Down Expand Up @@ -70,7 +58,6 @@ extern "C" {
class DynTypeTests : public ::testing::Test {
public:
DynTypeTests() {
dynType_logSetup(stdLog, NULL, 1);
}
~DynTypeTests() override {
}
Expand Down
15 changes: 0 additions & 15 deletions libs/dfi/gtest/src/json_serializer_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,6 @@ extern "C" {
#include "json_serializer.h"
#include "celix_err.h"

static void stdLog(void*, int level, const char *file, int line, const char *msg, ...) {
va_list ap;
const char *levels[5] = {"NIL", "ERROR", "WARNING", "INFO", "DEBUG"};
fprintf(stderr, "%s: FILE:%s, LINE:%i, MSG:",levels[level], file, line);
va_start(ap, msg);
vfprintf(stderr, msg, ap);
fprintf(stderr, "\n");
va_end(ap);
}

/*********** example 1 ************************/
/** struct type ******************************/
const char *example1_descriptor = "{DJISF a b c d e}";
Expand Down Expand Up @@ -780,11 +770,6 @@ void writeEnumFailed(void) {
class JsonSerializerTests : public ::testing::Test {
public:
JsonSerializerTests() {
int lvl = 1;
dynCommon_logSetup(stdLog, nullptr, lvl);
dynType_logSetup(stdLog, nullptr,lvl);
dynTypeCommon_logSetup(stdLog, nullptr,lvl);
jsonSerializer_logSetup(stdLog, nullptr, lvl);
}
~JsonSerializerTests() override {
}
Expand Down
78 changes: 0 additions & 78 deletions libs/dfi/include/dfi_log_util.h

This file was deleted.

4 changes: 0 additions & 4 deletions libs/dfi/include/dyn_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,12 @@
#include <string.h>
#include <sys/queue.h>

#include "dfi_log_util.h"
#include "celix_dfi_export.h"

#ifdef __cplusplus
extern "C" {
#endif

//logging
DFI_SETUP_LOG_HEADER(dynCommon) ;

TAILQ_HEAD(namvals_head, namval_entry);

struct namval_entry {
Expand Down
Loading

0 comments on commit 3e61888

Please sign in to comment.