Skip to content

Commit d8faab1

Browse files
committed
Change level2 record logging
Limit log messages for missing types to one message per type per pointer location.
1 parent f946109 commit d8faab1

File tree

1 file changed

+35
-26
lines changed

1 file changed

+35
-26
lines changed

cdm/radial/src/main/java/ucar/nc2/iosp/nexrad2/Level2Record.java

+35-26
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,7 @@ public static java.util.Date getDate(int julianDays, int msecs) {
511511
byte reflectHR_data_word_size, velocityHR_data_word_size, spectrumHR_data_word_size;
512512
byte zdrHR_data_word_size, phiHR_data_word_size, rhoHR_data_word_size;
513513

514-
private List<String> missingProductWarned = new ArrayList<>();
514+
private static List<String> missingProductWarned = new ArrayList<>();
515515

516516
public static Level2Record factory(RandomAccessFile din, int record, long message_offset31) throws IOException {
517517
long offset = record * RADAR_DATA_SIZE + FILE_HEADER_SIZE + message_offset31;
@@ -610,6 +610,10 @@ public Level2Record(RandomAccessFile din, int record, long message_offset31) thr
610610
int dbpp8 = 0;
611611
int dbpp9 = 0;
612612

613+
int missingPointerNumber = -999;
614+
int missingPointerValue = -999;
615+
String missingName = "";
616+
613617
if (dbp4 > 0) {
614618
String tname = getDataBlockStringValue(din, (short) dbp4, 1, 3);
615619
if (tname.startsWith("REF")) {
@@ -631,10 +635,9 @@ public Level2Record(RandomAccessFile din, int record, long message_offset31) thr
631635
hasHighResRHOData = true;
632636
dbpp9 = dbp4;
633637
} else {
634-
if (!missingProductWarned.contains(tname)) {
635-
logger.warn("Missing radial product dbp4={} tname={}", dbp4, tname);
636-
missingProductWarned.add(tname);
637-
}
638+
missingName = tname;
639+
missingPointerNumber = 4;
640+
missingPointerValue = dbp4;
638641
}
639642

640643
}
@@ -660,10 +663,9 @@ public Level2Record(RandomAccessFile din, int record, long message_offset31) thr
660663
hasHighResRHOData = true;
661664
dbpp9 = dbp5;
662665
} else {
663-
if (!missingProductWarned.contains(tname)) {
664-
logger.warn("Missing radial product dbp5={} tname={}", dbp5, tname);
665-
missingProductWarned.add(tname);
666-
}
666+
missingName = tname;
667+
missingPointerNumber = 5;
668+
missingPointerValue = dbp5;
667669
}
668670
}
669671
if (dbp6 > 0) {
@@ -688,10 +690,9 @@ public Level2Record(RandomAccessFile din, int record, long message_offset31) thr
688690
hasHighResRHOData = true;
689691
dbpp9 = dbp6;
690692
} else {
691-
if (!missingProductWarned.contains(tname)) {
692-
logger.warn("Missing radial product dbp6={} tname={}", dbp6, tname);
693-
missingProductWarned.add(tname);
694-
}
693+
missingName = tname;
694+
missingPointerNumber = 6;
695+
missingPointerValue = dbp6;
695696
}
696697
}
697698

@@ -717,10 +718,9 @@ public Level2Record(RandomAccessFile din, int record, long message_offset31) thr
717718
hasHighResRHOData = true;
718719
dbpp9 = dbp7;
719720
} else {
720-
if (!missingProductWarned.contains(tname)) {
721-
logger.warn("Missing radial product dbp7={} tname={}", dbp7, tname);
722-
missingProductWarned.add(tname);
723-
}
721+
missingName = tname;
722+
missingPointerNumber = 7;
723+
missingPointerValue = dbp7;
724724
}
725725
}
726726

@@ -746,10 +746,9 @@ public Level2Record(RandomAccessFile din, int record, long message_offset31) thr
746746
hasHighResRHOData = true;
747747
dbpp9 = dbp8;
748748
} else {
749-
if (!missingProductWarned.contains(tname)) {
750-
logger.warn("Missing radial product dbp8={} tname={}", dbp8, tname);
751-
missingProductWarned.add(tname);
752-
}
749+
missingName = tname;
750+
missingPointerNumber = 8;
751+
missingPointerValue = dbp8;
753752
}
754753
}
755754

@@ -775,13 +774,23 @@ public Level2Record(RandomAccessFile din, int record, long message_offset31) thr
775774
hasHighResRHOData = true;
776775
dbpp9 = dbp9;
777776
} else {
778-
if (!missingProductWarned.contains(tname)) {
779-
logger.warn("Missing radial product dbp9={} tname={}", dbp9, tname);
780-
missingProductWarned.add(tname);
781-
}
777+
missingName = tname;
778+
missingPointerNumber = 9;
779+
missingPointerValue = dbp9;
780+
}
781+
}
782+
783+
if (missingPointerNumber != -999) {
784+
// warn once per type per pointer location
785+
String missingKey = String.format("%s%d", missingName, missingPointerNumber);
786+
if (!missingProductWarned.contains(missingKey)) {
787+
String msg = String.format(
788+
"Unknown radial product dbp%d=%d tname=%s " + "(this is the only message you will see about this.)",
789+
missingPointerNumber, missingPointerValue, missingName);
790+
logger.warn(msg);
791+
missingProductWarned.add(missingKey);
782792
}
783793
}
784-
// hasHighResREFData = (dbp4 > 0);
785794

786795
if (hasHighResREFData) {
787796
reflectHR_gate_count = getDataBlockValue(din, (short) dbpp4, 8);

0 commit comments

Comments
 (0)