// Logging of char arrays void log_print(char* _info, char* _in) { if (txtLog == NULL) return; // Move lines on step down int i; for (i=LOG_LINES-1; i > 0; i--) { str_cpy((txtLog.pstring)[i], (txtLog.pstring)[i-1]); } char cbuffer[128]; sprintf(cbuffer, "%d: %s %s", total_frames, _info, _in); str_cpy((txtLog.pstring)[0], cbuffer); // Print to file? if (nLogToFile == 1) { vLogFileHandle = file_open_append(strLogFile); char cbuffer2[10]; // Change color to hex for HTML coding log_rgb_to_hex(cbuffer2,(long)cLogColor.red,(long)cLogColor.green,(long)cLogColor.blue); sprintf(cbuffer, "\n\t\t\t<tr BGCOLOR=\"%s\"><td>%d</td><td>%s</td><td>%s</td></tr>", cbuffer2, total_frames, _info, _in); file_str_write(vLogFileHandle, cbuffer); file_close(vLogFileHandle); } }
struct db *db_new(const char *directory) { struct db *db = _db_new(directory); struct file *logfile = file_open_append(db->log_dir, "ydb.log"); if (logfile == NULL) { goto error; } int fd = file_rind(logfile); if (fd == -1) { goto error; } db->log_fd = fd; db->index_dir = dir_openat(db->log_dir, "index"); if (db->index_dir == NULL) { db_free(db); return NULL; } return db; error:; dir_free(db->log_dir); free(db); return NULL; }
// Close HTML file void log_write_footer() { vLogFileHandle = file_open_append(strLogFile); file_str_write(vLogFileHandle, "\n\t\t</table>\n\t</body>\n</html>"); file_close(vLogFileHandle); }