@@ -28,7 +28,7 @@ const (
2828 dateTimeFormat = "02/Jan/2006:15:04:05 -0700"
2929)
3030
31- var errInvalidLogFormat = errors .New ("invalid log format" )
31+ var errInvalidTransactionFormat = errors .New ("invalid crypto transaction format" )
3232
3333// NewFile wraps an os.File creating a special apache common log format regex
3434// and adding useful helper functions such as seekLine and search for easier working with log files
@@ -105,7 +105,7 @@ func (file *File) IndexTime(lookupTime time.Time) (int64, error) {
105105 break
106106 }
107107
108- logTime , err := file .parseLogTime (line )
108+ logTime , err := file .parseTransactionTime (line )
109109 if err != nil {
110110 return - 1 , err
111111 }
@@ -222,13 +222,16 @@ func (file *File) seekLine(lines int64, whence int) (int64, error) {
222222 return pos , err
223223}
224224
225- // parseLogTime parses a given apache common log line and attempts to convert it into time.Time
226- // example of apache common log line:
227- // 127.0.0.1 user-identifier frank [04/Mar/2022:05:30:00 +0000] "GET /api/endpoint HTTP/1.0" 500 123
228- func (file * File ) parseLogTime (l string ) (time.Time , error ) {
225+ // parseTransactionTime parses a given apache common log line and attempts to convert it into time.Time
226+ // example of possible crypto transaction lines:
227+ //0xa42c9E5B5d936309D6B4Ca323B0dD5739643D2Dd WITHDRAW BTC/USD:26782.60 USD:13967.95 15USD 03/13/2022 11:35:51 +0000
228+ //0xeeaFf5e4B8B488303A9F1db36edbB9d73b38dFcf BUY BTC/USD:37448.30 USD:1.16 2%(0.02 USD) 03/13/2022 11:36:51 +0000
229+ //0x980Bc04e435C5E948B1f70a69cD377783500757b CONVERT USDT/BUSD:0.68 BUSD:3263.97 0% 03/13/2022 11:37:51 +0000
230+ //0xc68c701B5904fB27Ec72Cc8ff062530a0ffd2015 SELL SOL/GBP:74.60 GBP:36.52 3%(1.10 GBP) 03/13/2022 11:33:51 +0000
231+ func (file * File ) parseTransactionTime (l string ) (time.Time , error ) {
229232 matches := file .regEx .FindStringSubmatch (l )
230233 if len (matches ) == 0 {
231- return time.Time {}, fmt .Errorf ("line '%s': %w" , l , errInvalidLogFormat )
234+ return time.Time {}, fmt .Errorf ("line '%s': %w" , l , errInvalidTransactionFormat )
232235 }
233236
234237 var dateTime string
@@ -239,7 +242,7 @@ func (file *File) parseLogTime(l string) (time.Time, error) {
239242 }
240243 }
241244 if dateTime == "" {
242- return time.Time {}, fmt .Errorf ("invalid date: %w" , errInvalidLogFormat )
245+ return time.Time {}, fmt .Errorf ("invalid date: %w" , errInvalidTransactionFormat )
243246 }
244247
245248 t , err := time .Parse (dateTimeFormat , dateTime )
0 commit comments