Application log processing method and apparatus, electronic device, and storage medium

By collecting, formatting, and compressing log files in the background within a Flutter application, the problems of large log files and insufficient real-time performance are solved, achieving lightweight and efficient log collection and analysis.

CN115129670BActive Publication Date: 2026-06-09SHANGHAI PATEO INTERNET TECH SERVICE CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
SHANGHAI PATEO INTERNET TECH SERVICE CO LTD
Filing Date
2021-03-26
Publication Date
2026-06-09

AI Technical Summary

Technical Problem

Existing log collection methods in Flutter applications suffer from problems such as large log files, high system overhead, and failure to meet the need for real-time log viewing.

Method used

After the target application starts, Flutter logs are collected, formatted, and written to a log file. When the target application is switched to the background and the duration exceeds a preset time, the log file is compressed and uploaded to the server. Log collection and uploading are triggered by events.

Benefits of technology

It achieves accurate and real-time log collection, reduces traffic consumption, lowers system overhead, and ensures the responsiveness of the front-end interface.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115129670B_ABST
    Figure CN115129670B_ABST
Patent Text Reader

Abstract

The application provides an application log processing method and device, electronic equipment and a storage medium. The method comprises the following steps: collecting Flutter logs corresponding to a target application in the case that the target application is started, the target application being developed based on Flutter; writing the Flutter logs into a first log file after performing format processing on the Flutter logs; compressing the first log file to generate a first to-be-uploaded log file in the case that a target scenario is monitored, uploading the first to-be-uploaded log file to a server, and the target scenario being that the target application is switched to the background and the duration is greater than a preset duration. The application can collect and upload application logs based on event triggering, ensure the accuracy of log collection, and meet the demand of viewing corresponding logs in a period of time in real time. After the file is compressed and uploaded, the traffic can be saved on the basis of ensuring the lightness of the logs.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of computer technology, and in particular to an application log processing method, apparatus, electronic device, and storage medium. Background Technology

[0002] After the application goes live, if problems occur, they need to be resolved by analyzing logs. The existing log acquisition methods are mainly as follows: 1. The client captures all logs, uploads them to the cloud, and saves them with the PacketData Serving Node (PDSN) + date as the file name; 2. The system crash logs are captured by the tracking software and uploaded to the cloud, and the crash log details can be viewed in the management backend.

[0003] For applications developed using the Flutter (Google's open-source user interface toolkit) framework, or applications that integrate functional modules developed using Flutter as a Software Development Kit (SDK), when problems occur after the application goes live, it is usually necessary to find Flutter-related logs for analysis to resolve the issues. The above two methods of obtaining logs have the following problems.

[0004] Regarding the first method, it typically involves creating a new process or service to capture all logs in the background, which incurs significant system overhead. Since it collects the entire log set, the log files are extremely large, resulting in high bandwidth consumption during uploads and slow download speeds. Locating Flutter business issues within the full log set is also quite challenging. Furthermore, collecting logs requires running a service, which consumes considerable CPU and memory resources. Additionally, the real-time performance of uploaded logs is poor, typically occurring after the log file has accumulated to a certain size or after a certain period, failing to meet the need for real-time viewing of specific business log segments.

[0005] Regarding the second method, the logs collected by third parties are mainly crash logs, excluding business logs. Therefore, logs collected using the first method are suitable for analyzing operating system issues, while logs collected using the second method are unsuitable for analyzing business issues.

[0006] In summary, existing log collection methods suffer from several problems: the collected logs are not suitable for application analysis, the log files are too large, and the requirements for real-time log viewing are not met. Summary of the Invention

[0007] This invention provides an application log processing method, apparatus, electronic device, and storage medium to solve the problems of existing log collection methods that collect logs that are unsuitable for application analysis, have large log files, and fail to meet the requirements for real-time log viewing.

[0008] In a first aspect, embodiments of the present invention provide an application log processing method, including:

[0009] When the target application is running, collect the Flutter logs corresponding to the target application, which is developed based on Flutter.

[0010] The Flutter logs are formatted and then written to the first log file;

[0011] Upon detecting a target scenario, the first log file is compressed to generate a first log file to be uploaded, and the first log file to be uploaded is uploaded to the server. The target scenario is that the target application switches to the background and the duration is longer than a preset duration.

[0012] Secondly, embodiments of the present invention provide an application log processing apparatus, comprising:

[0013] The collection module is used to collect Flutter logs corresponding to the target application when the target application is started, and the target application is developed based on Flutter;

[0014] The first writing module is used to format the Flutter logs and write them to the first log file;

[0015] The first processing module is used to compress the first log file to generate a first log file to be uploaded when a target scenario is detected, and upload the first log file to be uploaded to the server. The target scenario is that the target application switches to the background and the duration is longer than a preset duration.

[0016] Thirdly, embodiments of the present invention provide an electronic device, including a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the computer program, when executed by the processor, implements the steps of the application log processing method described in the first aspect.

[0017] Fourthly, embodiments of the present invention provide a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps of the application log processing method described in the first aspect.

[0018] The technical solution of this invention collects Flutter logs after the target application starts, formats the collected Flutter logs and writes them to a first log file. When it is detected that the target application has switched to the background and the runtime in the background exceeds a preset duration, the first log file is compressed and uploaded to the server. This allows for the collection and uploading of application logs based on event triggers, enabling targeted collection of required logs, ensuring the accuracy of log collection, and meeting the need for real-time viewing of logs within a certain period. By compressing the files before uploading, bandwidth can be saved while maintaining a lightweight design. Attached Figure Description

[0019] Figure 1 A schematic diagram illustrating the application log processing method provided in an embodiment of the present invention;

[0020] Figure 2 This is a flowchart illustrating a specific implementation of the application log processing method provided in this invention.

[0021] Figure 3 This is a schematic diagram of the application log processing device provided in an embodiment of the present invention;

[0022] Figure 4 This diagram illustrates an electronic device provided in an embodiment of the present invention. Detailed Implementation

[0023] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0024] It should be understood that the phrase "one embodiment" or "an embodiment" throughout the specification means that a specific feature, structure, or characteristic related to the embodiment is included in at least one embodiment of the invention. Therefore, "in one embodiment" or "in an embodiment" appearing throughout the specification do not necessarily refer to the same embodiment. Furthermore, these specific features, structures, or characteristics can be combined in any suitable manner in one or more embodiments.

[0025] In various embodiments of the present invention, it should be understood that the sequence number of each process described below does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present invention.

[0026] This invention provides an application log processing method, such as... Figure 1 As shown, it includes:

[0027] Step 101: When the target application is running, collect the Flutter logs corresponding to the target application, which is developed based on Flutter.

[0028] The application log processing method provided in this embodiment of the invention is applied to a terminal, where a target application is installed and the target application is developed based on Flutter. Specifically, the target application can be developed based on the Flutter framework, or a Flutter-developed functional module can be integrated into the native target application (in which case the functional module is used as an SDK).

[0029] When the target application is running, its corresponding Flutter logs can be collected. These Flutter logs include at least one of the following three types: Hypertext Transfer Protocol (HTTP) access logs, custom logs printed by the developer, and error logs. By analyzing these logs, the business process can be reconstructed, and the cause of problems in the target application can be identified.

[0030] Step 102: Format the Flutter logs and write them to the first log file.

[0031] After collecting Flutter logs, the collected Flutter logs can be formatted, and then the formatted Flutter logs can be written to the first log file. The first log file is used to store the Flutter logs.

[0032] Step 103: When a target scenario is detected, compress the first log file to generate a first log file to be uploaded, and upload the first log file to be uploaded to the server. The target scenario is that the target application switches to the background and the duration is longer than a preset duration.

[0033] Upon detecting a target scenario, the first log file storing Flutter logs can be compressed to generate a first log file to be uploaded, which is then uploaded to the server. The target scenario can be the target application switching to the background and running in the background for a duration exceeding a preset time. This allows the compression and upload of the first log file to be triggered based on events occurring while the target application is running in the background. The preset time can be set according to requirements, such as 30 seconds. Since there are cases where the target application switches to the background, stays for a short time, and then switches back to the foreground, the compression and upload of the first log file needs to be triggered after the target application has switched to the background and run for a certain period. This ensures that the logs stored in the first log file represent relatively complete log data corresponding to the target application's foreground execution.

[0034] The first log file, after compression, is typically in the kilobyte level. By compressing the first log file, lightweight log files can be transmitted, saving users' bandwidth. By using event-driven compression and uploading of the first log file, there is no process-level system overhead, and the need to view logs over a period of time in real time can be met. Furthermore, by collecting application logs in a targeted manner, compared to the full log collection method, lightweight and accurate log collection can be guaranteed.

[0035] The above-described implementation process of this invention involves collecting Flutter logs after the target application starts, formatting the collected Flutter logs, and writing them into a first log file. When it is detected that the target application has switched to the background and its runtime in the background exceeds a preset duration, the first log file is compressed and uploaded to the server. This allows for the collection and uploading of application logs based on event triggers, enabling targeted collection of required logs, ensuring the accuracy of log collection, and meeting the need for real-time viewing of logs within a certain period. By compressing the files before uploading, bandwidth can be saved while maintaining a lightweight design.

[0036] In an optional embodiment of the present invention, after detecting the target scene, the method further includes:

[0037] The collected Flutter logs are formatted and then written to a second log file;

[0038] If the target scene is detected again, the second log file is compressed and uploaded to the server.

[0039] After the target scene is detected, that is, after compressing the first log file to generate the first log file to be uploaded and uploading the first log file to be uploaded to the server, the Flutter logs collected subsequently are formatted and written to the second log file. The second log file and the first log file are both used to store log data. The difference is that the two log files correspond to different time periods. That is, the first log file and the second log file store log data collected in different time periods respectively.

[0040] After formatting the collected Flutter logs and writing them to the second log file, the target scenario can continue to be monitored. When the target application is detected to switch to the background and run in the background for a longer period than the preset duration, the compression and uploading of the second log file will be triggered.

[0041] Specifically, during the period from the launch of the target application to the first detection of the target scenario, all collected Flutter logs are formatted and written to the first log file. During the period from the compression of the first log file to the compression of the second log file, all collected Flutter logs are formatted and written to the second log file.

[0042] In the above-described implementation process of this invention, after detecting the target scene, the collected Flutter logs are formatted and written to a new log file. When the target scene is detected again, the compression and uploading of the new log file are triggered. This can achieve the writing of Flutter logs to different files at different times, and by driving the compression and uploading of each log file based on the same event, it can be ensured that the log files are compressed and uploaded under the same conditions.

[0043] In an optional embodiment of the present invention, the step of formatting the Flutter logs and writing them to the first log file includes:

[0044] The Flutter logs are formatted using a log processing callback function to generate formatted log data. The formatted log data is generated by combining at least one of the following with the Flutter logs: the collection time, the name of the target application, the version of the target application, and the operating system.

[0045] The formatted log data is appended to the first log file.

[0046] When the target application starts, you can register log processing callback functions for all log data using Flutter's `async.runZoned` method. This means that raw Flutter logs need to be processed by this function before being output. `async.runZoned` is a function provided by Flutter that allows you to register log processing callback functions.

[0047] After collecting Flutter logs, a log processing callback function can be used to format the Flutter logs. The process of formatting Flutter logs is as follows: at least one of the following is used to format and assemble the Flutter logs: the collection time, the name of the target application, the version of the target application, and the operating system (the operating system of the device on which the target application is installed). This generates formatted log data in the corresponding format.

[0048] For example, by formatting and assembling the Flutter logs with the collection time, target application name, target application version, and target application operating system, formatted log data can be obtained. That is, by assembling it into the format of date and time + application name + application version number + operating system + original log, the corresponding formatted log data can be generated.

[0049] After generating the corresponding formatted log data for Flutter logs, the formatted log data can be appended to the first log file. That is, the first log file can store multiple formatted Flutter logs, and each Flutter log corresponds to the same format.

[0050] After generating formatted log data, the formatted log data can flow to a LogCollect object. The LogCollect object can determine the first log file corresponding to the formatted log data and append the formatted log data to the determined first log file.

[0051] In the above-described implementation process of the present invention, the original Flutter logs are processed by a log processing callback function, which ensures that the processed Flutter logs correspond to the same format. Furthermore, by writing the processed Flutter logs into a first log file, it is guaranteed that the logs stored in the first log file have the same format.

[0052] In an optional embodiment of the present invention, both the first log file and the second log file are named using a preset naming format, which is a format assembled based on the project identifier field, the device information field, the start timestamp field, and the end timestamp field.

[0053] Log files used to store processed Flutter logs are named using a preset naming scheme. Both the first and second log files have names corresponding to this preset naming format. This preset naming format can be based on a project identifier field, a device information field, a start timestamp field, and an end timestamp field. The project identifier field corresponds to a project identity document (ID), where a project can be understood as a specific service supported by the target application. The device information field can include at least one of the following: a device identifier field, a device-associated number field, and an operating system field. Correspondingly, the device information field can correspond to information about the user's device (including but not limited to the device identifier, the device-associated number, and the operating system corresponding to the device). The start timestamp field corresponds to the start time of the log file, and the end timestamp field corresponds to the end time of the log file. The end time is set to a specific duration after the start time, such as 1 hour, meaning that log data within this 1 hour is collected into this log file. By using the preset naming format to name the log files, multiple conditions can be filtered in the backend, such as filtering by device identifier, or by project ID and device identifier. Both the first log file and the second log file are in log format.

[0054] The above implementation process, by using a preset naming format to name the log files, can ensure the uniformity of the log file naming format and facilitate multi-condition filtering in the background, thereby improving the filtering speed.

[0055] Specifically, the first log file can correspond to both the beginning and the end of a time period. When formatted log data is appended to the first log file, there are two possible scenarios, which will be described below.

[0056] If the first end time corresponding to the current first log file is greater than or equal to the target time corresponding to the target scenario, the formatted log data will be written to the current first log file. That is, if the target time corresponding to the target scenario (the time when the target application switches to the background and the duration is greater than the preset duration) is earlier than the first end time corresponding to the current first log file, the formatted log data can be directly written to the current first log file, so that the formatted log data can be stored through a first log file.

[0057] If the first end time of the current first log file is less than the target time of the target scenario, formatted log data written at or before the first end time will be written to the current first log file. Since the target application did not maintain a background running time longer than the preset duration when the first end time arrives, the writing of formatted log data is incomplete. Therefore, formatted log data written after the first end time needs to be written to a newly created first log file. The second start time of the newly created first log file is temporally consecutive to the first end time. If the second end time of the newly created first log file is still less than the target time of the target scenario, formatted log data written after the second end time will be written to another newly created first log file. This process continues until the target scenario is detected, completing the storage of formatted log data through the first log files. Any two adjacent first log files are temporally consecutive. Correspondingly, there is at least one second log file, ensuring that at least one second log file is compressed and uploaded to the server when the target scenario is detected again.

[0058] In an optional embodiment of the present invention, uploading the first log file to be uploaded to the server includes: after generating the first log file to be uploaded, traversing the second log files to be uploaded that have not been uploaded corresponding to the target application; and uploading the first log file to be uploaded and the traversed second log files to be uploaded to the server.

[0059] The LogCollect object can compress a first log file to generate a first log file to be uploaded. When the terminal uploads the compressed first log file to the server, it can iterate through all unuploaded second log files corresponding to the target application after generating the first log file. These second log files are compressed files, and can be compressed files that failed to upload. Both the first and second log files can be in ZIP format. The iteration operation can be performed by the LogCollect object. Then, the generated first log file and the iterated second log files are uploaded to the server, achieving the effect of uploading logs immediately after the user completes the operation of the target application, meeting real-time requirements. Furthermore, uploading compressed files achieves file lightweighting and saves bandwidth. It should be noted that in this embodiment, the second log file to be uploaded refers to a legacy compressed file.

[0060] The above implementation process ensures the integrity of log file uploads by traversing the second, unuploaded log files corresponding to the target application while uploading the first log file to be uploaded.

[0061] In an optional embodiment of the present invention, after uploading the first log file to be uploaded to the server, the method further includes: traversing the unuploaded third log files corresponding to the target application; when the time interval between the generation time of the traversed third log file and the current time is greater than or equal to a preset time interval, clearing the third log file; when the time interval between the generation time of the traversed third log file and the current time is less than the preset time interval, and the target scenario is detected, uploading the third log file to the server. Both the third log file and the second log file are legacy compressed files, differing only in that they are legacy compressed files from different times. The third log file is a legacy compressed file uploaded to the server after the first log file to be uploaded, while the second log file is a legacy compressed file uploaded to the server before the first log file to be uploaded.

[0062] After uploading the first log file to the server, the system can iterate through the target application's corresponding unuploaded third log files (residual compressed files; if the first log file failed to upload, it's also considered a third log file; if the previously iterated second log file failed to upload, it's also considered a third log file). Then, for each third log file, the system retrieves its creation time and the time interval between its creation time and the current time. For each third log file, it checks if the time interval between its creation time and the current time is greater than or equal to a preset time interval. If it is, the third log file is cleared. For example, when a third log file that hasn't been uploaded for 7 days is detected, the LogCollect object will clear these log files to meet the requirement of not occupying storage space for an extended period.

[0063] For the third log file to be uploaded, whose generation time is less than the current time, the third log file to be uploaded can be uploaded to the server the next time the target scene is detected, so as to avoid the omission of log files.

[0064] In an optional embodiment of the present invention, at least one of the following operations is performed based on the first running thread in Flutter: writing the formatted Flutter logs to the first log file, compressing the first log file, traversing the unuploaded log files to be uploaded corresponding to the target application, and clearing the log files to be uploaded that meet the clearing conditions; wherein, the first running thread and the second running thread corresponding to the user interface (UI) are independent of each other.

[0065] The LogCollect object involves time-consuming input / output (IO) operations: writing formatted Flutter logs to the first log file, compressing the first log file, iterating through the second and / or third log files to be uploaded that have not yet been uploaded, and clearing at least one of the third log files to be uploaded that meet the clearing conditions. IO operations cannot be in the same isolate as user interface (UI) operations, otherwise it will affect the UI refresh response efficiency. The isolate is the running thread in Flutter. By controlling the LogCollect object to run in an independent isolate, the requirement of not affecting the response speed of the interface can be met.

[0066] The above process, by separating log processing from UI operations, ensures the refresh response of the front-end interface and avoids affecting the responsiveness of the user interface.

[0067] The log processing method provided in this embodiment of the invention is described below through a specific implementation process. (See attached document.) Figure 2 As shown, it includes:

[0068] Step 201: After starting the target application, collect the original Flutter logs corresponding to the target application.

[0069] Step 202: Format the original Flutter logs to generate formatted log data.

[0070] Step 203: Write the formatted log data to the first log file.

[0071] Step 204: When the target scene is detected, compress the first log file to generate the first log file to be uploaded, and then iterate through the second log files to be uploaded that have not been uploaded for the target application. The second log file to be uploaded is different from the first log file to be uploaded.

[0072] Step 205: Upload the first log file to be uploaded and the second log file to be uploaded obtained through iteration to the server.

[0073] Step 206: Traverse the unuploaded third log files to be uploaded, and clear the third log files to be uploaded that meet the clearing conditions. When the target scene is detected again, upload the third log files to be uploaded that do not meet the clearing conditions to the server.

[0074] The above implementation process can collect application logs based on event triggers, achieving targeted collection of required logs, ensuring the accuracy of log collection, and meeting the need to view the corresponding logs within a certain period of time in real time. By compressing the files before uploading, bandwidth can be saved while further ensuring lightweight operation. By traversing the log files to be uploaded, the integrity of the log file upload can be ensured. By clearing the log files to be uploaded that meet the clearing conditions, the requirement of not occupying storage space for a long time can be met.

[0075] The log processing method provided in this invention can be applied to different scenarios. The following examples illustrate the applicable scenarios: For instance, after an application is launched, users download and install it themselves. During use, it is found that the conversion rate from order placement to payment is low, and the same user initiates a large number of orders. In this case, it is necessary to collect and analyze the user's application operation logs to determine whether the error is due to an application error in the order placement to payment process or if this is simply the user's behavior. Alternatively, after an application is deployed to a .pro environment, for security reasons, logs are not output locally, requiring analysis of server-side logs to resolve the issue.

[0076] The above describes the overall implementation process of the application log processing method provided in this embodiment of the invention. After the target application starts, Flutter logs are collected, and the collected Flutter logs are formatted and written to a first log file. When it is detected that the target application has switched to the background and the runtime in the background exceeds a preset duration, the first log file is compressed and uploaded to the server. Application logs can be collected and uploaded based on event triggers, achieving targeted collection of required logs, ensuring the accuracy of log collection, and meeting the need to view the corresponding logs within a certain period of time in real time. By compressing the files before uploading, bandwidth can be saved while further ensuring lightweight operation.

[0077] Furthermore, the log collection system of the present invention has low system overhead, can save storage space by clearing logs, can improve log filtering efficiency by collecting logs in a targeted manner, and does not affect the refresh response of the front-end interface by distinguishing it from UI operations.

[0078] This invention also provides an application log processing device, such as... Figure 3 As shown, it includes:

[0079] The collection module 301 is used to collect Flutter logs corresponding to the target application when the target application is started, wherein the target application is developed based on Flutter;

[0080] The first writing module 302 is used to format the Flutter logs and write them to the first log file;

[0081] The first processing module 303 is used to compress the first log file to generate a first log file to be uploaded when a target scene is detected, and upload the first log file to be uploaded to the server. The target scene is that the target application switches to the background and the duration is longer than a preset duration.

[0082] Optionally, after detecting the target scene, the device also includes:

[0083] The second writing module is used to format the collected Flutter logs and write them to a second log file;

[0084] The second processing module is used to compress the second log file and upload it to the server when the target scene is detected again.

[0085] Optionally, the first write module is further configured to:

[0086] The Flutter logs are formatted using a log processing callback function to generate formatted log data. The formatted log data is generated by combining at least one of the following with the Flutter logs: the collection time, the name of the target application, the version of the target application, and the operating system.

[0087] The formatted log data is appended to the first log file.

[0088] Optionally, both the first log file and the second log file are named using a preset naming format, which is a format assembled based on the project identifier field, device information field, start timestamp field, and end timestamp field.

[0089] Optionally, the first processing module is further configured to:

[0090] After generating the first log file to be uploaded, iterate through the second log files to be uploaded that have not yet been uploaded for the target application.

[0091] The first log file to be uploaded and the second log file to be uploaded obtained by traversal are uploaded to the server.

[0092] Optionally, the device may also include:

[0093] The traversal module is used to traverse the third unuploaded log file corresponding to the target application after the first processing module uploads the first log file to the server.

[0094] The clearing module is used to clear the third log file to be uploaded when the time interval between the generation time of the third log file to be uploaded obtained by traversal and the current time is greater than or equal to a preset time interval;

[0095] The upload module is used to upload the third log file to be uploaded to the server when the time interval between the generation time of the third log file to be uploaded obtained through iteration and the current time is less than the preset time interval, and the target scene is detected.

[0096] Optionally, based on the first running thread in Flutter, perform at least one of the following operations: write the formatted Flutter logs to the first log file, compress the first log file, traverse the unuploaded log files to be uploaded corresponding to the target application, and clear the log files to be uploaded that meet the clearing conditions;

[0097] The first running thread and the second running thread corresponding to the user interface (UI) are independent of each other.

[0098] The application log processing device provided in this embodiment of the invention collects Flutter logs after the target application starts, formats the collected Flutter logs and writes them to a first log file. When it is detected that the target application has switched to the background and the runtime in the background exceeds a preset duration, the first log file is compressed and uploaded to the server. It can collect and upload application logs based on event triggers, realize targeted collection of required logs, ensure the accuracy of log collection, and meet the need to view the corresponding logs within a period of time in real time. By compressing the files before uploading, it can save data traffic while further ensuring lightweight operation.

[0099] Furthermore, the log collection system of the present invention has low system overhead, can save storage space by clearing logs, can improve log filtering efficiency by collecting logs in a targeted manner, and does not affect the refresh response of the front-end interface by distinguishing it from UI operations.

[0100] As the device embodiment is basically similar to the method embodiment, the description is relatively simple, and relevant parts can be found in the description of the method embodiment.

[0101] On the other hand, embodiments of the present invention also provide an electronic device, including a memory, a processor, a bus, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the steps in the above-described application log processing method.

[0102] For example, Figure 4 A schematic diagram of the physical structure of a live streaming interactive device is shown.

[0103] like Figure 4 As shown, the device may include a processor 410, a communications interface 420, a memory 430, and a communication bus 440, wherein the processor 410, communications interface 420, and memory 430 communicate with each other via the communication bus 440. The processor 410 can call logical instructions in the memory 430 to execute the following steps: when the target application is running, collect Flutter logs corresponding to the target application, the target application being developed based on Flutter; format the Flutter logs and write them to a first log file; when a target scenario is detected, compress the first log file to generate a first log file to be uploaded, and upload the first log file to be uploaded to the server, the target scenario being that the target application switches to the background and the duration exceeds a preset duration. The processor 410 can also execute other steps in the application log processing method example of this invention, which will not be elaborated here.

[0104] Furthermore, the logical instructions in the aforementioned memory 430 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, essentially, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0105] In another aspect, embodiments of the present invention also provide a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps in the application log processing methods provided in the above embodiments.

[0106] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.

[0107] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.

[0108] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. An application log processing method, characterized in that, include: When the target application is running, collect the Flutter logs corresponding to the target application, which is developed based on Flutter. The Flutter logs are formatted and written to the first log file; the Flutter logs are formatted using a log processing callback function to generate formatted log data; Upon detecting a target scenario, the first log file is compressed to generate a first log file to be uploaded, and the first log file to be uploaded is uploaded to the server. The target scenario is that the target application switches to the background and the duration is longer than a preset duration. After the target scene is detected, it also includes: The collected Flutter logs are formatted and then written to a second log file; When the target scenario is detected again, the second log file is compressed and uploaded to the server; wherein, the first log file contains the Flutter logs collected during the period from the start of the target application to the first detection of the target scenario, and the second log file contains the Flutter logs collected during the period from the compression of the first log file to the compression of the second log file. Uploading the first log file to be uploaded to the server includes: After generating the first log file to be uploaded, iterate through the second log files to be uploaded that have not yet been uploaded for the target application. Upload the first log file to be uploaded and the second log file to be uploaded obtained by traversal to the server; After uploading the first log file to be uploaded to the server, the process further includes: Iterate through the unuploaded third log files corresponding to the target application; If the time interval between the generation time of the third log file to be uploaded obtained through iteration and the current time is greater than or equal to a preset time interval, the third log file to be uploaded is cleared. If the time interval between the generation time of the third log file to be uploaded obtained through iteration and the current time is less than the preset time interval, and the target scenario is detected, the third log file to be uploaded is uploaded to the server. Both the third log file to be uploaded and the second log file to be uploaded are legacy compressed files. The third log file to be uploaded is a legacy compressed file that was uploaded to the server after the first log file to be uploaded, and the second log file to be uploaded is a legacy compressed file that was uploaded to the server before the first log file to be uploaded.

2. The method according to claim 1, characterized in that, The step of formatting the Flutter logs and writing them to the first log file includes: The formatted log data is generated by combining at least one of the following with the Flutter log: the collection time corresponding to the Flutter log, the name of the target application, the version of the target application, and the operating system; The formatted log data is appended to the first log file.

3. The method according to claim 1, characterized in that, Both the first log file and the second log file are named using a preset naming format, which is a format assembled based on the project identifier field, device information field, start timestamp field, and end timestamp field.

4. The method according to claim 1, characterized in that, Perform at least one of the following operations based on the first running thread in Flutter: write the formatted Flutter logs to the first log file, compress the first log file, traverse the unuploaded log files to be uploaded corresponding to the target application, and clear the log files to be uploaded that meet the clearing conditions; The first running thread and the second running thread corresponding to the user interface (UI) are independent of each other.

5. An application log processing device, characterized in that, include: The collection module is used to collect Flutter logs corresponding to the target application when the target application is started, and the target application is developed based on Flutter; The first writing module is used to format the Flutter logs and write them to the first log file; The first processing module is used to compress the first log file to generate a first log file to be uploaded when a target scene is detected, and upload the first log file to be uploaded to the server. The target scene is that the target application switches to the background and the duration is longer than a preset duration. After detecting the target scene, the device further includes: The second writing module is used to format the collected Flutter logs and write them to a second log file; The second processing module is used to compress the second log file and upload it to the server when the target scene is detected again; wherein, the first log file is written with the Flutter logs collected during the period from the start of the target application to the first detection of the target scene, and the second log file is written with the Flutter logs collected during the period from the compression of the first log file to the compression of the second log file. The first writing module is also used to format the Flutter logs through a log processing callback function to generate formatted log data; The first processing module is also used for: After generating the first log file to be uploaded, iterate through the second log files to be uploaded that have not yet been uploaded for the target application. Upload the first log file to be uploaded and the second log file to be uploaded obtained by traversal to the server; The device further includes: The traversal module is used to traverse the third unuploaded log file corresponding to the target application after the first processing module uploads the first log file to the server. The clearing module is used to clear the third log file to be uploaded when the time interval between the generation time of the third log file to be uploaded obtained by traversal and the current time is greater than or equal to a preset time interval; The upload module is used to upload the third log file to be uploaded to the server when the time interval between the generation time of the third log file to be uploaded obtained by traversal and the current time is less than the preset time interval, and the target scene is detected. Both the third log file to be uploaded and the second log file to be uploaded are legacy compressed files. The third log file to be uploaded is a legacy compressed file that was uploaded to the server after the first log file to be uploaded, and the second log file to be uploaded is a legacy compressed file that was uploaded to the server before the first log file to be uploaded.

6. An electronic device, characterized in that, It includes a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the computer program, when executed by the processor, implements the steps of the application log processing method as described in any one of claims 1 to 4.

7. A computer-readable storage medium, characterized in that, A computer program is stored on the computer-readable storage medium, which, when executed by a processor, implements the steps of the application log processing method as described in any one of claims 1 to 4.