summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosé Bollo <jose.bollo@iot.bzh>2017-06-30 17:17:56 +0200
committerJosé Bollo <jose.bollo@iot.bzh>2017-07-05 15:54:40 +0200
commit1a741e7978380669b0a876a594d5d4b5691dcc80 (patch)
treecb6523fe69dfd7263b43034c271eba523f5ebff5
parent7a21c8546d6762e18cd1bf5405e16f2195aa5f0a (diff)
Bindings V2: enforce prefix AFB_ to logging macros
This might break many codes but it is better in the long term. Change-Id: I346d13f0a6ef6b211edf25844489405351548299
-rw-r--r--bindings/samples/HelloWorld.c8
-rw-r--r--bindings/samples/tic-tac-toe.c34
-rw-r--r--include/afb/afb-binding.h3
3 files changed, 24 insertions, 21 deletions
diff --git a/bindings/samples/HelloWorld.c b/bindings/samples/HelloWorld.c
index 77de24a2..89ed829c 100644
--- a/bindings/samples/HelloWorld.c
+++ b/bindings/samples/HelloWorld.c
@@ -361,7 +361,7 @@ static void exitnow (afb_req request)
if (!json_object_object_get_ex(query,"reason",&l))
l = NULL;
- REQ_NOTICE(request, "in phase of exiting with code %d, reason: %s", code, l ? json_object_get_string(l) : "unknown");
+ AFB_REQ_NOTICE(request, "in phase of exiting with code %d, reason: %s", code, l ? json_object_get_string(l) : "unknown");
afb_req_success(request, NULL, NULL);
exit(code);
}
@@ -393,19 +393,19 @@ static void broadcast(afb_req request)
static int preinit()
{
- NOTICE("hello binding comes to live");
+ AFB_NOTICE("hello binding comes to live");
return 0;
}
static int init()
{
- NOTICE("hello binding starting");
+ AFB_NOTICE("hello binding starting");
return 0;
}
static void onevent(const char *event, struct json_object *object)
{
- NOTICE("received event %s(%s)", event, json_object_to_json_string(object));
+ AFB_NOTICE("received event %s(%s)", event, json_object_to_json_string(object));
}
// NOTE: this sample does not use session to keep test a basic as possible
diff --git a/bindings/samples/tic-tac-toe.c b/bindings/samples/tic-tac-toe.c
index bf4904ea..d600e192 100644
--- a/bindings/samples/tic-tac-toe.c
+++ b/bindings/samples/tic-tac-toe.c
@@ -315,7 +315,7 @@ static void new(struct afb_req req)
/* retrieves the context for the session */
board = board_of_req(req);
- INFO("method 'new' called for boardid %d", board->id);
+ AFB_INFO("method 'new' called for boardid %d", board->id);
/* reset the game */
memset(board->board, ' ', sizeof board->board);
@@ -338,7 +338,7 @@ static void board(struct afb_req req)
/* retrieves the context for the session */
board = board_of_req(req);
- INFO("method 'board' called for boardid %d", board->id);
+ AFB_INFO("method 'board' called for boardid %d", board->id);
/* describe the board */
description = describe(board);
@@ -358,7 +358,7 @@ static void move(struct afb_req req)
/* retrieves the context for the session */
board = board_of_req(req);
- INFO("method 'move' called for boardid %d", board->id);
+ AFB_INFO("method 'move' called for boardid %d", board->id);
/* retrieves the arguments of the move */
index = afb_req_value(req, "index");
@@ -366,27 +366,27 @@ static void move(struct afb_req req)
/* checks validity of arguments */
if (i < 0 || i > 8) {
- WARNING("can't move to %s: %s", index?:"?", index?"wrong value":"not set");
+ AFB_WARNING("can't move to %s: %s", index?:"?", index?"wrong value":"not set");
afb_req_fail(req, "error", "bad request");
return;
}
/* checks validity of the state */
if (winner(board->board) != 0) {
- WARNING("can't move to %s: game is terminated", index);
+ AFB_WARNING("can't move to %s: game is terminated", index);
afb_req_fail(req, "error", "game terminated");
return;
}
/* checks validity of the move */
if (board->board[i] != ' ') {
- WARNING("can't move to %s: room occupied", index);
+ AFB_WARNING("can't move to %s: room occupied", index);
afb_req_fail(req, "error", "occupied");
return;
}
/* applies the move */
- INFO("method 'move' for boardid %d, index=%s", board->id, index);
+ AFB_INFO("method 'move' for boardid %d, index=%s", board->id, index);
add_move(board, i);
/* replies */
@@ -407,7 +407,7 @@ static void level(struct afb_req req)
/* retrieves the context for the session */
board = board_of_req(req);
- INFO("method 'level' called for boardid %d", board->id);
+ AFB_INFO("method 'level' called for boardid %d", board->id);
/* retrieves the arguments */
level = afb_req_value(req, "level");
@@ -415,13 +415,13 @@ static void level(struct afb_req req)
/* check validity of arguments */
if (l < 1 || l > 10) {
- WARNING("can't set level to %s: %s", level?:"?", level?"wrong value":"not set");
+ AFB_WARNING("can't set level to %s: %s", level?:"?", level?"wrong value":"not set");
afb_req_fail(req, "error", "bad request");
return;
}
/* set the level */
- INFO("method 'level' for boardid %d, level=%d", board->id, l);
+ AFB_INFO("method 'level' for boardid %d, level=%d", board->id, l);
board->level = l;
/* replies */
@@ -441,7 +441,7 @@ static void join(struct afb_req req)
/* retrieves the context for the session */
board = board_of_req(req);
- INFO("method 'join' called for boardid %d", board->id);
+ AFB_INFO("method 'join' called for boardid %d", board->id);
/* retrieves the arguments */
id = afb_req_value(req, "boardid");
@@ -478,7 +478,7 @@ success:
return;
bad_request:
- WARNING("can't join boardid %s: %s", id ? : "?", !id ? "no boardid" : atoi(id) ? "not found" : "bad boardid");
+ AFB_WARNING("can't join boardid %s: %s", id ? : "?", !id ? "no boardid" : atoi(id) ? "not found" : "bad boardid");
afb_req_fail(req, "error", "bad request");
return;
}
@@ -493,11 +493,11 @@ static void undo(struct afb_req req)
/* retrieves the context for the session */
board = board_of_req(req);
- INFO("method 'undo' called for boardid %d", board->id);
+ AFB_INFO("method 'undo' called for boardid %d", board->id);
/* checks the state */
if (board->moves == 0) {
- WARNING("can't undo");
+ AFB_WARNING("can't undo");
afb_req_fail(req, "error", "bad request");
return;
}
@@ -523,11 +523,11 @@ static void play(struct afb_req req)
/* retrieves the context for the session */
board = board_of_req(req);
- INFO("method 'play' called for boardid %d", board->id);
+ AFB_INFO("method 'play' called for boardid %d", board->id);
/* checks validity of the state */
if (winner(board->board) != 0 || board->moves == 9) {
- WARNING("can't play: game terminated (%s)", winner(board->board) ? "has winner" : "no room left");
+ AFB_WARNING("can't play: game terminated (%s)", winner(board->board) ? "has winner" : "no room left");
afb_req_fail(req, "error", "game terminated");
return;
}
@@ -550,7 +550,7 @@ static void wait(struct afb_req req)
/* retrieves the context for the session */
board = board_of_req(req);
- INFO("method 'wait' called for boardid %d", board->id);
+ AFB_INFO("method 'wait' called for boardid %d", board->id);
/* creates the waiter and enqueues it */
waiter = calloc(1, sizeof *waiter);
diff --git a/include/afb/afb-binding.h b/include/afb/afb-binding.h
index 69be174a..45cff649 100644
--- a/include/afb/afb-binding.h
+++ b/include/afb/afb-binding.h
@@ -243,6 +243,9 @@ typedef struct afb_service_itf afb_service_itf;
# define afb_verbose_info() (afb_get_verbosity() >= 2)
# define afb_verbose_debug() (afb_get_verbosity() >= 3)
+# if !defined(AFB_BINDING_PRAGMA_KEEP_VERBOSE_UNPREFIX) && !defined(AFB_BINDING_PRAGMA_NO_VERBOSE_UNPREFIX)
+# define AFB_BINDING_PRAGMA_NO_VERBOSE_UNPREFIX
+# endif
#endif
/***************************************************************************************************/