mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-02-22 22:45:27 +01:00
Append to crash log instead of creating new one
Multiple crashes accumulate in case you have some kind of auto-restart for daemons.
This commit is contained in:
parent
f24a7b9356
commit
b4f7ce61b4
1 changed files with 7 additions and 3 deletions
|
@ -510,7 +510,7 @@ static void log_crash(int sig)
|
||||||
|
|
||||||
/* We expect to be in config dir. */
|
/* We expect to be in config dir. */
|
||||||
logfile = "crash.log";
|
logfile = "crash.log";
|
||||||
fd = open(logfile, O_WRONLY|O_CREAT, 0600);
|
fd = open(logfile, O_WRONLY|O_CREAT|O_APPEND, 0600);
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
logfile = "/tmp/lightning-crash.log";
|
logfile = "/tmp/lightning-crash.log";
|
||||||
fd = open(logfile, O_WRONLY|O_CREAT, 0600);
|
fd = open(logfile, O_WRONLY|O_CREAT, 0600);
|
||||||
|
@ -554,9 +554,13 @@ void log_dump_to_file(int fd, const struct log_book *lr)
|
||||||
{
|
{
|
||||||
const struct log_entry *i;
|
const struct log_entry *i;
|
||||||
char buf[100];
|
char buf[100];
|
||||||
|
int len;
|
||||||
struct log_data data;
|
struct log_data data;
|
||||||
time_t start;
|
time_t start;
|
||||||
|
|
||||||
|
write_all(fd, "Start of new crash log\n",
|
||||||
|
strlen("Start of new crash log\n"));
|
||||||
|
|
||||||
i = list_top(&lr->log, const struct log_entry, list);
|
i = list_top(&lr->log, const struct log_entry, list);
|
||||||
if (!i) {
|
if (!i) {
|
||||||
write_all(fd, "0 bytes:\n\n", strlen("0 bytes:\n\n"));
|
write_all(fd, "0 bytes:\n\n", strlen("0 bytes:\n\n"));
|
||||||
|
@ -564,8 +568,8 @@ void log_dump_to_file(int fd, const struct log_book *lr)
|
||||||
}
|
}
|
||||||
|
|
||||||
start = lr->init_time.ts.tv_sec;
|
start = lr->init_time.ts.tv_sec;
|
||||||
sprintf(buf, "%zu bytes, %s", lr->mem_used, ctime(&start));
|
len = sprintf(buf, "%zu bytes, %s", lr->mem_used, ctime(&start));
|
||||||
write_all(fd, buf, strlen(buf));
|
write_all(fd, buf, len);
|
||||||
|
|
||||||
/* ctime includes \n... WTF? */
|
/* ctime includes \n... WTF? */
|
||||||
data.prefix = "";
|
data.prefix = "";
|
||||||
|
|
Loading…
Add table
Reference in a new issue