Skip to content

Added log_heard to log non-aprs stations #435

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/direwolf.c
Original file line number Diff line number Diff line change
@@ -1099,6 +1099,7 @@ void app_process_rec_packet (int chan, int subchan, int slice, packet_t pp, alev
else {

dw_printf ("%s audio level = %s %s %s\n", heard, alevel_text, display_retries, spectrum);
log_heard(heard, alevel_text, display_retries, spectrum);
}
}

86 changes: 86 additions & 0 deletions src/log.c
Original file line number Diff line number Diff line change
@@ -426,6 +426,92 @@ void log_write (int chan, decode_aprs_t *A, packet_t pp, alevel_t alevel, retry_

} /* end log_write */

/*------------------------------------------------------------------
*
* Function: log_heard
*
* Purpose: Save packet information from non-APRS packets to log file.
* Basically the same info as written to stdout
*
*------------------------------------------------------------------*/


void log_heard(char *heard, char *alevel_text, char *display_retries, char *spectrum)
{
time_t now;
struct tm tm;

dw_printf ("Logging heard packet\n");

if (strlen(g_log_path) == 0) return;

now = time(NULL); // Get current time.
(void)gmtime_r (&now, &tm);


if (g_daily_names) {
char fname[20];
strftime (fname, sizeof(fname), "%Y-%m-%d.log", &tm);

// Close current file if name has changed
if (g_log_fp != NULL && strcmp(fname, g_open_fname) != 0) {
log_term ();
}
if (g_log_fp == NULL) { // Open for append if not already open.
char full_path[120];

strlcpy (full_path, g_log_path, sizeof(full_path));
#if __WIN32__
strlcat (full_path, "\\", sizeof(full_path));
#else
strlcat (full_path, "/", sizeof(full_path));
#endif
strlcat (full_path, fname, sizeof(full_path));

text_color_set(DW_COLOR_INFO);
dw_printf("Opening log file \"%s\".\n", fname);

g_log_fp = fopen (full_path, "a");

if (g_log_fp != NULL) {
strlcpy (g_open_fname, fname, sizeof(g_open_fname));
}
else {
text_color_set(DW_COLOR_ERROR);
dw_printf("Can't open log file \"%s\" for write.\n", full_path);
dw_printf ("%s\n", strerror(errno));
strlcpy (g_open_fname, "", sizeof(g_open_fname));
return;
}
}
} else { // Added in version 1.5. Single file.
if (g_log_fp == NULL) { // Open for append if not already open.
text_color_set(DW_COLOR_INFO);
dw_printf("Opening log file \"%s\"\n", g_log_path);

g_log_fp = fopen (g_log_path, "a");

if (g_log_fp == NULL) {
text_color_set(DW_COLOR_ERROR);
dw_printf("Can't open log file \"%s\" for write.\n", g_log_path);
dw_printf ("%s\n", strerror(errno));
strlcpy (g_log_path, "", sizeof(g_log_path));
return;
}
}
}

if (g_log_fp != NULL) {
char itime[24];
strftime (itime, sizeof(itime), "%Y-%m-%d %H:%M:%SZ", &tm);

fprintf (g_log_fp, "%s, %s, %s, %s, %s\n",
itime, heard, alevel_text, display_retries,spectrum);

fflush (g_log_fp);
}
} /* end log_heard */



/*------------------------------------------------------------------
4 changes: 3 additions & 1 deletion src/log.h
Original file line number Diff line number Diff line change
@@ -14,6 +14,8 @@ void log_init (int daily_names, char *path);

void log_write (int chan, decode_aprs_t *A, packet_t pp, alevel_t alevel, retry_t retries);

void log_heard(char *heard, char *alevel_text, char *display_retries, char *spectrum);

void log_rr_bits (decode_aprs_t *A, packet_t pp);

void log_term (void);
void log_term (void);