Log collection method, system, electronic device, storage medium and vehicle
Through the automated listening mechanism and log collection system, the errors and insufficient coverage of manual log collection are solved, efficient and accurate logging is achieved, and development efficiency is improved and costs are reduced.
Patent Information
- Application Number
- PCT/CN2024/125118
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2024-01-25
- Filing Date
- 2024-10-16
- Publication Date
- 2025-07-31
AI Technical Summary
In the prior art, manual code writing of log collection is prone to errors, insufficient coverage, and large workload, resulting in inaccurate logging and low development efficiency.
Through an automated listening mechanism, iterates over the code file and interface elements, generates unique parameter information, and stores and uploads the log when the monitoring event is triggered. Use Android Studio's transform API and Javaassist to insert the reporting log code, use SQLite database to store log information, and filter and upload according to log collection instructions.
It realizes fast and accurate logging, improves log coverage and accuracy, reduces manual intervention and workload, improves development efficiency and reduces development costs.
Smart Images

Figure CN2024125118_31072025_PF_FP_ABST
Abstract
Description
Log collection method, system, electronic device, storage medium and vehicle Technical Field
[0001] The present invention relates to the field of vehicle technology, and in particular to a log collection method, system, electronic equipment, storage medium and vehicle. Background Art
[0002] Currently, existing log collection and tracking technologies are typically performed manually. Specifically, developers need to manually write code to set logging points at key locations in the application to record critical information while the application is running. However, this manual approach has many pain points.
[0003] First, manually writing code is error-prone. Since developers are required to write the code themselves, errors or omissions in the code can lead to inaccurate or incomplete log records, which can affect subsequent data analysis and problem location.
[0004] Second, manual logging methods lack comprehensive coverage. Since developers cannot foresee all logging requirements, they may miss key logging points. This can prevent important application behaviors from being recorded, hindering a comprehensive understanding of application performance and behavior.
[0005] Furthermore, manual logging is labor-intensive and wastes manpower. The need to set up logging points at multiple key locations in the application requires developers to spend considerable time and effort on code writing and testing. This not only increases development costs but also reduces efficiency.
[0006] Therefore, the present application provides a log collection method to solve the above technical problems.
[0007] Summary of the Invention
[0008] The object of the present invention is to provide a log collection method, system, electronic device, storage medium and vehicle that can solve at least one of the technical problems mentioned above.
[0009] In order to solve the above technical problems, the present invention provides a log collection method, comprising:
[0010] In response to an application startup signal, traverse the code file information of the application and assign a monitoring mechanism to the code file information, wherein the monitoring mechanism is assigned accordingly according to a defined monitoring event;
[0011] Based on the interface information of the application, a control tree of the corresponding interface is generated, corresponding unique parameter information is generated for each interface element in each control tree, and each unique parameter information is bound to the corresponding code file information;
[0012] In response to the triggering of the monitoring event, based on the monitoring mechanism, the corresponding code file information, the unique parameter information and the corresponding interface information are stored in a corresponding log;
[0013] In response to the log collection instruction, the logs are traversed and the logs matching the log collection instruction are uploaded.
[0014] In some specific embodiments, in response to an application startup signal, code file information of the application is traversed and a monitoring mechanism is assigned to the code file information, wherein the monitoring mechanism is assigned accordingly according to a defined monitoring event, specifically including:
[0015] Based on the transform API in the Android Studio packaging process, traverse the code file information of the application;
[0016] Based on the monitoring mechanism, according to the defined monitoring events, in the corresponding code file information, the reporting log code is inserted according to JavaAssist;
[0017] Wherein, according to the reported log code, a monitoring mechanism is assigned to the code file information.
[0018] In some specific embodiments, based on the interface information of the application, a control tree of the corresponding interface is generated, corresponding unique parameter information is generated for each interface element in each control tree, and each unique parameter information is bound to the corresponding code file information, specifically including:
[0019] Based on each view in the interface information, construct a viewtree;
[0020] The vertical hierarchical depth of the view in the viewtree is used as the y coordinate, and according to the horizontal hierarchical relationship of the view, the position of the view in the horizontal hierarchical relationship is used as the x coordinate;
[0021] Using the x coordinate and the y coordinate of each view as the unique parameter information of each interface element, and binding the x and y coordinates of the view with the corresponding code file information;
[0022] When the view is a reused view, the absolute position of the view is used as the x-coordinate; when the view is not a reused view, the class name and relative position of the view are used as the x-coordinate.
[0023] In some specific embodiments, the method further comprises:
[0024] Based on the x and y coordinates of each view, the corresponding interface layout is obtained. When the x and y coordinates of the view are uploaded, the activity or fragment corresponding to the x and y coordinates of the view is uploaded.
[0025] In some specific embodiments, in response to the triggering of the monitoring event, based on the monitoring mechanism, the corresponding code file information, the unique parameter information, and the corresponding interface information are stored in the corresponding log, specifically including:
[0026] When the monitoring event is triggered, according to the monitoring mechanism, the log corresponding to the code file information, the unique parameter information and the corresponding interface information is stored through SQLite;
[0027] The monitoring events include interactive events of the interface, the monitoring mechanism is used to monitor the interactive events of the interface, and the log also includes the type, time and number of corresponding interactive events.
[0028] In some specific embodiments, in response to a log collection instruction, traversing the logs and uploading the logs matching the log collection instruction specifically includes:
[0029] According to the log collection instruction, obtain the view corresponding to the log collection instruction;
[0030] Based on the x and y coordinates of the view, the logs stored in the SQLite are traversed, and the logs matching the x and y coordinates of the view are extracted for uploading.
[0031] Based on the same concept, the present invention also provides a log collection system, including:
[0032] a monitoring mechanism assigning module configured to, in response to an application startup signal, traverse the code file information of the application and assign a monitoring mechanism to the code file information, wherein the monitoring mechanism is assigned accordingly according to a defined monitoring event;
[0033] a unique parameter information binding module configured to generate a control tree of the corresponding interface based on the interface information of the application, generate corresponding unique parameter information for each interface element in each control tree, and bind each unique parameter information with the corresponding code file information;
[0034] A log storage module is configured to, in response to the triggering of the monitoring event, store the corresponding code file information, the unique parameter information and the corresponding interface information in a corresponding log based on the monitoring mechanism;
[0035] The log collection module is configured to traverse the logs in response to the log collection instruction and upload the logs that match the log collection instruction.
[0036] Based on the same concept, the present invention also provides an electronic device, comprising: a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus; a computer program is stored in the memory, and when the computer program is executed by the processor, the processor executes the steps of the log collection method.
[0037] Based on the same concept, the present invention also provides a computer-readable storage medium storing a computer program executable by an electronic device. When the computer program runs on the electronic device, the electronic device executes the steps of the log collection method.
[0038] Based on the same concept, the present invention also provides a vehicle, which is provided with the log collection system as described above.
[0039] Compared with the prior art, the beneficial effects are:
[0040] The present invention discloses a log collection method, system, electronic device, storage medium and vehicle, which can automatically collect logs, realize fast and accurate log recording, improve log coverage and accuracy, reduce manual intervention and workload, thereby improving development efficiency and reducing development costs. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] FIG1 is a flow chart of a log collection method according to some specific embodiments of the present invention;
[0042] FIG2 is a flow chart of a log collection method of the present invention in some applications;
[0043] FIG3 is a schematic structural diagram of a log collection system in some specific embodiments of the present invention;
[0044] FIG4 is a schematic structural diagram of an electronic device according to some specific embodiments of the present invention. DETAILED DESCRIPTION
[0045] To make the objectives, technical solutions, and advantages of this application more clear, this application will be further described in detail below with reference to the accompanying drawings. Obviously, the embodiments described are only some of the embodiments of this application, not all of them. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making any creative efforts are within the scope of protection of this application.
[0046] The terms used in the examples of this application are for the purpose of describing specific embodiments only and are not intended to limit this application. The singular forms "a," "the," and "the" used in the examples of this application and the appended claims are also intended to include plural forms, and unless the context clearly indicates otherwise, "a plurality" generally includes at least two.
[0047] It should be understood that the term "and / or" as used herein is merely a description of the relationship between associated objects, indicating that three possible relationships exist. For example, "A and / or B" can represent: A exists alone, A and B exist simultaneously, or B exists alone. Furthermore, the character " / " in this document generally indicates that the associated objects are in an "or" relationship.
[0048] It should be understood that although the terms first, second, third, etc. may be used to describe in the embodiments of the present application, these descriptions should not be limited to these terms. These terms are only used to distinguish the descriptions. For example, without departing from the scope of the embodiments of the present application, the first may also be referred to as the second, and similarly, the second may also be referred to as the first.
[0049] As used herein, the words "if" and "if" may be interpreted as "at the time of" or "when" or "in response to determining" or "in response to detecting," depending on the context. Similarly, the phrases "if it is determined" or "if (stated condition or event) is detected" may be interpreted as "when it is determined" or "in response to the determination" or "when detecting (stated condition or event)" or "in response to detecting (stated condition or event)," depending on the context.
[0050] It should also be noted that the terms "include," "comprises," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a product or device comprising a series of elements includes not only those elements but also other elements not explicitly listed, or elements inherent to such product or device. In the absence of further limitations, an element defined by the phrase "comprises a..." does not exclude the presence of other identical elements in the product or device comprising the element.
[0051] It should be noted in particular that any symbols and / or numbers in the specification that are not marked in the accompanying drawings are not drawing marks.
[0052] Referring to FIG1 , a log collection method includes:
[0053] S101, in response to an application start signal, traverse code file information of the application and assign a monitoring mechanism to the code file information, wherein the monitoring mechanism is assigned accordingly according to a defined monitoring event;
[0054] It is understandable that in this step, all code files of the application are traversed through the defined automation tool to obtain information about these code files. This file information includes file path, file content, and dependencies between files, etc. A monitoring mechanism is assigned to the code file information. The function of this monitoring mechanism is to monitor monitoring events defined in the code file. In order to enable the monitoring mechanism to work more effectively, events that need to be monitored are defined based on the actual needs and operating environment of the application. These events include function calls, exceptions thrown, variables modified, etc. When the monitoring mechanism detects the occurrence of a defined event, it immediately triggers the corresponding logging operation and records detailed log information, so that the application's log information can be recorded quickly and accurately, and the coverage of the log can be greatly improved, reducing manual intervention and workload, thereby improving development efficiency and reducing development costs.
[0055] In some applications, in order to accurately assign a monitoring mechanism to the code file information, in response to the application startup signal, the code file information of the application is traversed and the monitoring mechanism is assigned to the code file information. The monitoring mechanism is assigned accordingly based on the defined monitoring events. Based on the transform API in the Android Studio packaging process, the code file information of the application is traversed; based on the monitoring mechanism, according to the defined monitoring events, the reporting log code is inserted into the corresponding code file information according to JavaAssist; and based on the reported log code, the monitoring mechanism is assigned to the code file information;
[0056] As you can understand, in this application, the Transform API is used during the Android Studio packaging process to traverse the application's code file information. The Transform API is a set of plug-in APIs provided by Android Studio that modify and transform projects during the build process. This API traverses all of the application's code files and obtains information about these files. Based on this code file information, a monitoring mechanism is assigned. Log reporting code is inserted into the corresponding code file information using the JavaAssist library. JavaAssist is an open-source library for analyzing, editing, and creating Java bytecode. With JavaAssist, we can dynamically modify Java bytecode to implement code-level tracking and reporting. Based on defined monitoring events, logging code is inserted into the corresponding code file information. This code automatically logs when an event occurs and sends the log information to a designated server. Based on the reported log code, a monitoring mechanism is assigned to the code file information. When an event occurs, the monitoring mechanism automatically triggers the corresponding logging operation, achieving automated log collection and tracking.
[0057] S102, based on the interface information of the application, generating a control tree of the corresponding interface, generating corresponding unique parameter information for each interface element in each control tree, and binding each unique parameter information with the corresponding code file information;
[0058] As you can understand, in this step, a corresponding control tree is generated based on the application's interface information. A control tree is a data structure used to describe the interface hierarchy, with each control being a node in the tree. Using the control tree, we can easily traverse and manipulate interface elements. For each interface element in the control tree, corresponding unique parameter information is generated. This unique parameter information is used to uniquely identify each interface element, enabling accurate identification and location of the element in subsequent log records. This unique parameter information is then bound to the corresponding code file information. Each interface element is associated with its implementation in the code, enabling tracking of the specific code location and logic in subsequent log records. This establishes a correlation between interface elements and code file information. When the application triggers logging, specific interface elements and code locations can be quickly located, yielding detailed log information. This correlation not only improves log accuracy and readability, but also provides powerful support for subsequent problem location and troubleshooting. By analyzing log information, developers can quickly locate the interface element and code location where the problem occurs, thereby improving development efficiency and speeding up problem resolution.
[0059] In some applications, in order to accurately obtain the unique parameter information of each element in the interface, a control tree of the corresponding interface is generated based on the interface information of the application, corresponding unique parameter information is generated for each interface element in each control tree, each unique parameter information is bound to the corresponding code file information, and a viewtree is constructed based on each view in each interface information; the vertical hierarchical depth of the view in the viewtree is used as the y coordinate, and according to the horizontal hierarchical relationship of the view, the position of the view in the horizontal hierarchical relationship is used as the x coordinate; the x coordinate and y coordinate of each view are used as the unique parameter information of each interface element, and the x and y coordinates of the view are bound to the corresponding code file information; when the view is a reused view, the absolute position of the view is used as the x coordinate, and when the view is not a reused view, the class name and relative position of the view are used as the x coordinate;
[0060] As you can understand, in this application, a ViewTree is constructed based on each View in the application's various interface information. The ViewTree is a data structure used to describe the hierarchical structure of Views in an interface, with each View being a node in the ViewTree. The vertical depth of each View in the ViewTree is used as the Y coordinate, allowing each View to be located on the Y axis based on the View's hierarchical relationship. The horizontal position of each View in the View's hierarchy is used as the X coordinate, allowing each View to be located on the X axis based on the View's horizontal position. Each View's X and Y coordinates serve as the unique parameter information for that interface element. This unique parameter information uniquely identifies each View, enabling accurate identification and location of the View in subsequent logging. This unique parameter information is bound to the corresponding code file information. This means that each interface element is associated with its implementation in the code, allowing subsequent logging to track the specific code location and logic. If a View is reused, the View's absolute position is used as the X coordinate. This ensures that views reused in multiple locations can be correctly identified and located. If a View is not reused, its class name and relative position are used as the X coordinate. This ensures that each non-reused View can be accurately identified and located. This application establishes an association between interface elements and code file information. When the application triggers logging, the specific interface element and code location can be quickly located to obtain detailed log information.
[0061] Furthermore, in this application, in order to accurately position the view, the corresponding interface layout is obtained based on the x and y coordinates of each view. When uploading the x and y coordinates of the view, the activity or fragment corresponding to the x and y coordinates of the view is uploaded;
[0062] As you can understand, this application retrieves the corresponding interface layout information based on the X and Y coordinates of each View. Interface layout information describes the position and size of a View on the interface, as well as the hierarchical relationship between Views. When uploading the X and Y coordinates of a View, the corresponding activity or fragment information is also uploaded. Activities and fragments are important components in Android applications, each representing an independent function or part of the application. By associating activity or fragment information with View coordinates, you can better understand the purpose and functionality of interface elements. Programmatically retrieve the coordinates of the current View during runtime, for example by listening for layout change events or periodically obtaining the coordinates of the current View. Once the View's X and Y coordinates are obtained, they are associated with the corresponding activity or fragment information. This can be achieved by appending the activity or fragment identifier to the coordinate information. This application establishes an association between View coordinates and activities or fragments. This allows you to quickly locate specific interface elements and their corresponding activities or fragments during subsequent log analysis and problem troubleshooting, thereby better understanding user actions and application behavior.
[0063] S103, in response to the triggering of the monitoring event, based on the monitoring mechanism, storing the corresponding code file information, the unique parameter information, and the corresponding interface information in a corresponding log;
[0064] It is understood that in this step, when a monitoring event is triggered, the monitoring mechanism responds to the event and, based on the nature and content of the event, stores the relevant code file information, unique parameter information, and corresponding interface information in the corresponding log. When a monitoring event occurs, the monitoring mechanism captures the event and obtains the code file information, unique parameter information, and interface information related to the event. This information includes the code file path, file content, coordinate positions of interface elements, and interface layout. The monitoring mechanism then stores this information in the corresponding log. This log can be a file, database, or cloud storage, used to store application operation logs for a long time. When storing the log, each log entry is assigned a unique identifier to facilitate subsequent query and analysis. The log entry creation time and event type are also recorded to better understand the application's operating status and the circumstances under which problems occurred. Through this application, the application's operating status and event responses can be stored in a structured log. During subsequent troubleshooting and performance optimization, these logs can be quickly queried and analyzed to obtain detailed operating information and problem clues. This not only improves the efficiency and accuracy of problem location but also provides strong data support for application performance optimization and improvement. By analyzing log information, developers can better understand user behavior and application operation, and thus make targeted optimizations and improvements.
[0065] In some applications, in order to store log content, in response to the triggering of a monitoring event, based on a monitoring mechanism, corresponding code file information, unique parameter information, and corresponding interface information are stored in the corresponding log. When a monitoring event is triggered, the monitoring mechanism stores the log corresponding to the code file information, unique parameter information, and corresponding interface information through SQLite. The monitoring event includes an interface interaction event. The monitoring mechanism is used to monitor the interface interaction event. The log also includes the type, time, and number of the corresponding interaction event.
[0066] As you can understand, this application uses a SQLite database to store logs related to code file information, unique parameter information, and corresponding interface information. When a monitoring event is triggered, the monitoring mechanism captures the event and obtains the relevant code file information, unique parameter information, and interface information. This information includes the code file path, file content, coordinate positions of interface elements, and interface layout. The monitoring mechanism then associates this information with the corresponding log entry and stores it in the SQLite database. Each log entry contains information such as the event type, event time, and event count, facilitating subsequent querying and analysis. A table is created in the SQLite database to store the log entries. This table contains the following columns: event type, event time, event count, code file path, unique parameter information, and interface layout. This application allows for structured storage of application operation status and event responses in the SQLite database. For subsequent troubleshooting and performance optimization, these logs can be quickly queried and analyzed to obtain detailed operation information and problem clues.
[0067] S104 , in response to the log collection instruction, traverse the logs and upload the logs that match the log collection instruction.
[0068] As you can understand, in this step, when a log collection instruction is received, all stored logs are traversed and those matching the instruction are uploaded. The specific requirements of the log collection instruction are first checked, such as the log types to be collected, logs within a specific time period, or logs related to specific events. The stored logs are then traversed and those that meet the requirements are filtered out according to the instruction. These logs may include application operation logs, user behavior logs, error logs, etc., depending on the specific requirements of the instruction. The filtered logs are then packaged and compressed for easier transmission and storage. The packaging and compression process removes duplicate and unnecessary log information, reducing the amount of data transmitted. Finally, the packaged logs are uploaded to a designated server or cloud storage platform via the network. The upload process can use protocols such as FTP, HTTP, and SFTP, depending on the server configuration and requirements. During the upload process, the system also records information such as the upload time and uploaded file size for subsequent auditing and monitoring. The system also checks whether the upload is successful and, if it fails, retries or performs appropriate error handling. This application enables rapid log collection, packaging, compression, and upload, improving the efficiency and accuracy of log management. At the same time, it can also filter out qualified logs according to the specific requirements of the instructions, providing strong data support for subsequent problem troubleshooting and performance optimization.
[0069] In some applications, to accurately collect the required logs, in response to log collection instructions, the logs are traversed and the logs matching the log collection instructions are uploaded. Based on the log collection instructions, the view corresponding to the log collection instructions is obtained. Based on the x and y coordinates of the view, the logs stored in SQLite are traversed and the logs matching the x and y coordinates of the view are extracted and uploaded.
[0070] As you can understand, in this application, when a log collection instruction is received, the system retrieves the corresponding View according to the instruction. Based on the View's X and Y coordinates, it traverses the logs stored in the SQLite database, extracting and uploading logs that match the View's coordinates. First, the log collection instruction is parsed to identify the View's identifier or condition to be collected. This identifier or condition can be the View's class name, ID, or other unique identifier, used to locate the specific View within the application. The application's interface layout is then searched for a View that matches the identifier or condition specified in the instruction. If a matching View is found, the View's X and Y coordinates are retrieved. These coordinates can include the View's position and size on the interface, or its offset relative to the parent container or screen. Next, based on the obtained View's X and Y coordinates, the logs stored in the SQLite database are traversed. This traversal process is achieved by executing a corresponding SQL query statement. The query statement can filter out matching log entries based on conditions such as the X and Y coordinate range and timestamp. During the traversal process, logs matching the View's X and Y coordinates are extracted and formatted as necessary. If necessary, these logs can also be associated and integrated with the corresponding code file information, event type, etc. Finally, the extracted and processed logs are uploaded to the designated server or cloud storage platform through an appropriate protocol (such as FTP, HTTP, etc.).
[0071] The above steps can automate log collection, achieve fast and accurate logging, improve log coverage and accuracy, reduce manual intervention and workload, thereby improving development efficiency and reducing development costs.
[0072] The following describes an embodiment of a log collection method of the present invention in some applications with reference to FIG2 :
[0073] Existing methods for collecting page usage behavior data, specifically page component lifecycle statistics, suffer from the following drawbacks: They require writing tracking statistics code for each page component, resulting in significant duplication and inefficiency, and prone to omissions and errors. This tracking statistics code is a section of code written somewhere during program execution that sends a network request containing raw information such as the event name, timestamp, and device to the server. The server then stores this raw information for subsequent data calculations.
[0074] As shown in Figure 2, this embodiment is non-invasive and imperceptible to the programmer writing the source code. Software logic is implemented through the packaging process. First, a plug-in is written to automatically collect logs. This plug-in utilizes the Transform API in the Android Studio packaging process. This API traverses all code files, adds a monitoring event (such as onclick) to the log in each code file through a monitoring mechanism, and uses JavaAssist to automatically insert a line of code to report the log. This completes the code insertion process.
[0075] After inserting this code, a control tree is generated for the entire interface, and unique parameter information is generated for each interface element.
[0076] Each view is a child view under the viewtree, so it has a vertical hierarchical depth, which we call the y-coordinate. For example, the login button on the login interface has a parent view of relativelayout, and the parent view of relativelayout is framelayout. Its vertical hierarchy is framelayout-relativelayout-button. View also has a property of horizontal hierarchical relationship. For example, the login button mentioned earlier has two buttons under its parent view, relativelayout, and it is the first of the two buttons. Its horizontal coordinate is button0. The horizontal hierarchical relationship indicates the number of subviews of the same type in the same parent view. For non-reused views, our x-coordinate consists of the view class name and relative position. For reused views, our x-coordinate consists of its absolute position. The case of fragments is the most special, and the fragment class name represents the fragment. When ViewPager embeds a fragment, the class name of the fragment instance is used to replace the fragment in the View Path, and the index value is added to the x-coordinate. With x and y coordinates for view events, we can match reported events to elements on the interface, making the collected logs meaningful.
[0077] In layouts, not only the x and y coordinates are reported, but also the activity or fragment where the event occurred, making it easier to locate. For dynamically changing layouts such as RecyclerView and ListView, the x coordinate is handled by the order in the list. For additional data, setTag is used to set a predetermined key for collection. When the log is needed, getTag is used to retrieve the data using the predetermined key and report it.
[0078] In this embodiment, SQLite is used locally to store data. The key is the coordinates of the view, and the value is the type, time, and number of events that occurred. When the user encounters a view that interests him or her, he or she finds the corresponding view, clicks on the view, selects the type of event to be monitored, sends the data, finds the corresponding coordinates of the view, and sends the coordinates through the background. When the application is started, a list of view coordinates will be pulled from the background and matched with the data stored in SQLite. After matching, the log will be uploaded to the user interface to facilitate user analysis. Through this embodiment, we do not need to manually write reporting codes for each view's interactive events, freeing up manpower, and this embodiment will report each view's interactive events, avoiding manual errors.
[0079] The following application scenario illustrates this. While writing code, Programmer A connects to the aforementioned plugin in Android Studio. When they click Package, the plugin automatically adds monitoring code to the generated APK, enabling it to automatically monitor interactive events. Once the programmer has packaged and generated the APK, they publish it to various app stores. Once users download and run it, this mechanism automatically runs, collecting user clicks and views in a local database. To investigate the click-through rate of a specific interface, they circle the desired view in the visualization interface. The backend then sends a command to the mobile APK. When the APK is launched again, it retrieves the view's coordinates, matches them to local data, and uploads the matched data to the backend operations analysis interface for shared operations analysis.
[0080] In summary, this embodiment first generates a plug-in program, and the plug-in program uses the transform hook system to insert the apk code and integrate it with the original program. In this way, each interactive event has a mechanism for uploading code. When the interaction occurs, the x, y coordinates generated by the interactive event will be automatically analyzed to generate unique parameter information, and the page information will be included. The log generated in this way will be saved in the local data cache pool. After the background sends the corresponding coordinates that need to be reported, the log will be automatically uploaded after the app is started to facilitate analysis, solving the problem of manual point tracking that is prone to errors. All component pages are uniformly taken over at the system level, and the statistical interface is exposed to developers, so that there is no need to write point tracking statistical code for each page component, reducing duplication of work, avoiding omissions and errors, greatly improving development efficiency, and there will be no problem of pollution to the project code.
[0081] By applying this embodiment, this plug-in is used in the packaging process of each car computer application, and then each car computer application will automatically write the code for reporting logs. When it is necessary to analyze the interaction of a certain interface, the coordinates can be sent and then the logs can be uploaded for analysis.
[0082] In this embodiment, by automatically inserting the reported code and generating corresponding coordinates, the log can be automatically reported and corresponded to the elements on the interface for easy analysis.
[0083] For the method steps disclosed in the above embodiments, for the purpose of simple description, the method steps are expressed as a series of action combinations. However, those skilled in the art should be aware that the embodiments of the present invention are not limited by the order of the actions described, because according to the embodiments of the present invention, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions involved are not necessarily required by the embodiments of the present invention.
[0084] As shown in FIG3 , the present invention further provides a log collection system, comprising:
[0085] The monitoring mechanism assigning module 201 is configured to, in response to an application startup signal, traverse the code file information of the application and assign a monitoring mechanism to the code file information, wherein the monitoring mechanism is assigned accordingly according to a defined monitoring event;
[0086] The unique parameter information binding module 202 is configured to generate a control tree of the corresponding interface based on the interface information of the application, generate corresponding unique parameter information for each interface element in each control tree, and bind each unique parameter information with the corresponding code file information;
[0087] The log storage module 203 is configured to store the corresponding code file information, the unique parameter information and the corresponding interface information in a corresponding log based on the monitoring mechanism in response to the triggering of the monitoring event;
[0088] The log collection module 204 is configured to traverse the logs in response to the log collection instruction and upload the logs that match the log collection instruction.
[0089] It is worth noting that although only some basic functional modules are disclosed in the embodiment of the present invention, it does not mean that the composition of the present system is limited to the above basic functional modules. On the contrary, what this embodiment wants to express is that on the basis of the above basic functional modules, those skilled in the art can arbitrarily add one or more functional modules in combination with the existing technology to form an infinite number of embodiments or technical solutions. In other words, this system is open rather than closed. Just because this embodiment only discloses individual basic functional modules, it cannot be considered that the scope of protection of the claims of the present invention is limited to the disclosed basic functional modules. At the same time, for the convenience of description, the above devices are described in terms of functions, which are divided into various units and modules. Of course, when implementing the present invention, the functions of each unit and module can be implemented in the same or one or more software and / or hardware.
[0090] As shown in Figure 4, the present invention also provides an electronic device, including: a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the communication bus; a computer program is stored in the memory, and when the computer program is executed by the processor, the processor executes the steps of the log collection method.
[0091] Figure 4 is a schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. As shown in Figure 4, the electronic device provided by an embodiment of the present invention includes: one or more processors 710 and a storage device 720. The electronic device may have one or more processors 710, and Figure 4 uses one processor 710 as an example. The storage device 720 is used to store one or more programs. The one or more programs are executed by the one or more processors 710, so that the one or more processors 710 implement the log collection method described in any of the embodiments of the present invention.
[0092] The electronic device may further include an input device 730 and an output device 740 .
[0093] The processor 710 , storage device 720 , input device 730 and output device 740 in the electronic device may be connected via a bus or other means. FIG4 takes the bus connection as an example.
[0094] The storage device 720 in the electronic device serves as a computer-readable storage medium and can be used to store one or more programs, which may be software programs, computer executable programs, and modules, such as the program instructions / modules corresponding to the log collection method provided in the embodiments of the present invention. The processor 710 executes the software programs, instructions, and modules stored in the storage device 720 to execute various functional applications and data processing of the electronic device, thereby implementing the log collection method in the above-mentioned method embodiment.
[0095] The storage device 720 may include a program storage area and a data storage area, wherein the program storage area may store an operating system and application programs required for at least one function; the data storage area may store data created based on the use of the electronic device, etc. In addition, the storage device 720 may include a high-speed random access memory and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other non-volatile solid-state storage device. In some instances, the storage device 720 may further include a memory remotely located relative to the processor 710, and these remote memories may be connected to the device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0096] The input device 730 may be used to receive input digital or character information and generate key signal input related to user settings and function control of the electronic device. The output device 740 may include a display device such as a display screen.
[0097] The present invention also provides a computer-readable storage medium storing a computer program executable by an electronic device. When the computer program runs on the electronic device, the electronic device executes the steps of the log collection method.
[0098] Specifically, the computer storage medium of the embodiment of the present invention can adopt any combination of one or more computer-readable media. The computer-readable medium can be a computer-readable signal medium or a computer-readable storage medium. The computer-readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or component, or any combination of the above. More specific examples of computer-readable storage media (a non-exhaustive list) include: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this embodiment, the computer-readable storage medium can be any tangible medium that contains or stores a program, which can be used by or in combination with an instruction execution system, device or device.
[0099] The present invention also provides a vehicle, wherein the vehicle is provided with the log collection system as described above.
[0100] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the above embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the above embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.
Claims
1. A log collection method, characterized in that, Including: In response to an application startup signal, traverse the code file information of the application and assign a monitoring mechanism to the code file information, where the monitoring mechanism is assigned accordingly according to defined monitoring events; Based on the interface information of each interface of the application, generate a control tree for the corresponding interface, generate corresponding unique parameter information for each interface element in each of the control trees, and bind each of the unique parameter information to the corresponding code file information; In response to the triggering of the monitoring event, based on the monitoring mechanism, store the corresponding code file information, the unique parameter information, and the corresponding interface information into the corresponding log; In response to a log collection instruction, traverse the log and upload the log that matches the log collection instruction.
2. The log collection method according to claim 1, wherein In response to an application startup signal, traverse the code file information of the application and assign a monitoring mechanism to the code file information, where the monitoring mechanism is assigned accordingly according to defined monitoring events, specifically including: Based on the transform api during the android studio packaging process, traverse the code file information of the application; Based on the monitoring mechanism, according to the defined monitoring events, insert reporting log code in the corresponding code file information according to javaassist; Among them, according to the reporting log code, a monitoring mechanism is assigned to the code file information.
3. The log collection method according to claim 1, wherein Based on the interface information of each interface of the application, generate a control tree for the corresponding interface, generate corresponding unique parameter information for each interface element in each of the control trees, and bind each of the unique parameter information to the corresponding code file information, specifically including: Based on each view in the respective interface information, construct a viewtree; Use the vertical hierarchical depth of the view in the viewtree as the y coordinate, and based on the horizontal hierarchical relationship of the view, use the position of the view in the horizontal hierarchical relationship as the x coordinate; Use the x coordinate and the y coordinate of each view as the respective unique parameter information of each interface element, and bind the x and y coordinates of the view to the corresponding code file information; Among them, when the view is a reused view, use the absolute position of the view as the x coordinate, and when the view is not the reused view, use the class name and relative position of the view as the x coordinate.
4. The log collection method according to claim 3, wherein The method further includes: Based on the x and y coordinates of each view, obtain the corresponding interface layout, and when uploading the x and y coordinates of the view, upload the activity or fragment corresponding to the x and y coordinates of the view.
5. The log collection method according to claim 3, characterized in that In response to the triggering of the monitoring event, based on the monitoring mechanism, store the corresponding code file information, the unique parameter information, and the corresponding interface information into the corresponding log, specifically including: When the monitoring event is triggered, according to the listening mechanism, the log corresponding to the code file information, the unique parameter information, and the corresponding interface information is stored through SQLite; Among them, the monitoring event includes an interaction event of the interface, the listening mechanism is used to listen to the interaction event of the interface, and the log also includes the type, time, and number of corresponding interaction events.
6. The log collection method according to claim 5, wherein In response to the log collection instruction, traverse the log and upload the log that matches the log collection instruction, specifically including: According to the log collection instruction, obtain the view corresponding to the log collection instruction; Based on the x and y coordinates of the view, traverse the log stored in SQLite, and extract and upload the log that matches the x and y coordinates of the view.
7. A log collection system, characterized in that, Include: The listening mechanism assignment module is configured to, in response to the application startup signal, traverse the code file information of the application and assign a listening mechanism to the code file information, where the listening mechanism is assigned accordingly according to the defined monitoring event; The unique parameter information binding module is configured to generate a control tree for each interface based on the interface information of the application, generate corresponding unique parameter information for each interface element in each control tree, and bind each unique parameter information to the corresponding code file information; The log storage module is configured to, in response to the triggering of the monitoring event, store the corresponding code file information, unique parameter information, and corresponding interface information in the corresponding log based on the listening mechanism; The log collection module is configured to, in response to the log collection instruction, traverse the log and upload the log that matches the log collection instruction.
8. An electronic device, characterized in that, Include: A processor, a communication interface, a memory, and a communication bus, where the processor, the communication interface, and the memory complete mutual communication through the communication bus; a computer program is stored in the memory, and when the computer program is executed by the processor, the processor executes the steps of the method according to any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that, It stores a computer program executable by an electronic device, and when the computer program runs on the electronic device, the electronic device executes the steps of the method according to any one of claims 1 to 6.
10. A vehicle, characterized in that, The vehicle is provided with the log collection system according to claim 7.
Citation Information
Patent Citations
Information processing method, device and equipment
CN111309574A
APP data dynamic collection method and device, statistics method and device, and data service center
CN111338885A
Front-end abnormity monitoring method, device and system
CN112749059A
Interface positioning method and device, electronic equipment and computer readable storage medium
CN115017024A
Log data processing method and device, equipment and storage medium
CN115510035A
Cited By
Log compressed file generation method, log compressed file decompression method and device
CN120929437A