Added log feature

Added "--log <filename>" option which writes all activity to specified
file.
This commit is contained in:
Martin Lund 2016-05-01 21:18:51 +02:00
parent d574172205
commit bbda0b8851
9 changed files with 140 additions and 4 deletions

View file

@ -23,6 +23,7 @@
#include <stdlib.h>
#include "gotty/options.h"
#include "gotty/tty.h"
#include "gotty/log.h"
int main(int argc, char *argv[])
{
@ -34,9 +35,16 @@ int main(int argc, char *argv[])
/* Configure output terminal */
configure_stdout();
/* Install log exit handler */
atexit(&log_exit);
/* Restore output terminal on exit */
atexit(&restore_stdout);
/* Create log file */
if (option.log)
log_open(option.log_filename);
/* Connect to tty device */
if (option.no_autoconnect)
status = connect_tty();
@ -50,5 +58,8 @@ int main(int argc, char *argv[])
}
}
/* Close log */
log_close();
return status;
}