Re: [PATCH 4/8 v3] cld: modify server code to use logging macros

2009-12-15 Thread Jeff Garzik

On 12/14/2009 07:32 PM, Colin McCabe wrote:

Signed-off-by: Colin McCabe


applied, with minor changes:

* include hail_log.h from server/cld.h, the header file common to all 
server code.  remove individual #include's in each .c file.


* fixed up #include of jgarzik-renamed common.h (to cld_commmon.h)

--
To unsubscribe from this list: send the line "unsubscribe hail-devel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 4/8 v3] cld: modify server code to use logging macros

2009-12-15 Thread Colin McCabe
Signed-off-by: Colin McCabe 
---
 server/cld.h |4 +-
 server/cldb.c|7 ++--
 server/msg.c |   50 +-
 server/server.c  |   87 -
 server/session.c |   58 ++-
 server/util.c|   28 +
 6 files changed, 105 insertions(+), 129 deletions(-)

diff --git a/server/cld.h b/server/cld.h
index 05c93ad..efe7ee4 100644
--- a/server/cld.h
+++ b/server/cld.h
@@ -26,6 +26,7 @@
 #include 
 #include "cldb.h"
 #include 
+#include 
 #include 
 
 struct client;
@@ -152,7 +153,7 @@ extern int sess_load(GHashTable *ss);
 /* server.c */
 extern const char *opstr(enum cld_msg_ops op);
 extern struct server cld_srv;
-extern int debugging;
+extern struct hail_log srv_log;
 extern struct timeval current_time;
 extern int udp_tx(int sock_fd, struct sockaddr *, socklen_t,
const void *, size_t);
@@ -161,7 +162,6 @@ extern void resp_err(struct session *sess,
  const struct cld_msg_hdr *src, enum cle_err_codes errcode);
 extern void resp_ok(struct session *sess, const struct cld_msg_hdr *src);
 extern bool authsign(struct cld_packet *pkt, size_t pkt_len);
-extern void applog(int prio, const char *fmt, ...);
 
 /* util.c */
 extern int write_pid_file(const char *pid_fn);
diff --git a/server/cldb.c b/server/cldb.c
index 2f012e5..ca5d849 100644
--- a/server/cldb.c
+++ b/server/cldb.c
@@ -25,6 +25,7 @@
 #include 
 #include 
 #include "cld.h"
+#include 
 
 static int cldb_up(struct cldb *cldb, unsigned int flags);
 
@@ -241,7 +242,7 @@ int cldb_init(struct cldb *cldb, const char *db_home, const 
char *db_password,
 
rc = db_env_create(&cldb->env, 0);
if (rc) {
-   applog(LOG_WARNING, "cldb->env_create failed: %d", rc);
+   HAIL_WARN(&srv_log, "cldb->env_create failed: %d", rc);
return rc;
}
 
@@ -375,7 +376,7 @@ static int cldb_up(struct cldb *cldb, unsigned int flags)
 
cldb->up = true;
 
-   applog(LOG_INFO, "databases up");
+   HAIL_INFO(&srv_log, "databases up");
return 0;
 
 err_out_handle_idx:
@@ -417,7 +418,7 @@ void cldb_down(struct cldb *cldb)
cldb->inodes = NULL;
cldb->sessions = NULL;
 
-   applog(LOG_INFO, "databases down");
+   HAIL_INFO(&srv_log, "databases down");
 }
 
 void cldb_fini(struct cldb *cldb)
diff --git a/server/msg.c b/server/msg.c
index dc5d5fa..34b4c14 100644
--- a/server/msg.c
+++ b/server/msg.c
@@ -27,6 +27,7 @@
 #include 
 #include 
 #include "cld.h"
+#include 
 
 enum {
CLD_MAX_UDP_SEG = 1024,
@@ -169,7 +170,7 @@ static bool dirdata_append(void **data, size_t *data_len,
 
mem = realloc(*data, new_len);
if (!mem) {
-   applog(LOG_CRIT, "out of memory for data [%lu]", (long)new_len);
+   HAIL_CRIT(&srv_log, "out of memory for data [%lz]", new_len);
return false;
}
 
@@ -238,15 +239,14 @@ static int inode_notify(DB_TXN *txn, cldino_t inum, bool 
deleted)
 
sess = g_hash_table_lookup(cld_srv.sessions, h.sid);
if (!sess) {
-   applog(LOG_WARNING, "inode_notify BUG");
+   HAIL_WARN(&srv_log, "inode_notify BUG");
continue;
}
 
if (!sess->sock_fd) {   /* Freshly recovered session */
-   if (debugging)
-   applog(LOG_DEBUG,
-  "Lost notify sid " SIDFMT " ino %lld",
-  SIDARG(sess->sid), (long long) inum);
+   HAIL_DEBUG(&srv_log, "Lost notify sid " SIDFMT
+   " ino %lld", SIDARG(sess->sid),
+   (long long) inum);
continue;
}
 
@@ -363,7 +363,7 @@ int inode_lock_rescan(DB_TXN *txn, cldino_t inum)
 
sess = g_hash_table_lookup(cld_srv.sessions, lock.sid);
if (!sess) {
-   applog(LOG_WARNING, "inode_lock_rescan BUG");
+   HAIL_WARN(&srv_log, "inode_lock_rescan BUG");
break;
}
 
@@ -372,10 +372,9 @@ int inode_lock_rescan(DB_TXN *txn, cldino_t inum)
 */
 
if (!sess->sock_fd) {   /* Freshly recovered session */
-   if (debugging)
-   applog(LOG_DEBUG,
-  "Lost success sid " SIDFMT " ino %lld",
-  SIDARG(sess->sid), (long long) inum);
+   HAIL_DEBUG(&srv_log, "Lost success sid " SIDFMT
+   " ino %lld", SIDARG(sess->sid),
+   (long long) inum);
continue;
}
 
@@ -455,13 +454,10 @@ void msg_get(struct msg_params *mp, bool metada