@@ -426,6 +426,92 @@ void log_write (int chan, decode_aprs_t *A, packet_t pp, alevel_t alevel, retry_
426
426
427
427
} /* end log_write */
428
428
429
+ /*------------------------------------------------------------------
430
+ *
431
+ * Function: log_heard
432
+ *
433
+ * Purpose: Save packet information from non-APRS packets to log file.
434
+ * Basically the same info as written to stdout
435
+ *
436
+ *------------------------------------------------------------------*/
437
+
438
+
439
+ void log_heard (char * heard , char * alevel_text , char * display_retries , char * spectrum )
440
+ {
441
+ time_t now ;
442
+ struct tm tm ;
443
+
444
+ dw_printf ("Logging heard packet\n" );
445
+
446
+ if (strlen (g_log_path ) == 0 ) return ;
447
+
448
+ now = time (NULL ); // Get current time.
449
+ (void )gmtime_r (& now , & tm );
450
+
451
+
452
+ if (g_daily_names ) {
453
+ char fname [20 ];
454
+ strftime (fname , sizeof (fname ), "%Y-%m-%d.log" , & tm );
455
+
456
+ // Close current file if name has changed
457
+ if (g_log_fp != NULL && strcmp (fname , g_open_fname ) != 0 ) {
458
+ log_term ();
459
+ }
460
+ if (g_log_fp == NULL ) { // Open for append if not already open.
461
+ char full_path [120 ];
462
+
463
+ strlcpy (full_path , g_log_path , sizeof (full_path ));
464
+ #if __WIN32__
465
+ strlcat (full_path , "\\" , sizeof (full_path ));
466
+ #else
467
+ strlcat (full_path , "/" , sizeof (full_path ));
468
+ #endif
469
+ strlcat (full_path , fname , sizeof (full_path ));
470
+
471
+ text_color_set (DW_COLOR_INFO );
472
+ dw_printf ("Opening log file \"%s\".\n" , fname );
473
+
474
+ g_log_fp = fopen (full_path , "a" );
475
+
476
+ if (g_log_fp != NULL ) {
477
+ strlcpy (g_open_fname , fname , sizeof (g_open_fname ));
478
+ }
479
+ else {
480
+ text_color_set (DW_COLOR_ERROR );
481
+ dw_printf ("Can't open log file \"%s\" for write.\n" , full_path );
482
+ dw_printf ("%s\n" , strerror (errno ));
483
+ strlcpy (g_open_fname , "" , sizeof (g_open_fname ));
484
+ return ;
485
+ }
486
+ }
487
+ } else { // Added in version 1.5. Single file.
488
+ if (g_log_fp == NULL ) { // Open for append if not already open.
489
+ text_color_set (DW_COLOR_INFO );
490
+ dw_printf ("Opening log file \"%s\"\n" , g_log_path );
491
+
492
+ g_log_fp = fopen (g_log_path , "a" );
493
+
494
+ if (g_log_fp == NULL ) {
495
+ text_color_set (DW_COLOR_ERROR );
496
+ dw_printf ("Can't open log file \"%s\" for write.\n" , g_log_path );
497
+ dw_printf ("%s\n" , strerror (errno ));
498
+ strlcpy (g_log_path , "" , sizeof (g_log_path ));
499
+ return ;
500
+ }
501
+ }
502
+ }
503
+
504
+ if (g_log_fp != NULL ) {
505
+ char itime [24 ];
506
+ strftime (itime , sizeof (itime ), "%Y-%m-%d %H:%M:%SZ" , & tm );
507
+
508
+ fprintf (g_log_fp , "%s, %s, %s, %s, %s\n" ,
509
+ itime , heard , alevel_text , display_retries ,spectrum );
510
+
511
+ fflush (g_log_fp );
512
+ }
513
+ } /* end log_heard */
514
+
429
515
430
516
431
517
/*------------------------------------------------------------------
0 commit comments