Application log printing method, device, computer equipment and storage medium

By receiving the log printing request, obtaining the mapping relationship table, and calling the log printing interface and stack information, the problem of low log printing efficiency is solved, and the standardization and unified printing of log information are realized.

CN109375884BInactive Publication Date: 2024-08-23CHINA PING AN LIFE INSURANCE CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN201811021666.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2018-09-03
Publication Date
2024-08-23
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

The log printing methods in the existing technology are not uniform, resulting in low log printing efficiency, and it is necessary to improve the log printing efficiency.

Method used

By receiving the log printing request, the pre-established mapping relationship table is obtained, the interface identification is obtained according to the class identification, the log printing interface is called, and the log information is obtained from the stack according to the tracking identification for printing, thereby realizing the isolation and encapsulation of the log interface.

Benefits of technology

It effectively improves the efficiency of log printing, and realizes the standardization and unified printing of log information through the mapping relationship table between class identifiers and interface identifiers.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN109375884B
    Figure CN109375884B
Patent Text Reader

Abstract

The present application relates to an application log printing method, device, computer equipment and storage medium based on interface data processing. The method comprises: receiving a log printing request sent by a first terminal, the log printing request carries a class identifier and a tracking identifier; obtaining a pre-established mapping relationship table, the mapping relationship between the class identifier and the corresponding interface identifier is recorded in the mapping relationship table; obtaining the corresponding interface identifier from the mapping relationship table according to the class identifier; calling the corresponding log printing interface from the interface library through the interface identifier, the log printing interface includes corresponding encapsulation information; calling the stack of the corresponding thread according to the tracking identifier, and obtaining the corresponding log information from the stack; printing the log information according to the log printing interface and the corresponding encapsulation information. The use of this method can effectively improve the efficiency of log printing.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to an application log printing method, device, computer equipment and storage medium based on interface data processing. Background Art

[0002] With the rapid development of computer technology, various software and applications are also increasing. After these software and applications are released, corresponding log information can be recorded during the operation. When these software and applications have problems, it is necessary to run and debug the software and applications, and print out the log information during the operation, so that the debugger can track the problem of the logic code according to the information in the log information to understand the problem of the software or application.

[0003] In most cases, the amount of log information is large and complex. In the traditional log printing method, it is usually printed using a unified interface, or different log frameworks need to be switched to print according to changes in demand. The specifications of this log printing method are not unified, and the workload of the log printing interface is relatively large, resulting in low efficiency of log printing. Therefore, how to effectively improve the efficiency of log printing has become a technical problem that needs to be solved at present. Summary of the invention

[0004] Based on this, it is necessary to provide an application log printing method, device, computer equipment and storage medium that can effectively improve the efficiency of log printing in response to the above technical problems.

[0005] An application log printing method, comprising:

[0006] receiving a log printing request sent by the first terminal, wherein the log printing request carries a class identifier and a tracking identifier;

[0007] Obtaining a pre-established mapping relationship table, wherein the mapping relationship between the class identifier and the corresponding interface identifier is recorded in the mapping relationship table;

[0008] Obtaining a corresponding interface identifier from a mapping relationship table according to the class identifier;

[0009] Calling a corresponding log printing interface from an interface library through the interface identifier, wherein the log printing interface includes corresponding encapsulation information;

[0010] Calling a stack of a corresponding thread according to the tracking identifier, and obtaining corresponding log information from the stack;

[0011] Print the log information according to the log printing interface and the corresponding encapsulation information.

[0012] In one of the embodiments, before receiving the log printing request sent by the first terminal, it also includes: isolating multiple log printing interfaces according to the function of the class; adding a corresponding class identifier to the isolated log printing interface; and establishing a mapping relationship table using the class identifier and the interface identifier of the corresponding log printing interface.

[0013] In one of the embodiments, the class includes a corresponding business type; after adding the corresponding class identifier to the isolated log printing interface, it also includes: obtaining a keyword for the business type; adding the keyword to the log printing interface corresponding to the class to which the business type belongs; and storing the log printing interface after adding the keyword in the interface library.

[0014] In one of the embodiments, after adding the corresponding class identifier to the isolated log printing interface, the method further includes: encapsulating the log printing interface and generating corresponding encapsulation information; and storing the encapsulated log printing interface and the corresponding encapsulation information.

[0015] In one of the embodiments, the method further includes: receiving a log framework switching request sent by the first terminal, the log framework switching request including an interface identifier; acquiring corresponding encapsulation information according to the interface identifier; and modifying the encapsulation information to switch the log printing framework.

[0016] In one of the embodiments, before receiving the log printing request sent by the debugging terminal, it also includes: obtaining an operation request sent by a second terminal, the operation request including a tracking identifier; obtaining a current running thread corresponding to the operation request, and writing the tracking identifier into a variable of the current running thread; obtaining a class identifier corresponding to the operation request, and calling a corresponding log printing framework according to the class identifier; generating corresponding log information according to the log printing framework and the tracking identifier, and storing it in a stack.

[0017] An application log printing device, comprising:

[0018] A receiving module, configured to receive a log printing request sent by the first terminal, wherein the log printing request carries a class identifier and a tracking identifier;

[0019] An acquisition module is used to acquire a pre-established mapping relationship table, wherein the mapping relationship between the class identifier and the corresponding interface identifier is recorded in the mapping relationship table; and the corresponding interface identifier is acquired from the mapping relationship table according to the function class identifier;

[0020] A calling module, used to call a corresponding log printing interface from an interface library through the interface identifier, wherein the log printing interface includes corresponding encapsulation information;

[0021] The acquisition module is further used to call the stack of the corresponding thread according to the tracking identifier, and obtain the corresponding log information from the stack;

[0022] The printing module is used to print the log information according to the log printing interface and the corresponding encapsulation information.

[0023] In one of the embodiments, the device also includes an isolation module for isolating multiple log printing interfaces according to the function of the class; an identification adding module for adding a corresponding class identification to the isolated log printing interface; and a relationship table establishment module for establishing a mapping relationship table using the class identification and the interface identification of the corresponding log printing interface.

[0024] A computer device comprises a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the following steps are implemented:

[0025] receiving a log printing request sent by the first terminal, wherein the log printing request carries a class identifier and a tracking identifier;

[0026] Obtaining a pre-established mapping relationship table, wherein the mapping relationship between the class identifier and the corresponding interface identifier is recorded in the mapping relationship table;

[0027] Obtaining a corresponding interface identifier from a mapping relationship table according to the class identifier;

[0028] Calling a corresponding log printing interface from an interface library through the interface identifier, wherein the log printing interface includes corresponding encapsulation information;

[0029] Calling a stack of a corresponding thread according to the tracking identifier, and obtaining corresponding log information from the stack;

[0030] Print the log information according to the log printing interface and the corresponding encapsulation information.

[0031] A computer-readable storage medium stores a computer program, which, when executed by a processor, implements the following steps:

[0032] receiving a log printing request sent by the first terminal, wherein the log printing request carries a class identifier and a tracking identifier;

[0033] Obtaining a pre-established mapping relationship table, wherein the mapping relationship between the class identifier and the corresponding interface identifier is recorded in the mapping relationship table;

[0034] Obtaining a corresponding interface identifier from a mapping relationship table according to the class identifier;

[0035] Calling a corresponding log printing interface from an interface library through the interface identifier, wherein the log printing interface includes corresponding encapsulation information;

[0036] Calling a stack of a corresponding thread according to the tracking identifier, and obtaining corresponding log information from the stack;

[0037] Print the log information according to the log printing interface and the corresponding encapsulation information.

[0038] The above-mentioned application log printing method, device, computer equipment and storage medium, the server receives the log printing request sent by the first terminal, and the log printing request carries the class identifier and the tracking identifier. A pre-established mapping relationship table is obtained, and the mapping relationship between the class identifier and the corresponding interface identifier is recorded in the mapping relationship table. The server can then obtain the corresponding interface identifier from the mapping relationship table according to the class identifier, and call the corresponding log printing interface from the interface library through the interface identifier, and the log printing interface includes corresponding encapsulation information. Then the server calls the stack of the corresponding thread according to the tracking identifier, and obtains the corresponding log information from the stack, thereby printing out the log information according to the log printing interface and the corresponding encapsulation information. Since each log printing interface is isolated according to the function of the class, the corresponding log information can be printed out through the corresponding log printing interface according to the class identifier during printing, thereby effectively improving the efficiency of log printing. BRIEF DESCRIPTION OF THE DRAWINGS

[0039] Figure 1 An application scenario diagram of an application log printing method in an embodiment;

[0040] Figure 2 A flow chart of a log printing method in one embodiment;

[0041] Figure 3 A schematic flow chart of the steps of isolating a log printing interface in one embodiment;

[0042] Figure 4 It is a flowchart of the steps of switching the log framework in one embodiment;

[0043] Figure 5 A flowchart of steps for generating log information in one embodiment;

[0044] Figure 6 A structural block diagram of an application log printing device in an embodiment;

[0045] Figure 7 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION

[0046] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0047] The application log printing method provided in this application can be applied to Figure 1 In the application environment shown. Among them, the first terminal 102 communicates with the server 104 through the network through the network. Among them, the first terminal 102 can be but not limited to various personal computers, laptops, smart phones, tablet computers and portable wearable devices, and the server 104 can be implemented by an independent server or a server cluster composed of multiple servers. The server 104 receives the log printing request sent by the first terminal 102, and the log printing request carries the class identifier and the tracking identifier. The server 104 then obtains a pre-established mapping relationship table, and the mapping relationship between the class identifier and the corresponding interface identifier is recorded in the mapping relationship table; the corresponding interface identifier is obtained from the mapping relationship table according to the class identifier. The server 104 calls the corresponding log printing interface from the interface library through the interface identifier, and the log printing interface includes the corresponding encapsulation information, and calls the stack of the corresponding thread according to the tracking identifier, and obtains the corresponding log information from the stack. The server 104 thus prints the log information according to the log printing interface and the corresponding encapsulation information. Since each log printing interface is isolated according to the function of the class, the corresponding log information can be printed out through the corresponding log printing interface according to the class identifier during printing, thereby effectively improving the efficiency of log printing.

[0048] In one embodiment, Figure 2 As shown, a method for printing an application log is provided, which is applied to Figure 1 The server in the example is used to illustrate the following steps:

[0049] Step 202: receiving a log printing request sent by the first terminal, where the log printing request carries a class identifier and a tracking identifier.

[0050] Various software and applications generate a large amount of log information during operation. When problems occur or maintenance is required, relevant log information can be printed out to debug or maintain the software and applications.

[0051] When the first terminal needs to obtain the log information in the server, it can send a log printing request to the server, and then the server receives the log printing request sent by the first terminal. The log printing request carries a class identifier and a tracking identifier. Among them, the first terminal can be a terminal corresponding to a debugger or a maintenance personnel. The class identifier can be an identifier corresponding to the class of the log information to be printed; the tracking identifier can be a tracking identifier corresponding to the operation request corresponding to the log information to be printed.

[0052] Step 204: Obtain a pre-established mapping relationship table, in which the mapping relationship between the class identifier and the corresponding interface identifier is recorded.

[0053] After receiving the log printing request sent by the first terminal, the server obtains a pre-established mapping relationship table from the database, in which the mapping relationship between the class identifier and the corresponding interface identifier is recorded. Among them, the server can pre-isolate multiple log printing interfaces according to the functions of the class, and add corresponding class identifiers to the isolated log printing interfaces, so that classes with different functions correspond to different log printing interfaces. The server then uses the class identifier and the interface identifier of the corresponding log printing interface to establish a mapping relationship table, and stores the established mapping relationship table.

[0054] Step 206: Obtain the corresponding interface identifier from the mapping relationship table according to the class identifier.

[0055] Step 208: calling the corresponding log printing interface from the interface library through the interface identifier, where the log printing interface includes corresponding encapsulation information.

[0056] After the server obtains the mapping table, it obtains the corresponding interface identifier from the mapping table according to the class identifier carried in the log printing request, and the server can further call the corresponding log printing interface from the interface library through the interface identifier. The log printing interface includes the corresponding encapsulation information.

[0057] Specifically, before receiving the log printing request sent by the first terminal, the server splits the multiple log printing interfaces according to the functions corresponding to each class, thereby isolating the multiple log printing interfaces, so that the dependencies between the classes are minimized. Each class has a corresponding function and class identifier, and each log printing interface has a corresponding interface identifier. The server allocates a corresponding log printing interface to each class according to the function of each class. Among them, multiple classes can correspond to one log printing interface, and one log printing interface can also correspond to multiple classes. Then the server adds the corresponding class identifier to the isolated log printing interface, thereby being able to effectively allocate the corresponding log printing interface according to the class identifier.

[0058] The encapsulation information is generated by the server after isolating multiple log printing interfaces in advance, encapsulating the log printing interfaces, and generating corresponding encapsulation information, which includes multiple attribute information of the log printing interfaces.

[0059] Step 210: Call the stack of the corresponding thread according to the tracking identifier, and obtain corresponding log information from the stack.

[0060] Among them, the log information can be generated according to the operation request of the user terminal. Specifically, the user terminal sends the operation request to the server, and the operation request carries a tracking identifier for tracking the log information generated by the operation request. The tracking identifier can be an identifier that the server generates according to the operation request after receiving the operation request and uniquely corresponds to the operation request. The server further calls the thread corresponding to the operation request. By obtaining the variables in the thread, the tracking identifier corresponding to the operation request is added to the thread variable, so that the tracking identifier can be added to the thread corresponding to the operation request. Each operation request sent by the user terminal has a corresponding class to respond to the operation request, and then the server obtains the corresponding class identifier according to the operation request, thereby calling the corresponding log framework according to the class identifier. The server reads the tracking identifier corresponding to the operation request from the thread, and writes the tracking identifier into the log framework corresponding to the operation request. The server further generates a corresponding log message based on the log framework and the tracking identifier, and stores the log information in the stack.

[0061] After the server calls the corresponding log printing interface from the interface library according to the interface identifier, it further calls the stack of the corresponding thread according to the tracking identifier carried in the log printing request. The stack stores the log information generated according to the operation request corresponding to the tracking identifier, so that the server can obtain the corresponding log information according to the tracking identifier.

[0062] Furthermore, after calling the stack of the corresponding thread according to the tracking identifier, the server can also match the class identifier with the class identifier in the log information in the stack, and a successful match indicates that this class matches the class actually called in the previous frame. Thus, the server can obtain the corresponding log information according to the tracking identifier.

[0063] Step 212: Print log information according to the log printing interface and corresponding encapsulation information.

[0064] After the server obtains the corresponding log information, it can print out the log information according to the called log printing interface and the corresponding encapsulation information. Since the encapsulation information includes multiple attribute information of the log printing interface, the log printing interface can be used to print out the log information in a manner corresponding to the encapsulation information. Since the log printing interface is isolated and encapsulated according to the function of the class, the server can call the corresponding log printing interface through the class identifier to print the log information in a standardized and unified manner, thereby effectively improving the efficiency of application log printing.

[0065] In the above-mentioned application log printing method, the server receives a log printing request sent by the first terminal, and the log printing request carries a class identifier and a tracking identifier. A pre-established mapping relationship table is obtained, and the mapping relationship between the class identifier and the corresponding interface identifier is recorded in the mapping relationship table. The server obtains the corresponding interface identifier from the mapping relationship table according to the class identifier, and calls the corresponding log printing interface from the interface library through the interface identifier, and the log printing interface includes corresponding encapsulation information. Then the server calls the stack of the corresponding thread according to the tracking identifier, and obtains the corresponding log information from the stack, thereby printing out the log information according to the log printing interface and the corresponding encapsulation information. Since each log printing interface is isolated and encapsulated according to the function of the class, the corresponding log information can be printed out in a unified and standardized manner according to the class identifier through the corresponding log printing interface during printing, thereby effectively improving the efficiency of log printing.

[0066] In one embodiment, Figure 3 As shown, before receiving the log printing request sent by the first terminal, a step of isolating the log printing interface is also included, and the step specifically includes the following contents:

[0067] Step 302: Isolate multiple log printing interfaces according to class functions.

[0068] Step 304: Add a corresponding class identifier to the isolated log printing interface.

[0069] Before receiving the log printing request sent by the first terminal, the server splits the multiple log printing interfaces according to the functions corresponding to each class, thereby isolating the multiple log printing interfaces to minimize the dependencies between the classes.

[0070] Specifically, each class has a corresponding function and class identifier, and each log printing interface has a corresponding interface identifier. The server allocates a corresponding log printing interface to each class according to the function of each class. Among them, multiple classes can correspond to one log printing interface, and one log printing interface can also correspond to multiple classes. Then the server adds a corresponding class identifier to the isolated log printing interface, thereby being able to effectively allocate the corresponding log printing interface according to the class identifier.

[0071] Step 306: Create a mapping relationship table using the class identifier and the interface identifier of the corresponding log printing interface.

[0072] After the server adds the corresponding class identifier to the isolated log printing interface, it uses the class identifier and the interface identifier of the corresponding log printing interface to establish a mapping relationship table and store it in the database, thereby effectively associating the class with the corresponding log printing interface. By isolating multiple log printing interfaces according to the functions of the class, the server can use the isolated log printing interface to print out the corresponding log information in a standardized manner, thereby effectively improving the efficiency of log printing.

[0073] In one embodiment, the class includes the corresponding business type; after adding the corresponding class identifier to the isolated log printing interface, it also includes: obtaining the keyword of the business type; adding the keyword to the log printing interface corresponding to the class to which the business type belongs; and storing the log printing interface after adding the keyword in the interface library.

[0074] Before receiving the log printing request sent by the first terminal, the server isolates multiple log printing interfaces according to the functions corresponding to each class, so that the dependencies between the classes are minimized.

[0075] Specifically, each class has a corresponding function and class identifier, and each log printing interface has a corresponding interface identifier. The server allocates a corresponding log printing interface to each class according to the function of each class. Among them, multiple classes can correspond to one log printing interface, and one log printing interface can also correspond to multiple classes. Then the server adds a corresponding class identifier to the isolated log printing interface, thereby being able to effectively allocate the corresponding log printing interface according to the class identifier.

[0076] Each class includes a corresponding business type, wherein multiple classes may belong to the same business type. After the server adds the corresponding class identifier to the isolated log printing interface, it obtains the keyword of the business type corresponding to the class. Among them, the keyword can be pre-defined or screened out according to preset rules. The server then adds the obtained keyword to the log printing interface corresponding to the class, and stores the log printing interface after adding the keyword in the interface library. Therefore, when it is necessary to uniformly manage these log printing interfaces, the corresponding log printing interface can be called according to the keyword of the business type of the class, and then these log printing interfaces are uniformly managed. By adding the keyword of the business type to the log printing interface, the log printing interface can be effectively uniformly managed.

[0077] In one embodiment, after adding the corresponding class identifier to the isolated log printing interface, the method further includes: encapsulating the log printing interface and generating corresponding encapsulation information; and storing the encapsulated log printing interface and the corresponding encapsulation information.

[0078] Before receiving the log printing request sent by the first terminal, the server isolates multiple log printing interfaces according to the functions corresponding to each class, so that the dependencies between the classes are minimized.

[0079] Specifically, each class has a corresponding function and class identifier, and each log printing interface has a corresponding interface identifier. The server allocates a corresponding log printing interface to each class according to the function of each class. Among them, multiple classes can correspond to one log printing interface, and one log printing interface can also correspond to multiple classes. Then the server adds a corresponding class identifier to the isolated log printing interface, thereby being able to effectively allocate the corresponding log printing interface according to the class identifier.

[0080] After the server adds the corresponding class identifier to the isolated log printing interface, the log printing interface is encapsulated. Specifically, the log printing interface can be encapsulated by a preset function, and the corresponding encapsulation information is generated after encapsulation. The encapsulation information includes multiple attribute information of the log printing interface. The server stores the encapsulated log printing interface and the corresponding encapsulation information so that the server can obtain the corresponding encapsulation information at the same time when calling the log printing interface. By encapsulating the log printing interface, the log printing interface can be effectively standardized, and then the printing efficiency of the log information can be effectively improved.

[0081] In one embodiment, Figure 4 As shown, the method also includes a step of switching the log framework, which specifically includes the following contents:

[0082] Step 402: receiving a log framework switching request sent by the first terminal, where the log framework switching request includes an interface identifier.

[0083] When the log framework needs to be switched according to demand, the first terminal may send a log framework switching request to the server, where the log framework switching request includes an interface identifier and modification information of a corresponding log printing interface.

[0084] Step 404: Obtain corresponding encapsulation information according to the interface identifier.

[0085] Step 406: modify the encapsulation information to switch the log printing framework.

[0086] After receiving the log frame switching request sent by the first terminal, the server obtains the encapsulation information of the corresponding log printing interface according to the interface identifier carried in the log frame switching request. Then the root server modifies the encapsulation information of the log printing interface according to the modification information in the log frame switching request, and modifies the printing frame by modifying the encapsulation information of the log printing interface. The encapsulation information includes the attribute information of the log printing interface, and by modifying the encapsulation information, the encapsulation package corresponding to the log frame can be modified.

[0087] For example, when the log printing interface corresponding to a class needs to switch the log framework, it only needs to modify the corresponding encapsulation information to effectively switch the log framework. By modifying the encapsulation information of the log printing interface, the log framework of the log printing interface corresponding to each class can be effectively modified and switched, thereby effectively improving the efficiency of log printing.

[0088] In one embodiment, Figure 5 As shown, before receiving the log printing request sent by the debugging terminal, the method also includes the step of generating log information, which specifically includes the following contents:

[0089] Step 502: Acquire an operation request sent by the second terminal, where the operation request includes a tracking identifier.

[0090] The second terminal may be a user terminal. The log information records feedback information and event information of related activities and performance of the operating system, webpage or application during operation. The log information can be used to understand the activity process of the operating system or other application and to track and diagnose problems of the operating system, webpage or application. The user can click on a control or link in the interface displayed in the user terminal.

[0091] After the user terminal detects the user's click operation, it triggers an operation request and sends the operation request to the server. The operation request carries a tracking identifier for tracking the log information generated by the operation request. The tracking identifier can be an identifier that the server generates based on the operation request after receiving the operation request and that uniquely corresponds to the operation request. For example, the server can use UUID (Universally Unique Identifier) ​​to randomly generate a corresponding tracking identifier for the operation request.

[0092] Step 504: Get the current running thread corresponding to the operation request, and write the tracking identifier into the variable of the current running thread.

[0093] Furthermore, each operation request has a corresponding thread to execute the operation request, and all program calls from receiving the request to returning the response belong to the same thread. After generating a tracking identifier uniquely corresponding to the operation request, the server calls the thread corresponding to the operation request. By obtaining the variable in the thread, the tracking identifier corresponding to the operation request is added to the thread variable, so that the tracking identifier can be added to the thread corresponding to the operation request.

[0094] Step 506: Obtain a class identifier corresponding to the operation request, and call a corresponding log printing framework according to the class identifier.

[0095] Each operation request sent by the user terminal has a corresponding class to respond to the operation request, and then the server obtains the corresponding class identifier according to the operation request, thereby calling the corresponding log framework according to the class identifier.

[0096] Step 508: Generate corresponding log information according to the log printing framework and the tracking identifier, and store it in the stack.

[0097] After the server calls the thread corresponding to the operation request according to the tracking identifier of the operation request, the server reads the tracking identifier corresponding to the operation request from the thread, and writes the tracking identifier into the log frame corresponding to the operation request. The server further generates a corresponding log message according to the log frame and the tracking identifier, and stores the log information in a stack. By using the tracking identifier and the log frame to generate the corresponding log information, the efficiency of the log printing interface to print the corresponding log information can be effectively improved.

[0098] Furthermore, the server can also create an index for the corresponding log information according to the tracking identifier, so that when the log message is queried, the corresponding log message can be quickly queried according to the index. Specifically, the server can generate a log storage table according to the tracking identifier and the corresponding log information, and the log storage table can be various data tables. The server can further set the tracking identifier of the operation request as the primary key in the log storage table, and use the tracking identifier to create an index of the log message corresponding to the operation request according to the primary key. In this way, the operation request can be associated with the corresponding log message according to the tracking identifier, thereby effectively improving the query efficiency and printing efficiency of the log information.

[0099] It should be understood that although Figure 2-5 The steps in the flowchart are shown in sequence as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified in this document, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. Moreover, Figure 2-5At least part of the steps may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily executed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be executed in turn or alternately with other steps or at least part of the sub-steps or stages of other steps.

[0100] In one embodiment, Figure 6 As shown, an application log printing device is provided, including: a receiving module 602, an acquisition module 604, a calling module 606 and a printing module 608, wherein:

[0101] The receiving module 602 is configured to receive a log printing request sent by the first terminal, wherein the log printing request carries a class identifier and a tracking identifier.

[0102] The acquisition module 604 is used to acquire a pre-established mapping relationship table, wherein the mapping relationship between the class identifier and the corresponding interface identifier is recorded in the mapping relationship table; and the corresponding interface identifier is acquired from the mapping relationship table according to the function class identifier.

[0103] The calling module 606 is used to call the corresponding log printing interface from the interface library through the interface identifier, and the log printing interface includes corresponding encapsulation information.

[0104] The acquisition module 604 is further configured to call a stack of a corresponding thread according to the tracking identifier, and acquire corresponding log information from the stack.

[0105] The printing module 608 is used to print the log information according to the log printing interface and the corresponding packaging information.

[0106] In one embodiment, the device also includes an isolation module for isolating multiple log printing interfaces according to class functions; adding corresponding class identifiers to the isolated log printing interfaces; and establishing a mapping relationship table using the class identifiers and interface identifiers of the corresponding log printing interfaces.

[0107] In one embodiment, the class includes a corresponding business type; the device also includes a keyword adding module for obtaining keywords of the business type; adding keywords to the log printing interface corresponding to the class to which the business type belongs; and storing the log printing interface with the added keywords in the interface library.

[0108] In one embodiment, the device further includes a packaging module for packaging the log printing interface and generating corresponding packaging information; and storing the packaged log printing interface and the corresponding packaging information.

[0109] In one embodiment, the receiving module 602 is also used to receive a log framework switching request sent by the first terminal, the log framework switching request includes an interface identifier; the device also includes a switching module, which is used to obtain corresponding encapsulation information according to the interface identifier; and modify the encapsulation information to switch the log printing framework.

[0110] In one embodiment, the acquisition module 604 is also used to obtain an operation request sent by the second terminal, and the operation request includes a tracking identifier; the device also includes a tracking identifier writing module, which is used to obtain the current running thread corresponding to the operation request and write the tracking identifier into the variable of the current running thread; a log information generation module is used to obtain the class identifier corresponding to the operation request, and call the corresponding log printing framework according to the class identifier; generate corresponding log information according to the log printing framework and the tracking identifier, and store it in the stack.

[0111] For the specific definition of the application log printing device, please refer to the definition of the application log printing method above, which will not be repeated here. Each module in the above-mentioned application log printing device can be implemented in whole or in part by software, hardware and a combination thereof. The above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.

[0112] In one embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as follows: Figure 7 As shown. The computer device includes a processor, a memory, a network interface and a database connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store data such as a mapping relationship table, log printing interface data, encapsulation information and log information. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, an application log printing method is implemented.

[0113] Those skilled in the art will understand that Figure 7 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0114] In one embodiment, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the following steps are implemented:

[0115] receiving a log printing request sent by the first terminal, the log printing request carrying a class identifier and a tracking identifier;

[0116] Obtain a pre-established mapping relationship table, in which the mapping relationship between the class identifier and the corresponding interface identifier is recorded;

[0117] Obtain the corresponding interface identifier from the mapping relationship table according to the class identifier;

[0118] The corresponding log printing interface is called from the interface library through the interface identifier, and the log printing interface includes the corresponding encapsulation information;

[0119] Call the stack of the corresponding thread according to the tracking identifier and obtain the corresponding log information from the stack;

[0120] Print log information according to the log printing interface and corresponding encapsulation information.

[0121] In one embodiment, when the processor executes the computer program, the following steps are also implemented: isolating multiple log printing interfaces according to class functions; adding corresponding class identifiers to the isolated log printing interfaces; and establishing a mapping relationship table using the class identifiers and the interface identifiers of the corresponding log printing interfaces.

[0122] In one embodiment, the class includes the corresponding business type; when the processor executes the computer program, it also implements the following steps: obtaining the keyword of the business type; adding the keyword to the log printing interface corresponding to the class to which the business type belongs; and storing the log printing interface with the added keyword in the interface library.

[0123] In one embodiment, when the processor executes the computer program, the following steps are further implemented: encapsulating the log printing interface and generating corresponding encapsulation information; and storing the encapsulated log printing interface and the corresponding encapsulation information.

[0124] In one embodiment, when the processor executes the computer program, the following steps are further implemented: receiving a log framework switching request sent by the first terminal, the log framework switching request including an interface identifier; obtaining corresponding encapsulation information according to the interface identifier; and modifying the encapsulation information to switch the log printing framework.

[0125] In one embodiment, when the processor executes the computer program, the following steps are also implemented: obtaining an operation request sent by the second terminal, the operation request including a tracking identifier; obtaining a current running thread corresponding to the operation request, and writing the tracking identifier into a variable of the current running thread; obtaining a class identifier corresponding to the operation request, and calling a corresponding log printing framework according to the class identifier; generating corresponding log information according to the log printing framework and the tracking identifier, and storing it in a stack.

[0126] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented:

[0127] receiving a log printing request sent by the first terminal, the log printing request carrying a class identifier and a tracking identifier;

[0128] Obtain a pre-established mapping relationship table, in which the mapping relationship between the class identifier and the corresponding interface identifier is recorded;

[0129] Obtain the corresponding interface identifier from the mapping relationship table according to the class identifier;

[0130] The corresponding log printing interface is called from the interface library through the interface identifier, and the log printing interface includes the corresponding encapsulation information;

[0131] Call the stack of the corresponding thread according to the tracking identifier and obtain the corresponding log information from the stack;

[0132] Print log information according to the log printing interface and corresponding encapsulation information.

[0133] In one embodiment, when the computer program is executed by the processor, the following steps are also implemented: multiple log printing interfaces are isolated according to the functions of the class; corresponding class identifiers are added to the isolated log printing interfaces; and a mapping relationship table is established using the class identifiers and the interface identifiers of the corresponding log printing interfaces.

[0134] In one embodiment, the class includes the corresponding business type; when the computer program is executed by the processor, the following steps are also implemented: obtaining the keyword of the business type; adding the keyword to the log printing interface corresponding to the class to which the business type belongs; and storing the log printing interface with the added keyword in the interface library.

[0135] In one embodiment, when the computer program is executed by the processor, the following steps are further implemented: encapsulating the log printing interface and generating corresponding encapsulation information; and storing the encapsulated log printing interface and the corresponding encapsulation information.

[0136] In one embodiment, when the computer program is executed by the processor, the following steps are also implemented: receiving a log framework switching request sent by the first terminal, the log framework switching request including an interface identifier; obtaining corresponding encapsulation information according to the interface identifier; and modifying the encapsulation information to switch the log printing framework.

[0137] In one embodiment, when the computer program is executed by the processor, the following steps are also implemented: obtaining an operation request sent by the second terminal, the operation request including a tracking identifier; obtaining a current running thread corresponding to the operation request, and writing the tracking identifier into a variable of the current running thread; obtaining a class identifier corresponding to the operation request, and calling a corresponding log printing framework according to the class identifier; generating corresponding log information according to the log printing framework and the tracking identifier, and storing it in a stack.

[0138] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).

[0139] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0140] The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the patent of the present application shall be subject to the attached claims.

Claims

1. A method for printing an application log, comprising: Isolate multiple log printing interfaces according to class functions; Add the corresponding class identifier to the isolated log printing interface; Establishing a mapping relationship table using the class identifier and the interface identifier of the corresponding log printing interface; Obtain an operation request sent by a user terminal, the operation request including a tracking identifier, which is an identifier uniquely corresponding to the operation request; obtain a thread corresponding to the operation request, and write the tracking identifier into a variable of the thread; obtain a class identifier corresponding to the operation request, and call a corresponding log printing framework according to the class identifier corresponding to the operation request; Generate corresponding log information according to the log printing framework and the tracking identifier, and store it in a stack; receiving a log printing request sent by the first terminal, wherein the log printing request carries a class identifier and the tracking identifier; Acquire the pre-established mapping relationship table, wherein the mapping relationship between the class identifier and the corresponding interface identifier is recorded in the mapping relationship table; Obtaining a corresponding interface identifier from the mapping relationship table according to the class identifier carried in the log printing request; Calling a corresponding log printing interface from an interface library through the interface identifier, wherein the log printing interface includes corresponding encapsulation information; Calling a stack of a corresponding thread according to the tracking identifier, and obtaining corresponding log information from the stack; Print the log information according to the log printing interface and the corresponding encapsulation information.

2. The method according to claim 1, characterized in that Printing the log information according to the log printing interface and the corresponding encapsulation information includes: The log printing interface is called to print the log information in a manner corresponding to the encapsulation information.

3. The method according to claim 1, characterized in that The class includes a corresponding business type; after adding a corresponding class identifier to the isolated log printing interface, it also includes: Obtain a keyword for the business type; Add the keyword to the log printing interface corresponding to the class to which the business type belongs; The log printing interface after adding keywords is stored in the interface library.

4. The method according to claim 1, characterized in that: After adding the corresponding class identifier to the isolated log printing interface, the method further includes: Encapsulate the log printing interface and generate corresponding encapsulation information; The encapsulated log printing interface and the corresponding encapsulation information are stored.

5. The method according to claim 4, characterized in that The method further comprises: Receiving a log framework switching request sent by the first terminal, wherein the log framework switching request includes an interface identifier; Acquire corresponding encapsulation information according to the interface identifier; The encapsulation information is modified to switch the log printing framework.

6. The method according to claim 1, characterized in that The calling of the stack of the corresponding thread according to the tracking identifier and obtaining the corresponding log information from the stack includes: The class identifier carried in the log printing request is matched with the class identifier of the log information in the stack, and when the match succeeds, the corresponding log information is obtained from the stack according to the tracking identifier.

7. An application log printing device, comprising: Isolation module, used to isolate multiple log printing interfaces according to class functions; The identification adding module is used to add the corresponding class identification to the isolated log printing interface; A relationship table establishment module, used to establish a mapping relationship table using the class identifier and the interface identifier of the corresponding log printing interface; A receiving module is used to obtain an operation request sent by a user terminal, wherein the operation request includes a tracking identifier, which is an identifier uniquely corresponding to the operation request; obtain a thread corresponding to the operation request, and write the tracking identifier into a variable of the thread; obtain a class identifier corresponding to the operation request, and call a corresponding log printing framework according to the class identifier corresponding to the operation request; Generate corresponding log information according to the log printing framework and the tracking identifier, and store it in a stack; receiving a log printing request sent by the first terminal, wherein the log printing request carries a class identifier and the tracking identifier; An acquisition module, used to acquire the pre-established mapping relationship table, wherein the mapping relationship between the class identifier and the corresponding interface identifier is recorded in the mapping relationship table; and acquire the corresponding interface identifier from the mapping relationship table according to the class identifier carried in the log printing request; A calling module, used to call a corresponding log printing interface from an interface library through the interface identifier, wherein the log printing interface includes corresponding encapsulation information; The acquisition module is further used to call the stack of the corresponding thread according to the tracking identifier, and obtain the corresponding log information from the stack; The printing module is used to print the log information according to the log printing interface and the corresponding encapsulation information.

8. The device according to claim 7, characterized in that The class includes a corresponding business type; the device also includes a keyword adding module for obtaining a keyword for the business type; adding the keyword to the log printing interface corresponding to the class to which the business type belongs; and storing the log printing interface after adding the keyword in the interface library.

9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 6 are implemented.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.

Citation Information

Patent Citations

  • Log printing method and device and log printing system

    CN106909325A

  • Consistent interface for invoice schedule and invoice schedule processing log

    US20140006236A1

  • Batch processed data structures in a log repository referencing a template repository and an attribute repository

    US20160070739A1

  • Unifying application log messages using runtime instrumentation

    US20160098325A1