// Log an executed command to the CCACHE_LOGFILE location. void cc_log_argv(const char *prefix, char **argv) { if (!init_log()) { return; } log_prefix(true); if (logfile) { fputs(prefix, logfile); print_command(logfile, argv); int rc = fflush(logfile); if (rc) { warn_log_fail(); } } #ifdef HAVE_SYSLOG if (use_syslog) { char *s = format_command(argv); syslog(LOG_DEBUG, "%s", s); free(s); } #endif if (debug_log_buffer) { append_to_debug_log(prefix, strlen(prefix)); char *s = format_command(argv); append_to_debug_log(s, strlen(s)); free(s); } }
static void vlog(const char *format, va_list ap, bool log_updated_time) { if (!init_log()) { return; } va_list aq; va_copy(aq, ap); log_prefix(log_updated_time); if (logfile) { int rc1 = vfprintf(logfile, format, ap); int rc2 = fprintf(logfile, "\n"); if (rc1 < 0 || rc2 < 0) { warn_log_fail(); } } #ifdef HAVE_SYSLOG if (use_syslog) { vsyslog(LOG_DEBUG, format, ap); } #endif if (debug_log_buffer) { char buf[8192]; int len = vsnprintf(buf, sizeof(buf), format, aq); if (len >= 0) { append_to_debug_log(buf, MIN((size_t)len, sizeof(buf) - 1)); append_to_debug_log("\n", 1); } } va_end(aq); }
void log_serror(const char *file, const char *func, int line, int no) { if(verbosity <= 0 || log == NULL) return; log_prefix(file, func, line); fprintf(log, " %s\n", strerror(no)); }
void log_werror(const char *file, const char *func, int line, int no) { if(verbosity <= 0 || log == NULL) return; log_prefix(file, func, line); fprintf(log, " Windows error code: %d\n", no); }
static void vlog(const char *format, va_list ap, bool log_updated_time) { if (!init_log()) { return; } log_prefix(log_updated_time); vfprintf(logfile, format, ap); fprintf(logfile, "\n"); }
/* * Log an executed command to the CCACHE_LOGFILE location. */ void cc_log_argv(const char *prefix, char **argv) { if (!init_log()) { return; } log_prefix(); fputs(prefix, logfile); print_command(logfile, argv); fflush(logfile); }
static void log_stdio(void *data, int level, const char *module, const char *format, va_list args) { FILE *out = (FILE *)data; int codepage = (out == stderr || out == stdout) ? stdio_codepage : 0; const char *prefix = log_prefix(level); size_t len = strlen(format); fprintf(out, "%s: ", prefix); _log_write(out, codepage, format, args); if (format[len - 1] != '\n') { fputc('\n', out); } fflush(out); }
/* * Log an executed command to the CCACHE_LOGFILE location. */ void cc_log_argv(const char *prefix, char **argv) { int rc; if (!init_log()) { return; } log_prefix(true); fputs(prefix, logfile); print_command(logfile, argv); rc = fflush(logfile); if (rc) warn_log_fail(); }
static void vlog(const char *format, va_list ap, bool log_updated_time) { int rc1, rc2; if (!init_log()) { return; } log_prefix(log_updated_time); rc1 = vfprintf(logfile, format, ap); rc2 = fprintf(logfile, "\n"); if (rc1 < 0 || rc2 < 0) { warn_log_fail(); } }
/* * Write a message to the CCACHE_LOGFILE location (adding a newline). */ void cc_log(const char *format, ...) { va_list ap; if (!init_log()) { return; } log_prefix(); va_start(ap, format); vfprintf(logfile, format, ap); va_end(ap); fprintf(logfile, "\n"); fflush(logfile); }
static int check_dupe(const char *format, int level) { static int last_type; /* STATIC_XCALL: used across calls */ static char last_message[32] = { 0 }; /* STATIC_XCALL: used across calls */ static int dupes = 0; /* STATIC_XCALL: used across calls */ if (strncmp(last_message, format, sizeof(last_message)) == 0) { /* TODO: C6054: String 'last_message' might not be zero - terminated. */ ++dupes; return 1; } if (dupes) { if (level & LOG_CPERROR) { fprintf(stderr, "%s: last message repeated %d times\n", log_prefix(last_type), dupes + 1); } dupes = 0; } str_strlcpy(last_message, format, sizeof(last_message)); last_type = level; return 0; }
static struct io_plan *jcon_connected(struct io_conn *conn, struct lightningd_state *dstate) { struct json_connection *jcon; jcon = tal(dstate, struct json_connection); jcon->dstate = dstate; jcon->used = 0; jcon->buffer = tal_arr(jcon, char, 64); jcon->stop = false; jcon->current = NULL; jcon->log = new_log(jcon, dstate->log_record, "%sjcon fd %i:", log_prefix(dstate->base_log), io_conn_fd(conn)); list_head_init(&jcon->output); io_set_finish(conn, finish_jcon, jcon); return io_duplex(conn, io_read_partial(conn, jcon->buffer, tal_count(jcon->buffer), &jcon->len_read, read_json, jcon), write_json(conn, jcon)); }