Quieten startup logging a bit

This commit is contained in:
Andrew Bettison 2012-07-27 19:59:16 +09:30
parent ce12258f63
commit 8db737ee6f
3 changed files with 28 additions and 12 deletions

View File

@ -601,7 +601,10 @@ int app_server_start(int argc, const char *const *argv, struct command_line_opti
INFOF("Server already running (pid=%d)", pid);
ret = 10;
} else {
INFOF("Starting server %s", execpath ? execpath : "without exec");
if (foregroundP)
INFOF("Foreground server process %s", execpath ? execpath : "without exec");
else
INFOF("Starting background server %s", execpath ? execpath : "without exec");
/* Start the Serval process. All server settings will be read by the server process from the
instance directory when it starts up. */
if (server_remove_stopfile() == -1)

9
log.c
View File

@ -60,6 +60,9 @@ void set_logging(FILE *f)
FILE *open_logging()
{
#ifdef ANDROID
return NULL;
#endif
if (!logfile) {
const char *logpath = getenv("SERVALD_LOG_FILE");
if (!logpath) {
@ -126,8 +129,8 @@ static int _log_prepare(int level, const char *file, unsigned int line, const ch
return 0;
if (strbuf_is_empty(&logbuf))
strbuf_init(&logbuf, _log_buf, sizeof _log_buf);
#ifndef ANDROID
open_logging(); // Put initial INFO message at start of log file
#ifndef ANDROID
const char *levelstr = "UNKWN:";
switch (level) {
case LOG_LEVEL_FATAL: levelstr = "FATAL:"; break;
@ -392,7 +395,9 @@ int log_backtrace(const char *file, unsigned int line, const char *function)
char execpath[160];
if (get_self_executable_path(execpath, sizeof execpath) == -1)
return WHY("cannot log backtrace: own executable path unknown");
char tempfile[] = "/tmp/servalXXXXXX.gdb";
char tempfile[512];
if (!FORM_SERVAL_INSTANCE_PATH(tempfile, "servalXXXXXX.gdb"))
return -1;
int tmpfd = mkstemps(tempfile, 4);
if (tmpfd == -1)
return WHY_perror("mkstemps");

View File

@ -273,7 +273,8 @@ int overlay_route_init(int mb_ram)
}
strbuf_sprintf(b, " %d", overlay_route_hash_order[i]);
}
DEBUGF("Generating byte-order for hash function:%s", strbuf_str(b));
if (debug&DEBUG_OVERLAYROUTING)
DEBUGF("Generating byte-order for hash function:%s", strbuf_str(b));
overlay_route_hash_bytes=16;
int associativity=4;
@ -294,46 +295,53 @@ int overlay_route_init(int mb_ram)
{
space=(sizeof(overlay_neighbour*)*1024LL*mb_ram)+sizeof(overlay_node)*bin_count*associativity*1LL;
int percent=100LL*space/(mb_ram*1048576LL);
INFOF("Using %d%% of %dMB RAM allows for %d bins with %d-way associativity and %d direct neighbours",
percent,mb_ram,bin_count,associativity,1024*mb_ram);
if (debug&DEBUG_OVERLAYROUTING)
DEBUGF("Using %d%% of %dMB RAM allows for %d bins with %d-way associativity and %d direct neighbours",
percent,mb_ram,bin_count,associativity,1024*mb_ram);
}
/* Now allocate the structures */
overlay_nodes=calloc(sizeof(overlay_node*),bin_count);
if (!overlay_nodes) return WHY("calloc() failed.");
if (!overlay_nodes) return WHY_perror("calloc");
overlay_neighbours=calloc(sizeof(overlay_neighbour),1024*mb_ram);
if (!overlay_neighbours) {
WHY_perror("calloc");
free(overlay_nodes);
return WHY("calloc() failed.");
return -1;
}
for(i=0;i<bin_count;i++)
{
overlay_nodes[i]=calloc(sizeof(overlay_node),associativity);
if (!overlay_nodes[i]) {
WHY_perror("calloc");
while(--i>=0) free(overlay_nodes[i]);
free(overlay_nodes);
free(overlay_neighbours);
return WHY("calloc() failed.");
return -1;
}
}
overlay_max_neighbours=1024*mb_ram;
overlay_bin_count=bin_count;
overlay_bin_size=associativity;
INFOF("Node (%dbins) and neighbour tables allocated",bin_count);
if (debug&DEBUG_OVERLAYROUTING)
DEBUGF("Node (%d bins) and neighbour tables allocated",bin_count);
/* Work out number of bytes required to represent the bin number.
Used for calculation of sid hash */
overlay_bin_bytes=1;
while(bin_count&0xffffff00) {
INFOF("bin_count=0x%08x, overlay_bin_bytes=%d",bin_count,overlay_bin_bytes);
if (debug&DEBUG_OVERLAYROUTING)
DEBUGF("bin_count=0x%08x, overlay_bin_bytes=%d",bin_count,overlay_bin_bytes);
overlay_bin_bytes++;
bin_count=bin_count>>8;
}
INFOF("bin_count=0x%08x, overlay_bin_bytes=%d",bin_count,overlay_bin_bytes);
if (debug&DEBUG_OVERLAYROUTING)
DEBUGF("bin_count=0x%08x, overlay_bin_bytes=%d",bin_count,overlay_bin_bytes);
return 0;
}