@@ -62,21 +62,29 @@ public void saveGossipMessageDecodingError(
62
62
if (!enabled ) {
63
63
return ;
64
64
}
65
- final String fileName = String .format ("%s.ssz" , formatTimestamp (arrivalTimestamp ));
65
+ final String formattedTimestamp = formatTimestamp (arrivalTimestamp );
66
+ final String fileName = String .format ("%s.ssz" , formattedTimestamp );
66
67
final Path topicPath =
67
68
Path .of (GOSSIP_MESSAGES_DIR ).resolve (DECODING_ERROR_SUB_DIR ).resolve (topic );
69
+ final String identifiers = String .format ("on topic %s at %s" , topic , formattedTimestamp );
68
70
saveBytesToFile (
69
- "gossip message with decoding error" , topicPath .resolve (fileName ), originalMessage );
71
+ "gossip message with decoding error" ,
72
+ identifiers ,
73
+ topicPath .resolve (fileName ),
74
+ originalMessage );
70
75
}
71
76
72
77
public void saveGossipRejectedMessageToFile (
73
78
final String topic , final Optional <UInt64 > arrivalTimestamp , final Bytes decodedMessage ) {
74
79
if (!enabled ) {
75
80
return ;
76
81
}
77
- final String fileName = String .format ("%s.ssz" , formatTimestamp (arrivalTimestamp ));
82
+ final String formattedTimestamp = formatTimestamp (arrivalTimestamp );
83
+ final String fileName = String .format ("%s.ssz" , formattedTimestamp );
78
84
final Path topicPath = Path .of (GOSSIP_MESSAGES_DIR ).resolve (REJECTED_SUB_DIR ).resolve (topic );
79
- saveBytesToFile ("rejected gossip message" , topicPath .resolve (fileName ), decodedMessage );
85
+ final String identifiers = String .format ("on topic %s at %s" , topic , formattedTimestamp );
86
+ saveBytesToFile (
87
+ "rejected gossip message" , identifiers , topicPath .resolve (fileName ), decodedMessage );
80
88
}
81
89
82
90
public void saveInvalidBlockToFile (
@@ -85,16 +93,21 @@ public void saveInvalidBlockToFile(
85
93
return ;
86
94
}
87
95
final String fileName = String .format ("%s_%s.ssz" , slot , blockRoot .toUnprefixedHexString ());
88
- saveBytesToFile ("invalid block" , Path .of (INVALID_BLOCK_DIR ).resolve (fileName ), blockSsz );
96
+ final String identifiers = String .format ("at slot %s(%s)" , slot , blockRoot );
97
+ saveBytesToFile (
98
+ "invalid block" , identifiers , Path .of (INVALID_BLOCK_DIR ).resolve (fileName ), blockSsz );
89
99
}
90
100
91
101
@ VisibleForTesting
92
102
protected void saveBytesToFile (
93
- final String description , final Path relativeFilePath , final Bytes bytes ) {
103
+ final String description ,
104
+ final String identifiers ,
105
+ final Path relativeFilePath ,
106
+ final Bytes bytes ) {
94
107
final Path path = directory .resolve (relativeFilePath );
95
108
try {
96
109
Files .write (path , bytes .toArray ());
97
- LOG .info ("Saved {} bytes to file. Location: {}" , description , relativeFilePath );
110
+ LOG .info ("Saved {} {}" , description , identifiers );
98
111
} catch (NoSuchFileException e ) {
99
112
if (!path .getParent ().toFile ().mkdirs ()) {
100
113
LOG .error ("Failed to save {} bytes to file." , description , e );
@@ -111,7 +124,7 @@ private void saveAfterCreatingTopicDirectory(
111
124
final Path path = directory .resolve (relativeFilePath );
112
125
try {
113
126
Files .write (path , bytes .toArray ());
114
- LOG .info ("Saved {} bytes to file. Location: {} " , description , relativeFilePath );
127
+ LOG .info ("Saved {} " , description );
115
128
} catch (IOException e ) {
116
129
LOG .error ("Failed to save {} bytes to file." , description , e );
117
130
if (!path .getParent ().toFile ().exists ()) {
0 commit comments