Log processing method and apparatus, electronic device, and medium

By enabling the logging switch in electronic devices to capture log information only when system resource usage reaches a threshold, the problem of wasted cache resources is solved, and efficient resource utilization is achieved.

CN116662392BActive Publication Date: 2026-04-17VIVO MOBILE COMM CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
VIVO MOBILE COMM CO LTD
Filing Date
2023-05-30
Publication Date
2026-04-17

AI Technical Summary

Technical Problem

The problem of electronic devices wasting cache resources by capturing log information in real time while running applications.

Method used

When obtaining parameter values ​​indicating the system resource usage of the target application, log information capture is only enabled when the parameter value is greater than or equal to the threshold.

Benefits of technology

This reduces the size of log information stored in the cache space, saving cache resources.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116662392B_ABST
    Figure CN116662392B_ABST
Patent Text Reader

Abstract

The application discloses a log processing method and device, electronic equipment and medium, and belongs to the technical field of data processing. The log processing method comprises the following steps: acquiring N first parameter values in the case of running a target application; each first parameter value is used for indicating the occupation amount of a system resource of the electronic equipment by the target application, and N is a positive integer; in the case that a target parameter value in the N first parameter values is greater than or equal to a target threshold value, a target log switch is started, and log information is captured.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application belongs to the field of data processing technology, specifically relating to a log processing method, apparatus, electronic device, and medium. Background Technology

[0002] Typically, to determine the cause of an anomaly occurring while an electronic device is running an application, the device can enable the application's logging function from the start of the application's operation and capture the application's log information in real time. This captured log information is then stored in the device's cache. When an anomaly occurs while running the application, the device can retrieve the anomaly log information from this cache and upload it, allowing developers to determine the cause of the anomaly during application operation based on this anomaly log information.

[0003] However, since electronic devices capture the log information of a particular application in real time from the start of its operation and store it in the cache, there may be a situation where the electronic device stores a large amount of log information of a particular application in the cache, thus wasting the cache resources of the electronic device. Summary of the Invention

[0004] The purpose of this application is to provide a log processing method, apparatus, electronic device, and medium that can solve the problem of wasted cache resources in electronic devices.

[0005] In a first aspect, embodiments of this application provide a log processing method, which includes: when running a target application, obtaining N first parameter values; each first parameter value is used to indicate the amount of system resources occupied by the target application on an electronic device, where N is a positive integer; when a target parameter value among the N first parameter values ​​is greater than or equal to a target threshold, turning on a target log switch and capturing log information.

[0006] Secondly, embodiments of this application provide a log processing apparatus, comprising: an acquisition module and a control module. The acquisition module is configured to acquire N first parameter values ​​when a target application is running; each first parameter value indicates the amount of system resources occupied by the target application on the log processing apparatus, where N is a positive integer. The control module is configured to activate a target log switch and capture log information when a target parameter value among the N first parameter values ​​acquired by the acquisition module is greater than or equal to a target threshold.

[0007] Thirdly, embodiments of this application provide an electronic device including a processor and a memory, wherein the memory stores programs or instructions executable on the processor, and the programs or instructions, when executed by the processor, implement the steps of the method described in the first aspect.

[0008] Fourthly, embodiments of this application provide a readable storage medium on which a program or instructions are stored, which, when executed by a processor, implement the steps of the method described in the first aspect.

[0009] Fifthly, embodiments of this application provide a chip, the chip including a processor and a communication interface, the communication interface being coupled to the processor, the processor being used to run programs or instructions to implement the method as described in the first aspect.

[0010] In a sixth aspect, embodiments of this application provide a computer program product stored in a storage medium, which is executed by at least one processor to implement the method described in the first aspect.

[0011] In this embodiment, the electronic device can acquire N first parameter values ​​while running the target application. Each first parameter value indicates the amount of system resources occupied by the target application on the electronic device. If any of the N first parameter values ​​is greater than or equal to a target threshold, the target log switch is activated, and log information is captured. N is a positive integer. Since the electronic device can acquire N first parameter values ​​indicating the amount of system resources occupied by the target application while running the target application, and only activate the target log switch and capture log information if any one of the first parameter values ​​is greater than or equal to the target threshold, the electronic device only captures log information when the target application's usage of any system resource is greater than or equal to a certain threshold, instead of activating the target application's log switch and capturing log information in real time when the target application is running. Therefore, the size of the target application's log information captured by the electronic device can be reduced, thereby reducing the size of the target application's log information stored in the cache space, thus saving cache resources of the electronic device. Attached Figure Description

[0012] Figure 1 This is one of the flowcharts illustrating the log processing method provided in the embodiments of this application;

[0013] Figure 2 This is a second schematic flowchart of the log processing method provided in the embodiments of this application;

[0014] Figure 3 This is the third flowchart illustrating the log processing method provided in the embodiments of this application;

[0015] Figure 4 This is the fourth flowchart illustrating the log processing method provided in the embodiments of this application;

[0016] Figure 5 This is the fifth flowchart illustrating the log processing method provided in the embodiments of this application;

[0017] Figure 6 This is the sixth flowchart illustrating the log processing method provided in the embodiments of this application;

[0018] Figure 7 This is a schematic diagram of the log processing device provided in the embodiments of this application;

[0019] Figure 8 This is a schematic diagram of the structure of the electronic device provided in the embodiments of this application;

[0020] Figure 9 This is a schematic diagram of the hardware structure of the electronic device provided in the embodiments of this application. Detailed Implementation

[0021] The technical solutions of the embodiments of this application will be clearly described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this application. All other embodiments obtained by those skilled in the art based on the embodiments of this application are within the scope of protection of this application.

[0022] The terms "first," "second," etc., used in the specification and claims of this application are used to distinguish similar objects and not to describe a specific order or sequence. It should be understood that such use of data can be interchanged where appropriate so that embodiments of this application can be implemented in orders other than those illustrated or described herein, and the objects distinguished by "first," "second," etc., are generally of the same class and the number of objects is not limited; for example, a first object can be one or more. Furthermore, in the specification and claims, "and / or" indicates at least one of the connected objects, and the character " / " generally indicates that the preceding and following objects are in an "or" relationship.

[0023] The log processing method, apparatus, electronic device, and medium provided in this application will be described in detail below with reference to the accompanying drawings and through specific embodiments and application scenarios.

[0024] In related technologies, to determine the causes of low-probability anomalies occurring on an electronic device while running application A, the device can enable application A's logging from the start of application A's operation and capture its log information in real time. This captured log information is then stored in a cache. When an anomaly occurs during application A's operation, the device can retrieve and upload the anomaly log information from this cache, allowing developers to determine the cause of the anomaly. However, because the device captures and stores application A's log information in real time from the start of application A's operation, a large amount of application A's log information may end up in the cache, resulting in a waste of the device's cache resources.

[0025] However, in this embodiment, when the electronic device is running application A, it can obtain parameter values ​​indicating the amount of system resources occupied by application A on the electronic device. Only when any one of the at least one parameter value is greater than or equal to a threshold will the logging switch of application A be turned on, and log information be captured. It can be understood that because the electronic device only turns on the logging switch of application A and captures log information when any one parameter value is greater than or equal to a threshold—that is, the electronic device only captures log information when the amount of system resources occupied by application A is greater than or equal to a certain threshold, rather than turning on the logging switch of the target application from the start of application A and capturing log information in real time—the size of the log information of application A captured by the electronic device can be reduced, thereby reducing the size of the log information of application A stored in the cache space. Therefore, cache resources of the electronic device can be saved.

[0026] The execution subject of the log processing method provided in this application embodiment can be an electronic device, or a functional module and / or functional entity in the electronic device that can implement the log processing method. The following will use an electronic device as an example to describe the technical solution provided in this application embodiment.

[0027] Figure 1 A flowchart of a log processing method provided in an embodiment of this application is shown. Figure 1 As shown, a log processing method provided in this application embodiment may include the following steps 101 to 102.

[0028] Step 101: When the electronic device is running the target application, the electronic device acquires N first parameter values.

[0029] In some embodiments of this application, the target application described above can specifically be any application already installed in an electronic device.

[0030] In some embodiments of this application, the target application can be any of the following: chat application, image processing application, web application, short video interactive application, game application, etc.

[0031] In this embodiment of the application, each of the above N first parameter values ​​is used to indicate the amount of system resources occupied by the target application on the electronic device, where N is a positive integer.

[0032] In some embodiments of this application, the N system resources may include at least one of the following: memory resources, central processing unit (CPU) resources, graphics processing unit (GPU) resources, network resources, etc.

[0033] In some embodiments of this application, the N system resources can be: all system resources of the electronic device, or system resources corresponding to the target application.

[0034] In some embodiments of this application, when N system resources are system resources corresponding to the target application, the electronic device, while in a working state, can obtain a target relationship list. This target relationship list includes M application identifiers and T resource identifiers. Each application identifier indicates a first application, and each resource identifier indicates a system resource. Each first application identifier corresponds to at least one resource identifier. The M first applications include the target application, and the T system resources include N system resources. Thus, when the target application is running in the foreground or background of the electronic device, the electronic device can determine the N resource identifiers corresponding to the target application from the target relationship list based on the application identifier of the target application, and check the N system resources indicated by the N resource identifiers through the target application to obtain N first parameter values. Each application identifier can be any of the following: application name, application package name, etc., and each resource identifier can specifically be a resource name. M is a positive integer, and T is a positive integer greater than or equal to M.

[0035] For each of the M first applications, a first application can be any of the following: chat application, image processing application, web application, short video interactive application, etc. The system resources of a first application and the corresponding applications can be partially the same or completely different.

[0036] It is understandable that, due to the different functional requirements of various first applications, application developers also have different focuses when designing and developing various first applications. Therefore, the system resources corresponding to various first applications may be partially the same or completely different.

[0037] For example, suppose a first application is a short video interactive application. Short video interactive applications are prone to memory leaks. Therefore, in the target relationship list, the resource identifier corresponding to the application identifier of the first application can be the resource identifier of memory resources.

[0038] For example, suppose a first application is a game application. Game applications are more prone to load anomalies that lead to severe CPU and GPU consumption. Therefore, in the target relationship list, the resource identifier corresponding to the application identifier of this first application can be the resource identifier of CPU resources and GPU resources.

[0039] In some embodiments of this application, the above-mentioned N first parameter values ​​may include at least one of the following: memory usage, CPU utilization, GPU utilization, network upload speed, network download speed, etc.

[0040] Step 102: If the target parameter value among the N first parameter values ​​is greater than or equal to the target threshold, the electronic device turns on the target log switch and captures log information.

[0041] In some embodiments of this application, the target parameter value can be any one of N first parameter values.

[0042] In some embodiments of this application, the aforementioned target threshold may specifically be a preset threshold or a threshold of system resources corresponding to a target parameter value. The target threshold may be a threshold corresponding to a target parameter, and the target parameter may be a parameter corresponding to a target parameter value.

[0043] It should be noted that the "system resources corresponding to the target parameter value" mentioned above can be understood as: the target parameter value indicates the utilization rate of the system resources by the target application.

[0044] For example, assuming the target parameter value is parameter value 1, which is used to indicate the amount of system resource 1 occupied by the target application, then the system resource corresponding to parameter value 1 can be understood as system resource 1.

[0045] In some embodiments of this application, when the target threshold is the threshold of the system resource corresponding to the target parameter value, the above target relationship column also includes T thresholds, each threshold corresponding to a resource identifier. Each threshold is the threshold of the system resource indicated by the corresponding resource identifier. The T thresholds include the target threshold, so that the electronic device can determine N thresholds based on N resource identifiers. After obtaining N first parameter values, the electronic device can compare each first parameter value with a threshold of the corresponding system resource. If the target parameter value is greater than or equal to the target threshold, the electronic device can turn on the target log switch.

[0046] In this embodiment of the application, if the target parameter value is greater than or equal to the target threshold, it can be considered that the target application is running abnormally. Therefore, the electronic device can turn on the target log switch and capture log information.

[0047] Alternatively, in one possible embodiment of this application, the target log switch described above can be all log switches of the target application.

[0048] Optionally, in another possible embodiment of this application, the above-mentioned target log switch is: the log switch corresponding to the target parameter value in the log switches of the target application.

[0049] It should be noted that the "log switch corresponding to the target parameter value" mentioned above can be understood as: the log switch of the system resource corresponding to the target parameter value.

[0050] In some embodiments of this application, the number of the aforementioned target log switches can be at least one.

[0051] In some embodiments of this application, the electronic device can control the target application to turn on the target log switch through the system callback of the log information interface, so that the electronic device can capture log information.

[0052] Specifically, electronic devices can send callback information to the target application through the log information interface to implement system callbacks. This callback information is used to instruct the target application to enable or disable the target log. This callback information can be a piece of program instruction code.

[0053] For example, assuming the target application is application A, after application A starts, the electronic device obtains N first parameter values ​​of application A through program instructions. These values ​​might be, for example, memory usage of 4096MB, CPU utilization of 80%, GPU utilization of 60%, and network speed of 1MB / s. If the target parameter value (e.g., memory usage of 4096MB) among the N first parameter values ​​is greater than or equal to a target threshold, the electronic device can send a callback message to the target application through a log information interface, enabling the target application to enable the target log switch. This callback message could be as follows:

[0054] public class System{

[0055] publicvoidcallback(StringpkgName,arg1,arg2,arg3…){

[0056] pkgName.isOpenLog(arg1,arg2,arg3…)}

[0057] }

[0058] System.callback(APPX,arg1,arg2,arg3…);

[0059] }

[0060] In this way, electronic devices can notify target applications through system callbacks, so that the target applications can turn on the logging switch corresponding to the memory usage size, i.e. the memory resource logging switch, and capture log information according to the instructions in the callback information.

[0061] In some embodiments of this application, after the electronic device turns on the target log switch, the electronic device can continuously capture the log information output by the target application; or, it can capture the log information output by the target application within a certain time period.

[0062] The following example illustrates a specific method for determining target thresholds in electronic devices.

[0063] Optionally, in the embodiments of this application, combined with Figure 1 ,like Figure 2 As shown, prior to step 101 above, the log processing method provided in this application embodiment may further include steps 201 and 202 as described below.

[0064] Step 201: The electronic device receives the registration information submitted by the target application.

[0065] In some embodiments of this application, the registration information may include: an application identifier of the target application, N corresponding resource identifiers, and N thresholds. The N resource identifiers and N thresholds correspond one-to-one.

[0066] For example, assuming the target application is application A, application A can submit registration information to an electronic device. The specific code included in this registration information can be as follows:

[0067] < / scenepkgName=“com.andrord.APPA”>

[0068] <itemagr1=“menSize”value=“2048MB” / >

[0069] <itemagr2=“cpuusage”value=“60%” / >

[0070] <itemagr3=“gpuusage”value=“70%” / >

[0071] <itemagr4=“netspeed”value=“1MB / s” / >

[0072] <itemagrX=“XXXX”value=“XXXX” / >

[0073]

[0074] The registration information includes the target application's package name "com.andrord.APPA", N resource identifiers and corresponding N thresholds, such as the memory resource identifier "menSize" and the corresponding memory usage threshold "2048MB", the CPU resource identifier "cpuusage" and the corresponding CPU utilization threshold "60%", the GPU resource identifier "gpuusage" and the corresponding GPU utilization threshold "70%", and the network resource identifier "netspeed" and the corresponding network speed threshold "1MB / s".

[0075] In some embodiments of this application, during the installation of a target application on an electronic device, the electronic device can obtain registration information from the installation package of the target application to receive registration information submitted by the target application; or, if the target application has already been installed on the electronic device, the electronic device can send an instruction to the target application so that the target application can send registration information to the electronic device according to the instruction, thereby enabling the electronic device to receive registration information submitted by the target application.

[0076] Step 202: The electronic device obtains the target threshold based on the registration information.

[0077] It is understandable that electronic devices can directly obtain the application identifier of the target application, the corresponding N resource identifiers, and the N thresholds from the registration information, and thus the electronic device can obtain the target threshold from the N thresholds.

[0078] In some embodiments of this application, after the electronic device obtains N thresholds, the electronic device can add the application identifier of the target application, N resource identifiers, and N thresholds to the target relationship list, and establish a correspondence between the application identifier of the target application, the N resource identifiers, and the N thresholds. Thus, the electronic device can determine the N resource identifiers from the target relationship list, detect the N system resources indicated by the N resource identifiers to obtain N first parameter values, and compare the N first parameter values ​​with the N thresholds to determine whether the target parameter value is greater than or equal to the target threshold.

[0079] For example, assuming the registration information includes the application identifier of the target application (e.g., the application package name of the target application "com.andrord.APPA") and N resource identifiers, such as the memory resource identifier "menSize", the CPU resource identifier "cpuusage", the GPU resource identifier "gpuusage", and the network resource identifier "netspeed", after the electronic device obtains these N resource identifiers, the electronic device can add the application package name "com.andrord.APPA", the memory resource identifier "menSize", the CPU resource identifier "cpuusage", the GPU resource identifier "gpuusage", and the network resource identifier "netspeed" to the target relationship list, and establish the correspondence between the two. Thus, when the target application is running, the electronic device can determine the corresponding memory resource identifier "menSize", CPU resource identifier "cpuusage", GPU resource identifier "gpuusage", and network resource identifier "netspeed" based on the application package name of the target application "com.andrord.APPA", and detect the memory resource, CPU resource, GPU resource, and network resource to obtain four first parameter values.

[0080] Thus, since electronic devices can obtain the target threshold based on the registration information submitted by the target application, it is possible to accurately determine whether the target application has malfunctioned based on this target threshold.

[0081] It should be noted that, for the other applications in the M first applications besides the target application, registration information can also be sent to the electronic device, so that the electronic device can obtain the resource identifier corresponding to the application identifier of the M first applications and the threshold corresponding to the resource identifier based on the registration information. For a detailed description, please refer to steps 201 and 202 above, which will not be repeated here in the embodiments of this application.

[0082] The log processing method provided in this application embodiment allows an electronic device to acquire N first parameter values ​​while running a target application. Each first parameter value indicates the amount of system resources occupied by the target application on the electronic device. If a target parameter value among the N first parameter values ​​is greater than or equal to a target threshold, a target log switch is activated, and log information is captured. N is a positive integer. Since the electronic device can acquire N first parameter values ​​indicating the amount of system resources occupied by the target application while running the target application, and only activate the target log switch and capture log information if any one of the first parameter values ​​is greater than or equal to the target threshold, the electronic device only captures log information when the target application's usage of any system resource is greater than or equal to a certain threshold, rather than activating the target application's log switch and capturing log information in real time when the target application is running. Therefore, the size of the target application's log information captured by the electronic device can be reduced, thereby reducing the size of the target application's log information stored in the cache space, thus saving cache resources of the electronic device.

[0083] Of course, different applications on electronic devices have different functional requirements, and application developers also have different focuses when designing and developing applications. Therefore, electronic devices can also flexibly determine which log information to capture and when to capture it according to the application developer's own needs. The following is a detailed explanation.

[0084] Optionally, in the embodiments of this application, combined with Figure 1 ,like Figure 3 As shown, before “the electronic device turns on the target log switch” in step 102 above, the log processing method provided in this application embodiment may also include the following steps 301 and 302, and the above step 102 can be specifically implemented by the following step 102a.

[0085] Step 301: If the target parameter value among the N first parameter values ​​is greater than or equal to the target threshold, the electronic device determines the target parameter range in which the target parameter value is located.

[0086] In some embodiments of this application, the electronic device determines the target parameter range in which the parameter value of the target parameter lies from a possible Q first parameter ranges.

[0087] In this embodiment of the application, each of the above first parameter ranges corresponds to a first quantity, where Q is a positive integer.

[0088] In some embodiments of this application, when the target parameter value is greater than or equal to a preset threshold, the electronic device determines that the target application is running abnormally, and notifies the target application through the system callback of the log information interface, controlling the target application to call and execute the methods defined in the log information interface, so as to enable the log switch corresponding to the target parameter value and capture log information.

[0089] In some embodiments of this application, the method defined in the above-mentioned log information interface may include: setting Q first parameter ranges for the target parameter value; thereby, the electronic device can determine the target parameter range in which the target parameter value is located from the Q first parameter ranges.

[0090] Step 302: The electronic device determines the target number of log switches from the log switches corresponding to the target application based on the target parameter range, and obtains the target log switches.

[0091] In some embodiments of this application, each of the Q first parameter ranges corresponds to a first quantity; thus, the electronic device can determine the target parameter range it is in based on the target parameter value, and thus determine the target quantity corresponding to the target parameter range.

[0092] The first quantity indicates the number of log switches that are turned on.

[0093] In some embodiments of this application, after the electronic device determines the target number of log switches and obtains the target log switches, the electronic device can control the target application to call and execute the method in the log information interface through the log information interface system callback, that is, determine the target number of log switches from the log switches of the target application and obtain the target log switches, so that the target application can output the log information corresponding to the target log switches.

[0094] For example, assuming the target application is application A, the registration information submitted by application A to the electronic device pre-sets a memory usage threshold of 1024MB, and the memory usage parameter has two first parameter ranges, each corresponding to a first quantity, as follows: Parameter range 1: Memory usage X < 2048MB, first quantity: 1; Parameter range 2: 2048MB < Memory usage X < 4096MB, first quantity: 2. Therefore, when application A is running, the electronic device can obtain the memory usage of application A as 3072MB through program instructions. This 3072MB is greater than the memory usage threshold of 1024MB, meaning the memory usage of 3072MB is the target parameter value, and since the memory usage of 3072MB falls within parameter range 2, the electronic device can determine the target quantity as 2. Thus, the electronic device can control the target application to determine log switch 1 and log switch 2 as the target log switches from the log switches. The specific code for the method defined in the log information interface is as follows:

[0095] Case: ” memorylog ”

[0096] If (arg1 < 2048MB) {

[0097] OPENLOG_1();

[0098] OPENLOG_2();

[0099] {

[0100] If (2048MB) <arg1<4096MB){

[0101] OPENLOG_3();

[0102] {.

[0103] Step 102a: The electronic device turns on the target log switch and captures log information.

[0104] Thus, electronic devices can determine the target number of log switches based on the target parameter value's range, thereby obtaining the target number of log switches. This allows different numbers of log switches to be activated based on different ranges of the target parameter value, thus improving the flexibility of log capture.

[0105] Optionally, in the embodiments of this application, combined with Figure 3 ,like Figure 4 As shown, the log processing method provided in this application embodiment may further include the following step 401, and the above step 102 may be specifically implemented by the following step 102b.

[0106] Step 401: The electronic device determines the target duration based on the target parameter range.

[0107] It should be noted that the execution order of steps 401 and 301 described above is not limited in this embodiment of the application. Figure 4 The illustration shows the electronic device performing step 401 after step 301.

[0108] In some embodiments of this application, each of the Q first parameter ranges also corresponds to a first duration, so that the electronics and devices can determine the duration corresponding to the target parameter range among the Q first durations as the target duration.

[0109] Step 102b: If the target parameter value among the N first parameter values ​​is greater than or equal to the target threshold, the electronic device turns on the target log switch and captures log information within the target duration.

[0110] For example, suppose the target application is application A. Application A has a preset memory usage threshold of 1024MB set in its registration file, and the memory usage parameter has two first parameter ranges, each corresponding to a first duration, as follows: Parameter range 1: Memory usage X < 2048MB, first duration: 5 seconds; Parameter range 2: 2048MB < Memory usage X < 4096MB, first duration: 8 seconds. After application A starts, the electronic device obtains the memory usage of application A as 3072MB through program instructions. Since the memory usage of application A is 3072MB, the target parameter range belongs to parameter range 2, and the target duration is 8 seconds. Therefore, the target application keeps the log switch corresponding to the memory usage parameter on for 8 seconds, allowing the electronic device system to capture the log information output by the target application within 8 seconds.

[0111] For example, suppose the target application is application A. The registration information submitted by application A to the electronic device pre-sets a memory usage threshold of 1024MB, and the memory usage parameter has two first parameter ranges, each corresponding to a first duration, as follows: Parameter range 1: Memory usage X < 2048MB, first duration: 5 seconds; Parameter range 2: 2048MB < Memory usage X < 4096MB, first duration: 8 seconds. Therefore, when application A is running, the electronic device can obtain the memory usage of application A as 3072MB through program instructions. This 3072MB is greater than the memory usage threshold of 1024MB, meaning the memory usage of 3072MB is the target parameter value, and since the memory usage of 3072MB falls within parameter range 2, the electronic device can determine 8 seconds. Thus, the electronic device can activate the target log switch and capture log information within 8 seconds.

[0112] Thus, electronic devices can determine the duration for which the log switch is turned on based on the parameter range of the target parameter value from the log switch of the target application. This allows log information to be captured within different durations based on different parameter ranges of the target parameter value, thereby improving the flexibility of log capture.

[0113] Optionally, in the embodiments of this application, combined with Figure 1 ,like Figure 5 As shown, after step 102 above, the log processing method provided in this application embodiment may further include the following steps 501 and 502.

[0114] Step 501: The electronic device generates the target log file based on the captured log information.

[0115] In some embodiments of this application, the target application can capture log information corresponding to the target parameters according to the method defined by the log information interface, and transmit it to the electronic device through the log information interface, so that the electronic device can create a new log file in the cache space and write the captured log information into the new log file, thereby obtaining the target log file.

[0116] In some embodiments of this application, the target log file can be a txt file, and the file name of the target log file can be: AppNameopenLog.txt.

[0117] Step 502: When the system time of the electronic device is within a preset time period and the electronic device is in a screen-off state, the electronic device sends the target log file to the server.

[0118] In some embodiments of this application, the aforementioned preset time period can be a period during which the electronic device is idle. Furthermore, during the preset time period, the user does not perform any operation on the target application. Specifically, the preset time period can be nighttime.

[0119] It is understandable that when the electronic device is in a screen-off state, the target application does not receive any user operations. At this time, the target application needs to execute fewer program instructions, and the target application does not compete with other applications for the electronic device's system resources. Therefore, the electronic device can send the target log file to the server corresponding to the target application.

[0120] In some embodiments of this application, after the server receives the target log file, the developers can analyze the target log file to determine the cause of the anomaly in the target application.

[0121] Thus, it can be seen that since electronic devices can generate target log files based on the captured log information and send the target log files to the server when the electronic devices are idle, the target application and other applications can avoid competing for system resources, thereby ensuring the smooth operation of other applications.

[0122] In addition, when a background application malfunction indirectly causes a foreground application to lag or malfunction, the electronic device can accurately identify the malfunctioning background application, capture the real source of the malfunction, and limit the system resources of the malfunctioning background application to ensure the normal use of other foreground applications. The following is a detailed explanation.

[0123] Optionally, in the embodiments of this application, combined with Figure 1 ,like Figure 6 As shown, after step 102 above, the log processing method provided in this application embodiment may further include step 601 below.

[0124] Step 601: When the target application is running in the background on the electronic device, the electronic device restricts system resources for the target application.

[0125] In some embodiments of this application, when the lag or stuttering of an application running in the foreground of an electronic device is caused by an abnormal background application, the operating system of the electronic device can restrict the allocation of system resources to the abnormal background application or directly reclaim the system resources of the abnormal background application.

[0126] For example, an instant messaging application B runs in the foreground of an electronic device, while a short video application C runs in the background. If short video application C experiences a memory leak, causing excessive memory consumption by the electronic device's operating system, it can lead to lag in the instant messaging application B. Assume both instant messaging application B and short video application C access the operating system's log information interface. When the operating system detects an anomaly in the background short video application C, it uses a system callback via the log information interface to control short video application C to enable / disable logging corresponding to its memory usage parameters and capture log information. Simultaneously, the operating system limits memory allocation for short video application C, ensuring smooth operation of the foreground instant messaging application B and preventing interference from short video application C while instant messaging application B is capturing abnormal log information. The operating system can limit the system resource allocation of short video application C through a bandwidth control mechanism.

[0127] Therefore, when a background application malfunctions, electronic devices can restrict system resources for the malfunctioning background application, thereby ensuring the smooth operation of the foreground application.

[0128] The method provided in this application can be executed by a log processing device. This application uses the example of a log processing device executing a log processing method to illustrate the log processing device provided in this application.

[0129] Figure 7 A log processing device 60 according to the above embodiments is shown. The log processing device includes an acquisition module 61 and a control module 62. The acquisition module 61 is used to acquire N first parameter values ​​when a target application is running; each first parameter value indicates the amount of system resources occupied by the target application on the log processing device 60, where N is a positive integer. The control module 62 is used to activate a target log switch and capture log information when a target parameter value among the N first parameter values ​​acquired by the acquisition module 61 is greater than or equal to a target threshold.

[0130] In one possible implementation, the target log switch mentioned above is: the log switch in the target application's log switches that corresponds to the target parameter value.

[0131] In one possible implementation, the log processing apparatus 60 provided in this application embodiment may further include a receiving module. The receiving module is configured to receive registration information submitted by a target application. The control module 62 is further configured to obtain a target threshold based on the registration information received by the receiving module.

[0132] In one possible implementation, the log processing apparatus 60 provided in this application embodiment may further include: a determining module. The determining module is configured to determine the target parameter range in which the target parameter value lies; and, based on the target parameter range, determine a target number of log switches from the log switches corresponding to the target application, thereby obtaining the target log switches.

[0133] In one possible implementation, the aforementioned determining module is further configured to determine the target duration based on the target parameter range. Specifically, the control module 62 is configured to capture log information within the target duration determined by the determining module.

[0134] In one possible implementation, the log processing device 60 further includes a generation module and a sending module. The generation module generates a target log file based on the captured log information. The sending module sends the target log file generated by the generation module to the server when the system time of the log processing device 60 is within a preset time period and the log processing device 60 is in a screen-off state.

[0135] The log processing device provided in this application embodiment can obtain N first parameter values ​​indicating the target application's usage of N system resources while the target application is running, and only activate the target log switch and capture log information when any of the first parameter values ​​is greater than or equal to a target threshold. That is, the log processing device will only capture log information when the target application's usage of any system resource is greater than or equal to a certain threshold, instead of activating the target application's log switch and capturing log information in real time when the target application is running. Therefore, the size of the target application's log information captured by the log processing device can be reduced, thereby reducing the size of the target application's log information stored in the cache space. Thus, the cache resources of the log processing device can be saved.

[0136] The log processing device in this application embodiment can be an electronic device or a component within an electronic device, such as an integrated circuit or a chip. The electronic device can be a terminal or other devices besides a terminal. For example, the electronic device can be a mobile phone, tablet computer, laptop computer, PDA, in-vehicle electronic device, mobile internet device (MID), augmented reality (AR) / virtual reality (VR) device, robot, wearable device, ultra-mobile personal computer (UMPC), netbook, or personal digital assistant (PDA), etc. It can also be a server, network attached storage (NAS), personal computer (PC), television (TV), ATM, or self-service machine, etc. This application embodiment does not specifically limit the device.

[0137] The log processing device in this application embodiment can be a device with an operating system. The operating system can be Android, iOS, or other possible operating systems; this application embodiment does not specifically limit the specific operating system used.

[0138] The log processing device provided in this application embodiment can achieve... Figures 1 to 6 The various processes implemented in the method implementation examples will not be described again here to avoid repetition.

[0139] Optionally, in the embodiments of this application, such as Figure 8As shown, this application embodiment also provides an electronic device 80, including a processor 81 and a memory 82. The memory 82 stores a program or instructions that can run on the processor 81. When the program or instructions are executed by the processor 81, they implement the various process steps of the above method embodiments and can achieve the same technical effect. To avoid repetition, they will not be described again here.

[0140] It should be noted that the electronic devices in the embodiments of this application include the aforementioned mobile electronic devices and non-mobile electronic devices.

[0141] Figure 9 A schematic diagram of the hardware structure of an electronic device to implement an embodiment of this application.

[0142] The electronic device 100 includes, but is not limited to, components such as: radio frequency unit 1001, network module 1002, audio output unit 1003, input unit 1004, sensor 1005, display unit 1006, user input unit 1007, interface unit 1008, memory 1009, and processor 110.

[0143] Those skilled in the art will understand that the electronic device 100 may also include a power supply (such as a battery) for supplying power to various components. The power supply may be logically connected to the processor 110 through a power management system, thereby enabling functions such as managing charging, discharging, and power consumption through the power management system. Figure 7 The electronic device structure shown does not constitute a limitation on the electronic device. The electronic device may include more or fewer components than shown, or combine certain components, or have different component arrangements, which will not be elaborated here.

[0144] The processor 110 is used to obtain N first parameter values ​​when the target application is running; each first parameter value is used to indicate the amount of system resources occupied by the target application on the electronic device, where N is a positive integer; if the target parameter value among the N first parameter values ​​is greater than or equal to the target threshold, the target log switch is turned on and log information is captured.

[0145] The electronic device provided in this application embodiment can obtain N first parameter values ​​indicating the target application's usage of N system resources while the target application is running, and only activate the target log switch and capture log information when any of the first parameter values ​​is greater than or equal to a target threshold. That is, the electronic device will only capture log information when the target application's usage of any system resource is greater than or equal to a certain threshold, instead of activating the target application's log switch and capturing log information in real time when the target application is running. Therefore, the size of the target application's log information captured by the electronic device can be reduced, thereby reducing the size of the target application's log information stored in the cache space, thus saving the electronic device's cache resources.

[0146] Optionally, in this embodiment of the application, the processor 110 receives registration information submitted by the target application and obtains the target threshold based on the registration information.

[0147] Optionally, in this embodiment of the application, the processor 110 is specifically used to determine the target parameter range in which the target parameter value is located; and to determine the target number of log switches from the log switches corresponding to the target application according to the target parameter range, thereby obtaining the target log switches.

[0148] Optionally, in this embodiment, the processor 110 is further configured to determine the target duration based on the target parameter range. Specifically, the processor 110 is configured to capture log information within the target duration.

[0149] Optionally, in this embodiment of the application, the processor 110 is further configured to limit the system resources of the target application when the target application is running in the background.

[0150] Optionally, in this embodiment of the application, the processor 110 is further configured to generate a target log file based on the captured log information; and send the target log file to the target server when the system time of the electronic device is within a preset time period and the electronic device is in a screen-off state.

[0151] It should be understood that, in this embodiment, the input unit 1004 may include a graphics processing unit (GPU) 1041 and a microphone 1042. The GPU 1041 processes image data of still images or videos obtained by an image capture device (such as a camera) in video capture mode or image capture mode. The display unit 1006 may include a display panel 1061, which may be configured in the form of a liquid crystal display, an organic light-emitting diode, or the like. The user input unit 1007 includes at least one of a touch panel 1071 and other input devices 1072. The touch panel 1071 is also called a touch screen. The touch panel 1071 may include a touch detection device and a touch controller. Other input devices 1072 may include, but are not limited to, physical keyboards, function keys (such as volume control buttons, power buttons, etc.), trackballs, mice, and joysticks, which will not be described in detail here.

[0152] The memory 1009 can be used to store software programs and various data. The memory 1009 may primarily include a first storage area for storing programs or instructions and a second storage area for storing data. The first storage area may store the operating system, application programs or instructions required for at least one function (such as sound playback function, image playback function, etc.). Furthermore, the memory 1009 may include volatile memory or non-volatile memory, or both. The non-volatile memory may be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), or flash memory. Volatile memory can be random access memory (RAM), static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDRSDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous linked dynamic random access memory (SLDRAM), and direct rambus RAM (DRRAM). The memory 1009 in this embodiment includes, but is not limited to, these and any other suitable types of memory.

[0153] Processor 110 may include one or more processing units; optionally, processor 110 integrates an application processor and a modem processor, wherein the application processor mainly handles operations involving the operating system, user interface, and applications, and the modem processor mainly handles wireless communication signals, such as a baseband processor. It is understood that the aforementioned modem processor may also not be integrated into processor 110.

[0154] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element. Furthermore, it should be noted that the scope of the methods and apparatuses in the embodiments of this application is not limited to performing functions in the order shown or discussed, but may also include performing functions substantially simultaneously or in the reverse order, depending on the functions involved. For example, the described methods may be performed in a different order than described, and various steps may be added, omitted, or combined. Additionally, features described with reference to certain examples may be combined in other examples.

[0155] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a computer software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) and includes several instructions to cause a terminal (which may be a mobile phone, computer, server, or network device, etc.) to execute the methods described in the various embodiments of this application.

[0156] The embodiments of this application have been described above with reference to the accompanying drawings. However, this application is not limited to the specific embodiments described above. The specific embodiments described above are merely illustrative and not restrictive. Those skilled in the art can make many other forms under the guidance of this application without departing from the spirit and scope of the claims, and all of these forms are within the protection scope of this application.

Claims

1. A log processing method, characterized in that, The method includes: When the target application is running, N first parameter values ​​are obtained; each first parameter value is used to indicate the amount of system resources occupied by the target application on the electronic device, where N is a positive integer; If the target parameter value among the N first parameter values ​​is greater than or equal to the target threshold, the target log switch is turned on and log information is captured. Prior to activating the target log switch, the method further includes: Determine the target parameter range in which the target parameter value falls; Based on the target parameter range, determine the target number of log switches from the log switches corresponding to the target application, and obtain the target log switches.

2. The method according to claim 1, characterized in that, The target log switch is the log switch in the target application that corresponds to the target parameter value.

3. The method according to claim 1, characterized in that, The method further includes: Receive the registration information submitted by the target application; The target threshold is obtained based on the registration information.

4. The method according to claim 1, characterized in that, The method further includes: The target duration is determined based on the target parameter range; The process of capturing log information includes: Log information is captured within the target duration.

5. The method according to claim 1, characterized in that, After turning on the target log switch and capturing log information, the method further includes: Generate the target log file based on the captured log information; When the system time of the electronic device is within a preset time period and the electronic device is in a screen-off state, the target log file is sent to the server.

6. A log processing device, characterized in that, The log processing device includes: an acquisition module and a control module; The acquisition module is used to acquire N first parameter values ​​when the target application is running; each first parameter value is used to indicate the amount of system resources occupied by the target application on the log processing device, where N is a positive integer; The control module is used to activate the target log switch and capture log information when the target parameter value among the N first parameter values ​​obtained by the acquisition module is greater than or equal to the target threshold. The log processing device further includes: a determination module; The determining module is used to determine the target parameter range in which the target parameter value is located; and to determine the target number of log switches from the log switches corresponding to the target application based on the target parameter range, thereby obtaining the target log switches.

7. The log processing apparatus according to claim 6, characterized in that, The target log switch is the log switch in the target application that corresponds to the target parameter value.

8. The log processing apparatus according to claim 6, characterized in that, The log processing device further includes: a receiving module; The receiving module is used to receive the registration information submitted by the target application; The control module is further configured to obtain a target threshold based on the registration information received by the receiving module.

9. The log processing apparatus according to claim 6, characterized in that, The determining module is further configured to determine the target duration based on the target parameter range; The control module is specifically used to capture log information within the target duration determined by the determining module.

10. The log processing apparatus according to claim 6, characterized in that, The log processing device further includes: a generation module and a sending module; The generation module is used to generate a target log file based on the captured log information; The sending module is used to send the target log file generated by the generation module to the server when the system time of the log processing device is within a preset time period and the log processing device is in a screen-off state.

11. An electronic device, characterized in that, It includes a processor and a memory, the memory storing a program or instructions that can run on the processor, the program or instructions being executed by the processor to implement the steps of the log processing method as described in any one of claims 1 to 5.

12. A readable storage medium, characterized in that, The readable storage medium stores a program or instructions that, when executed by a processor, implement the steps of the log processing method as described in any one of claims 1 to 5.

Citation Information

Patent Citations

  • Process resource real-time monitoring method

    CN105808412A

  • Log collection method and device for application server

    CN110502495A