void btif_debug_conn_dump(int fd) { const uint8_t current_event_local = current_event; // Cache to avoid threading issues uint8_t dump_event = current_event_local; char ts_buffer[TEMP_BUFFER_SIZE] = {0}; char name_buffer[TEMP_BUFFER_SIZE] = {0}; dprintf(fd, "\nConnection Events:\n"); if (connection_events[dump_event].ts == 0) dprintf(fd, " None\n"); while (connection_events[dump_event].ts) { conn_event_t *evt = &connection_events[dump_event]; dprintf(fd, " %s %s %s", format_ts(evt->ts, ts_buffer, sizeof(ts_buffer)), format_state(evt->state), bdaddr_to_string(&evt->bda, name_buffer, sizeof(name_buffer)) ); if (evt->state == BTIF_DEBUG_DISCONNECTED) dprintf(fd, " reason=%d", evt->disconnect_reason); dprintf(fd,"\n"); // Go to previous event; wrap if needed if (dump_event > 0) --dump_event; else dump_event = NUM_CONNECTION_EVENTS - 1; // Check if we dumped all events if (dump_event == current_event_local) break; } }
/* Log the string */ void logmsg(int level, char *message) { FILE *fp = loginfo.fp; if (level < loginfo.level) return; if (level >= FATAL && ! fp) fp = stderr; if (fp) { char ts[TMBUFLEN]; format_ts(ts); fprintf(fp, "[%s] %s\n", ts, message); } if (loginfo.syslog) { syslog(levels[level].priority, "%s", message); } }
/* Log the string, along with strerror(errno) appended after a colon * (similarly to perror()) */ void logerr(int level, char *message) { FILE *fp = loginfo.fp; if (level < loginfo.level) return; if (level >= FATAL && ! fp) fp = stderr; if (fp) { char ts[TMBUFLEN]; int en = errno; format_ts(ts); fprintf(fp, "[%s] %s: %s\n", ts, message, strerror(en)); errno = en; } if (loginfo.syslog) { syslog(levels[level].priority, "%s: %m", message); } }