Skip to content

Commit 979b0e0

Browse files
committed
feat: Log in microseconds
1 parent 375d024 commit 979b0e0

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

backend/pkg/logger/data/logger.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ func (sublogger *Logger) PushRecord(record abstraction.LoggerRecord) error {
120120
}
121121

122122
err = saveFile.Write([]string{
123-
fmt.Sprint(dataRecord.Packet.Timestamp().UnixMilli()),
123+
fmt.Sprint(dataRecord.Packet.Timestamp().UnixMicro()),
124124
dataRecord.From,
125125
dataRecord.To,
126126
valueRepresentation,

backend/pkg/logger/logger_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ func TestLogger(t *testing.T) {
7777
t.Error(err)
7878
}
7979

80-
if output[0] != fmt.Sprint(dataPacketTime.UnixMilli()) || output[1] != "test" || output[2] != "test" || output[3] != "true" {
81-
t.Errorf("dataErr: expected [%v test test true], got %v", timestamp.UnixMilli(), output)
80+
if output[0] != fmt.Sprint(dataPacketTime.UnixMicro()) || output[1] != "test" || output[2] != "test" || output[3] != "true" {
81+
t.Errorf("dataErr: expected [%v test test true], got %v", timestamp.UnixMicro(), output)
8282
}
8383

8484
// Order
@@ -111,7 +111,7 @@ func TestLogger(t *testing.T) {
111111
t.Error(err)
112112
}
113113

114-
if output[0] != fmt.Sprint(orderPacketTime.UnixMilli()) || output[1] != "test" || output[2] != "test" {
114+
if output[0] != fmt.Sprint(orderPacketTime.UnixMicro()) || output[1] != "test" || output[2] != "test" {
115115
t.Errorf("orderErr: expected [test test], got %v", output)
116116
}
117117

@@ -163,7 +163,7 @@ func TestLogger(t *testing.T) {
163163
t.Error(err)
164164
}
165165

166-
if output[0] != fmt.Sprint(timestamp.UnixMilli()) || output[1] != "test" || output[2] != "test" || output[3] != "0" || output[4] != "7" || output[5] != "3" || output[6] != "test" || output[7] != "&{0 0}" || output[8] != protectionPacketTime.Format(time.RFC3339) {
166+
if output[0] != fmt.Sprint(timestamp.UnixMicro()) || output[1] != "test" || output[2] != "test" || output[3] != "0" || output[4] != "7" || output[5] != "3" || output[6] != "test" || output[7] != "&{0 0}" || output[8] != protectionPacketTime.Format(time.RFC3339) {
167167
t.Errorf("orderErr: expected [test test 0], got %v", output)
168168
}
169169

backend/pkg/logger/order/logger.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ func (sublogger *Logger) PushRecord(record abstraction.LoggerRecord) error {
9696
}
9797

9898
err := sublogger.writer.Write([]string{
99-
fmt.Sprint(orderRecord.Packet.Timestamp().UnixMilli()),
99+
fmt.Sprint(orderRecord.Packet.Timestamp().UnixMicro()),
100100
orderRecord.From,
101101
orderRecord.To,
102102
fmt.Sprint(orderRecord.Packet.Id()),

backend/pkg/logger/protection/logger.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ func (sublogger *Logger) PushRecord(record abstraction.LoggerRecord) error {
8282
}
8383

8484
err = saveFile.Write([]string{
85-
fmt.Sprint(infoRecord.Timestamp.UnixMilli()),
85+
fmt.Sprint(infoRecord.Timestamp.UnixMicro()),
8686
infoRecord.From,
8787
infoRecord.To,
8888
fmt.Sprint(infoRecord.Packet.Id()),

0 commit comments

Comments
 (0)