Log recording method and device, electronic device, and computer-readable storage medium
By processing API call requests and log data generation through asynchronous threads, combining batch storage and filtering mechanisms, the problem of logging affecting API response speed in the existing technology is solved, and the logging efficiency and system performance are improved.
Patent Information
- Application Number
- CN202180002696.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-09-16
- Publication Date
- 2024-11-29
- Estimated Expiration
- 2041-09-16
AI Technical Summary
In the prior art, audit logging methods will affect the response speed of API call requests, resulting in low log data recording efficiency and high redundancy, affecting system performance.
The first asynchronous thread is used to intercept the client's API call request, generate log data and store it in the log storage queue, and use business threads to respond to API call requests to realize asynchronous log data generation and storage, reduce the impact on API response, and filter through presets Parameters are stored in batches to the database, reducing redundancy and improving efficiency.
It improves the response speed of API call requests, reduces unnecessary logging, reduces redundancy of log data, improves logging efficiency and query efficiency, and enhances system performance.
Smart Images

Figure CN113661484B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to intelligent identification technology, and more particularly to a log recording method and device, an electronic device, and a computer-readable storage medium. Background Art
[0002] In today's computer software industry, a fully-authorized software needs to be able to record the operation behaviors of all users in the system, record them in the system in the form of operation logs and provide retrieval functions to facilitate statistics, auditing, tracking and tracing needs.
[0003] Today's software architecture design generally adopts the form of front-end and back-end separation, that is, it is divided into two projects: client interface style and server application programming interface (Application Programming Interface, API). Usually, the server provides a Hypertext Transfer Protocol (HTTP) or Remote Procedure Call (RPC) API interface, and the client calls the back-end API through the Transmission Control Protocol (TCP) to achieve the purpose of communication.
[0004] In the related art, the commonly used audit log recording method is often to respond to the API call request by the server while recording the data of the API call request. However, in this way, the read and write (Input / Output, I / O) operations of the log data may slow down the API response speed. In other words, in the related art, the way of recording log data will affect the response speed to the API call request. Summary of the invention
[0005] The embodiments of the present disclosure provide a log recording method and device, an electronic device, and a computer-readable storage medium, which can improve the response speed to API call requests.
[0006] The technical solution of the embodiment of the present disclosure is implemented as follows:
[0007] The embodiment of the present disclosure provides a log recording method, including: using a first asynchronous thread to intercept an application program interface call request sent by a client; generating log data based on the application program interface call request, and storing the log data in a log storage queue; the log storage queue is used to store the log data stored in a database after filtering; using a business thread to respond to a modification request in the application program interface call request to achieve real-time recording of a scene state.
[0008] In an embodiment, since the first asynchronous thread is used to intercept the API call request sent by the client and the modification request for triggering the modification operation of the working parameters, a business thread different from the first asynchronous thread is used to modify the working parameters according to the modification request sent by the client, and the modified working parameters are used to record the scene state. At the same time, the first asynchronous thread is also used to generate log data according to the API call request and store the generated log data. Therefore, while recording the scene state, the log data can be asynchronously generated and stored, so that responding to the API call request and recording the log data do not affect each other, thereby improving the response speed to the API call request in the process of recording the log data, and reducing the recording of unnecessary log data, thereby improving the recording efficiency of the log data and reducing the redundancy of the recorded log data.
[0009] In one embodiment, the method further includes: filtering the log data in the log storage queue based on a preset first filtering parameter, and storing the filtered log data in batches to the database.
[0010] In an embodiment, through the first filtering parameter, the redundancy of log data in the database can be effectively reduced, which can not only improve the query efficiency of log data when the user queries the log data in the database, but also reduce the disk occupancy; and, by using a batch processing method, the filtered log data is stored in the database, which can reduce the I / O operations on the database and improve the log storage efficiency.
[0011] In one embodiment, the method further includes: using the first asynchronous thread to obtain user authority information according to the request header parsed from the application program interface call request, and authenticating the user authority information to obtain an authentication result;
[0012] The generating log data based on the application program interface call request includes: using the first asynchronous thread, when the authentication result characterizes passing, generating the log data based on the application program interface call request.
[0013] In an embodiment, the API call request is authenticated, and if the authentication is successful, corresponding log data is generated based on the API call request, so that situations in which the client requests forged operation user or user behavior data can be discovered in time, thereby making the generated log data more authentic.
[0014] In one embodiment, the log data is generated based on the application interface call request, including: extracting first data from the request header parsed from each call request in the application interface call request; the first data includes at least: user identity data and resource path data; extracting second data from the request body and request line parsed from each call request; the second data includes at least: request method data and request content data; combining the first data and the second data to obtain a log data corresponding to each call request.
[0015] In an embodiment, data is extracted from a corresponding application program interface call request, and a log data is generated according to the extracted data, which can facilitate subsequent filtering and recording of the log data.
[0016] In one embodiment, at least one log data is stored in the log storage queue, and each log data includes: a log parameter; based on a preset first filtering parameter, the log data in the log storage queue is filtered, and the filtered log data is stored in batches to the database, including: obtaining the at least one log data from the log storage queue; matching the log parameter of each log data in the at least one log data with the first filtering parameter to obtain matching matching parameters; determining the filtered log data based on at least one target log data corresponding to the matching parameter; and storing the filtered log data in the database when the number of the filtered log data reaches a preset number.
[0017] In an embodiment, the filtering accuracy of log data can be improved by a one-by-one matching method, thereby further reducing the redundancy of log data stored in the database.
[0018] In one embodiment, obtaining the at least one log data from the log storage queue includes: reading log data from the log storage queue at a preset frequency; when the current log data is read, continuing to read the next log data from the log storage queue until the last log data stored in the log storage queue is read, thereby obtaining the at least one log data.
[0019] In an embodiment, the above acquisition method is adopted to improve the efficiency of acquiring log data.
[0020] In one embodiment, the matching parameter includes at least one of the following: a method parameter, a resource path parameter, a resource path prefix parameter, a non-target parameter in a parameter blacklist, and a target parameter in a parameter whitelist.
[0021] In the embodiment, the diversity of filtering methods can be increased, thereby improving the flexibility of data recording.
[0022] In one embodiment, determining the filtered log data according to at least one target log data corresponding to the matching parameter includes: determining candidate log data according to at least one target log data corresponding to the matching parameter; and determining the filtered log data based on the candidate log data.
[0023] In an embodiment, determining the filtered log data based on the candidate log data can make the obtained filtered log data more accurate.
[0024] In one embodiment, determining the candidate log data according to the at least one target log data corresponding to the matching parameter includes: when the matching parameter is a method parameter, determining the at least one target log data corresponding to the method parameter in the at least one log data as the candidate log data; when the matching parameter is a resource path parameter, determining the at least one target log data corresponding to the resource path parameter as the candidate log data; when the matching parameter is a resource path prefix parameter, determining the at least one target log data corresponding to the resource path prefix parameter in the at least one log data as the candidate log data; when the matching parameter is at least one non-target parameter in a parameter blacklist, determining the log data other than the at least one target log data corresponding to the at least one non-target parameter in the at least one log data as the candidate log data; when the matching parameter is at least one target parameter in a parameter whitelist, determining the at least one target log data corresponding to the at least one target parameter in the at least one log data as the candidate log data.
[0025] In the embodiment, through the above filtering method, a variety of filtered log data can be obtained, which improves the flexibility of data recording.
[0026] In one embodiment, the method further includes: receiving a filtering parameter setting instruction carrying the preset first filtering parameter; and in response to the filtering parameter setting instruction, changing the preset first initial filtering parameter to the preset first filtering parameter.
[0027] In an embodiment, according to the received filtering parameter setting instruction, the preset first initial filtering parameter is changed to the preset first filtering parameter for subsequent filtering of log data, which can increase the diversity of filtering methods and improve the flexibility of data recording.
[0028] In one embodiment, the business thread is used to respond to the modification request in the application interface call request to achieve real-time recording of the scene status, including: using the business thread to respond to the modification request in the application interface call request, modifying the working parameters of the business thread to obtain modified working parameters; determining the real-time status of the scene based on the modified working parameters and the real-time scene data collected by the received acquisition device; comparing the real-time status with the preset status to obtain a comparison result, and recording the comparison result in real time.
[0029] In an embodiment, based on the modified working parameters, the real-time recording of the scene status is achieved, which can improve the accuracy of the recording of the scene status.
[0030] In one embodiment, the method further comprises: issuing a prompt message when the comparison result indicates that the real-time status is abnormal.
[0031] In the embodiment, the above-mentioned method is adopted so that relevant maintenance personnel can timely intervene in the equipment related to the scene status, such as acquisition equipment, etc., so that these equipment can operate normally.
[0032] The embodiment of the present disclosure provides a log recording device, including: an interceptor, used to intercept an application program interface call request sent by a client; and based on the application program interface call request, generating log data, and storing the log data in a log storage queue; the log storage queue is used to store the log data stored in a database after filtering; a business thread is used to respond to a modification request in the application program interface call request to achieve real-time recording of a scene state.
[0033] In one embodiment, the interceptor is further used to filter the log data in the log storage queue based on a preset first filtering parameter, and store the filtered log data in batches to the database.
[0034] In one embodiment, the interceptor is also used to obtain user authority information based on the request header parsed from the application interface call request, and authenticate the user authority information to obtain an authentication result; when the authentication result indicates that it passes, the log data is generated based on the application interface call request.
[0035] In one embodiment, the interceptor is also used to extract first data from the request header parsed from each call request in the application interface call request; the first data includes at least: user identity data and resource path data; extract second data from the request body and request line parsed from each call request; the second data includes at least: request method data and request content data; combine the first data and the second data to obtain a log data corresponding to each call request.
[0036] In one embodiment, at least one log data is stored in the log storage queue, and each log data includes: log parameters; the interceptor is also used to obtain the at least one log data from the log storage queue; match the log parameters of each log data in the at least one log data with the first filtering parameter to obtain matching matching parameters; determine the filtered log data based on at least one target log data corresponding to the matching parameter; when the number of the filtered log data reaches a preset number, store the filtered log data in the database.
[0037] In one embodiment, the interceptor is also used to read log data from the log storage queue at a preset frequency; when the current log data is read, the next log data continues to be read from the log storage queue until the last log data stored in the log storage queue is read, thereby obtaining the at least one log data.
[0038] In one embodiment, the matching parameter includes at least one of the following: a method parameter, a resource path parameter, a resource path prefix parameter, a non-target parameter in a parameter blacklist, and a target parameter in a parameter whitelist.
[0039] In one embodiment, the interceptor is further used to determine candidate log data according to at least one target log data corresponding to the matching parameter; and determine the filtered log data based on the candidate log data.
[0040] In one embodiment, the interceptor is further used to, when the matching parameter is a method parameter, determine at least one target log data corresponding to the method parameter in the at least one log data as the candidate log data; when the matching parameter is a resource path parameter, determine at least one target log data corresponding to the resource path parameter as the candidate log data; when the matching parameter is a resource path prefix parameter, determine at least one target log data corresponding to the resource path prefix parameter in the at least one log data as the candidate log data; when the matching parameter is at least one non-target parameter in a parameter blacklist, determine the log data in the at least one log data other than the at least one target log data corresponding to the at least one non-target parameter as the candidate log data; when the matching parameter is at least one target parameter in a parameter whitelist, determine at least one target log data corresponding to the at least one target parameter in the at least one log data as the candidate log data.
[0041] In one embodiment, the device further comprises a modification module for receiving a filtering parameter setting instruction carrying the preset first filtering parameter; and in response to the filtering parameter setting instruction, changing the preset first initial filtering parameter to the preset first filtering parameter.
[0042] In one embodiment, the business thread is also used to respond to the modification request in the application interface call request, modify its own working parameters, and obtain modified working parameters; determine the real-time state of the scene based on the modified working parameters and the real-time scene data collected by the received acquisition device; compare the real-time state with the preset state to obtain a comparison result, and record the comparison result in real time.
[0043] In one embodiment, the business thread is further configured to issue a prompt message when the comparison result indicates that the real-time status is abnormal.
[0044] An embodiment of the present disclosure provides an electronic device, including:
[0045] a memory for storing executable computer programs;
[0046] The processor is used to implement the above-mentioned logging method when executing the executable computer program stored in the memory.
[0047] The embodiment of the present disclosure provides a computer-readable storage medium storing a computer program for implementing the above-mentioned log recording method when executed by a processor. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] Figure 1 An optional schematic diagram of the architecture of an exemplary logging system provided for an embodiment of the present disclosure;
[0049] Figure 2 An optional flowchart of an exemplary log recording method provided by an embodiment of the present disclosure;
[0050] Figure 3 An optional flowchart of an exemplary log recording method provided by an embodiment of the present disclosure;
[0051] Figure 4 An optional flowchart of an exemplary log recording method provided by an embodiment of the present disclosure;
[0052] Figure 5 A flowchart of an exemplary method for generating log data and responding to an API call request provided in an embodiment of the present disclosure;
[0053] Figure 6 An optional flowchart of an exemplary log recording method provided by an embodiment of the present disclosure;
[0054] Figure 7 An optional flowchart of an exemplary log recording method provided by an embodiment of the present disclosure;
[0055] Figure 8 A flowchart of an exemplary method for filtering log data and cleaning log data stored in a database provided in an embodiment of the present disclosure;
[0056] Fig. 9 A schematic diagram of the structure of a log recording device provided in an embodiment of the present disclosure;
[0057] Fig.10 A schematic diagram of the structural composition of an electronic device provided in an embodiment of the present disclosure. DETAILED DESCRIPTION
[0058] In order to make the objectives, technical solutions and advantages of the present disclosure clearer, the present disclosure will be further described in detail below in conjunction with the accompanying drawings. The described embodiments should not be regarded as limiting the present disclosure. All other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of the present disclosure.
[0059] In the following description, reference is made to “some embodiments”, which describe a subset of all possible embodiments, but it will be understood that “some embodiments” may be the same subset or different subsets of all possible embodiments and may be combined with each other without conflict.
[0060] In the following description, the terms "first\second\third" involved are merely used to distinguish similar objects and do not represent a specific ordering of the objects. It can be understood that "first\second\third" can be interchanged with a specific order or sequence where permitted, so that the embodiments of the present disclosure described herein can be implemented in an order other than that illustrated or described herein.
[0061] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which the present disclosure belongs. The terms used herein are only for the purpose of describing the embodiments of the present disclosure and are not intended to limit the present disclosure.
[0062] Before further describing the embodiments of the present disclosure in detail, the nouns and terms involved in the embodiments of the present disclosure are described. The nouns and terms involved in the embodiments of the present disclosure are subject to the following interpretations.
[0063] In today's computer software industry, a fully authorized software needs to be able to record the operation behaviors of all users in the system, record them in the system in the form of operation logs and provide retrieval functions to meet the needs of statistics, auditing, tracking and tracing. Today's software architecture design generally adopts the form of front-end and back-end separation, that is, it is divided into two projects: client interface style and server application programming interface (Application Programming Interface, API). Usually, the server provides a Hypertext Transfer Protocol (HTTP) or Remote Procedure Call (RPC) API interface, and the client calls the server API through the Transmission Control Protocol (TCP) to achieve the purpose of communication.
[0064] In the related art, the commonly used audit log recording method is often controlled by the client, and some user behaviors on the interface are recorded by the client, and sent to the server for storage through the log recording API. Another way is to respond to the API call request in the process of recording the data of the API call request by the server. However, the first method requires a large number of data requests, which occupies most of the bandwidth. Although the second method solves the problem of occupying most of the bandwidth brought by the first method, the reading and writing (Input / Output, I / O) operations of the log data may slow down the API response speed. In other words, in the related art, the way of recording log data will affect the response speed to the API call request.
[0065] The embodiments of the present disclosure provide a log recording method and device, an electronic device, and a computer-readable storage medium, which can improve the response speed to API call requests. The exemplary application of the electronic device provided by the embodiments of the present disclosure is described below. The electronic device provided by the embodiments of the present disclosure can be implemented as various types of user terminals such as laptops, tablet computers, desktop computers, set-top boxes, mobile devices (for example, mobile phones, portable music players, personal digital assistants, dedicated messaging devices, portable gaming devices), etc.; it can also be implemented as an independent physical server, or a server cluster or distributed system composed of multiple physical servers, and can also be a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms in real time. But it is not limited to this.
[0066] See also Figure 1 , Figure 1 Schematic diagram of an optional architecture of a logging system 10 provided in an embodiment of the present disclosure; the logging system 10 includes a client 100 (a client 100A is shown as an example) and a server 200 (a server 200A is shown as an example).
[0067] In some embodiments of the present disclosure, the scene state may be a game state of a game table, and the following will take this as an example. Figure 1 For explanation. Figure 1In the example, the server 200A may be used to record the game status of multiple smart game tables in real time, wherein the server 200A stores working parameters, for example, the angle of the camera set on each smart game table, the game participant information of the smart game table, the heat map, the game rules, and the network configuration parameters of the server 200A itself, such as the network address, the maximum number of connections, the connected client address, the port number, etc. The client 100A may be an intelligent device that provides a target website for the user, for example, a desktop computer or a laptop computer. The user logs in to the operation and maintenance management system corresponding to the server 200A through the target website provided by the client 100A, and manages the working parameters of the server 200A through the operation and maintenance management system. In the process of the user logging into the operation and maintenance management system corresponding to the server 200A through the client 100A and managing the working parameters of the server 200A through the system, on the one hand, the server 200A can use the first asynchronous thread to intercept the application interface call request sent by the client; based on the application interface call request, generate log data, and store the log data in the log storage queue used to store the log data stored in the database after filtering; on the other hand, the server 200A can use a business thread different from the first asynchronous thread to respond to the modification request in the application interface call request, so as to realize the real-time recording of the game status of the game table.
[0068] See also Figure 2 , Figure 2 This is an optional flow chart of the log recording method provided by the embodiment of the present disclosure. The following will take the server as the execution subject and combine Figure 2 The steps shown are explained.
[0069] S101. Using a first asynchronous thread, intercepting an application program interface call request sent by a client.
[0070] In an embodiment of the present disclosure, the server may intercept an API call request sent by the client during the communication process with the client.
[0071] In an embodiment of the present disclosure, the server may set interceptors on all of its API interfaces that are used to interact with the client for information; after the interceptors are set, the API call requests sent by the client to the server's API interface must all pass through the interceptors set on the corresponding API interfaces, and thus, the API call requests sent by the client to the server can be obtained through the interceptors set on the server's API interface.
[0072] In the embodiments of the present disclosure, the interceptor may be implemented through software code or through other methods, which is not limited in the embodiments of the present disclosure.
[0073] In an embodiment of the present disclosure, the API call request may be an HTTP request.
[0074] S102: Generate log data based on the application program interface call request, and send the log data to a log storage queue; the log storage queue is used to store the log data stored in the database after filtering.
[0075] In an embodiment of the present disclosure, when the server intercepts and obtains the API call request sent by the client through the first asynchronous thread, it also generates log data corresponding to the API call request through the first asynchronous working thread, and sends the generated log data to its own log storage queue for storage, wherein the log storage queue is used to store the log data stored in the database after filtering.
[0076] In the embodiment of the present disclosure, for each API call request, one piece of log data may be generated accordingly, and thus, for multiple API call requests, multiple pieces of log data may be generated accordingly.
[0077] S103: Using a business thread to respond to a modification request in an application program interface call request to achieve real-time recording of the scene status.
[0078] In an embodiment of the present disclosure, after the API call request sent by the client is intercepted, the server will also use a business thread different from the first asynchronous thread to parse the modification request from the intercepted application interface call request, and perform corresponding processing according to the modification request to respond to the modification request. After responding to the modification request, the server will record the scene status in real time based on the processing result obtained by performing corresponding processing according to the modification request.
[0079] In some embodiments of the present disclosure, the above S103 may be implemented through S1031-S1032:
[0080] S1031. Using a service thread, responding to a modification request in the application program interface call request, modifying a working parameter of the service thread to obtain a modified working parameter.
[0081] S1032. Based on the modified working parameters, the scene status is recorded in real time.
[0082] In an embodiment of the present disclosure, the server will also use a business thread different from the first asynchronous thread to parse a modification request for triggering the modification operation of the working parameters from the received application interface call request, and modify its own working parameters according to the data carried in the modification request, thereby obtaining the modified working parameters, and based on the modified working parameters, record the scene status in real time.
[0083] In some embodiments of the present disclosure, the business thread may also include: a business processing sub-thread and a recording sub-thread; wherein the business processing thread is used to respond to the modification request in the application interface call request, modify its own working parameters, and obtain the modified working parameters; the recording sub-thread is used to realize real-time recording of the scene status based on the modified working parameters.
[0084] In some embodiments of the present disclosure, the data carried in the modification request may be the parameters to be modified and the target parameters, so that the server can modify the parameters to be modified in its own working parameters to the target parameters according to the modification request.
[0085] For example, in the game state of the game table, the parameter to be modified is the angle of the camera set on the smart game table A, and the target parameter is θ 1 In the case of 0 Modified to θ 1 , thereby realizing the change of the camera angle set on the smart game table A, and then the camera set on the smart game table A can change its own image acquisition angle according to the target parameter; thus, the server can subsequently continue to record the game status of the smart game table A in real time based on the scene image of the smart game table A captured by the camera after the image acquisition angle is updated.
[0086] In other embodiments of the present disclosure, the data carried in the modification request may also be other data, as long as the server can correctly modify its own working parameters according to the data in the modification request, and the embodiments of the present disclosure do not specifically limit this.
[0087] In the disclosed embodiment, since the first asynchronous thread is used to intercept the API call request sent by the client and includes a modification request for triggering a modification operation on the working parameters, a business thread different from the first asynchronous thread is used to modify the working parameters according to the modification request sent by the client, and the modified working parameters are used to record the scene status. At the same time, the first asynchronous thread is also used to generate log data according to the API call request and store the generated log data. Therefore, while recording the scene status, the log data can be asynchronously generated and stored, so that responding to the API call request and recording the log data do not affect each other, thereby improving the response speed to the API call request in the process of recording the log data, and reducing the recording of unnecessary log data, thereby improving the recording efficiency of the log data and reducing the redundancy of the recorded log data.
[0088] In some embodiments of the present disclosure, the above S1032 may also be implemented through S1-S2, and S3 may be executed after S2:
[0089] S1. Determine the real-time state of the scene based on the modified working parameters and the real-time scene data collected by the received collection device.
[0090] In an embodiment of the present disclosure, after the server has modified its own working parameters through the business thread, it can use the modified working parameters and real-time scene data (e.g., scene images) received from the acquisition device (e.g., a camera) to obtain the real-time status of the scene.
[0091] In some embodiments of the present disclosure, when the scene state is the game state of a game table, the acquisition device may be a camera on the game table, and the real-time scene data may be an image of the game table that is acquired. The game state may be any state of the game on the game table, for example, it may be the game mode of each player during the game (for example, the player's operation mode for each link of the game, the player's game area, and the player's operation sequence for each link of the game, etc.), or it may be the operation of a game prop operator, etc., which is not limited in the embodiments of the present disclosure.
[0092] S2. Compare the real-time state with the preset state to obtain a comparison result, and record the comparison result in real time.
[0093] S3. When the comparison result indicates that the real-time status is abnormal, a prompt message is issued.
[0094] In an embodiment of the present disclosure, when the server determines the real-time status of the scene, it can compare it with the preset status to determine whether the real-time status of the determined scene is abnormal, thereby obtaining a comparison result characterizing whether the real-time status of the determined scene is abnormal, and recording the comparison result for convenience in subsequent data analysis; and, when the comparison result characterizes that the real-time status is abnormal, the server can also send a prompt message to related equipment so that related maintenance personnel can intervene in time on equipment related to the scene status, such as acquisition equipment, so that these devices can operate normally.
[0095] In the embodiments of the present disclosure, the preset state represents the correct state. For example, when the scene state is the game state on the game table, the preset state can be the correct game method for each player in the game (for example, the correct operation method for each link of the game, the correct game area and the correct operation sequence for each link of the game, etc.), or it can be the standard operation of the game prop operator, etc., and the embodiments of the present disclosure are not limited to this.
[0096] Continuing with the example of the scene state being the game state on the game table, when the determined real-time state of the scene is the game area of each player, the server can compare the determined game areas of each player with the correct game areas of each player, and then determine whether the game area of each player is correct, and finally obtain a comparison result of which player's game area is wrong; and when it is determined that a certain player's game area is wrong, a prompt message is sent to the relevant display device to provide information prompts to the relevant maintenance personnel operating the display device.
[0097] In the embodiments of the present disclosure, Figure 3 is an optional flow chart of the log recording method provided by the embodiment of the present disclosure; Figure 3 As shown, in Figure 2 After S102, S201 may be performed, which will be described below in conjunction with the steps shown in 3.
[0098] S201 : Filter the log data in the log storage queue based on a preset first filtering parameter, and store the filtered log data in batches to a database.
[0099] In an embodiment of the present disclosure, the server can use a preset first filtering parameter to filter the log data stored in the log storage queue, thereby filtering out log data that does not need to be stored, and storing the filtered log data that needs to be stored in the database, thereby realizing the recording of the log data.
[0100] In some embodiments of the present disclosure, the server can filter the log data in the log storage queue based on a preset first filter parameter through a first asynchronous thread, and store the filtered log data in batches to a database. In other embodiments of the present disclosure, the server can also use a thread different from the first asynchronous thread, for example, a batch processing thread, to filter the log data in the log storage queue based on a preset first filter parameter, and store the filtered log data in batches to a database. Here, using two different threads to generate log data and filter and store the generated log data respectively can improve the efficiency of log data recording.
[0101] In some embodiments of the present disclosure, the first filtering parameter may include at least one of the following: a method parameter, a resource path parameter, a resource path prefix parameter, a parameter blacklist, and a parameter whitelist.
[0102] It should be noted that the parameter whitelist may be composed of multiple target parameters, and the parameter blacklist may be composed of multiple non-target parameters. In the embodiments of the present disclosure, the target parameter or non-target parameter may be an access time period, an IP address of a client, etc., which is not limited in the embodiments of the present disclosure. For example, when the parameter blacklist is composed of multiple different access time periods, it indicates that the log data corresponding to these multiple different access time periods do not need to be recorded in the database and need to be filtered out; when the parameter whitelist is composed of multiple client IP addresses, it indicates that the log data corresponding to these multiple client IP addresses need to be recorded in the database and do not need to be filtered out.
[0103] Exemplarily, when the first filtering parameter is a method parameter, through the method parameter, the log data stored in the log queue that meets the method parameter can be used as filtered log data and stored in the database; for another example, when the first filtering parameter is at least one target resource path parameter in the parameter whitelist, the log data stored in the log queue that meets the at least one target resource path parameter can be used as filtered log data and stored in the database; in this way, through the first filtering parameter, the redundancy of log data in the database can be effectively reduced, which can not only improve the query efficiency of log data when the user queries the log data in the database, but also reduce disk occupancy.
[0104] Here, batch processing is used to store the filtered log data in the database, which can reduce the I / O operations on the database and improve the log storage efficiency.
[0105] It should be noted that if Figure 3 As shown, S201 can be executed together with S103; in other embodiments, S201 can also be executed after S103, which is not limited in the embodiment of the present disclosure.
[0106] In some embodiments of the present disclosure, Figure 4 is an optional flow chart of the log recording method provided by the embodiment of the present disclosure; Figure 4 As shown, after S101 and before S102, S301 may be further executed, and S102 may also be implemented through S1021, which will be described below in conjunction with the steps shown in FIG. 4 .
[0107] S301. Using a first asynchronous thread, parse a request header from an application program interface call request to obtain user authority information, authenticate the user authority information, and obtain an authentication result.
[0108] In the embodiments of the present disclosure, the request header of the API call request generally includes several attributes, such as the type of browser that generates the request, the host address, the accepted encoding method and compression method, etc. For each received API call request, the server can parse the API call request, and obtain the user authority information of the client according to several attributes contained in the HTTP Header parsed from the API call request, such as at least one of the type of browser that generates the request and the host address, and determine whether the obtained user authority information is legal according to the preset user authority information, thereby realizing the authentication of the user authority information.
[0109] In the embodiments of the present disclosure, the preset user authority information may be set according to actual needs, and the embodiments of the present disclosure are not limited to this.
[0110] S1021. Using the first asynchronous thread, when the authentication result is characterized as passed, based on the application program interface call request, log data is generated and stored in a log storage queue; the log storage queue is used to store the log data stored in the database after filtering.
[0111] In an embodiment of the present disclosure, for each API call request, when the server authenticates the user authority information through the first asynchronous thread, the first asynchronous thread can continue to generate corresponding log data according to the API call request.
[0112] Here, the user permission information parsed from each API call request is authenticated, and when the authentication result indicates a pass, corresponding log data is generated according to each API call request for subsequent filtering and storage. This can timely detect situations where the client requests forge operation user or user behavior data, thereby making the generated log data more authentic and effective.
[0113] In some embodiments of the present disclosure, after S101 and before S102, when S301 is also included, Figure 2 S103 in can also be realized through S1033:
[0114] S1033. When the authentication result indicates that the authentication result is passed, a business thread is used to respond to a modification request in the application program interface call request to achieve real-time recording of the scene status.
[0115] In an embodiment of the present disclosure, for each API call request, the server can use a business thread to respond to the modification request in the API call request if the user authority information in the API call request is authenticated and the API call request contains a modification request, thereby realizing real-time recording of the scene status.
[0116] In some embodiments of the present disclosure, for each API call request that does not include a modification request, the server may directly respond to the API call request using a business thread if the user authority information in the API call request is authenticated. Exemplarily, if the API call request that does not include a modification request is a request to log in to the operation and maintenance management system, the server uses a business thread to directly perform the corresponding login operation.
[0117] In some embodiments of the present disclosure, for each intercepted API call request, if the first asynchronous thread authenticates the API call request, the API call request can be stored in another queue that is different from the log storage queue, and the business thread can periodically obtain the authenticated API call requests from the other queue to respond to the authenticated API call requests.
[0118] In other embodiments of the present disclosure, for each intercepted API call request, if the first asynchronous thread authenticates the API call request, the API call request can be sent directly to the business thread, so that the business thread can respond to the received authenticated API call request.
[0119] It can be understood that for API call requests that include modification requests, if authentication is passed, it will respond to the modification request and modify its own working parameters. It can promptly discover situations where the client requests forge operations on users or user behavior data, thereby improving data security.
[0120] In some embodiments of the present disclosure, Figure 3 Before S201 in the program, you can also execute S11-S12:
[0121] S11. Receive a filtering parameter setting instruction carrying a preset first filtering parameter.
[0122] S12. Based on the filtering parameter setting instruction, change the preset first initial filtering parameter to the preset first filtering parameter.
[0123] In an embodiment of the present disclosure, before filtering the log data stored in the log storage queue, the server can receive a filter parameter setting instruction sent by the user that carries a preset first filter parameter, and according to the filter parameter setting instruction, change its own preset first initial filter parameter to the preset first filter parameter, so as to subsequently filter the log data stored in the log storage queue based on the preset first filter parameter.
[0124] Here, by dynamically modifying the filtering parameters to control the filtering logic of the log data, the diversity of the filtering logic can be increased, thereby increasing the diversity of the recorded log data and improving the flexibility of data recording.
[0125] In some embodiments of the present disclosure, Figure 2 In S102, based on the application program interface call request, log data is generated, which can be implemented through S21-S23:
[0126] S21. Extract first data from a request header parsed from each call request in the application program interface call request; the first data includes at least: user identity data and resource path data.
[0127] S22. Extract second data from the request body and request line parsed from each call request; the second data at least includes: request method data and request content data.
[0128] S23: Combine the first data and the second data to obtain a piece of log data corresponding to each call request.
[0129] Here, the API call request disclosed in the present invention is an HTTP request, which generally includes: a request header (HTTPHeader), a request line and a request body (HTTP Body), wherein the request line generally includes: a request method field, a URI field and an HTTP protocol version; the request methods generally include: GET, POST, HEAD, PUT, DELETE, OPTIONS, TRACE, CONNECT, etc.; the HTTP Header generally includes the type of browser that generates the request, the host address, the accepted encoding method and compression method, etc.; the HTTP Body generally includes the request content data, etc. In an embodiment of the present disclosure, the server can intercept at least one API call request each time, and when intercepting the at least one API call request, for each of the at least one API call request, user permission information can be extracted from the HTTP Header, such as the type of browser that generates the request, the host address, and the resource path (path, also known as URI), etc., thereby obtaining first data; and the request method (method) and request content data can be extracted from the HTTP Body and the request line, respectively, thereby obtaining second data; and after obtaining the first data and the second data, the first data and the second data can be combined according to a preset data format, thereby obtaining a structured log data corresponding to the API call request.
[0130] Here, the preset data format can be set according to actual needs, and the embodiments of the present disclosure do not limit this.
[0131] For the above steps, the following Figure 5 An exemplary description is given. Figure 5 As shown, interceptors are set on all APIs of the server. When the client sends an HTTP request to the API interface of the server, all HTTP requests will pass through the interceptor, so that the interceptor can obtain all HTTP requests sent by the client. When the HTTP request is intercepted and obtained, the server obtains the user's permission token (token) from the HTTP Header of each HTTP request through the interceptor, authenticates the user according to the user's permission token to determine whether the user is a legitimate user, and obtains the resource path (path) from the HTTP Header when it is determined that the user is a legitimate user, and reads the HTTP Body and request line of the HTTP request, and obtains the resource path (path) from the HTTP Header of the HTTP request. The request method and request content data are read from the Body and request lines respectively, and then the user's permission token, path, method and request content data are combined into a structured log data for the HTTP request using a preset format, and the structured log data is stored in the log storage queue; at the same time, the server also uses a business thread to perform corresponding processing according to the HTTP request that has been authenticated in the HTTP request obtained by the interceptor, so as to respond to the HTTP request that has been authenticated and implement the business logic; in this way, the server can realize the asynchronous generation of structured log data corresponding to the HTTP request, and the response to the HTTP request.
[0132] In some embodiments of the present disclosure, Figure 6 is an optional flow chart of the log recording method provided by the embodiment of the present disclosure; Figure 6 As shown, Figure 3 S201 in the embodiment can also be implemented through S401-S404, which will be described below in conjunction with the steps shown in FIG. 6.
[0133] S401, obtaining at least one piece of log data from a log storage queue; the log storage queue of the server stores at least one piece of log data, wherein each piece of log data includes: log parameters.
[0134] S402: Match a log parameter of each log data in at least one log data with a first filtering parameter to obtain a matching matching parameter.
[0135] In an embodiment of the present disclosure, the server can adopt the above-mentioned batch processing thread to obtain at least one log data stored in the log storage queue, and compare the log parameters of each log data in the at least one log data obtained with the first filtering parameter, so as to determine the matching parameters in the log parameters of the log data that correspond to the same as the first filtering parameter.
[0136] Exemplarily, when the first filter parameter is at least one of a method parameter, a resource path parameter, and a resource path prefix parameter, and the first filter parameter includes N sub-filter parameters, and the log parameters of each log data include M sub-parameters, when there are N sub-parameters that are identical to the N sub-filter parameters among the M sub-parameters, the N sub-parameters can be determined as the matching parameters of the log data; and when there are no N sub-parameters that are identical to the N sub-filter parameters among the M sub-parameters (for example, there are only N-1 sub-parameters that are identical to N-1 sub-filter parameters among the M sub-parameters, or there is no sub-parameter among the M sub-parameters that is identical to any sub-filter parameter among the N sub-filter parameters, etc.), the matching parameters of the log data are empty.
[0137] Exemplarily, when the first filter parameter is a parameter whitelist and the first filter parameter includes N sub-filter parameters (that is, the parameter whitelist consists of N target parameters), and the log parameters of each log data include M sub-parameters, when there is at least one sub-parameter among the M sub-parameters that is identical to a corresponding sub-filter parameter among the N sub-filter parameters, the at least one sub-parameter can be determined as a matching parameter for the log data; and when there are no N sub-parameters among the M sub-parameters that are identical to the corresponding N sub-filter parameters, the matching parameter for the log data is empty.
[0138] Exemplarily, when the first filtering parameter is a parameter blacklist and the first filtering parameter includes N sub-filtering parameters (i.e., the parameter blacklist consists of N non-target parameters), and the log parameters of each log data include M sub-parameters, when there is at least one sub-parameter among the M sub-parameters that is identical to a corresponding sub-filtering parameter among the N sub-filtering parameters, the M sub-parameters can be determined as matching parameters for the log data; and when there are no N sub-parameters among the M sub-parameters that are identical to the corresponding N sub-filtering parameters, the matching parameters for the log data are empty.
[0139] Here, N and M are both integers greater than or equal to 1. It should be noted that the matching parameter of each log data may be referred to as a set of matching parameters; wherein a set of matching parameters includes at least one matching parameter.
[0140] In an embodiment of the present disclosure, the log parameters of each log data may include at least one of the following: method parameter (method(array)), resource path parameter (path(array)), resource path prefix parameter (prefix(array)), access time period and client IP address, etc.
[0141] S403: Determine filtered log data according to at least one target log data corresponding to the matching parameter.
[0142] In the embodiment of the present disclosure, for each log data, when the matching parameter is empty, the matching parameter does not correspond to the log data, that is, the matching parameter does not correspond to any target log data; when the matching parameter is not empty, the matching parameter corresponds to the log data, and the log data is a target log data; for example, for a log data A, when the matching parameter matching the first filter parameter in the log parameter of the log data A is empty, the log data A is not a target log data, and when the matching parameter matching the first filter parameter in the log parameter of the log data A is not empty, the log data A is a target log data. It should be noted that, since each log data corresponds to a set of matching parameters, and there is currently at least one log data, multiple sets of matching parameters can be obtained for at least one log data, so that at least one target log data can be obtained according to the multiple sets of matching parameters, so that the filtered log data can be determined according to the obtained at least one target log data.
[0143] S404: When the amount of the filtered log data reaches a preset amount, the filtered log data is stored in a database.
[0144] In an embodiment of the present disclosure, after the server determines all the filtered log data through a batch processing thread, and the amount of the filtered log data reaches a preset amount, all the filtered log data are stored in a database.
[0145] In some embodiments of the present disclosure, Figure 6 S401 can be realized through S4011-S4012:
[0146] S4011. Read log data from the log storage queue at a preset frequency.
[0147] S4012: When the current log data is read, continue to read the next log data from the log storage queue until the last log data stored in the log storage queue is read, thereby obtaining the at least one log data.
[0148] In an embodiment of the present disclosure, the server uses a batch processing thread to read log data from a log storage queue at a preset frequency, and when a log data is read at a certain time, the log data is continuously read from the log storage queue until all the log data stored in the log storage queue are read, thereby obtaining at least one log data. For example, the server uses a processing thread to read log data from the log storage queue every 10ms, and when no log data is read for the first time, that is, when the read data is empty, after 10ms, the log data is read from the log storage queue for the second time, and when a log data is read from the log storage queue for the second time, the log data is continuously read from the log storage queue until all 10 log data stored in the log storage queue are read, thereby obtaining 10 log data.
[0149] It should be noted that after all 10 log data stored in the log storage queue are read, the server will continue to read log data from the log storage queue through the batch processing thread after 10ms, and determine whether the data is read; if the log data is not read, it will wait for 10ms and continue to read from the log storage queue; if the log data is read, it will continue to read log data from the log storage queue until all the log data stored in the log storage queue are read. This method is repeated until the reading is stopped when an instruction to stop reading is received.
[0150] In the embodiment of the present disclosure, the preset frequency can be set according to actual needs, for example, it can be 1s, or it can be 10ms or 30ms, etc., and the embodiment of the present disclosure is not limited to this.
[0151] In some embodiments of the present disclosure, matching parameters include: method parameters, resource path parameters, resource path prefix parameters, non-target parameters in a parameter blacklist, and target parameters in a parameter whitelist.
[0152] In some embodiments of the present disclosure, the above S403 may be implemented through S4031-S4032:
[0153] S4031. Determine candidate log data according to at least one target log data corresponding to a matching parameter.
[0154] S4032: Determine filtered log data based on the candidate log data.
[0155] In some embodiments of the present disclosure, the server may first determine candidate log data based on at least one target log data corresponding to a matching parameter, and after obtaining matching parameters of all log data, determine filtered log data based on the candidate log data.
[0156] In some embodiments of the present disclosure, determining candidate log data based on at least one target log data corresponding to a matching parameter may be achieved by directly determining at least one target log data corresponding to the matching parameter as the candidate log data; in other embodiments of the present disclosure, determining candidate log data based on at least one obtained target log data may be achieved by determining other log data other than the at least one target log data corresponding to the matching parameter as the candidate log data.
[0157] In some embodiments of the present disclosure, the above S4031 may also be implemented by at least one of steps S501-S505:
[0158] S501: When the matching parameter is a method parameter, determine at least one target log data corresponding to the method parameter in at least one log data as candidate log data.
[0159] In some embodiments of the present disclosure, for each piece of at least one piece of log data obtained, when the matching parameter of the log data is not empty and is a method parameter, the log data is used as a target log data; thus, for the at least one piece of log data obtained, there may be at least one target log data, and the server can use the at least one target log data determined from the at least one piece of log data obtained as candidate log data.
[0160] S502: When the matching parameter is a resource path parameter, at least one target log data corresponding to the resource path parameter is determined as candidate log data.
[0161] In some embodiments of the present disclosure, for each piece of at least one piece of log data obtained, when the matching parameter of the log data is not empty and is a resource path parameter, the log data is used as a target log data; thus, for the at least one piece of log data obtained, there may be at least one target log data, and the server can use the at least one target log data determined from the at least one piece of log data obtained as candidate log data.
[0162] S503: When the matching parameter is a resource path prefix parameter, determine at least one target log data corresponding to the resource path prefix parameter in at least one log data as candidate log data.
[0163] In some embodiments of the present disclosure, for each piece of at least one piece of log data obtained, when the matching parameter of the log data is not empty and is a resource path prefix parameter, the log data is used as a target log data; thus, for the at least one piece of log data obtained, there may be at least one target log data, and the server can use the at least one target log data determined from the at least one piece of log data obtained as candidate log data.
[0164] From the above, it can be seen that when the matching parameters are method parameters, resource path parameters and resource path prefix parameters, the above S4031 determines the candidate log data based on at least one target log data corresponding to the matching parameters, which is achieved by directly determining at least one target log data corresponding to the matching parameters as candidate log data.
[0165] S504: When the matching parameter is at least one non-target parameter in the parameter blacklist, determine the log data in the at least one log data except the at least one target log data corresponding to the at least one non-target parameter as candidate log data.
[0166] In other embodiments of the present disclosure, for each of the at least one log data obtained, if the matching parameter of the log data is not empty and is at least one non-target parameter in the parameter blacklist, the log data can be used as a target log data; thus, for the at least one log data obtained, there may be at least one target log data, and the server can use the log data other than the at least one target log data in the at least one log data obtained as candidate log data. Exemplarily, when the at least one log data obtained is 5 and 3 target log data are determined from the 5 log data, the other two log data in the 5 log data are used as candidate log data. That is, when the matching parameter is at least one non-target parameter in the parameter blacklist, the candidate log data is determined according to the at least one target log data corresponding to the matching parameter in S4031, which is achieved by determining the other log data other than the at least one target log data corresponding to the matching parameter as candidate log data.
[0167] S505: When the matching parameter is at least one target parameter in the parameter whitelist, determine at least one target log data corresponding to at least one target parameter in at least one log data as candidate log data.
[0168] In some embodiments of the present disclosure, for each piece of at least one piece of log data obtained, if the matching parameter of the log data is not empty and is at least one target parameter in the parameter whitelist, the log data can be used as a target log data; thus, for the at least one piece of log data obtained, there may be at least one target log data, and the server can use the at least one target log data determined from the at least one piece of log data obtained as candidate log data.
[0169] In some embodiments of the present disclosure, when the above S4031 is implemented through S501-S505, the above S4032 can be implemented in the following manner: the server can determine all log data corresponding to the method parameter, resource path parameter and at least one target parameter, and not corresponding to at least one non-target parameter, from all candidate log data consisting of at least one target log data corresponding to the method parameter, at least one target log data corresponding to the resource path parameter, log data other than at least one target log data corresponding to at least one non-target parameter, and at least one target log data corresponding to at least one target parameter, and use the determined log data as the filtered log data. That is, when the above S4031 is implemented through S501-S505, the filtered log data finally determined by the above S4032 must correspond to the method parameter, resource path parameter, and at least one target parameter in the parameter whitelist, and must not correspond to at least one non-target parameter in the parameter blacklist.
[0170] In some embodiments of the present disclosure, when the above S4031 is implemented through S501, S502, S503, or S505, the above S4032 can be implemented in the following manner: the server can directly use the determined candidate log data as the filtered log data through batch processing threads. For example, when S4031 is implemented through S501, the server can directly use at least one target log data corresponding to the method parameter as the filtered log data through batch processing threads.
[0171] Exemplarily, when the matching parameter is the path value of the login API, the server may store the login log data as filtered log data in a database for recording.
[0172] Exemplarily, when the matching parameters are "post, put, delete", the server may store all modification scenario log data corresponding to the modification request for modifying its own working parameters as filtered log data in the database for recording.
[0173] In other embodiments of the present disclosure, when the above-mentioned S4031 is implemented through S501-S502, implemented through S501-S503, implemented through S501-S504, implemented through S502-S503, implemented through S502-S504, implemented through S503-S504, or implemented through S504-S505, etc., the above-mentioned S4032 can be implemented in the following manner: the server can use the batch processing thread to process the log data that satisfies all corresponding filter parameters among all the determined candidate log data as the filtered log data. For example, when S4031 is implemented through S501-S502, the above-mentioned S4032 can be implemented in the following manner: the server can use the batch processing thread to process the log data that corresponds to both the method parameter and the resource path parameter among at least one target log data corresponding to the method parameter and at least one target log data corresponding to the resource path parameter, as the filtered log data. For another example, when S4031 is implemented through S501-S503, the above S4032 can be implemented in the following manner: the server can use a batch processing thread to process all candidate log data consisting of at least one target log data corresponding to a method parameter, at least one target log data corresponding to a resource path parameter, and at least one target log data corresponding to a resource path prefix parameter, including the log data that corresponds to both the method parameter and the resource path parameter and the resource path prefix parameter, as filtered log data.
[0174] In some embodiments of the present disclosure, Figure 7 As shown, in Figure 3 After S201 in step 7, S601 may be further executed, which will be described below in conjunction with the steps shown in step 7.
[0175] S601. Use a second asynchronous thread to delete log data in the database whose time parameter does not satisfy a second filter parameter; the second filter parameter represents a preset storage duration of each log data in the database; each log data stored in the database includes: a time parameter; the time parameter represents the storage duration of each log data in the database.
[0176] In an embodiment of the present disclosure, each log data stored in the database corresponds to a time parameter. The server can use a second asynchronous thread different from the first asynchronous thread to retrieve multiple log data from the database, and use the time parameter of each log data to compare with the second filter parameter that represents the preset storage time of each log data in the database, and delete the log data from the database if the time parameter of a log data is greater than the second filter parameter.
[0177] In some embodiments of the present disclosure, after storing each log data in the database through the first asynchronous thread, the server can set a timer for the log data to count the storage time of the log data in the database, and the value of the timer is the time parameter of the log data. In some embodiments of the present disclosure, when the server uses the second asynchronous thread to compare the time parameter of each log data with the second filter parameter, it can retrieve multiple log data from the database at one time and compare them one by one, or read one log data from the database at a time and then compare them, which is not limited in the embodiments of the present disclosure.
[0178] Exemplarily, when the second filtering parameter is "history-remain(365d)", the server may clean up historical log data stored in the database for more than one year.
[0179] In view of the above content, the following Figure 8 An exemplary description is given. Figure 8 As shown, the first asynchronous processing thread may include a batch processing thread, the second asynchronous processing thread may be a cleaning thread, the batch processing thread may read multiple structured log data from the log storage queue at a preset frequency, for each structured log data read, the batch processing thread may match each parameter in the log parameter of the structured log data with the first filtering parameter, the first filtering parameter is composed of two sub-filtering parameters, method and path, and in the case where there are two sub-parameters in the log parameter of the log data that are the same as the two sub-filtering parameters of method and path, the structured log data is stored in the database, and in the case where there are no two sub-parameters in the log parameter that are the same as the two sub-filtering parameters of method and path, the structured log data is discarded. At the same time, the cleaning thread may periodically take out each structured log data from the database, and compare the time parameter of each structured log data with the second filtering parameter, determine whether the structured log data is expired according to the comparison result, and in the case where it is determined that the structured log data is expired, discard the structured data, and in the case where it is determined that the structured log data is not expired, put the structured data back into the database for continued storage.
[0180] Fig. 9 Schematic diagram of the structure of the log recording device according to the embodiment of the present disclosure. Fig. 9As shown, the log recording device 20 includes: an interceptor 2001, which is used to intercept the application interface call request sent by the client; and based on the application interface call request, generates log data, and stores the log data in a log storage queue; the log storage queue is used to store the log data stored in the database after filtering; a business thread 2002, which is used to respond to the modification request in the application interface call request to realize real-time recording of the scene status.
[0181] In some embodiments, the interceptor 2001 is further used to filter the log data in the log storage queue based on a preset first filtering parameter, and store the filtered log data in batches to the database.
[0182] In some embodiments, the interceptor 2001 is also used to use the first asynchronous thread to obtain user authority information according to the request header parsed from the application interface call request, and authenticate the user authority information to obtain an authentication result; and use the first asynchronous thread to generate the log data based on the application interface call request when the authentication result indicates that it has passed.
[0183] In some embodiments, the interceptor 2001 is also used to extract first data from the request header parsed from each call request in the application interface call request; the first data includes at least: user identity data and resource path data; extract second data from the request body and request line parsed from each call request; the second data includes at least: request method data and request content data; combine the first data and the second data to obtain a log data corresponding to each call request.
[0184] In some embodiments, at least one log data is stored in the log storage queue, and each log data includes: log parameters; the interceptor 2001 is also used to obtain the at least one log data from the log storage queue; match the log parameters of each log data in the at least one log data with the first filtering parameter to obtain matching matching parameters; determine the filtered log data based on at least one target log data corresponding to the matching parameter; when the number of the filtered log data reaches a preset number, store the filtered log data in the database.
[0185] In some embodiments, the interceptor 2001 is also used to read log data from the log storage queue at a preset frequency; when the current log data is read, the next log data continues to be read from the log storage queue until the last log data stored in the log storage queue is read, thereby obtaining the at least one log data.
[0186] In some embodiments, the matching parameter includes at least one of the following: a method parameter, a resource path parameter, a resource path prefix parameter, a non-target parameter in a parameter blacklist, and a target parameter in a parameter whitelist.
[0187] In some embodiments, the interceptor 2001 is further used to determine candidate log data according to at least one target log data corresponding to the matching parameter; and determine the filtered log data based on the candidate log data.
[0188] In some embodiments, the interceptor 2001 is further used to implement at least one of the following:
[0189] In the case where the matching parameter is a method parameter, at least one target log data corresponding to the method parameter in the at least one log data is determined as the candidate log data; in the case where the matching parameter is a resource path parameter, at least one target log data corresponding to the resource path parameter in the at least one log data is determined as the candidate log data; in the case where the matching parameter is a resource path prefix parameter, at least one target log data corresponding to the resource path prefix parameter in the at least one log data is determined as the candidate log data; in the case where the matching parameter is at least one non-target parameter in a parameter blacklist, log data other than the at least one target log data corresponding to the at least one non-target parameter in the at least one log data is determined as the candidate log data; in the case where the matching parameter is at least one target parameter in a parameter whitelist, at least one target log data corresponding to the at least one target parameter in the at least one log data is determined as the candidate log data.
[0190] In some embodiments, the device further includes a modification module for receiving a filtering parameter setting instruction carrying the preset first filtering parameter; and in response to the filtering parameter setting instruction, changing the preset first initial filtering parameter to the preset first filtering parameter.
[0191] In some embodiments, the business thread 2002 is also used to adopt the business thread to respond to the modification request in the application interface call request, modify its own working parameters, and obtain modified working parameters; determine the real-time state of the scene based on the modified working parameters and the real-time scene data collected by the received acquisition device; compare the real-time state with the preset state to obtain a comparison result, and record the comparison result in real time.
[0192] In some embodiments, the business thread 2002 is further used to issue a prompt message when the comparison result indicates that the real-time status is abnormal.
[0193] In some embodiments, each log data stored in the database includes: a time parameter; the time parameter represents the length of time that each log data has been stored in the database; the device also includes a second asynchronous thread, which is used to use the second asynchronous thread to delete the log data in the database whose time parameter does not meet the second filter parameter; the second filter parameter represents the preset storage length of each log data in the database.
[0194] It should be noted that the “module” described in the embodiments of the present disclosure refers to a software module, or a module including part of software and part of hardware, etc.
[0195] Fig.10 FIG. 1 is a schematic diagram of the structure of an electronic device according to an embodiment of the present disclosure. Fig.10 As shown, the electronic device 30 includes a memory 3001, a processor 3002, and a computer program stored in the memory 3001 and executable on the processor 3002; wherein the processor 3002 is used to execute the logging method in the aforementioned embodiment when running the computer program.
[0196] It is understood that the electronic device 30 also includes a communication bus 3003; the various devices in the electronic device 30 are coupled together through the communication bus 3003. It is understood that the communication bus 3003 is used to realize the connection and communication between these devices. In addition to the data bus, the communication bus 3003 also includes a power bus, a control bus and a status signal bus.
[0197] The memory 3001 is configured to store computer programs and applications used by the processor 3002, and can also cache data to be processed or processed by the processor 3002 and various modules in the electronic device (for example, image data, audio data, voice communication data, and video communication data), which can be implemented through flash memory (FLASH) or random access memory (Random Access Memory, RAM).
[0198] When the processor 3002 executes the program, the steps of the above-mentioned logging method are implemented. The processor 3002 generally controls the overall operation of the electronic device 30.
[0199] The processor may be at least one of an Application Specific Integrated Circuit (ASIC), a Digital Signal Processor (DSP), a Digital Signal Processing Device (DSPD), a Programmable Logic Device (PLD), a Field Programmable Gate Array (FPGA), a Central Processing Unit (CPU), a controller, a microcontroller, and a microprocessor. It is understandable that the electronic device that implements the functions of the processor may also be other, which is not limited by the embodiments of the present disclosure.
[0200] The above-mentioned computer-readable storage medium / memory can be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), a magnetic random access memory (FRAM), a flash memory (Flash Memory), a magnetic surface memory, an optical disk, or a compact disc read-only memory (CD-ROM) and the like; it can also be various terminals including one or any combination of the above-mentioned memories, such as mobile phones, computers, tablet devices, personal digital assistants, etc.
[0201] The embodiment of the present disclosure provides a computer program product or a computer program, which includes a computer instruction, and the computer instruction is stored in a computer-readable storage medium. The processor of the computer device reads the computer instruction from the computer-readable storage medium, and the processor executes the computer instruction, so that the computer device executes the above-mentioned log recording method of the embodiment of the present disclosure.
[0202] In some embodiments, executable instructions may be in the form of a program, software, software module, script or code, written in any form of programming language (including compiled or interpreted languages, or declarative or procedural languages), and may be deployed in any form, including as a stand-alone program or as a module, component, subroutine or other unit suitable for use in a computing environment.
[0203] As an example, executable instructions may, but need not, correspond to a file in a file system, may be stored as part of a file that stores other programs or data, such as in one or more scripts in a HyperText Markup Language (HTML) document, in a single file dedicated to the program in question, or in multiple coordinated files (e.g., files storing one or more modules, subroutines, or code portions).
[0204] By way of example, executable instructions may be deployed to be executed on one computing device, or on multiple computing devices located at one site, or on multiple computing devices distributed across multiple sites and interconnected by a communication network.
[0205] It should be noted that the description of the above storage medium and device embodiments is similar to the description of the above method embodiments, and has similar beneficial effects as the method embodiments. For technical details not disclosed in the storage medium and device embodiments of the present disclosure, please refer to the description of the method embodiments of the present disclosure for understanding.
[0206] The above description is only an embodiment of the present disclosure and is not intended to limit the protection scope of the present disclosure. Any modification, equivalent replacement and improvement made within the spirit and scope of the present disclosure are included in the protection scope of the present disclosure.
Claims
1. A log recording method, characterized in that: include: Using a first asynchronous thread to intercept an application program interface call request sent by a client; Based on the application program interface call request, log data is generated, and the log data is stored in a log storage queue; the log storage queue is used to store the log data stored in the database after filtering; Receiving a filtering parameter setting instruction sent by a user and carrying a preset first filtering parameter; In response to the filtering parameter setting instruction, changing the preset first initial filtering parameter to the preset first filtering parameter; Based on the preset first filtering parameter, a batch processing thread different from the first asynchronous thread is used to filter each log data in the log storage queue, and the filtered log data is stored in batches in the database; A business thread is used to respond to the modification request in the application program interface call request to achieve real-time recording of the scene state; the scene state is the game state of the game table.
2. The log recording method according to claim 1, characterized in that: The method further comprises: Using the first asynchronous thread, obtaining user authority information according to the request header parsed from the application program interface call request, and authenticating the user authority information to obtain an authentication result; The generating log data based on the application program interface call request includes: The first asynchronous thread is used to generate the log data based on the application program interface call request when the authentication result indicates that the authentication result is passed.
3. The log recording method according to claim 1 or 2, characterized in that: The generating log data based on the application program interface call request includes: Extracting first data from the request header parsed from each call request in the application program interface call request; the first data at least includes: user identity data and resource path data; Extracting second data from the request body and request line parsed from each call request; the second data at least includes: request method data and request content data; The first data and the second data are combined to obtain a piece of log data corresponding to each calling request.
4. The log recording method according to claim 1, characterized in that: The log storage queue stores at least one log data, each log data including: log parameters; The filtering of the log data in the log storage queue based on the preset first filtering parameter and storing the filtered log data in batches to the database includes: Acquire the at least one piece of log data from the log storage queue; Matching the log parameter of each log data in the at least one log data with the first filtering parameter to obtain a matching matching parameter; Determining the filtered log data according to at least one target log data corresponding to the matching parameter; When the amount of the filtered log data reaches a preset amount, the filtered log data is stored in the database.
5. The log recording method according to claim 4, characterized in that: The obtaining the at least one piece of log data from the log storage queue includes: Reading log data from the log storage queue at a preset frequency; When the current log data is read, the next log data is read from the log storage queue until the last log data stored in the log storage queue is read, thereby obtaining the at least one log data.
6. The log recording method according to claim 4, characterized in that: The matching parameters include at least one of the following: Method parameters, resource path parameters, resource path prefix parameters, non-target parameters in the parameter blacklist, and target parameters in the parameter whitelist.
7. The log recording method according to claim 4, characterized in that: The step of determining the filtered log data according to at least one target log data corresponding to the matching parameter includes: Determining candidate log data according to at least one target log data corresponding to the matching parameter; Based on the candidate log data, the filtered log data is determined.
8. The log recording method according to claim 7, characterized in that: The determining of candidate log data according to at least one target log data corresponding to the matching parameter includes at least one of the following: In the case where the matching parameter is a method parameter, determining at least one target log data corresponding to the method parameter in the at least one log data as the candidate log data; In the case where the matching parameter is a resource path parameter, determining at least one target log data corresponding to the resource path parameter in the at least one log data as the candidate log data; In a case where the matching parameter is a resource path prefix parameter, determining at least one target log data corresponding to the resource path prefix parameter in the at least one log data as the candidate log data; In a case where the matching parameter is at least one non-target parameter in the parameter blacklist, determining the log data in the at least one log data except the at least one target log data corresponding to the at least one non-target parameter as the candidate log data; In a case where the matching parameter is at least one target parameter in the parameter whitelist, at least one target log data corresponding to the at least one target parameter in the at least one log data is determined as the candidate log data.
9. The log recording method according to any one of claims 1-2, 4-8, characterized in that: The adopting of the business thread to respond to the modification request in the application program interface call request to achieve real-time recording of the scene state includes: Using the service thread, responding to the modification request in the application program interface call request, modifying the working parameters of the service thread to obtain the modified working parameters; Determine the real-time state of the scene based on the modified working parameters and the received real-time scene data collected by the collection device; The real-time state is compared with the preset state to obtain a comparison result, and the comparison result is recorded in real time.
10. The log recording method according to claim 9, characterized in that: The method further comprises: When the comparison result indicates that the real-time status is abnormal, a prompt message is issued.
11. An electronic device, characterized in that: include: a memory for storing executable computer programs; A processor, configured to execute the executable computer program stored in the memory to implement the following operations: Using a first asynchronous thread to intercept an application program interface call request sent by a client; Based on the application program interface call request, log data is generated, and the log data is stored in a log storage queue; the log storage queue is used to store the log data stored in the database after filtering; Receiving a filtering parameter setting instruction sent by a user and carrying a preset first filtering parameter; In response to the filtering parameter setting instruction, changing the preset first initial filtering parameter to the preset first filtering parameter; Based on the preset first filtering parameter, a batch processing thread different from the first asynchronous thread is used to filter each log data in the log storage queue, and the filtered log data is stored in batches in the database; A business thread is used to respond to the modification request in the application program interface call request to achieve real-time recording of the scene state; the scene state is the game state of the game table.
12. The electronic device according to claim 11, characterized in that: The processor is also configured to implement the following operations: Using the first asynchronous thread, obtaining user authority information according to the request header parsed from the application program interface call request, and authenticating the user authority information to obtain an authentication result; The generating log data based on the application program interface call request includes: The first asynchronous thread is used to generate the log data based on the application program interface call request when the authentication result indicates that the authentication result is passed.
13. The electronic device according to claim 11 or 12, characterized in that: The operation of generating log data based on the application program interface call request includes: Extracting first data from the request header parsed from each call request in the application program interface call request; the first data at least includes: user identity data and resource path data; Extracting second data from the request body and request line parsed from each call request; the second data at least includes: request method data and request content data; The first data and the second data are combined to obtain a piece of log data corresponding to each calling request.
14. The electronic device according to claim 11, characterized in that: The log storage queue stores at least one log data, each log data including: log parameters; The operation of filtering the log data in the log storage queue based on the preset first filtering parameter and storing the filtered log data in batches to the database includes: Acquire the at least one piece of log data from the log storage queue; Matching the log parameter of each log data in the at least one log data with the first filtering parameter to obtain a matching matching parameter; Determining the filtered log data according to at least one target log data corresponding to the matching parameter; When the amount of the filtered log data reaches a preset amount, the filtered log data is stored in the database.
15. A computer-readable storage medium, characterized in that: A computer program is stored, which is used to be executed by a processor to implement the following operations: Using a first asynchronous thread to intercept an application program interface call request sent by a client; Based on the application program interface call request, log data is generated, and the log data is stored in a log storage queue; the log storage queue is used to store the log data stored in the database after filtering; Receiving a filtering parameter setting instruction sent by a user and carrying a preset first filtering parameter; In response to the filtering parameter setting instruction, changing the preset first initial filtering parameter to the preset first filtering parameter; Based on the preset first filtering parameter, a batch processing thread different from the first asynchronous thread is used to filter each log data in the log storage queue, and the filtered log data is stored in batches in the database; A business thread is used to respond to the modification request in the application program interface call request to achieve real-time recording of the scene state; the scene state is the game state of the game table.
16. A computer program product comprising computer readable code, characterized in that: When the computer readable code is executed by an electronic device, the processor in the electronic device is caused to perform the following operations: Using a first asynchronous thread to intercept an application program interface call request sent by a client; Based on the application program interface call request, log data is generated, and the log data is stored in a log storage queue; the log storage queue is used to store the log data stored in the database after filtering; Receiving a filtering parameter setting instruction sent by a user and carrying a preset first filtering parameter; In response to the filtering parameter setting instruction, changing the preset first initial filtering parameter to the preset first filtering parameter; Based on the preset first filtering parameter, a batch processing thread different from the first asynchronous thread is used to filter each log data in the log storage queue, and the filtered log data is stored in batches in the database; A business thread is used to respond to the modification request in the application program interface call request to achieve real-time recording of the scene state; the scene state is the game state of the game table.
Citation Information
Patent Citations
Business execution method and server
CN105912455A
Log processing method and device
CN112860456A
