Change in libosmo-netif[master]: Stream client: update logging

2019-02-05 Thread Harald Welte
Harald Welte has submitted this change and it was merged. ( 
https://gerrit.osmocom.org/12836 )

Change subject: Stream client: update logging
..

Stream client: update logging

Introduce logging macro wrapper to properly log current client state and
function to aid in debugging.

Change-Id: Ie22a80dcec95998cce0b25053fdf74f23eab6e53
---
M src/stream.c
1 file changed, 25 insertions(+), 16 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  osmith: Looks good to me, but someone else must approve
  Jenkins Builder: Verified



diff --git a/src/stream.c b/src/stream.c
index dbbaa9c..f1d87d4 100644
--- a/src/stream.c
+++ b/src/stream.c
@@ -49,6 +49,9 @@
 #include 
 #endif

+#define LOGSCLI(cli, level, fmt, args...) \
+   LOGP(DLINP, level, "[%s] %s(): " fmt, 
get_value_string(stream_cli_state_names, (cli)->state), __func__, ## args)
+
 /*! \addtogroup stream Osmocom Stream Socket
  *  @{
  *
@@ -131,6 +134,13 @@
 STREAM_CLI_STATE_MAX
 };

+static const struct value_string stream_cli_state_names[] = {
+   { STREAM_CLI_STATE_NONE,   "  NONE" },
+   { STREAM_CLI_STATE_CONNECTING, "CONNECTING" },
+   { STREAM_CLI_STATE_CONNECTED,  " CONNECTED" },
+   { 0, NULL }
+};
+
 #define OSMO_STREAM_CLI_F_RECONF   (1 << 0)
 #define OSMO_STREAM_CLI_F_NODELAY  (1 << 1)

@@ -160,12 +170,12 @@
 void osmo_stream_cli_reconnect(struct osmo_stream_cli *cli)
 {
if (cli->reconnect_timeout < 0) {
-   LOGP(DLINP, LOGL_DEBUG, "not reconnecting, disabled.\n");
+   LOGSCLI(cli, LOGL_DEBUG, "not reconnecting, disabled.\n");
return;
}
-   LOGP(DLINP, LOGL_DEBUG, "connection closed\n");
+   LOGSCLI(cli, LOGL_DEBUG, "connection closed\n");
osmo_stream_cli_close(cli);
-   LOGP(DLINP, LOGL_DEBUG, "retrying in %d seconds...\n",
+   LOGSCLI(cli, LOGL_DEBUG, "retrying in %d seconds...\n",
cli->reconnect_timeout);
osmo_timer_schedule(>timer, cli->reconnect_timeout, 0);
cli->state = STREAM_CLI_STATE_CONNECTING;
@@ -186,7 +196,7 @@

 static void osmo_stream_cli_read(struct osmo_stream_cli *cli)
 {
-   LOGP(DLINP, LOGL_DEBUG, "message received\n");
+   LOGSCLI(cli, LOGL_DEBUG, "message received\n");

if (cli->read_cb)
cli->read_cb(cli);
@@ -201,7 +211,7 @@
struct llist_head *lh;
int ret;

-   LOGP(DLINP, LOGL_DEBUG, "sending data\n");
+   LOGSCLI(cli, LOGL_DEBUG, "sending data\n");

if (llist_empty(>tx_queue)) {
cli->ofd.when &= ~BSC_FD_WRITE;
@@ -212,7 +222,7 @@
msg = llist_entry(lh, struct msgb, list);

if (cli->state == STREAM_CLI_STATE_CONNECTING) {
-   LOGP(DLINP, LOGL_ERROR, "not connected, dropping data!\n");
+   LOGSCLI(cli, LOGL_ERROR, "not connected, dropping data!\n");
return 0;
}

@@ -235,7 +245,7 @@
if (errno == EPIPE || errno == ENOTCONN) {
osmo_stream_cli_reconnect(cli);
}
-   LOGP(DLINP, LOGL_ERROR, "error to send\n");
+   LOGSCLI(cli, LOGL_ERROR, "error to send\n");
}
msgb_free(msg);
return 0;
@@ -255,7 +265,7 @@
return 0;
}
ofd->when &= ~BSC_FD_WRITE;
-   LOGP(DLINP, LOGL_DEBUG, "connection done.\n");
+   LOGSCLI(cli, LOGL_DEBUG, "connection done.\n");
cli->state = STREAM_CLI_STATE_CONNECTED;
if (cli->proto == IPPROTO_SCTP) {
 #ifdef SO_NOSIGPIPE
@@ -263,7 +273,7 @@

ret = setsockopt(ofd->fd, SOL_SOCKET, SO_NOSIGPIPE, 
(void*), sizeof(val));
if (ret < 0)
-   LOGP(DLINP, LOGL_DEBUG, "Failed setting 
SO_NOSIGPIPE: %s\n", strerror(errno));
+   LOGSCLI(cli, LOGL_DEBUG, "Failed setting 
SO_NOSIGPIPE: %s\n", strerror(errno));
 #endif
sctp_sock_activate_events(ofd->fd);
}
@@ -272,11 +282,11 @@
break;
case STREAM_CLI_STATE_CONNECTED:
if (what & BSC_FD_READ) {
-   LOGP(DLINP, LOGL_DEBUG, "connected read\n");
+   LOGSCLI(cli, LOGL_DEBUG, "connected read\n");
osmo_stream_cli_read(cli);
}
if (what & BSC_FD_WRITE) {
-   LOGP(DLINP, LOGL_DEBUG, "connected write\n");
+   LOGSCLI(cli, LOGL_DEBUG, "connected write\n");
osmo_stream_cli_write(cli);
}
break;
@@ -503,7 +513,7 @@
 {
struct osmo_stream_cli *cli = data;

-   LOGP(DLINP, LOGL_DEBUG, "reconnecting.\n");
+   LOGSCLI(cli, LOGL_DEBUG, "reconnecting.\n");

switch(cli->state) {
case 

Change in libosmo-netif[master]: Stream client: update logging

2019-02-05 Thread Harald Welte
Harald Welte has posted comments on this change. ( 
https://gerrit.osmocom.org/12836 )

Change subject: Stream client: update logging
..


Patch Set 3: Code-Review+2


--
To view, visit https://gerrit.osmocom.org/12836
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmo-netif
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ie22a80dcec95998cce0b25053fdf74f23eab6e53
Gerrit-Change-Number: 12836
Gerrit-PatchSet: 3
Gerrit-Owner: Max 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Reviewer: Max 
Gerrit-Reviewer: daniel 
Gerrit-Reviewer: osmith 
Gerrit-Comment-Date: Tue, 05 Feb 2019 16:21:24 +
Gerrit-HasComments: No
Gerrit-HasLabels: Yes


Change in libosmo-netif[master]: Stream client: update logging

2019-02-05 Thread Max
Max has posted comments on this change. ( https://gerrit.osmocom.org/12836 )

Change subject: Stream client: update logging
..


Patch Set 3:

(2 comments)

https://gerrit.osmocom.org/#/c/12836/1/src/stream.c
File src/stream.c:

https://gerrit.osmocom.org/#/c/12836/1/src/stream.c@52
PS1, Line 52:
> it's customary to put (cli) in such macros, as you don't know how exactly the 
> 'cli' will be specifie […]
Done


https://gerrit.osmocom.org/#/c/12836/1/src/stream.c@136
PS1, Line 136:
> static?
Done



-- 
To view, visit https://gerrit.osmocom.org/12836
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmo-netif
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ie22a80dcec95998cce0b25053fdf74f23eab6e53
Gerrit-Change-Number: 12836
Gerrit-PatchSet: 3
Gerrit-Owner: Max 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Reviewer: Max 
Gerrit-Reviewer: daniel 
Gerrit-Reviewer: osmith 
Gerrit-CC: Harald Welte 
Gerrit-Comment-Date: Tue, 05 Feb 2019 16:03:59 +
Gerrit-HasComments: Yes
Gerrit-HasLabels: No


Change in libosmo-netif[master]: Stream client: update logging

2019-02-05 Thread osmith
osmith has posted comments on this change. ( https://gerrit.osmocom.org/12836 )

Change subject: Stream client: update logging
..


Patch Set 3: Code-Review+1


--
To view, visit https://gerrit.osmocom.org/12836
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmo-netif
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ie22a80dcec95998cce0b25053fdf74f23eab6e53
Gerrit-Change-Number: 12836
Gerrit-PatchSet: 3
Gerrit-Owner: Max 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Reviewer: Max 
Gerrit-Reviewer: daniel 
Gerrit-Reviewer: osmith 
Gerrit-CC: Harald Welte 
Gerrit-Comment-Date: Tue, 05 Feb 2019 15:56:58 +
Gerrit-HasComments: No
Gerrit-HasLabels: Yes


Change in libosmo-netif[master]: Stream client: update logging

2019-02-05 Thread Max
Hello daniel, osmith, Jenkins Builder,

I'd like you to reexamine a change. Please visit

https://gerrit.osmocom.org/12836

to look at the new patch set (#3).

Change subject: Stream client: update logging
..

Stream client: update logging

Introduce logging macro wrapper to properly log current client state and
function to aid in debugging.

Change-Id: Ie22a80dcec95998cce0b25053fdf74f23eab6e53
---
M src/stream.c
1 file changed, 25 insertions(+), 16 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmo-netif refs/changes/36/12836/3
--
To view, visit https://gerrit.osmocom.org/12836
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmo-netif
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: Ie22a80dcec95998cce0b25053fdf74f23eab6e53
Gerrit-Change-Number: 12836
Gerrit-PatchSet: 3
Gerrit-Owner: Max 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Reviewer: Max 
Gerrit-Reviewer: daniel 
Gerrit-Reviewer: osmith 
Gerrit-CC: Harald Welte 


Change in libosmo-netif[master]: Stream client: update logging

2019-02-05 Thread osmith
osmith has posted comments on this change. ( https://gerrit.osmocom.org/12836 )

Change subject: Stream client: update logging
..


Patch Set 2: Code-Review-1

(1 comment)

https://gerrit.osmocom.org/#/c/12836/2/src/stream.c
File src/stream.c:

https://gerrit.osmocom.org/#/c/12836/2/src/stream.c@52
PS2, Line 52: #define LOGSCLI(cli, level, fmt, args...) LOGP(DLINP, level, 
"[%s] %s(): " fmt, get_value_string(stream_cli_state_names, (cli)->state), 
__func__, ## args)
This line is longer than 120 characters



--
To view, visit https://gerrit.osmocom.org/12836
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmo-netif
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ie22a80dcec95998cce0b25053fdf74f23eab6e53
Gerrit-Change-Number: 12836
Gerrit-PatchSet: 2
Gerrit-Owner: Max 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Reviewer: Max 
Gerrit-Reviewer: daniel 
Gerrit-Reviewer: osmith 
Gerrit-CC: Harald Welte 
Gerrit-Comment-Date: Tue, 05 Feb 2019 15:40:38 +
Gerrit-HasComments: Yes
Gerrit-HasLabels: Yes


Change in libosmo-netif[master]: Stream client: update logging

2019-02-05 Thread Max
Hello Jenkins Builder,

I'd like you to reexamine a change. Please visit

https://gerrit.osmocom.org/12836

to look at the new patch set (#2).

Change subject: Stream client: update logging
..

Stream client: update logging

Introduce logging macro wrapper to properly log current client state and
function to aid in debugging.

Change-Id: Ie22a80dcec95998cce0b25053fdf74f23eab6e53
---
M src/stream.c
1 file changed, 24 insertions(+), 16 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmo-netif refs/changes/36/12836/2
--
To view, visit https://gerrit.osmocom.org/12836
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmo-netif
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: Ie22a80dcec95998cce0b25053fdf74f23eab6e53
Gerrit-Change-Number: 12836
Gerrit-PatchSet: 2
Gerrit-Owner: Max 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-CC: Harald Welte 


Change in libosmo-netif[master]: Stream client: update logging

2019-02-05 Thread Harald Welte
Harald Welte has posted comments on this change. ( 
https://gerrit.osmocom.org/12836 )

Change subject: Stream client: update logging
..


Patch Set 1:

(2 comments)

https://gerrit.osmocom.org/#/c/12836/1/src/stream.c
File src/stream.c:

https://gerrit.osmocom.org/#/c/12836/1/src/stream.c@52
PS1, Line 52: cli
it's customary to put (cli) in such macros, as you don't know how exactly the 
'cli' will be specified by the caller.


https://gerrit.osmocom.org/#/c/12836/1/src/stream.c@136
PS1, Line 136: const struct value_string stream_cli_state_names[] = {
static?



--
To view, visit https://gerrit.osmocom.org/12836
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmo-netif
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ie22a80dcec95998cce0b25053fdf74f23eab6e53
Gerrit-Change-Number: 12836
Gerrit-PatchSet: 1
Gerrit-Owner: Max 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-CC: Harald Welte 
Gerrit-Comment-Date: Tue, 05 Feb 2019 15:06:57 +
Gerrit-HasComments: Yes
Gerrit-HasLabels: No


Change in libosmo-netif[master]: Stream client: update logging

2019-02-05 Thread Max
Max has uploaded this change for review. ( https://gerrit.osmocom.org/12836


Change subject: Stream client: update logging
..

Stream client: update logging

Introduce logging macro wrapper to properly log current client state and
function to aid in debugging.

Change-Id: Ie22a80dcec95998cce0b25053fdf74f23eab6e53
---
M src/stream.c
1 file changed, 24 insertions(+), 16 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmo-netif refs/changes/36/12836/1

diff --git a/src/stream.c b/src/stream.c
index dbbaa9c..ca67aa0 100644
--- a/src/stream.c
+++ b/src/stream.c
@@ -49,6 +49,8 @@
 #include 
 #endif

+#define LOGSCLI(cli, level, fmt, args...) LOGP(DLINP, level, "[%s] %s(): " 
fmt, get_value_string(stream_cli_state_names, cli->state), __func__, ## args)
+
 /*! \addtogroup stream Osmocom Stream Socket
  *  @{
  *
@@ -131,6 +133,13 @@
 STREAM_CLI_STATE_MAX
 };

+const struct value_string stream_cli_state_names[] = {
+   { STREAM_CLI_STATE_NONE,   "  NONE" },
+   { STREAM_CLI_STATE_CONNECTING, "CONNECTING" },
+   { STREAM_CLI_STATE_CONNECTED,  " CONNECTED" },
+   { 0, NULL }
+};
+
 #define OSMO_STREAM_CLI_F_RECONF   (1 << 0)
 #define OSMO_STREAM_CLI_F_NODELAY  (1 << 1)

@@ -160,12 +169,12 @@
 void osmo_stream_cli_reconnect(struct osmo_stream_cli *cli)
 {
if (cli->reconnect_timeout < 0) {
-   LOGP(DLINP, LOGL_DEBUG, "not reconnecting, disabled.\n");
+   LOGSCLI(cli, LOGL_DEBUG, "not reconnecting, disabled.\n");
return;
}
-   LOGP(DLINP, LOGL_DEBUG, "connection closed\n");
+   LOGSCLI(cli, LOGL_DEBUG, "connection closed\n");
osmo_stream_cli_close(cli);
-   LOGP(DLINP, LOGL_DEBUG, "retrying in %d seconds...\n",
+   LOGSCLI(cli, LOGL_DEBUG, "retrying in %d seconds...\n",
cli->reconnect_timeout);
osmo_timer_schedule(>timer, cli->reconnect_timeout, 0);
cli->state = STREAM_CLI_STATE_CONNECTING;
@@ -186,7 +195,7 @@

 static void osmo_stream_cli_read(struct osmo_stream_cli *cli)
 {
-   LOGP(DLINP, LOGL_DEBUG, "message received\n");
+   LOGSCLI(cli, LOGL_DEBUG, "message received\n");

if (cli->read_cb)
cli->read_cb(cli);
@@ -201,7 +210,7 @@
struct llist_head *lh;
int ret;

-   LOGP(DLINP, LOGL_DEBUG, "sending data\n");
+   LOGSCLI(cli, LOGL_DEBUG, "sending data\n");

if (llist_empty(>tx_queue)) {
cli->ofd.when &= ~BSC_FD_WRITE;
@@ -212,7 +221,7 @@
msg = llist_entry(lh, struct msgb, list);

if (cli->state == STREAM_CLI_STATE_CONNECTING) {
-   LOGP(DLINP, LOGL_ERROR, "not connected, dropping data!\n");
+   LOGSCLI(cli, LOGL_ERROR, "not connected, dropping data!\n");
return 0;
}

@@ -235,7 +244,7 @@
if (errno == EPIPE || errno == ENOTCONN) {
osmo_stream_cli_reconnect(cli);
}
-   LOGP(DLINP, LOGL_ERROR, "error to send\n");
+   LOGSCLI(cli, LOGL_ERROR, "error to send\n");
}
msgb_free(msg);
return 0;
@@ -255,7 +264,7 @@
return 0;
}
ofd->when &= ~BSC_FD_WRITE;
-   LOGP(DLINP, LOGL_DEBUG, "connection done.\n");
+   LOGSCLI(cli, LOGL_DEBUG, "connection done.\n");
cli->state = STREAM_CLI_STATE_CONNECTED;
if (cli->proto == IPPROTO_SCTP) {
 #ifdef SO_NOSIGPIPE
@@ -263,7 +272,7 @@

ret = setsockopt(ofd->fd, SOL_SOCKET, SO_NOSIGPIPE, 
(void*), sizeof(val));
if (ret < 0)
-   LOGP(DLINP, LOGL_DEBUG, "Failed setting 
SO_NOSIGPIPE: %s\n", strerror(errno));
+   LOGSCLI(cli, LOGL_DEBUG, "Failed setting 
SO_NOSIGPIPE: %s\n", strerror(errno));
 #endif
sctp_sock_activate_events(ofd->fd);
}
@@ -272,11 +281,11 @@
break;
case STREAM_CLI_STATE_CONNECTED:
if (what & BSC_FD_READ) {
-   LOGP(DLINP, LOGL_DEBUG, "connected read\n");
+   LOGSCLI(cli, LOGL_DEBUG, "connected read\n");
osmo_stream_cli_read(cli);
}
if (what & BSC_FD_WRITE) {
-   LOGP(DLINP, LOGL_DEBUG, "connected write\n");
+   LOGSCLI(cli, LOGL_DEBUG, "connected write\n");
osmo_stream_cli_write(cli);
}
break;
@@ -503,7 +512,7 @@
 {
struct osmo_stream_cli *cli = data;

-   LOGP(DLINP, LOGL_DEBUG, "reconnecting.\n");
+   LOGSCLI(cli, LOGL_DEBUG, "reconnecting.\n");

switch(cli->state) {
case STREAM_CLI_STATE_CONNECTING:
@@ -535,18 +544,17 @@
ret = recv(cli->ofd.fd, msg->data, msg->data_len, 0);
if