mardi 23 février 2021

Search or filtering data log file with PHP

Search and filter log file in PHP,

I have file log like this. the file name example.log

Input

2021-02-22 12:12:32 Plugin: 

Table Number: 2001K

Operation: ProcessOpenTablet

Stored Procedure: sp_HDS_OpenTablet

Payload: {"id":"POS026","staff_id":"2","table_no":"2001K","customer_first_name":null}

Response: [{"ErrCode":"01","ErrMsg":""}]

--------------------------------------------------------------------------------------------------------------------------------------------------
2021-02-22 12:12:32 Plugin: 

Table Number: 2001K

Operation: GetListDishFormPOST

Stored Procedure: sp_HDS_GetDishesList

Payload: {"id":"POS026"}

Response: []

--------------------------------------------------------------------------------------------------------------------------------------------------  
2021-02-22 12:12:40 Plugin: 

Table Number: 2001K

Operation: SettlePayment

Stored Procedure: sp_HDS_Payment

Payload: {"id":"POS026","operator_no":"2","table_no":"2001K"}

Response: [{"ErrCode":"01","ErrMsg":""}]

--------------------------------------------------------------------------------------------------------------------------------------------------
2021-02-22 12:18:17 Plugin: 

Table Number: 2002K

Operation: ProcessOpenTablet

Stored Procedure: sp_HDS_OpenTablet

Payload: {"id":"POS027","staff_id":"2","table_no":"2001K","customer_first_name":null}

Response: [{"ErrCode":"01","ErrMsg":""}]

--------------------------------------------------------------------------------------------------------------------------------------------------
2021-02-22 12:18:18 Plugin: 

Table Number: 2002K

Operation: GetListDishFormPOST

Stored Procedure: sp_HDS_GetDishesList

Payload: {"id":"POS027"}

Response: []

--------------------------------------------------------------------------------------------------------------------------------------------------
2021-02-22 12:18:28 Plugin: 

Table Number: 2002K

Operation: SettlePayment

Stored Procedure: sp_HDS_Payment

Payload: {"id":"POS027","operator_no":"2","table_no":"2001K"}

Response: [{"ErrCode":"01","ErrMsg":""}]

--------------------------------------------------------------------------------------------------------------------------------------------------
2021-02-22 15:18:28 Plugin: 

Table Number: 2002K

Operation: SettlePayment

Stored Procedure: sp_HDS_Payment

Payload: {"id":"POS028","operator_no":"2","table_no":"2001K"}

Response: [{"ErrCode":"01","ErrMsg":""}]

--------------------------------------------------------------------------------------------------------------------------------------------------
2021-02-22 12:24:04 Plugin: 

Table Number: 2003K

Operation: ProcessOpenTablet

Stored Procedure: sp_HDS_OpenTablet

Payload: {"id":"POS028","staff_id":"2","table_no":"2001K","customer_first_name":null}

Response: [{"ErrCode":"01","ErrMsg":""}]

--------------------------------------------------------------------------------------------------------------------------------------------------
2021-02-22 12:24:04 Plugin: 

Table Number: 2003K

Operation: GetListDishFormPOST

Stored Procedure: sp_HDS_GetDishesList

Payload: {"id":"POS026"}

Response: []

--------------------------------------------------------------------------------------------------------------------------------------------------

I want to extract to json or another log response, and can dynamically search or filter with PHP code, example :

I want to filter the date "2021-02-22" Stored Procedure "sp_HDS_Payment", and the result will be

Expected Output

2021-02-22 12:18:28 Plugin: 

Table Number: 2002K

Operation: SettlePayment

Stored Procedure: sp_HDS_Payment

Payload: {"id":"POS027","operator_no":"2","table_no":"2001K"}

Response: [{"ErrCode":"01","ErrMsg":""}]

--------------------------------------------------------------------------------------------------------------------------------------------------
2021-02-22 15:18:28 Plugin: 

Table Number: 2002K

Operation: SettlePayment

Stored Procedure: sp_HDS_Payment

Payload: {"id":"POS028","operator_no":"2","table_no":"2001K"}

Response: [{"ErrCode":"01","ErrMsg":""}]

--------------------------------------------------------------------------------------------------------------------------------------------------

I have no idea for case this.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire