Log data generation method, log data display method, and apparatus
By creating a wrapper function for the target function and generating log data carrying function identifiers, the problem of lack of correlation in log data is solved, enabling convenient log data analysis and problem localization.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- TENCENT TECHNOLOGY (SHENZHEN) CO LTD
- Filing Date
- 2020-02-26
- Publication Date
- 2026-07-31
AI Technical Summary
In existing technologies, application log data lacks correlation, making it difficult to trace function call processes and increasing the difficulty of log data analysis and problem localization.
By creating a target wrapper function for the target function, assigning a function identifier, determining the outer function identifier, generating log data carrying the function identifier, and establishing the relationship between log data, the system can achieve the desired outcome.
It establishes correlations between log data, facilitating the analysis and location of application problems, simplifying the log data acquisition process, and avoiding modifications to the resource package source code.
Smart Images

Figure CN113312249B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to a log data generation method, log data display method, apparatus, computer device, and computer-readable storage medium. Background Technology
[0002] During application development, developers can debug the application based on log data generated during runtime. Currently, obtaining log data typically requires adding code to the functions corresponding to each function within the application. When a function is called, this code records the function's execution, thus obtaining the corresponding log data for that function, which is then reported to the server. However, because the log data for each function is reported separately and lacks correlation, it's difficult to trace the call process of the corresponding functions based on this log data, leading to significant challenges in log data analysis and application problem localization. Summary of the Invention
[0003] This application provides a log data generation method, a log data display method, an apparatus, a computer device, and a computer-readable storage medium, which can establish the correlation between log data and facilitate log data analysis. The technical solution is as follows: On the one hand, a method for generating log data is provided, which includes: In response to the call instruction of the target function, a target wrapper function corresponding to the target function is created. The target wrapper function contains program code for generating log data, and the target wrapper function has the same type as the target function. The first function identifier is assigned to the target function through the target wrapper function; Determine the second function identifier corresponding to the outer function of the objective function, which is used to call the objective function; The target wrapper function generates log data for the target function based on the execution process of the target function, the first function identifier, and the second function identifier.
[0004] On the one hand, a method for displaying log data is provided, which includes: In response to the log data viewing command, the log data corresponding to each function is obtained. The log data of any function is generated by the wrapper function corresponding to that function. The wrapper function contains program code for generating log data. The wrapper function is of the same type as the function. The log data of any function carries a function identifier. Based on the function identifier carried by each log data, the relationship between the log data is determined; Based on the relationships between these log data, the log data is displayed.
[0005] On the one hand, a log data generation device is provided, the device comprising: The function creation module is used to create a target wrapper function corresponding to the target function in response to the call instruction of the target function. The target wrapper function contains program code for generating log data, and the target wrapper function is of the same type as the target function. The allocation module is used to assign a first function identifier to the target function through the target wrapper function; The identifier determination module is used to determine the second function identifier corresponding to the outer function of the objective function, which is used to call the objective function; The generation module is used to generate log data for the target function based on the execution process of the target function, the first function identifier, and the second function identifier through the target wrapper function.
[0006] In one possible implementation, the allocation module is used for: In response to the execution of the target wrapper function, the identifier generation function is called to generate the first function identifier; The first function identifier is assigned to the target function through the target wrapper function.
[0007] In one possible implementation, the identifier determination module is used for: Retrieve the latest stored function identifier from the target data table as the second function identifier. The target data table is used to store the function identifiers of the functions currently being executed.
[0008] In one possible implementation, the device further includes: The storage module is used to store the first function identifier into the target data table.
[0009] In one possible implementation, the device further includes: The deletion module is used to delete the first function identifier from the target data table in response to the completion of the execution of the target function.
[0010] In one possible implementation, the device further includes: The caching module is used to cache this log data; The sending module is used to determine the number of log data entries cached in the current device; if the number of entries is equal to the target threshold, then each cached log data entry is sent to the target server.
[0011] On the one hand, a log data display device is provided, the device comprising: The log acquisition module is used to retrieve the log data corresponding to each function in response to the log data viewing command. The log data of any function is generated by the wrapper function corresponding to that function. The wrapper function contains the program code used to generate the log data. The wrapper function is of the same type as the function. The log data of any function carries the function identifier. The association determination module is used to determine the association between log data based on the function identifier carried by each log data. The display module is used to display the log data based on the relationships between the various log data.
[0012] In one possible implementation, the association determination module is used for: Based on the function identifier carried in the log data of any function, determine the outer function of any function; The log data of the outer function and the log data of any function are used as associated log data.
[0013] In one possible implementation, the display module is used for: Logs with related relationships are displayed in adjacent locations.
[0014] On one hand, a computer device is provided, the computer device including one or more processors and one or more memories, the one or more memories storing at least one piece of program code, the at least one piece of program code being loaded and executed by the one or more processors to implement the operations performed by the log data generation method or the log data display method.
[0015] On the one hand, a computer-readable storage medium is provided, which stores at least one piece of program code, which is loaded and executed by a processor to implement the operations performed by the log data generation method or the log data display method.
[0016] The technical solution provided in this application, in response to a call instruction from a target function, creates a target wrapper function corresponding to the target function. This target wrapper function contains program code for generating log data, and the type of the target wrapper function is the same as that of the target function. A first function identifier is assigned to the target function through the target wrapper function. A second function identifier is determined for the outer function of the target function, which is used to call the target function. Based on the execution process of the target function, the first function identifier, and the second function identifier, the target wrapper function generates log data for the target function. By applying this solution, the function identifiers carried by each log data point indicate the relationships between log data, thereby allowing the determination of the call process of each function based on these relationships, facilitating problem localization in the application. Attached Figure Description
[0017] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0018] Figure 1 This is a schematic diagram of the implementation environment of a log data processing method provided in an embodiment of this application; Figure 2 This is a flowchart of a log data generation method provided in an embodiment of this application; Figure 3 This is a flowchart of a function identifier processing method provided in an embodiment of this application; Figure 4 This is a schematic diagram of a resource packet monitoring process provided in an embodiment of this application; Figure 5 This is a flowchart of a log data display method provided in an embodiment of this application; Figure 6 This is a schematic diagram of a log data display method provided in an embodiment of this application; Figure 7 This is a flowchart illustrating log data generation and display provided in an embodiment of this application; Figure 8 This is a schematic diagram of the structure of a log data generation device provided in an embodiment of this application; Figure 9 This is a schematic diagram of the structure of a log data display device provided in an embodiment of this application; Figure 10 This is a schematic diagram of the structure of a terminal provided in an embodiment of this application; Figure 11This is a schematic diagram of the structure of a server provided in an embodiment of this application. Detailed Implementation
[0019] To make the objectives, technical solutions, and advantages of this application clearer, the embodiments of this application will be described in further detail below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments in this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0020] In this application, the terms "first," "second," etc., are used to distinguish identical or similar items with essentially the same function. It should be understood that there is no logical or temporal dependency between "first," "second," and "nth," nor are there any restrictions on quantity or execution order.
[0021] The following is an explanation of the terms used in this application: API (Application Programming Interface): These are predefined functions that allow an application to perform a specific function without needing to access the source code of that function or understand the details of its internal workings.
[0022] SDK (Software Development Kit): A software development kit is a collection of development tools that can be used to create application software for specific software packages, software frameworks, hardware platforms, operating systems, etc. An SDK can include multiple APIs.
[0023] Callback function: This is a parameter of the API. The callback function can be called after the API has finished executing. When calling the callback function of the API, the execution result of the API can be passed as a parameter to the callback function.
[0024] A wrapper function is a function that can process a target function. This wrapper function is typically placed outside the target function. When accessing the target function, the outer function must be executed first; that is, the wrapper function is executed first, and then the wrapper function calls the target function. This wrapper function can be generated based on a proxy and the target function. A proxy is a front-end language whose function is to set up an interceptor layer before the proxied target object, i.e., to set up a function. All external access to the target object must first pass through this interceptor, thus providing a mechanism to filter and modify external access. Furthermore, this interceptor adds wrapper functions to the various target functions within the target object. For example, the target object can be an SDK; by setting an interceptor outside the SDK, wrapper functions can be added to the various APIs within the SDK.
[0025] Outer and inner functions: If a function needs to call other functions during its execution, then the function in question can be called the outer function, and the other function can be called the inner function. In other words, the outer function can call the inner function.
[0026] Figure 1 This is a schematic diagram of the implementation environment of a log data processing method provided in an embodiment of this application. See also: Figure 1 The implementation environment may include a terminal 101 and a server 102. The terminal 101 can be a development and testing device, equipped with an application development environment for application development. During application development, the terminal 101 can acquire application log data and send it to the server 102. The terminal 101 can be a smartphone, tablet, e-book reader, MP3 (Moving Picture Experts Group Audio Layer III) player, MP4 (Moving Picture Experts Group Audio Layer IV) player, laptop, or desktop computer, etc. The server 102 can be a backend server, test server, cloud computing platform, etc., corresponding to the application.
[0027] Each terminal and server can be connected via a wired or wireless network, enabling data exchange between them.
[0028] Those skilled in the art will understand that the number of terminals described above can be more or less. For example, there may be only one terminal, or there may be dozens or hundreds of terminals, or even more. This disclosure does not limit the number of terminals or the type of device.
[0029] Figure 2 This is a flowchart illustrating a log data generation method provided in an embodiment of this application. This method can be applied to the aforementioned implementation environment. See also... Figure 2 This embodiment may specifically include the following steps: 201. In response to the call instruction of the target function, the terminal creates the target wrapper function corresponding to the target function.
[0030] In this embodiment, the target wrapper function may contain program code for generating log data. During runtime, the target wrapper function can use this program code to record the execution status of the target function, i.e., generate log data for the target function. The target wrapper function has the same type as the target function; for example, if the target function is a callback function, then the target wrapper function is also a callback function.
[0031] In one possible implementation, the terminal can respond to the call instruction of the target function and determine the resource package to which the target function belongs. A resource package can correspond to a proxy object, which can include at least one function wrapping logic for creating different types of wrapper functions. Different function wrapping logics can be used to wrap different types of functions; that is, a resource package can correspond to at least one function wrapping logic for creating different types of wrapper functions. Based on the function type of the target function, the terminal can determine the target function wrapping logic corresponding to that function type from among the various function wrapping logics, and create the target wrapper function based on the target function wrapping logic and the target function. The resource package includes at least one function; for example, the resource package can be an SDK, which can include at least one API. In this embodiment, a proxy object can be constructed for each resource package using a proxy. The function wrapping logic included in different proxy objects is different. The number, type, and specific content of the function wrapping logic in each proxy object can all be set by the developer based on the function call situation in each resource package. This embodiment does not limit this. For example, during application runtime, if only functions A and B in a certain resource package need to be called, the function wrapping logic corresponding to functions A and B can be set only in the proxy object. If functions A and B include callback functions, the function wrapping logic can also be set based on the callback functions of functions A and B. In this embodiment, setting the wrapping function based on the specific function call situation in the resource package can effectively avoid code redundancy and facilitate application maintenance.
[0032] 202. The terminal assigns a first function identifier to the target function through the target wrapper function.
[0033] The function identifier can be used to uniquely identify a function. In the embodiments of this application, a new function identifier can be assigned each time a function is called. That is, when a function is called multiple times, the function identifier assigned to the function in the later call is different from the function identifier assigned in the previous call.
[0034] In one possible implementation, the target wrapper function can obtain the generated function identifier, increment the function identifier with the largest value by one to obtain the first function identifier, and assign the first function identifier to the target function. Alternatively, the target wrapper function can randomly generate a function identifier as the first function identifier; this embodiment does not limit this approach. In this embodiment, the method for generating the function identifier can be encapsulated as an identifier generation function, and the target wrapper function can include program code that calls the identifier generation function. That is, in response to the execution of the target wrapper function, the terminal can call the identifier generation function to generate the first function identifier, and then assign the first function identifier to the target function through the target wrapper function.
[0035] It should be noted that the above description of assigning the first function identifier to the objective function is merely an exemplary description, and the embodiments of this application do not limit which method is specifically used to assign function identifiers to each function.
[0036] 203. The terminal determines the second function identifier corresponding to the outer function of the objective function.
[0037] The outer function can be used to call the target function.
[0038] In this embodiment, the terminal can maintain a target data table, which can be used to store function identifiers of currently executing functions. The terminal can retrieve the most recently stored function identifier from the target data table as the second function identifier. In one possible implementation, the target data table can be represented as a stack, and the most recently generated function identifier can be stored at the tail of the stack. The terminal retrieves the most recently stored function identifier from the target data table, that is, it retrieves the function identifier stored at the tail of the stack.
[0039] In the above technical solution, the execution status of each function is indicated by the function identifiers stored in the data list, which makes it easy to query the outer function of each function.
[0040] It should be noted that the above description of the method for obtaining the function identifier of the outer function is only an exemplary description, and the embodiments of this application do not limit it.
[0041] 204. The terminal stores the first function identifier of the objective function.
[0042] In this embodiment, before the target function is executed, the terminal can store the first function identifier of the target function in the target data table. When the inner function of the target function is called, the terminal can obtain the first function identifier from the target data table to accurately determine the outer function that calls the inner function. Of course, after the target function is executed, the terminal needs to delete the first function identifier from the target data table so that the functions indicated by the function identifiers stored in the target data table are all currently executing functions, ensuring that the query results obtained when querying the function identifier of the outer function corresponding to any function are accurate. That is, in response to the completion of the target function execution, the first function identifier is deleted from the target data table.
[0043] See Figure 3 , Figure 3 This is a flowchart of a function identifier processing method provided in an embodiment of this application. Taking the process of outer function 301 calling inner function 302 as an example, the above function identifier processing method is explained. First, the terminal responds to the call instruction of outer function 301 and runs the wrapper function 303 of outer function 301. The wrapper function 303 generates the function identifier of outer function 301 and stores the function identifier in target data table 304. The outer function 301 calls inner function 302 and runs the wrapper function 305 corresponding to inner function 302. The wrapper function 305 generates the function identifier of inner function 302. The function identifier of outer function 301 is obtained from the target data table. Based on the two function identifiers, the subsequent log data generation step 205 is executed. The two function identifiers can be used to reflect the relationship between functions and the relationship between log data.
[0044] 205. The terminal generates log data for the target function based on the execution process of the target function, the first function identifier, and the second function identifier through the target wrapper function.
[0045] In one possible implementation, during the execution of the target function, the wrapper function can record the execution status of the target function, generating multiple log data entries for the target function. Each log data entry can carry a first function identifier and a second function identifier. Using the first and second function identifiers, the target function corresponding to the log data and the outer function that called the target function can be accurately identified. The function identifiers establish the relationships between the various log data entries.
[0046] Of course, if a function does not have an outer function, its corresponding log data can carry only a function identifier, that is, only the function identifier of that function.
[0047] It should be noted that the log data may also contain other information, such as function name, function execution result, etc., but this application embodiment does not limit this.
[0048] All of the above-mentioned optional technical solutions can be combined in any way to form the optional embodiments of this application, and will not be described in detail here.
[0049] The technical solution provided in this application, in response to a call instruction from a target function, creates a target wrapper function corresponding to the target function. This target wrapper function contains program code for generating log data, and the type of the target wrapper function is the same as that of the target function. A first function identifier is assigned to the target function through the target wrapper function. A second function identifier is determined for the outer function of the target function, which is used to call the target function. Based on the execution process of the target function, the first function identifier, and the second function identifier, the target wrapper function generates log data for the target function. By applying this solution, the function identifiers carried by each log data point indicate the relationships between log data, thereby allowing the determination of the call process of each function based on these relationships, facilitating problem localization in the application.
[0050] In this embodiment, by setting up interception at the outer layer of each resource package—that is, constructing proxy objects for each resource package—and then creating wrapper functions for each function within the resource package, the execution status of each function in the resource package can be monitored during the execution of each wrapper function. This allows for monitoring of attribute calls, function execution, and parameter settings within the resource package without modifying its source code. Furthermore, during the execution of each function in the resource package, the wrapper function can also wrap the callback functions of each function, monitoring their execution and generating log data for each function. This log data can include information such as the function name, callback function name, and callback function parameters. Applying this technical solution avoids modifying the source code of the resource package, simplifying the log data acquisition process; and it also allows for complete and accurate recording of the function execution process.
[0051] In this embodiment, the principle of a stack is used to store the function identifiers of each function. The steps of pushing and popping function identifiers from the stack are performed before and after function execution, respectively. When each function in the resource package is executed, its outer function can be accurately determined through the function identifier stored at the end of the stack. By adding function identifiers to the log data, the relationships between log data can be determined, thereby identifying the calling relationships between functions.
[0052] The above embodiments mainly describe the process by which the terminal generates log data through the corresponding wrapper functions of each function. After obtaining the log data, the terminal needs to report the log data to the server. In this embodiment, to avoid excessive system load affecting the reporting of log data, the terminal can limit the reporting frequency of log data.
[0053] In one possible implementation, the terminal can cache the log data, determine the number of log entries cached in the current device, and if the number equals a target threshold, send all cached log entries to the target server. This target threshold can be set by the developers, and this embodiment does not limit its implementation. Alternatively, the terminal can determine the timing of log data reporting based on the total amount of currently cached log data; for example, reporting log data when the amount of cached log data is 10MB. This embodiment does not limit its implementation either.
[0054] In one possible implementation, the terminal can maintain a function blacklist, which can store the function names of at least one function. The terminal can filter functions based on the function blacklist. When the function name of any function appears in the function blacklist, the log data of any function does not need to be reported to the server.
[0055] It should be noted that the above description of the method for limiting the frequency of log data reporting is only an exemplary description. For example, the terminal can also limit the number of log reports for each function. This application embodiment does not limit which method is specifically adopted.
[0056] By applying the above technical solution, on the one hand, when the system is under heavy operating pressure and there is a lot of log data, it is possible to avoid data accumulation due to the inability to report log data in real time, which would affect the normal operation of the system; on the other hand, it can effectively reduce the reporting frequency of log data and reduce the occupation of system resources.
[0057] Figure 4 This is a schematic diagram of a resource packet monitoring process provided in an embodiment of this application, such as... Figure 4As shown, taking this resource package as an example of an SDK, a proxy can be used to proxy the SDK, creating a proxy object 401, which is the proxied SDK. When calling the API in the proxied SDK, a wrapper function for that API can be created. This wrapper function monitors the API's execution and generates log data. When the API includes a callback function, a wrapper function for that callback function can be created using the API's wrapper function. This wrapper function can obtain the callback function's parameters and also generates log data during its execution. The terminal can then report this log data to the server 402. By calling the proxied SDK and creating wrapper functions for each function in the SDK, the execution status of each function in the SDK can be comprehensively monitored, and log data can be obtained without modifying the resource package's source code, thus improving the convenience of log acquisition.
[0058] The above embodiments mainly describe the process of obtaining log data of various functions and reporting the log data to the server. In this embodiment, the terminal can obtain and display the log data of various functions from the server based on the log data viewing command. See also... Figure 5 , Figure 5 This is a flowchart of a log data display method provided in an embodiment of this application. The method may specifically include the following steps: 501. The terminal responds to the log data viewing command and retrieves the log data corresponding to each function.
[0059] In this embodiment, the log data for any function is generated by its corresponding wrapper function. This wrapper function contains program code for generating the log data and is of the same type as the function. The log data for any function carries a function identifier. In this embodiment, when the function has no outer function, the log data may carry only one function identifier, i.e., the function identifier of the function itself; when the function has an outer function, the log data may carry two function identifiers, i.e., the function identifier of the function itself and the function identifier of the outer function.
[0060] In this embodiment, the log data viewing instruction can be triggered by clicking on a control on the log data viewing page. This embodiment does not limit the specific triggering method of the log data viewing instruction. The terminal can respond to the log viewing instruction by sending a log retrieval request to the server, and the server can return log data based on the log retrieval request. In one possible implementation, the log data viewing instruction can carry a time range, and the server can return log data generated within that time range. Of course, the server can also return log data based on other information in the log generation instruction; this embodiment does not limit this approach.
[0061] 502. The terminal determines the relationship between the log data based on the function identifier carried by each log data.
[0062] In one possible implementation, the terminal can determine the outer function of any function based on the function identifier carried in the log data of any function; and associate the log data of the outer function with the log data of the function.
[0063] In one possible implementation, step 502 above can also be performed by the server. This application embodiment does not limit this. For example, the server can analyze the relationship between log data based on the function identifier carried by each log data, sort the log data based on the relationship, and send the sorted log data to the terminal.
[0064] 503. The terminal displays the log data based on the relationships between the various log data.
[0065] In one possible implementation, the terminal can display related log data in adjacent locations. Figure 6 This is a schematic diagram of a log data display method provided in an embodiment of this application, such as... Figure 6 As shown, associated log data can be arranged sequentially. For example, the log data of inner function 602 of function 601 and other inner functions can be displayed in the area below adjacent to the display area of the log data corresponding to function 601. In this embodiment, log data can also be hidden based on data hiding control 603. When any function includes multiple inner functions, the data hiding control 603 can be displayed before the log data display area of any function. The user can click on the data hiding control 603 to hide the log data corresponding to each inner function of any function. The data hiding control allows for flexible control of the amount of log data displayed on the page, improving page readability and facilitating data analysis. It should be noted that the above description of the log data display method is only an exemplary description, and this embodiment does not limit the specific display method used.
[0066] See Figure 7 , Figure 7This is a flowchart of log data generation and display provided in an embodiment of this application. Taking a resource package as an SDK as an example, the SDK can be proxied based on a Proxy, that is, a proxy object of the SDK can be constructed. During the call process of each API of the SDK, a wrapper function for each API is created through the proxy object. The wrapper function is used to execute the listening step 701. For example, it can listen to the running process of the API, the running process of the callback function in the API, the change of the callback function parameters, and the usage of various attributes in the SDK. Then, the log reporting step 702 is executed to report the log data to the server. When a log data viewing instruction is received, the context analysis step 703 of the log data is executed, that is, the relationship between the log data is determined. Based on the relationship, the visualization step 704 is executed. In this embodiment of the application, a proxy object is constructed using a Proxy to listen to the SDK, obtain log data with relationships, and visualize the log data based on the relationship between the log data. This facilitates data analysis, traces back the call process of each function, and efficiently locates the problems that occur during the function execution.
[0067] In one possible implementation, the above technical solutions can be combined to set fixed input and output values for the application to obtain test cases. Furthermore, test cases can be constructed by combining multiple functions based on certain business logic to enrich the test case data during the testing process.
[0068] All of the above-mentioned optional technical solutions can be combined in any way to form the optional embodiments of this application, and will not be described in detail here.
[0069] Figure 8 This is a schematic diagram of the structure of a log data generation device provided in an embodiment of this application. See also... Figure 8 The device includes: The function creation module 801 is used to create a target wrapper function corresponding to the target function in response to the call instruction of the target function. The target wrapper function contains program code for generating log data, and the target wrapper function is of the same type as the target function. Allocation module 802 is used to allocate a first function identifier to the target function through the target wrapper function; The identifier determination module 803 is used to determine the second function identifier corresponding to the outer function of the target function, which is used to call the target function; The generation module 804 is used to generate log data of the target function based on the execution process of the target function, the first function identifier, and the second function identifier through the target wrapper function.
[0070] In one possible implementation, the function creates module 801 for: In response to the call instruction of the target function, the resource package to which the target function belongs is determined, and one of the resource packages corresponds to at least one function wrapping logic for creating different types of wrapping functions; Based on the function type of the target function, determine the target function wrapping logic corresponding to the function type from the various function wrapping logics of the proxy object; Based on the objective function wrapper logic and the objective function, create the objective wrapper function.
[0071] In one possible implementation, the allocation module 802 is used for: In response to the execution of the target wrapper function, the identifier generation function is called to generate the first function identifier; The first function identifier is assigned to the target function through the target wrapper function.
[0072] In one possible implementation, the identifier determination module 803 is used for: Retrieve the latest stored function identifier from the target data table as the second function identifier. The target data table is used to store the function identifiers of the functions currently being executed.
[0073] In one possible implementation, the device further includes: The storage module is used to store the first function identifier into the target data table.
[0074] In one possible implementation, the device further includes: The deletion module is used to delete the first function identifier from the target data table in response to the completion of the execution of the target function.
[0075] In one possible implementation, the device further includes: The caching module is used to cache this log data; The sending module is used to determine the number of log data entries cached in the current device; if the number of entries is equal to the target threshold, then each cached log data entry is sent to the target server.
[0076] The apparatus provided in this application creates a target wrapper function corresponding to the target function in response to a call instruction of the target function. The target wrapper function contains program code for generating log data, and the type of the target wrapper function is the same as that of the target function. A first function identifier is assigned to the target function through the target wrapper function. A second function identifier is determined for the outer function of the target function, which is used to call the target function. Log data for the target function is generated by the target wrapper function based on the execution process of the target function, the first function identifier, and the second function identifier. By using the above apparatus, the function identifiers carried by each log data point indicate the relationships between log data points, thereby allowing the call process of each function to be determined based on these relationships, facilitating problem localization in the application.
[0077] It should be noted that the log data generation device provided in the above embodiments is only illustrated by the division of the above functional modules. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above. In addition, the log data generation device and the log data generation method embodiments provided in the above embodiments belong to the same concept, and their specific implementation process can be found in the method embodiments, which will not be repeated here.
[0078] Figure 9 This is a schematic diagram of a log data display device provided in an embodiment of this application. See also... Figure 9 The device includes: The log acquisition module 901 is used to acquire the log data corresponding to each function in response to the log data viewing command. The log data of any function is generated by the wrapper function corresponding to that function. The wrapper function contains program code for generating log data. The type of the wrapper function is the same as that function. The log data of any function carries a function identifier. The association determination module 902 is used to determine the association between the log data based on the function identifier carried by each log data. Display module 903 is used to display the log data based on the correlation between the various log data.
[0079] In one possible implementation, the association determination module 902 is used for: Based on the function identifier carried in the log data of any function, determine the outer function of any function; The log data of the outer function and the log data of any function are used as associated log data.
[0080] In one possible implementation, the display module 903 is used for: Logs with related relationships are displayed in adjacent locations.
[0081] It should be noted that the log data display device provided in the above embodiments is only illustrated by the division of the above functional modules when displaying log data. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above. In addition, the log data display device and the log data display method embodiments provided in the above embodiments belong to the same concept, and the specific implementation process can be found in the method embodiments, which will not be repeated here.
[0082] Figure 10 This is a schematic diagram of the structure of a terminal provided in an embodiment of this application. The terminal 1000 can be: a smartphone, tablet computer, MP3 player (Moving Picture Experts Group Audio Layer III), MP4 player (Moving Picture Experts Group Audio Layer IV), laptop computer, or desktop computer. The terminal 1000 may also be referred to as user equipment, portable terminal, laptop terminal, desktop terminal, or other names.
[0083] Typically, terminal 1000 includes one or more processors 1001 and one or more memories 1002.
[0084] Processor 1001 may include one or more processing cores, such as a quad-core processor, a deca-core processor, etc. Processor 1001 may be implemented using at least one hardware form selected from DSP (Digital Signal Processing), FPGA (Field-Programmable Gate Array), and PLA (Programmable Logic Array). Processor 1001 may also include a main processor and a coprocessor. The main processor, also known as a CPU (Central Processing Unit), is used to process data in the wake-up state; the coprocessor is a low-power processor used to process data in the standby state. In some embodiments, processor 1001 may integrate a GPU (Graphics Processing Unit), which is responsible for rendering and drawing the content to be displayed on the screen. In some embodiments, processor 1001 may also include an AI (Artificial Intelligence) processor, which is used to handle computational operations related to machine learning.
[0085] The memory 1002 may include one or more computer-readable storage media, which may be non-transitory. The memory 1002 may also include high-speed random access memory and non-volatile memory, such as one or more disk storage devices or flash memory devices. In some embodiments, the non-transitory computer-readable storage media in the memory 1002 are used to store at least one piece of program code, which is executed by the processor 1001 to implement the log data generation method or log data display method provided in the method embodiments of this application.
[0086] In some embodiments, the terminal 1000 may also optionally include a peripheral device interface 1003 and at least one peripheral device. The processor 1001, memory 1002, and peripheral device interface 1003 can be connected via a bus or signal line. Each peripheral device can be connected to the peripheral device interface 1003 via a bus, signal line, or circuit board. Specifically, the peripheral device includes at least one of the following: a radio frequency circuit 1004, a display screen 1005, a camera assembly 1006, an audio circuit 1007, and a power supply 1009.
[0087] Peripheral device interface 1003 can be used to connect at least one I / O (Input / Output) related peripheral device to processor 1001 and memory 1002. In some embodiments, processor 1001, memory 1002 and peripheral device interface 1003 are integrated on the same chip or circuit board; in some other embodiments, any one or two of processor 1001, memory 1002 and peripheral device interface 1003 can be implemented on separate chips or circuit boards, which is not limited in this embodiment.
[0088] The radio frequency (RF) circuit 1004 is used to receive and transmit RF (Radio Frequency) signals, also known as electromagnetic signals. The RF circuit 1004 communicates with communication networks and other communication devices via electromagnetic signals. The RF circuit 1004 converts electrical signals into electromagnetic signals for transmission, or converts received electromagnetic signals back into electrical signals. Optionally, the RF circuit 1004 includes: an antenna system, an RF transceiver, one or more amplifiers, a tuner, an oscillator, a digital signal processor, a codec chipset, a user identity module card, etc. The RF circuit 1004 can communicate with other terminals via at least one wireless communication protocol. This wireless communication protocol includes, but is not limited to: metropolitan area networks (MANs), various generations of mobile communication networks (2G, 3G, 4G, and 5G), wireless local area networks (WLANs), and / or WiFi (Wireless Fidelity) networks. In some embodiments, the RF circuit 1004 may also include circuitry related to NFC (Near Field Communication), which is not limited in this application.
[0089] Display screen 1005 is used to display a UI (User Interface). This UI may include graphics, text, icons, videos, and any combination thereof. When display screen 1005 is a touch display screen, it also has the ability to collect touch signals on or above its surface. These touch signals can be input as control signals to processor 1001 for processing. In this case, display screen 1005 can also be used to provide virtual buttons and / or a virtual keyboard, also known as soft buttons and / or a soft keyboard. In some embodiments, there may be one display screen 1005, which serves as the front panel of terminal 1000; in other embodiments, there may be at least two display screens, respectively disposed on different surfaces of terminal 1000 or in a folded design; in some embodiments, display screen 1005 may be a flexible display screen, disposed on a curved or folded surface of terminal 1000. Furthermore, display screen 1005 may be configured as a non-rectangular irregular shape, i.e., a non-rectangular screen. Display screen 1005 may be made of materials such as LCD (Liquid Crystal Display) or OLED (Organic Light-Emitting Diode).
[0090] The camera assembly 1006 is used to acquire images or videos. Optionally, the camera assembly 1006 includes a front-facing camera and a rear-facing camera. Typically, the front-facing camera is located on the front panel of the terminal, and the rear-facing camera is located on the back of the terminal. In some embodiments, there are at least two rear-facing cameras, which are any one of a main camera, a depth-sensing camera, a wide-angle camera, and a telephoto camera, to achieve background blurring by fusion of the main camera and the depth-sensing camera, panoramic shooting by fusion of the main camera and the wide-angle camera, VR (Virtual Reality) shooting, or other fusion shooting functions. In some embodiments, the camera assembly 1006 may also include a flash. The flash can be a single-color temperature flash or a dual-color temperature flash. A dual-color temperature flash refers to a combination of a warm-light flash and a cool-light flash, which can be used for light compensation at different color temperatures.
[0091] The audio circuit 1007 may include a microphone and a speaker. The microphone is used to collect sound waves from the user and the environment, converting the sound waves into electrical signals that are input to the processor 1001 for processing, or input to the radio frequency circuit 1004 for voice communication. For stereo sound acquisition or noise reduction purposes, multiple microphones may be used, each positioned at a different location on the terminal 1000. The microphone may also be an array microphone or an omnidirectional microphone. The speaker is used to convert electrical signals from the processor 1001 or the radio frequency circuit 1004 into sound waves. The speaker may be a conventional diaphragm speaker or a piezoelectric ceramic speaker. When the speaker is a piezoelectric ceramic speaker, it can convert electrical signals not only into audible sound waves but also into inaudible sound waves for purposes such as distance measurement. In some embodiments, the audio circuit 1007 may also include a headphone jack.
[0092] The power supply 1009 is used to power the various components in the terminal 1000. The power supply 1009 can be AC power, DC power, a disposable battery, or a rechargeable battery. When the power supply 1009 includes a rechargeable battery, the rechargeable battery can support wired charging or wireless charging. The rechargeable battery can also be used to support fast charging technology.
[0093] In some embodiments, the terminal 1000 further includes one or more sensors 1010. The one or more sensors 1010 include, but are not limited to: an acceleration sensor 1011, a gyroscope sensor 1012, a pressure sensor 1013, an optical sensor 1015, and a proximity sensor 1016.
[0094] Accelerometer 1011 can detect the magnitude of acceleration along the three coordinate axes of a coordinate system established by terminal 1000. For example, accelerometer 1011 can be used to detect the components of gravitational acceleration along the three coordinate axes. Processor 1001 can control display screen 1005 to display the user interface in either a landscape or portrait view based on the gravitational acceleration signal acquired by accelerometer 1011. Accelerometer 1011 can also be used for games or for acquiring user motion data.
[0095] The gyroscope sensor 1012 can detect the orientation and rotation angle of the terminal 1000. The gyroscope sensor 1012, in conjunction with the accelerometer sensor 1011, can collect 3D motion data from the user on the terminal 1000. Based on the data collected by the gyroscope sensor 1012, the processor 1001 can perform the following functions: motion sensing (e.g., changing the UI based on the user's tilt), image stabilization during shooting, game control, and inertial navigation.
[0096] The pressure sensor 1013 can be disposed on the side bezel of the terminal 1000 and / or on the lower layer of the display screen 1005. When the pressure sensor 1013 is disposed on the side bezel of the terminal 1000, it can detect the user's grip signal on the terminal 1000, and the processor 1001 can perform left / right hand recognition or quick operation based on the grip signal collected by the pressure sensor 1013. When the pressure sensor 1013 is disposed on the lower layer of the display screen 1005, the processor 1001 can control the operable controls on the UI interface based on the user's pressure operation on the display screen 1005. The operable controls include at least one of button controls, scroll bar controls, icon controls, and menu controls.
[0097] An optical sensor 1015 is used to collect ambient light intensity. In one embodiment, the processor 1001 can control the display brightness of the display screen 1005 based on the ambient light intensity collected by the optical sensor 1015. Specifically, when the ambient light intensity is high, the display brightness of the display screen 1005 is increased; when the ambient light intensity is low, the display brightness of the display screen 1005 is decreased. In another embodiment, the processor 1001 can also dynamically adjust the shooting parameters of the camera assembly 1006 based on the ambient light intensity collected by the optical sensor 1015.
[0098] The proximity sensor 1016, also known as a distance sensor, is typically mounted on the front panel of the terminal 1000. The proximity sensor 1016 is used to detect the distance between the user and the front of the terminal 1000. In one embodiment, when the proximity sensor 1016 detects that the distance between the user and the front of the terminal 1000 is gradually decreasing, the processor 1001 controls the display screen 1005 to switch from a screen-on state to a screen-off state; when the proximity sensor 1016 detects that the distance between the user and the front of the terminal 1000 is gradually increasing, the processor 1001 controls the display screen 1005 to switch from a screen-off state to a screen-on state.
[0099] Those skilled in the art will understand that Figure 10 The structure shown does not constitute a limitation on terminal 1000 and may include more or fewer components than shown, or combine certain components, or use different component arrangements.
[0100] Figure 11This is a schematic diagram of a server structure provided in an embodiment of this application. The server 1100 can vary considerably due to different configurations or performance. It may include one or more Central Processing Units (CPUs) 1101 and one or more memories 1102. The one or more memories 1102 store at least one line of program code, which is loaded and executed by the one or more processors 1101 to implement the methods provided in the above-described method embodiments. Of course, the server 1100 may also have wired or wireless network interfaces, a keyboard, and input / output interfaces for input and output. The server 1100 may also include other components for implementing device functions, which will not be elaborated here.
[0101] In an exemplary embodiment, a computer-readable storage medium is also provided, such as a memory including at least one line of program code, which can be executed by a processor to complete the log data generation method or log data display method in the above embodiments. For example, the computer-readable storage medium may be a read-only memory (ROM), a random access memory (RAM), a compact disc read-only memory (CD-ROM), magnetic tape, floppy disk, and optical data storage device, etc.
[0102] Those skilled in the art will understand that all or part of the steps of the above embodiments can be implemented by hardware, or by a program with at least one piece of program code associated with the hardware. The program can be stored in a computer-readable storage medium, such as a read-only memory, a disk, or an optical disk.
[0103] The above are merely optional embodiments of this application and are not intended to limit this application. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the protection scope of this application.
Claims
1. A log data generation method characterized by comprising: The method includes: In response to the call instruction of the target function, the resource package to which the target function belongs is determined; based on the target function's function type and the target function itself, a target wrapper function corresponding to the target function is created and executed; the target wrapper function contains program code for generating log data, and the target wrapper function has the same type as the target function. In this context, each resource package corresponds to a proxy object constructed through a proxy. The proxy object includes at least one function wrapping logic for creating different types of wrapper functions. The number, type, and specific content of the function wrapping logic in each proxy object are determined based on the function call situation in each resource package. The resource package is a software development kit (SDK) that includes at least one application programming interface (API). When the API in the SDK is called, the SDK can create a wrapper function for the API. When the API includes a callback function, a wrapper function for the callback function is created through the wrapper function of the API. The wrapper function for the callback function can obtain the parameters of the callback function. A first function identifier is assigned to the target function; the first function identifier is generated by the target wrapper function and then assigned to the target function, or the first function identifier is generated by the terminal and then assigned to the target function by the target wrapper function; a new function identifier is assigned each time the function is called; the latest stored function identifier is obtained from the target data table and used as the second function identifier corresponding to the outer function that calls the target function; the target wrapper function generates log data of the target function based on the execution process of the target function, the first function identifier, and the second function identifier, with each log data carrying the first function identifier and the second function identifier; The method further includes: when calling an inner function of the target function through the target function, before the target function is executed, the first function identifier is stored in the target data table; when the target function is completed, the first function identifier is deleted from the target data table, so that the functions indicated by the function identifiers stored in the target data table are all the functions that are being executed; In response to a log data viewing command, the system retrieves the log data corresponding to each function. Based on the function identifier carried in the log data of any function, it determines the outer function of that function and associates the log data of the outer function with the log data of the function. When any function includes multiple inner functions, the system displays the log data of the multiple inner functions in the lower layer adjacent to the log data display area corresponding to the function, and displays a data hiding control in front of the log data display area corresponding to the function to control the hiding of the log data corresponding to the multiple inner functions.
2. The method according to claim 1, characterized in that, Assigning a first function identifier to the objective function includes: In response to the execution of the target wrapper function, the identifier generation function is called to generate the first function identifier; The first function identifier is assigned to the target function through the target wrapper function.
3. The method of claim 1, wherein, After generating log data for the target function based on the execution process of the target function, the first function identifier, and the second function identifier through the target wrapping function, the method further includes: The log data is cached; Determine the number of log entries currently cached in the device; If the number of records equals the target threshold, then all cached log data will be sent to the target server.
4. A log data display method characterized by comprising: The method includes: In response to a log data viewing command, log data corresponding to each function is obtained. The log data of any function is generated by the wrapper function corresponding to that function. The wrapper function contains program code for generating log data. The wrapper function is of the same type as the function. The log data of any function carries a function identifier. Based on the function identifier carried in the log data of any function, determine the outer function of any function, and associate the log data of the outer function with the log data of any function as related log data; When any function includes multiple inner functions, the log data of the multiple inner functions is displayed in the lower layer area adjacent to the log data display area corresponding to the function, and a data hiding control for controlling the hiding of the log data corresponding to the multiple inner functions is displayed in front of the log data display area corresponding to the function. The log data for the objective function is obtained based on a log generation process, which includes: In response to the call instruction of the target function, determine the resource package to which the target function belongs; Based on the target function's function type and the target function itself, a target wrapper function is created and executed; the target wrapper function has the same type as the target function. In this context, each resource package corresponds to a proxy object constructed through a proxy. The proxy object includes at least one function wrapping logic for creating different types of wrapper functions. The number, type, and specific content of the function wrapping logic in each proxy object are determined based on the function call situation in each resource package. The resource package is a software development kit (SDK) that includes at least one application programming interface (API). When the API in the SDK is called, the SDK can create a wrapper function for the API. When the API includes a callback function, a wrapper function for the callback function is created through the wrapper function of the API. The wrapper function for the callback function can obtain the parameters of the callback function. A first function identifier is assigned to the target function; the first function identifier is generated by the target wrapper function and then assigned to the target function, or the first function identifier is generated by the terminal and then assigned to the target function by the target wrapper function; a new function identifier is assigned each time the function is called; the latest stored function identifier is obtained from the target data table and used as the second function identifier corresponding to the outer function that calls the target function; the target wrapper function generates log data of the target function based on the execution process of the target function, the first function identifier, and the second function identifier, with each log data carrying the first function identifier and the second function identifier.
5. A log data generating apparatus characterized by comprising: The device includes: Function creation module, used for: In response to the call instruction of the target function, the resource package to which the target function belongs is determined; based on the target function's function type and the target function itself, a target wrapper function corresponding to the target function is created and executed; the target wrapper function contains program code for generating log data, and the target wrapper function has the same type as the target function. In this context, each resource package corresponds to a proxy object constructed through a proxy. The proxy object includes at least one function wrapping logic for creating different types of wrapper functions. The number, type, and specific content of the function wrapping logic in each proxy object are determined based on the function call situation in each resource package. The resource package is a software development kit (SDK) that includes at least one application programming interface (API). When the API in the SDK is called, the SDK can create a wrapper function for the API. When the API includes a callback function, a wrapper function for the callback function is created through the wrapper function of the API. The wrapper function for the callback function can obtain the parameters of the callback function. The allocation module is used to allocate a first function identifier to the target function; the first function identifier is generated by the target wrapper function and then allocated to the target function, or the first function identifier is generated by the terminal and then allocated to the target function by the target wrapper function; a new function identifier is allocated each time the function is called; The identifier determination module is used to obtain the latest stored function identifier from the target data table, and use it as the second function identifier corresponding to the outer function that calls the target function; The generation module is used to generate log data of the target function based on the execution process of the target function, the first function identifier, and the second function identifier through the target wrapping function, wherein each log data carries the first function identifier and the second function identifier; The apparatus further includes: when calling an inner function of the target function through the target function, before the target function is executed, the first function identifier is stored in the target data table; when the target function is completed, the first function identifier is deleted from the target data table, so that the functions indicated by the function identifiers stored in the target data table are all functions that are currently being executed; The device further includes: The log acquisition module is used to retrieve the log data corresponding to each function in response to log data viewing commands; The association determination module is used to determine the outer function of any function based on the function identifier carried in the log data of any function, and to regard the log data of the outer function and the log data of the any function as associated log data. The display module is used to display the log data of the multiple inner functions in a lower area adjacent to the log data display area corresponding to the function when any function includes multiple inner functions, and to display a data hiding control in front of the log data display area corresponding to the function to control the hiding of the log data corresponding to the multiple inner functions.
6. The apparatus of claim 5, wherein, The allocation module is used for: In response to the execution of the target wrapper function, the identifier generation function is called to generate the first function identifier; The first function identifier is assigned to the target function through the target wrapper function.
7. The apparatus of claim 5, wherein, The device further includes: A caching module is used to cache the log data; The sending module is used to determine the number of log data entries cached in the current device; if the number of entries is equal to the target threshold, then each cached log data entry is sent to the target server.
8. A log data display device characterized by comprising: The device includes: The log acquisition module is used to acquire log data corresponding to each function in response to a log data viewing command. The log data of any function is generated by the wrapper function corresponding to the function. The wrapper function contains program code for generating log data. The wrapper function is of the same type as the function. The log data of any function carries a function identifier. The association determination module is used to determine the outer function of any function based on the function identifier carried in the log data of any function, and to regard the log data of the outer function and the log data of the any function as associated log data. The display module is used to display the log data of the multiple inner functions in a lower area adjacent to the log data display area corresponding to the function when any function includes multiple inner functions, and to display a data hiding control in front of the log data display area corresponding to the function to control the hiding of the log data corresponding to the multiple inner functions. The log data for the objective function is obtained based on a log generation process, which includes: In response to the call instruction of the target function, determine the resource package to which the target function belongs; Based on the target function's function type and the target function itself, a target wrapper function is created and executed; the target wrapper function has the same type as the target function. In this context, each resource package corresponds to a proxy object constructed through a proxy. The proxy object includes at least one function wrapping logic for creating different types of wrapper functions. The number, type, and specific content of the function wrapping logic in each proxy object are determined based on the function call situation in each resource package. The resource package is a software development kit (SDK) that includes at least one application programming interface (API). When the API in the SDK is called, the SDK can create a wrapper function for the API. When the API includes a callback function, a wrapper function for the callback function is created through the wrapper function of the API. The wrapper function for the callback function can obtain the parameters of the callback function. A first function identifier is assigned to the target function; the first function identifier is generated by the target wrapper function and then assigned to the target function, or the first function identifier is generated by the terminal and then assigned to the target function by the target wrapper function; a new function identifier is assigned each time the function is called; the latest stored function identifier is obtained from the target data table and used as the second function identifier corresponding to the outer function that calls the target function; the target wrapper function generates log data of the target function based on the execution process of the target function, the first function identifier, and the second function identifier, with each log data carrying the first function identifier and the second function identifier.
9. A computer device, comprising: The computer device includes one or more processors and one or more memories, wherein at least one piece of program code is stored in the one or more memories, and the at least one piece of program code is loaded and executed by the one or more processors to perform the operations performed by the log data generation method as described in any one of claims 1 to 3; or the operations performed by the log data display method as described in claim 4.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores at least one piece of program code, which is loaded and executed by a processor to perform the operations performed by the log data generation method as described in any one of claims 1 to 3; or the operations performed by the log data display method as described in claim 4.