Log collection method, electronic device and storage medium
By collecting communication logs on the mobile terminal based on the fault monitoring results and controlling them on demand, the problem that the mobile terminal cannot capture communication logs in time due to the default log collection function being turned off during use, and effectively manages the load and power consumption of the equipment system.
Patent Information
- Application Number
- CN202311432785.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-10-30
- Publication Date
- 2025-04-29
- Estimated Expiration
- 2043-10-30
AI Technical Summary
During use, a mobile terminal may experience network communication-related faults, resulting in the log collection function being turned off by default, and the communication log cannot be captured in time, affecting the fault location.
Electronic equipment collects communication logs as needed based on the fault monitoring results, and controls the acquisition operations to avoid excessive impact on system load and power consumption.
It realizes timely collecting related logs when a communication failure occurs, reducing the impact on the load and power consumption of the equipment system, and supports multi-service concurrent communication log collection scenarios.
Smart Images

Figure CN118467282B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of intelligent terminals, and in particular to a log collection method, an electronic device and a storage medium. Background Art
[0002] With the rapid development of communication technology and terminal technology, mobile terminals such as smart phones, tablet computers, and laptops are increasingly being used. When using mobile terminals, network communication-related failures may occur, such as call failures, data service interruptions, and application failures, which seriously affect the user experience.
[0003] For the above faults, professionals usually need to analyze the mobile terminal's tcpdump and other communication logs to locate the mobile terminal fault. However, such logs often contain user privacy data, and the collection function of such logs will seriously increase the load of the mobile terminal when it is turned on. Usually, the collection function of such logs is turned off by default in the mobile terminal, resulting in the inability to capture such logs in time, thus affecting the fault location of the mobile terminal. Summary of the invention
[0004] In order to solve the above technical problems, the present application provides a log collection method, an electronic device and a storage medium. In this method, the electronic device collects communication logs on demand based on the fault monitoring results, and controls the communication log collection operation, which will not cause too much impact on the electronic device system load and power consumption, and can also capture the communication logs related to the communication fault in time.
[0005] In the first aspect, an embodiment of the present application provides a log collection method. The method includes: an electronic device monitors whether a communication failure occurs in an application; when a communication failure occurs in a first application, or when a communication failure is predicted to occur in the first application, it is determined whether to allow the collection of communication logs corresponding to a first port; the first port is a port used by the first application to perform services; when the judgment result indicates that collection is allowed, the collection of communication logs corresponding to the first port is started; when the judgment result indicates that collection is allowed, it is determined whether it is necessary to stop collecting communication logs corresponding to the first port; when the judgment result indicates that collection needs to be stopped, the collection of communication logs corresponding to the first port is stopped.
[0006] The communication log may be a tcpdump log.
[0007] In this way, the electronic device collects communication logs on demand based on the communication fault monitoring results, and controls the start and stop of the communication log collection operation, which will not cause too much impact on the electronic device system load and power consumption. The communication logs related to the communication fault can also be captured in time, so that professionals can locate the fault of the electronic device based on the relevant communication logs.
[0008] According to the first aspect, the electronic device includes a business user and a log collection function provider. In the method, the electronic device determines whether to allow the collection of communication logs corresponding to the first port, including: the business user determines whether to allow the collection of communication logs corresponding to the first port based on a preset first management and control policy. Correspondingly, when the judgment result indicates that the collection is allowed, the electronic device starts to collect the communication logs corresponding to the first port, including: when the judgment result indicates that the collection is allowed, the business user sends a first log collection request to the log collection function provider; the log collection function provider starts to collect the communication logs corresponding to the first port according to the first log collection request.
[0009] Exemplarily, the service user may be the interconnection service mentioned below, and the log collection function provider (or log capture capability provider) may be the maintenance and testing service mentioned below.
[0010] Exemplarily, the log collection request may include but is not limited to the application name (or business name), log collection port number, log collection byte length, file information for saving logs (such as file name, storage path, number of files, etc.), etc.
[0011] Among them, the first control strategy can be understood as a weak control strategy and is configurable.
[0012] In this implementation, the control over the start of communication log collection can be implemented by the business user, and the log collection function provider does not need to control the communication log collection operation.
[0013] According to the first aspect, or any implementation of the first aspect above, in the method, the electronic device determines whether it is necessary to stop collecting the communication log corresponding to the first port, including: the business user determines whether it is necessary to stop collecting the communication log corresponding to the first port based on the first management and control policy. Correspondingly, when the judgment result indicates that the collection needs to be stopped, the electronic device stops collecting the communication log corresponding to the first port, including: when the judgment result indicates that the collection needs to be stopped, the business user sends a first log stop collection request to the log collection function provider; the log collection function provider stops collecting the communication log corresponding to the first port according to the first log stop collection request.
[0014] In this implementation, the control over stopping the collection of communication logs can be implemented by the service user, and the log collection function provider does not need to control the communication log collection operation.
[0015] According to the first aspect, or any implementation of the first aspect above, the first control strategy includes at least one of the following: log collection timing control, log collection timeout control, and log collection authority control.
[0016] According to the first aspect, or any implementation of the first aspect above, the operating system of the electronic device is a Windows operating system.
[0017] In this way, when the operating system of the electronic device is the Windows operating system, the electronic device can adopt a weak control strategy to control the communication log collection function based on communication fault monitoring, and the control is implemented by the business user.
[0018] According to the first aspect, or any one of the implementations of the first aspect above, the electronic device includes a business user and a log collection function provider. When a communication failure is detected in the first application, or when a communication failure is predicted to occur in the first application, the method further includes: the business user sends a second log collection request to the log collection function provider, and the second log collection request is used to request the collection of the communication log corresponding to the first port. Correspondingly, the electronic device determines whether the collection of the communication log corresponding to the first port is allowed, and when the judgment result indicates that the collection is allowed, the collection of the communication log corresponding to the first port is started, including: the log collection function provider determines whether the response to the second log collection request is allowed based on a preset second management and control policy; when the judgment result indicates that the response to the second log collection request is allowed, the log collection function provider starts collecting the communication log corresponding to the first port according to the second log collection request.
[0019] Among them, the second control strategy can be understood as a strong control strategy, which is configurable.
[0020] In this implementation, the control over the start of communication log collection can be implemented by the log collection function provider, and the service user only needs to submit a log collection request to the log collection function provider without the need for relevant control.
[0021] According to the first aspect, or any implementation method of the first aspect above, the electronic device determines whether it is necessary to stop collecting the communication log corresponding to the first port, and when the judgment result indicates that the collection needs to be stopped, stops collecting the communication log corresponding to the first port, including: the business user determines whether it is necessary to stop collecting the communication log corresponding to the first port based on a preset third management and control policy; when the judgment result indicates that the collection needs to be stopped, the business user sends a second log stop collection request to the log collection function provider; the log collection function provider stops collecting the communication log corresponding to the first port according to the second log stop collection request.
[0022] The third control strategy can be understood as a weak control strategy, which can be the same as the first control strategy or different from the first control strategy. Exemplarily, the third control strategy can include log timeout collection control and the like.
[0023] In this implementation, the control over stopping the collection of communication logs can be implemented by the business user, so as to avoid excessive impact on the load of the electronic device caused by too many communication log collection operations.
[0024] According to the first aspect, or any implementation method of the first aspect above, the electronic device determines whether it is necessary to stop collecting the communication log corresponding to the first port, and when the judgment result indicates that the collection needs to be stopped, stops collecting the communication log corresponding to the first port, including: the log collection function provider determines whether it is necessary to stop collecting the communication log corresponding to the first port based on the second management and control strategy; when the judgment result indicates that the collection needs to be stopped, the log collection function provider stops collecting the communication log corresponding to the first port.
[0025] In this implementation, the control over stopping the collection of communication logs may also be implemented by the log collection function provider, so as to avoid excessive impact on the load of the electronic device caused by too many communication log collection operations.
[0026] According to the first aspect, or any implementation of the first aspect above, the log collection function provider determines whether to allow responding to the second log collection request based on a preset second management and control policy, including at least one of the following:
[0027] If the service corresponding to the second log collection request is not included in the service whitelist, the log collection function provider determines that it is not allowed to respond to the second log collection request;
[0028] If the current system load exceeds the load threshold, the log collection function provider determines that it is not allowed to respond to the second log collection request;
[0029] If the currently counted communication log collection frequency is higher than the frequency threshold, or the currently counted communication log collection frequency is higher than the number threshold, the log collection function provider determines that it is not allowed to respond to the second log collection request;
[0030] If the currently counted communication log collection flow rate is higher than the flow threshold, the log collection function provider determines that it is not allowed to respond to the second log collection request;
[0031] If there is no remaining communication log collection quota, the log collection function provider determines that it is not allowed to respond to the second log collection request;
[0032] If there is a repeated collection phenomenon corresponding to the second log collection request, the log collection function provider determines that it is not allowed to respond to the second log collection request.
[0033] According to the first aspect, or any implementation of the first aspect above, the method further includes:
[0034] When a communication failure of the second application is detected or a communication failure of the second application is predicted to occur, the service user sends a third log collection request to the log collection function provider, where the third log collection request is used to request collection of communication logs corresponding to the second port; the second port is a port used by the second application to execute services;
[0035] The log collection function provider determines whether to allow responding to the third log collection request based on the second control policy;
[0036] When the determination result indicates that the third log collection request is allowed to be responded to, the log collection function provider starts collecting the communication log corresponding to the second port according to the third log collection request.
[0037] In this way, the electronic device supports concurrent execution of communication log collection operations triggered by multiple services. The log collection function provider can collect communication logs for multiple ports at the same time, which can adapt to the scenario of multiple concurrent communication failures.
[0038] According to the first aspect, or any implementation of the first aspect above, the operating system of the electronic device is an Android operating system.
[0039] When the operating system of the electronic device is the Android operating system, the electronic device can adopt a strong control strategy to control the communication log collection function based on communication fault monitoring, and the control is implemented by the communication log collection function provider.
[0040] According to the first aspect, or any implementation of the first aspect above, before starting to collect the communication log corresponding to the first port, it also includes: if the log collection function corresponding to the first port is not turned on, then turn on the log collection function corresponding to the first port. Correspondingly, after stopping collecting the communication log corresponding to the first port, the method also includes: if the first target service does not currently exist, then turn off the log collection function corresponding to the first port; wherein the first target service is used to collect the communication log corresponding to the first port, and the first target service is actively triggered by the user.
[0041] Exemplarily, the first target service may be triggered by a user in a trouble ticket application.
[0042] In this way, the electronic device can turn on or off the log collection function of the relevant port as needed based on the fault monitoring result, without conflicting with other services for collecting communication logs and affecting the user experience.
[0043] According to the first aspect, or any implementation method of the first aspect above, before starting to collect the communication log corresponding to the first port, it also includes: determining whether the storage operation of the communication log corresponding to the first port conflicts with the second target business; wherein the second target business is used to collect the communication log, and the second target business is actively triggered by the user; if there is a conflict, adjusting relevant parameters to resolve the conflict.
[0044] Exemplarily, the second target service may be triggered by a user in a trouble ticket application.
[0045] Exemplarily, the conflict may be a log file naming conflict, a log file storage path conflict, or the like.
[0046] In this way, the electronic device collects communication logs on demand based on the fault monitoring result, and does not conflict with other services for collecting communication logs, and does not affect the user experience.
[0047] According to the first aspect, or any implementation of the first aspect above, the method further includes: in response to a user operation, packaging and uploading the collected communication logs corresponding to the first port to a cloud server.
[0048] Illustratively, the user operation may be a trouble ticket operation performed by the user in a trouble ticket application.
[0049] In this way, the communication logs collected by the electronic device based on the communication fault monitoring results can be packaged and uploaded to the cloud server when the user picks up the order for professionals to review and locate the fault of the electronic device based on these communication logs.
[0050] In a second aspect, an embodiment of the present application provides an electronic device. The electronic device includes: one or more processors; a memory; and one or more computer programs, wherein the one or more computer programs are stored in the memory, and when the computer programs are executed by the one or more processors, the electronic device executes the log collection method of the first aspect and any one of the first aspects.
[0051] The second aspect and any implementation of the second aspect correspond to the first aspect and any implementation of the first aspect respectively. The technical effects corresponding to the second aspect and any implementation of the second aspect can refer to the technical effects corresponding to the above-mentioned first aspect and any implementation of the first aspect, which will not be repeated here.
[0052] In a third aspect, an embodiment of the present application provides a computer-readable storage medium. The computer-readable storage medium includes a computer program, and when the computer program is executed on an electronic device, the electronic device executes the log collection method of the first aspect and any one of the first aspects.
[0053] The third aspect and any implementation of the third aspect correspond to the first aspect and any implementation of the first aspect, respectively. The technical effects corresponding to the third aspect and any implementation of the third aspect can refer to the technical effects corresponding to the first aspect and any implementation of the first aspect, which will not be repeated here.
[0054] In a fourth aspect, an embodiment of the present application provides a computer program product, including a computer program, which, when executed, enables a computer to execute a log collection method according to the first aspect or any one of the first aspects.
[0055] The fourth aspect and any implementation of the fourth aspect correspond to the first aspect and any implementation of the first aspect, respectively. The technical effects corresponding to the fourth aspect and any implementation of the fourth aspect can refer to the technical effects corresponding to the above-mentioned first aspect and any implementation of the first aspect, which will not be repeated here.
[0056] In a fifth aspect, the present application provides a chip, the chip comprising a processing circuit and a transceiver pin, wherein the transceiver pin and the processing circuit communicate with each other through an internal connection path, and the processing circuit executes the log collection method as in the first aspect or any one of the first aspects to control the receiving pin to receive a signal, and to control the sending pin to send a signal.
[0057] The fifth aspect and any implementation of the fifth aspect correspond to the first aspect and any implementation of the first aspect, respectively. The technical effects corresponding to the fifth aspect and any implementation of the fifth aspect can refer to the technical effects corresponding to the first aspect and any implementation of the first aspect, which will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0058] Figure 1a A schematic diagram of an application scenario is shown as an example;
[0059] Figure 1b A schematic diagram of an application scenario is shown as an example;
[0060] Figure 2 This is a schematic diagram of an interface for exemplarily showing a user submitting a fault notification to a terminal in a fault notification application;
[0061] Figure 3 is a schematic diagram of the hardware structure of an electronic device shown as an example;
[0062] Figure 4 A schematic diagram of the software structure of an electronic device is shown as an example;
[0063] Figure 5aThe diagram is a schematic diagram of module interactions involved in the log collection method shown as an example;
[0064] Figure 5b A flow chart of a log collection method is shown as an example;
[0065] Figure 6 The diagram is a schematic diagram of module interactions involved in the log collection method shown as an example;
[0066] Figure 7 The diagram is a schematic diagram of module interactions involved in the log collection method shown as an example;
[0067] Figure 8 The diagram is a schematic diagram of module interactions involved in the log collection method shown as an example;
[0068] Figure 9a The following is a framework diagram of an implementation of a log collection method in an electronic device of an Android operating system, which is exemplified;
[0069] Figure 9b The figure is a framework diagram for implementing a log collection method in an electronic device of a Windows operating system, which is shown as an example. DETAILED DESCRIPTION
[0070] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0071] The term "and / or" in this article is merely a description of the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone.
[0072] The terms "first" and "second" in the description and claims of the embodiments of the present application are used to distinguish different objects rather than to describe a specific order of objects. For example, a first target object and a second target object are used to distinguish different target objects rather than to describe a specific order of target objects.
[0073] In the embodiments of the present application, words such as "exemplary" or "for example" are used to indicate examples, illustrations or descriptions. Any embodiment or design described as "exemplary" or "for example" in the embodiments of the present application should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of words such as "exemplary" or "for example" is intended to present related concepts in a specific way.
[0074] In the description of the embodiments of the present application, unless otherwise specified, the meaning of "multiple" refers to two or more than two. For example, multiple processing units refer to two or more processing units; multiple systems refer to two or more systems.
[0075] With the rapid development of communication technology and terminal technology, terminals such as smart phones, tablet computers, and laptops are being used more and more widely. Moreover, with the continuous enrichment of terminal types, the coordinated use of multiple devices is becoming more and more widespread. Whether the terminal is used by the user alone or in collaboration with other terminals, network communication-related failures may occur during the use of the terminal, such as call failures, data service interruptions, and application failures, which seriously affect the user experience.
[0076] Figure 1a An exemplary keyboard and mouse sharing application scenario is shown. Figure 1a As shown, the wireless mouse 11 and the wireless keyboard 12 establish a Bluetooth connection with the laptop computer 13, and the wireless mouse 11 and the wireless keyboard 12 establish a Bluetooth connection with the desktop computer 14, and the wireless mouse 11 and the wireless keyboard 12 also establish a Bluetooth connection with the tablet computer 15. After the wireless mouse 11 and the wireless keyboard 12 are connected to multiple hosts, and the user completes the relevant settings of the keyboard and mouse crossing function, the user moves the wireless mouse 11, and the cursor of the wireless mouse 11 can cross the host screen boundary to achieve the keyboard and mouse (i.e., the wireless mouse 11 and the wireless keyboard 12) crossing between multiple devices. That is, the user can use the wireless mouse 11 and the wireless keyboard 12 to control the laptop computer 13, the desktop computer 14, and the tablet computer 15. For example, when the cursor of the wireless mouse 11 is displayed on the interface 1 of the laptop computer 13, the user can use the wireless keyboard 12 to implement the typing operation on the laptop computer 13. At this time, the user moves the wireless mouse 11, and can control the cursor of the wireless mouse 11 to pass from the interface 1 of the laptop computer 13 to the interface 2 of the desktop computer 14. The wireless keyboard 12 passes along with the wireless mouse 11, and then the user can use the wireless keyboard 12 to perform typing operations on the desktop computer 14. Similarly, the user moves the wireless mouse 11, and can control the cursor of the wireless mouse 11 to pass from the interface 2 of the desktop computer 14 to the interface 3 of the tablet computer 15. The wireless keyboard 12 passes along with the wireless mouse 11, and then the user can use the wireless keyboard 12 to perform typing operations on the tablet computer 15. However, in Figure 1a In the keyboard and mouse sharing application scenario shown, the user may move the wireless mouse 11 but fail to move the keyboard and mouse across multiple devices, or the user may fail to type using the wireless keyboard 12, which seriously affects the user experience.
[0077] Based on the device interconnection service, task status transfer and task data synchronization can be achieved between mobile phones, PCs (Personal Computers), tablets, smart screens and other devices, providing users with an experience of freely transferring application tasks between different devices. For example, devices in the same trust ring can automatically connect when they are close to each other, and calls, notifications, documents, audio and video services can flow between various devices. Figure 1b The schematic diagram of the application scenario of audio and video playback continuity is shown as an example. Figure 1b As shown, the user is watching a movie on the mobile phone. When the user arrives home, the mobile phone automatically prompts the nearby smart screen that can be connected. For example, after the mobile phone automatically connects to the smart screen, a prompt window 201 pops up to indicate that the user can use the smart screen to continue watching the movie. The user clicks the prompt window 201. In response to the user's operation, the current playback progress of the movie on the mobile phone is seamlessly synchronized to the smart screen. At this time, the user continues to watch the movie through the smart screen, so that the user's immersive viewing experience is not interrupted. However, in, for example Figure 1b In the application connection scenario shown, problems such as device interconnection failure, application connection failure, and application interruption may occur, which seriously affects the user experience.
[0078] When the terminal has the above-mentioned problems related to network communication, professionals usually need to analyze the communication logs (log) such as the tcpdump log of the terminal to locate the fault of the terminal. It can be understood that the communication log (log) refers to the log related to the communication protocol layer, which can be used to analyze the communication network failure. Among them, the tcpdump log is a kind of communication log, which is a log related to the tcp protocol layer. This embodiment does not limit the specific type of the communication log.
[0079] The characteristic of communication logs (logs) is that a large number of data packets are generated in a short period of time, and the content is relatively rich. When the terminal collects (or captures) such logs, it will seriously consume the terminal's CPU (Central Processing Unit), I / O (Input / Output) and other resources, resulting in a serious increase in the system load of the entire machine. Moreover, such logs often contain user privacy data. Therefore, the terminal usually turns off the collection function of such logs by default.
[0080] In this way, when the terminal encounters the above-mentioned problems related to network communication, the terminal cannot collect relevant communication logs in time, which makes it impossible for professionals to locate the fault of the terminal.
[0081] Since the terminal communication log collection function is disabled by default, after the terminal encounters the above-mentioned network communication-related problems, the capture of relevant communication logs can only rely on the terminal failure to recur (reproduce). Among them, users can obtain relevant communication logs through the fault ticket tool (or fault ticket application) and upload the relevant communication logs to the cloud for professional review.
[0082] Figure 2 The following is an example of a fault ticketing tool interface diagram. When a user files a fault ticket for a terminal device, he needs to first select the fault problem so that the fault ticketing tool can call the relevant packet capture tool to capture the logs related to the fault. When the fault problem selected by the user is a protocol problem (including calls, network searches, data, etc.), the user needs to turn on the "communication log capture" function in the fault ticketing tool. For example, Figure 2 As shown in (1), the user clicks control 301 to enable the "communication log capture" function in the fault ticket tool, so that the fault ticket tool calls the relevant packet capture tool to capture the relevant communication log. After the user selects the fault problem, the packet capture tool starts to capture the relevant communication log and record the communication log. Figure 2 As shown in (1). The user clicks the "one-click package" control 302 to package the recorded communication logs. Then, when the user submits a fault ticket, the packaged communication logs are uploaded to the cloud together with the fault ticket information for analysis by professionals. Regarding the instructions for using the fault ticket tool, any details not explained here can be referred to the existing technology and will not be repeated here.
[0083] In the process of capturing logs by the fault ticket tool, if the terminal fault recurs, the packet capture tool can automatically capture the communication logs related to the fault, and then the user can package the relevant communication logs through the "one-click packaging" control. The packaged communication logs and fault ticket information are uploaded to the cloud together for professionals to view. That is, when the user successfully reproduces the terminal fault scenario, the professional can obtain the communication logs related to the corresponding fault, and then locate the terminal fault by analyzing the relevant communication logs. However, some terminal faults are sporadic or occur infrequently, which makes it difficult for users to reproduce the terminal fault scenario, making the communication logs related to the corresponding fault unable to be captured by the packet capture tool, thereby affecting the professional's location of the terminal fault, which becomes the main pain point for professionals when performing business maintenance and testing.
[0084] In order to solve the above problems, an embodiment of the present application provides a log collection method. In this method, the electronic device performs communication fault monitoring and automatically starts the communication log collection function when a communication fault occurs or when a communication fault is estimated to occur. In this way, the electronic device starts the communication log collection function on demand, which will not cause too much impact on the electronic device system load and power consumption, and can also capture the communication log related to the communication fault in time, so that professionals can locate the fault of the electronic device based on the relevant communication log.
[0085] The above-mentioned electronic devices may include mobile phones, tablet computers, laptops, smart screens, smart speakers, personal computers, ultra-mobile personal computers (UMPCs), handheld computers, netbooks, smart home devices (such as smart TVs, large screens, smart air conditioners, etc.), personal digital assistants (PDAs), wearable devices (such as smart watches, smart bracelets, etc.), vehicle-mounted devices, virtual reality devices, etc., and the embodiments of the present application do not impose any restrictions on this.
[0086] The operating system of the above-mentioned electronic device can be a Windows system, an Android system, etc., and the embodiments of the present application do not impose any restrictions on this.
[0087] like Figure 3 FIG. 1 is a schematic diagram of the structure of the electronic device 100. Optionally, the electronic device 100 may be a terminal, which may also be referred to as a terminal device. The terminal may be a cellular phone or a tablet computer, etc., which is not limited in this application. It should be noted that the schematic diagram of the structure of the electronic device 100 may be applicable to Figure 1a to Figure 1b mobile phones, tablet computers, laptops, desktop computers, etc. It should be understood that Figure 3 The electronic device 100 shown is only one example of an electronic device, and the electronic device 100 may have more or fewer components than shown in the figure, may combine two or more components, or may have a different configuration of components. Figure 3 The various components shown in the EMBODIMENTS 2000 may be implemented in hardware, software, or a combination of hardware and software, including one or more signal processing and / or application specific integrated circuits.
[0088] The electronic device 100 may include: a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, an earphone interface 170D, a sensor module 180, a button 190, a motor 191, an indicator 192, a camera 193, a display screen 194, and a subscriber identification module (SIM) card interface 195, etc. The sensor module 180 may include a pressure sensor, a gyroscope sensor, an acceleration sensor, a temperature sensor, a motion sensor, an air pressure sensor, a magnetic sensor, a distance sensor, a proximity light sensor, a fingerprint sensor, a touch sensor, an ambient light sensor, a bone conduction sensor, etc.
[0089] The processor 110 may include one or more processing units, for example, the processor 110 may include an application processor (AP), a modem processor, a graphics processor (GPU), an image signal processor (ISP), a controller, a memory, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU), etc. Different processing units may be independent devices or integrated into one or more processors.
[0090] The controller may be the nerve center and command center of the electronic device 100. The controller may generate an operation control signal according to the instruction operation code and the timing signal to complete the control of fetching and executing instructions.
[0091] A memory may also be provided in the processor 110 for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory.
[0092] In some embodiments, the processor 110 may include one or more interfaces. The interface may include an inter-integrated circuit (I2C) interface, an inter-integrated circuit sound (I2S) interface, a pulse code modulation (PCM) interface, a universal asynchronous receiver / transmitter (UART) interface, a mobile industry processor interface (MIPI), a general-purpose input / output (GPIO) interface, a subscriber identity module (SIM) interface, and / or a universal serial bus (USB) interface, etc.
[0093] It is understandable that the interface connection relationship between the modules illustrated in the embodiment of the present application is only a schematic illustration and does not constitute a structural limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 may also adopt different interface connection methods in the above embodiments, or a combination of multiple interface connection methods.
[0094] The wireless communication function of the electronic device 100 can be implemented through the antenna 1, the antenna 2, the mobile communication module 150, the wireless communication module 160, the modem processor and the baseband processor.
[0095] Antenna 1 and antenna 2 are used to transmit and receive electromagnetic wave signals. Each antenna in electronic device 100 can be used to cover a single or multiple communication frequency bands. Different antennas can also be reused to improve the utilization of antennas. For example, antenna 1 can be reused as a diversity antenna for a wireless local area network. In some other embodiments, the antenna can be used in combination with a tuning switch.
[0096] The mobile communication module 150 can provide solutions for wireless communications including 2G / 3G / 4G / 5G, etc., applied to the electronic device 100. The mobile communication module 150 may include at least one filter, a switch, a power amplifier, a low noise amplifier (LNA), etc. The mobile communication module 150 can receive electromagnetic waves from the antenna 1, and filter, amplify, and process the received electromagnetic waves, and transmit them to the modulation and demodulation processor for demodulation. The mobile communication module 150 can also amplify the signal modulated by the modulation and demodulation processor, and convert it into electromagnetic waves for radiation through the antenna 1. In some embodiments, at least some of the functional modules of the mobile communication module 150 can be set in the processor 110. In some embodiments, at least some of the functional modules of the mobile communication module 150 can be set in the same device as at least some of the modules of the processor 110.
[0097] The modem processor may include a modulator and a demodulator. Among them, the modulator is used to modulate the low-frequency baseband signal to be sent into a medium-high frequency signal. The demodulator is used to demodulate the received electromagnetic wave signal into a low-frequency baseband signal. The demodulator then transmits the demodulated low-frequency baseband signal to the baseband processor for processing. After the low-frequency baseband signal is processed by the baseband processor, it is passed to the application processor. The application processor outputs a sound signal through an audio device (not limited to a speaker 170A, a receiver 170B, etc.), or displays an image or video through a display screen 194. In some embodiments, the modem processor may be an independent device. In other embodiments, the modem processor may be independent of the processor 110 and be set in the same device as the mobile communication module 150 or other functional modules.
[0098] The wireless communication module 160 can provide wireless communication solutions including wireless local area networks (WLAN) (such as wireless fidelity (Wi-Fi) networks), bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), infrared (IR), etc., which are applied to the electronic device 100. The wireless communication module 160 can be one or more devices integrating at least one communication processing module. The wireless communication module 160 receives electromagnetic waves via the antenna 2, modulates the frequency of the electromagnetic wave signal and performs filtering, and sends the processed signal to the processor 110. The wireless communication module 160 can also receive the signal to be sent from the processor 110, modulate the frequency of it, amplify it, and convert it into electromagnetic waves for radiation through the antenna 2.
[0099] In some embodiments, antenna 1 of electronic device 100 is coupled to mobile communication module 150, and antenna 2 is coupled to wireless communication module 160, so that electronic device 100 can communicate with the network and other devices through wireless communication technology.
[0100] The electronic device 100 implements the display function through a GPU, a display screen 194, and an application processor. The GPU is a microprocessor for image processing, which connects the display screen 194 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. The processor 110 may include one or more GPUs that execute program instructions to generate or change display information.
[0101] The display screen 194 is used to display images, videos, etc. The display screen 194 includes a display panel. In some embodiments, the electronic device 100 may include 1 or N display screens 194, where N is a positive integer greater than 1.
[0102] The external memory interface 120 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device 100. The external memory card communicates with the processor 110 via the external memory interface 120 to implement a data storage function.
[0103] The internal memory 121 can be used to store computer executable program codes, which include instructions. The processor 110 executes various functional applications and data processing of the electronic device 100 by running the instructions stored in the internal memory 121. The internal memory 121 may include a program storage area and a data storage area. Among them, the program storage area may store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc. The data storage area may store data created during the use of the electronic device 100 (such as audio data, a phone book, etc.), etc. In addition, the internal memory 121 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, a universal flash storage (UFS), etc.
[0104] The electronic device 100 can implement audio functions such as music playing and recording through the audio module 170, the speaker 170A, the receiver 170B, the microphone 170C, the headphone jack 170D, and the application processor.
[0105] The pressure sensor is used to sense the pressure signal and can convert the pressure signal into an electrical signal. In some embodiments, the pressure sensor can be arranged on the display screen 194. The electronic device 100 can also calculate the touch position according to the detection signal of the pressure sensor.
[0106] The touch sensor is also called a "touch panel". The touch sensor can be set on the display screen 194. The touch sensor and the display screen 194 form a touch screen, also called a "touch screen". The touch sensor is used to detect a touch operation on or near it. The touch sensor can pass the detected touch operation to the application processor to determine the type of touch event.
[0107] The key 190 includes a power key (or power key), a volume key, etc. The key 190 may be a mechanical key or a touch key. The electronic device 100 may receive key input and generate key signal input related to user settings and function control of the electronic device 100.
[0108] Motor 191 can generate vibration prompts. Motor 191 can be used for incoming call vibration prompts, and can also be used for touch vibration feedback. For example, touch operations acting on different applications (such as taking pictures, audio playback, etc.) can correspond to different vibration feedback effects.
[0109] Indicator 192 may be an indicator light, which may be used to indicate charging status, power changes, messages, missed calls, notifications, etc.
[0110] The SIM card interface 195 is used to connect a SIM card. The SIM card can be connected to or disconnected from the electronic device 100 by inserting or removing the SIM card interface 195. The electronic device 100 can support 1 or N SIM card interfaces, where N is a positive integer greater than 1.
[0111] The software system of the electronic device 100 may adopt a layered architecture, an event-driven architecture, a micro-core architecture, a micro-service architecture, or a cloud architecture. The embodiment of the present application takes the Android system of the layered architecture as an example to exemplify the software structure of the electronic device 100.
[0112] Figure 4 It is a software structure block diagram of the electronic device 100 according to an embodiment of the present application.
[0113] The layered architecture of the electronic device 100 divides the software into several layers, each with clear roles and division of labor. The layers communicate with each other through software interfaces. In some embodiments, the Android system is divided into four layers, from top to bottom, namely, the application layer, the application framework layer, the Android runtime (Android Runtime) and the Native system library, and the kernel layer.
[0114] The application layer can include a series of application packages.
[0115] like Figure 4 As shown, the application package may include office business applications, such as super call, super connection, super keyboard and mouse, super notification, etc., and fault ticket applications (such as BetaClub applications). In addition, the application package may also include camera, gallery, WLAN, Bluetooth, call, calendar, map, navigation, music, video, short message and other applications.
[0116] Among them, users can use the fault ticket tool to feedback problems encountered during the use of electronic devices to professionals. The fault ticket tool can capture relevant logs (such as communication logs) according to the user's settings and upload the captured relevant logs to the cloud for professionals to review.
[0117] The application framework layer provides an application programming interface (API) and a programming framework for the applications in the application layer. The application framework layer includes some predefined functions.
[0118] like Figure 4 As shown, the application framework layer may include interconnection services and maintenance services.
[0119] Among them, the interconnection service can be used to provide management services related to terminal interconnection, for example, it can be used to support the function implementation of applications such as super call, super connection, super keyboard and mouse, super notification, etc. Exemplarily, the interconnection service may include a connection management module and a connection communication module. The connection management module can be used to implement relevant management of terminal interconnection, and the connection communication module can be used to implement connection communication when the terminals are interconnected.
[0120] In an embodiment of the present application, the interconnection service may further include a fault monitoring module and a log collection decision module. Among them, the fault monitoring module can be used to monitor the communication failure of the application in the electronic device, such as whether there is packet loss in the application, whether the data packet delay of the application is too large, whether the electronic device has a network disconnection phenomenon, whether the application has not received the request response information, etc. The log collection decision module can be used to determine whether it is necessary to capture the communication log of the electronic device based on the communication failure monitoring results of the fault monitoring module. For example, when the fault monitoring module detects that a communication failure has occurred in the electronic device or a communication failure is about to occur, it is determined that the communication log of the electronic device needs to be captured.
[0121] Maintenance and testing services can be used to provide services related to electronic equipment maintenance and testing, such as providing log collection and reporting functions. Exemplarily, maintenance and testing services can include a log collection management module, a log collection module, a log packaging module, and a log reporting module.
[0122] Among them, the log collection control module can be used to control the communication log capture and determine whether it is possible to start capturing the communication log. For example, the log collection control module can control the communication log collection based on one or more of the business whitelist, communication log collection frequency, communication log collection quota, and total communication log collection amount, and determine whether it is possible to start collecting communication logs.
[0123] The log packaging module can be used to package the collected logs. In this embodiment, the log packaging module can be specifically used to package the collected communication logs.
[0124] The log reporting module can be used to report the log (such as the communication log) packaged by the log packaging module, for example, to the cloud server. Exemplarily, the log reporting module can report the communication log packaged by the log packaging module when the user files a fault ticket.
[0125] In an optional implementation, the maintenance and testing service may also be integrated into the fault ticket tool, which is not limited in the present application embodiment. For example, when the operating system of the electronic device is not an Android system, for example, the operating system of the electronic device is a Windows system, the maintenance and testing service may be integrated into the fault ticket tool.
[0126] Continue to refer to Figure 4 , the application framework layer can also include window manager, content provider, view system, phone manager, resource manager, notification manager, etc.
[0127] The window manager is used to manage window programs. The window manager can obtain the display screen size, determine whether there is a status bar, lock the screen, capture the screen, etc.
[0128] Content providers are used to store and retrieve data and make it accessible to applications. The data may include videos, images, audio, calls made and received, browsing history and bookmarks, phone books, etc.
[0129] The view system includes visual controls, such as controls for displaying text, controls for displaying images, etc. The view system can be used to build applications. A display interface can be composed of one or more views. For example, a display interface including a text notification icon can include a view for displaying text and a view for displaying images.
[0130] The phone manager is used to provide communication functions for electronic devices, such as the management of call status (including answering, hanging up, etc.).
[0131] The resource manager provides various resources for applications, such as localized strings, icons, images, layout files, video files, and so on.
[0132] The notification manager allows applications to display notification information in the status bar, which can be used to convey notification-type messages and can disappear automatically after a short stay without user interaction. For example, notification information is used to inform the completion of downloads, message reminders, etc. Notification information can also appear in the system top status bar in the form of icons or scroll bar text, such as notifications of applications running in the background, or in the form of dialog windows on the screen. Notification information can be, for example, text information prompted in the status bar, a prompt sound, vibration of electronic equipment, flashing indicator lights, etc.
[0133] Android Runtime includes core libraries and virtual machines. Android Runtime is responsible for scheduling and management of the Android system.
[0134] The core library consists of two parts: one part is the function that needs to be called by the Java language, and the other part is the Android core library.
[0135] The application layer and the application framework layer run in a virtual machine. The virtual machine executes the Java files of the application layer and the application framework layer as binary files. The virtual machine is used to perform functions such as object life cycle management, stack management, thread management, security and exception management, and garbage collection.
[0136] The Native system library can include multiple functional modules, such as maintenance and testing modules, log collection services, surface managers, media libraries, 3D graphics processing libraries (such as OpenGL ES), 2D graphics engines (such as SGL), etc.
[0137] The maintenance and testing module can be used to support the functional implementation of the maintenance and testing service in the application framework layer. For example, the log collection module can be called to perform communication log collection operations under the instruction of the maintenance and testing service.
[0138] The log collection module can be used to start the log collection operation under the call of the maintenance and testing module. In this embodiment, the log collection module can start the communication log collection operation under the call of the maintenance and testing module. Exemplarily, the log collection module can be a tcpdump log collection service.
[0139] It should be noted that the maintenance and testing services in the application framework layer and the maintenance and testing modules in the Native system library can be used together to provide functions related to log collection. Due to some permission issues, the maintenance and testing services in the application framework layer can call the maintenance and testing modules in the Native system library, and the maintenance and testing modules in the Native system library can call the log collection module to perform log collection operations.
[0140] The surface manager is used to manage the display subsystem and provide the fusion of 2D and 3D layers for multiple applications.
[0141] The media library supports playback and recording of a variety of commonly used audio and video formats, as well as static image files, etc. The media library can support a variety of audio and video encoding formats, such as: MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, etc.
[0142] The 3D graphics processing library is used to implement 3D graphics drawing, image rendering, compositing, and layer processing.
[0143] A 2D graphics engine is a drawing engine for 2D drawings.
[0144] The kernel layer is the layer between hardware and software. The kernel layer includes at least display drivers, Bluetooth drivers, Wi-Fi drivers, sensor drivers, etc. Among them, the hardware includes at least processors, display screens, wireless communication chips (such as Bluetooth chips, Wi-Fi chips, etc.), sensors, etc.
[0145] Understandably, Figure 4 The layers in the software structure shown and the components included in each layer do not constitute a specific limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 may include more or fewer layers than shown, and each layer may include more or fewer components, which is not limited in the present application.
[0146] It is understandable that in order to implement the log collection method in the embodiment of the present application, the electronic device includes hardware and / or software modules corresponding to the execution of each function. In combination with the algorithm steps of each example described in the embodiments disclosed herein, the present application can be implemented in the form of hardware or a combination of hardware and computer software. Whether a function is executed in the form of hardware or computer software driving hardware depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application in combination with the embodiments, but such implementation should not be considered to be beyond the scope of the present application.
[0147] The embodiment of the present application provides a log collection method. In this method, the electronic device can monitor whether a communication failure occurs in an application, or can predict whether a communication failure is about to occur in an application, and when a communication failure is detected in the application, or when a communication failure is predicted to occur in the application, the electronic device starts to collect relevant communication logs, and stops collecting relevant communication logs when certain conditions are met, such as when the communication failure is eliminated or the communication log collection times out.
[0148] like Figure 5a The following is a schematic diagram of the interaction between the modules. Figure 5a The process of the log collection method provided in the embodiment of the present application specifically includes:
[0149] S401, the fault monitoring module detects that a communication fault occurs in application 1, or predicts that a communication fault is about to occur in application 1, and sends the monitoring result to the log collection decision module.
[0150] The fault monitoring module monitors whether each application has a communication fault, or predicts whether each application is about to have a communication fault. Exemplarily, the fault monitoring module can monitor whether each application has a communication fault, or predict whether each application is about to have a communication fault based on information such as whether the application has packet loss, data packet delay, and whether a request response is not received after sending a request.
[0151] S402, the log collection decision module calls the log collection module / tool to start collecting communication logs corresponding to application 1.
[0152] The communication log may specifically refer to a tcpdump log. The log collection module / tool may be a functional module for collecting tcpdump logs or a third-party packet capture tool.
[0153] When receiving the monitoring results of the fault monitoring module, the log collection decision module determines that it is necessary to start collecting the communication logs corresponding to application 1, and constructs relevant calling parameters to call the log collection module / tool to start collecting the communication logs corresponding to application 1.
[0154] When it is determined that the communication log corresponding to the application 1 needs to be collected, if the communication log collection function of the electronic device is not turned on, the communication log collection function of the electronic device needs to be turned on first.
[0155] Exemplarily, the parameters for calling the log collection module / tool to start collecting communication logs may include, but are not limited to, application identifier (or business identifier), log collection port, number of log collection bytes, file information for saving logs (such as file path, file name, etc.), number of files for saving logs, log collection duration, etc.
[0156] S403 , the log collection module / tool starts collecting communication logs corresponding to application 1 .
[0157] S404 , the log collection decision module determines to stop collecting the communication logs corresponding to application 1 , and calls the log collection module / tool to stop collecting the communication logs corresponding to application 1 .
[0158] When certain conditions are met, the log collection decision module can determine to stop collecting the communication logs corresponding to application 1. For example, when the duration of the communication log collection by the log collection module / tool reaches the log collection duration, or when the number of communication log bytes collected by the log collection module / tool reaches the number of log collection bytes, the log collection decision module determines to stop collecting the communication logs corresponding to application 1. For another example, when the fault monitoring module detects that the communication fault of application 1 disappears, the log collection decision module determines to stop collecting the communication logs corresponding to application 1.
[0159] When the log collection decision module determines to stop collecting the communication logs corresponding to application 1, relevant call parameters are constructed to call the log collection module / tool to stop collecting the communication logs corresponding to application 1. Exemplarily, the parameters for calling the log collection module / tool to stop collecting the communication logs may include but are not limited to the application identifier (or service identifier), the log collection port, etc.
[0160] S405 , the log collection module / tool stops collecting the communication logs corresponding to application 1 .
[0161] If the port used by application 1 to execute the service is port 1, the log collection module / tool starts collecting the communication logs corresponding to application 1, that is, starts collecting the communication logs corresponding to port 1. Correspondingly, the log collection module / tool stops collecting the communication logs corresponding to application 1, that is, stops collecting the communication logs corresponding to port 1.
[0162] Before starting to collect the communication log corresponding to port 1, if the communication log collection function corresponding to port 1 is turned off, the communication log collection function corresponding to port 1 needs to be turned on. After stopping collecting the communication log corresponding to port 1, if the electronic device does not have other services that require collecting the communication log corresponding to port 1, such as log collection services actively triggered by the user in the fault ticket application, the communication log collection function corresponding to port 1 will be turned off. The same is true for turning on and off the communication log collection function corresponding to other ports, which will not be repeated here.
[0163] In this way, the electronic device monitors the communication failure of the application and dynamically turns on or off the communication log collection function according to the communication failure monitoring results, thereby timely collecting communication logs related to the communication failure and reducing the impact on the device system load and power consumption.
[0164] Given that the collection of communication logs (such as tcpdump logs) consumes resources such as CPU and I / O, resulting in a high load on the entire machine, frequent collection of communication logs due to frequent failures will inevitably seriously affect the load and power consumption of the device system. Therefore, in the log collection method provided in the embodiment of the present application, the communication logs collected dynamically based on communication failures of electronic devices are managed and controlled, and the rationality of the power consumption of communication log collection is controlled to avoid serious impact on the load and power consumption of the device system.
[0165] Figure 5b The flowchart of a log collection method is shown as an example. Figure 5b As shown, when the electronic device detects that application 1 has a communication failure, or predicts that application 1 is about to have a communication failure, the electronic device determines whether to allow the collection of the communication log corresponding to port 1. Only when the judgment result indicates that the collection is allowed, the electronic device starts to collect the communication log corresponding to port 1. After the electronic device starts to collect the communication log corresponding to port 1, it is also necessary to determine whether to stop collecting the communication log corresponding to port 1, so as to stop collecting the relevant logs in time.
[0166] In this way, the electronic device controls the log collection operation based on the communication fault monitoring result, so as to avoid the communication log collection operation from having an excessive impact on the load and power consumption of the electronic device.
[0167] In an embodiment of the present application, the control mode of the electronic device for the collection of communication logs can be divided into a weak control mode and a strong control mode to reduce the impact on the device system and power consumption. In the weak control mode, the log capture capability provider (such as maintenance and testing services) does not perform control, but is controlled by the business user (such as Internet services). Specifically, the business user can control privacy compliance and the timing of log capture according to its application scenario. In the strong control mode, the log capture capability provider performs control, and the business user only calls the relevant interface to realize the collection of communication logs when communication logs need to be collected. Specifically, the log capture capability provider can control the business name (or application name) that allows log collection, the number of collection times, collection frequency, collection quota, etc. of communication logs, the execution of communication log collection, and the concurrent collection and conflict of communication logs.
[0168] Compared with the strong control method, the weak control method uses fixed parameters to call related interfaces to realize the collection of communication logs. The business user confirms whether to obtain security and privacy permissions and manages the number of communication log collections. There is no need to control log collection quotas, nor to support concurrent collection of communication logs. Moreover, the weak control method can support business whitelist control and timeout control of communication log collection. However, compared with the strong control method, the weak control method is not strong enough. It does not control quotas such as the total number of communication log collections and the total data volume. It does not support concurrent collection of communication logs. It does not support the use of dynamic parameters to call related interfaces to realize the collection of communication logs. It does not count communication failures and does not perform aging and deletion processing on log files.
[0169] In an embodiment of the present application, the communication log collection control method adopted by the electronic device can be determined according to the operating system of the electronic device. In view of the fact that the Windows operating system is relatively mature and there are many third-party packet capture tools that can be selected, electronic devices with Windows operating systems can use a weak control method for communication log collection. And electronic devices with Android operating systems can use a strong control method for communication log collection. In an embodiment of the present application, the communication log collection control method adopted by the electronic device can also be determined according to the power supply method of the electronic device. For example, a battery-powered electronic device can use a strong control method for communication log collection, and a mains-powered electronic device can use a weak control method for communication log collection.
[0170] The following uses the weak control method of communication log collection adopted by electronic devices of Windows operating system as an example to explain the communication log collection scenario of electronic devices of Windows operating system. Figure 6 The following is a schematic diagram of the interaction between the modules. Figure 6 The process of the log collection method provided in the embodiment of the present application specifically includes:
[0171] S501, the fault monitoring module detects that a communication fault occurs in application 1, or predicts that a communication fault is about to occur in application 1, and sends the fault monitoring result to the log collection decision module.
[0172] S502, the log collection decision module determines whether to allow the collection of communication logs according to the preset weak control policy, and if so, executes S503.
[0173] Among them, the weak control strategy is configurable.
[0174] In this scenario, the control of whether to allow the collection of communication logs is performed by the business user. The business user can control whether to allow the collection of communication logs based on business scenarios, privacy compliance, etc., and can also control the timing of communication log collection.
[0175] Exemplarily, when the log collection decision module receives a fault monitoring result indicating that a communication fault occurs in application 1, the electronic device pops up a prompt window, and the information in the prompt window is used to ask the user whether to allow the collection of communication logs, or whether to allow the communication log collection function to be enabled, etc. If the user clicks the "Allow" control or the "Agree" control in the prompt window, the log collection decision module determines that the collection of communication logs is currently allowed.
[0176] As another example, the weak control strategy may also include, but is not limited to, business whitelist control, crawling times control, etc. For example, if application 1 is included in the business whitelist, then when the log collection decision module receives a fault monitoring result indicating that a communication failure has occurred in application 1, the log collection decision module determines that the communication log is currently allowed to be collected. For another example, if application 1 is included in the business whitelist, and the currently counted communication log collection times does not reach the quantity threshold, then when the log collection decision module receives a fault monitoring result indicating that a communication failure has occurred in application 1, the log collection decision module determines that the communication log is currently allowed to be collected. Among them, the communication log collection times can be counted within a set statistical period, which is not limited in this embodiment.
[0177] As another example, the weak control strategy may also include but is not limited to capture timing control, etc. For example, when the log collection decision module receives a fault monitoring result indicating that a communication fault occurs in application 1, the log collection decision module also needs to determine the time interval between the current moment and the previous communication log collection. If the time interval is greater than a set threshold, the log collection decision module determines that the communication log collection is currently allowed.
[0178] It should be pointed out that in this scenario, the control over whether to allow the collection of communication logs is implemented by the business user rather than the log capture capability provider, and the control is relatively weak.
[0179] If the log collection decision module determines that communication log collection is not allowed at present according to the preset weak control policy, the subsequent steps will not be executed, that is, the log collection decision module will not send a communication log collection request to the maintenance and testing service.
[0180] S503, the log collection decision module sends a communication log collection request to the maintenance and testing service through the interface provided by the fault ticket application.
[0181] After the log collection decision module determines that the communication log collection is currently allowed, the interconnection service sends a communication log collection request to the maintenance and testing service through the interface provided by the fault ticket application. The interconnection service can create a corresponding process to run the program of the relevant log capture tool to perform the communication log capture operation.
[0182] In the technical solution provided by this application, the communication log capture is abstracted as an instantiated service. After the interconnection service initiates the communication log collection request, it is processed layer by layer from top to bottom by the maintenance and testing service. Among them, in this scenario (that is, the weak control scenario of communication log collection), the maintenance and testing service is integrated into the fault ticket application. The fault ticket application provides a service request interface to the interconnection service (that is, the business user), and the interconnection service sends a communication log collection request to the maintenance and testing service in the fault ticket application through the interface.
[0183] Exemplarily, the communication log collection request may include but is not limited to the application name (or service name), log collection port number, log collection byte length, file information for saving logs (such as file name, storage path, number of files, etc.), etc.
[0184] S504: After receiving the communication log collection request, the maintenance and testing service sends a communication log collection instruction to the log collection module.
[0185] After the maintenance service receives the communication log collection request, if the communication log collection function of the electronic device is not enabled, the communication log collection function of the electronic device needs to be enabled first.
[0186] The maintenance and testing service mentioned here is the log capture capability provider. In this scenario, the maintenance and testing service does not control whether the communication log collection is allowed, but processes it layer by layer under the request of the interconnection service to collect the communication log. Among them, after the maintenance and testing service receives the communication log collection request, it can generate the corresponding communication log collection instruction according to the parameters carried by the communication log collection request, and send the communication log collection instruction to the log collection module to start the collection of communication logs.
[0187] In some cases, users can actively trigger the collection of communication logs in the form of a fault ticket through the fault ticket application in the Windows device. That is, the fault ticket application can act as a client of the maintenance and testing service and request the maintenance and testing service to collect communication logs. When a communication failure is monitored, the interconnection service will also act as another client of the maintenance and testing service and request the maintenance and testing service to collect communication logs. At this time, there may be a conflict with the communication log collection requested by the fault ticket application, such as a conflict with the log file (i.e., the file that stores the log), thereby affecting the communication log collection requested by the fault ticket application, and then affecting the user experience of the fault ticket application.
[0188] In order to resolve such conflicts, the maintenance and testing service responds to the received communication log collection request and executes the communication log collection operation corresponding to the communication log collection request. It can maintain the log file directory, for example, detect whether there are conflicts in the log files and whether there are conflicts in the log file storage paths, and make relevant adjustments when conflicts are detected to avoid affecting the communication log collection requested by the fault ticket application.
[0189] S505: The log collection module calls a log collection tool to perform a communication log collection operation.
[0190] The log collection tool may be a third-party log collection tool, such as a windump tool, a dumpcap tool, and the like.
[0191] S506: The log collection tool starts collecting communication logs.
[0192] The log collection tool runs, starts collecting communication logs, and stores the collected communication logs in corresponding log files.
[0193] It should be noted that the start of communication log collection mentioned here refers to the start of communication log collection corresponding to the relevant port (the port corresponding to the communication log collection request or the port included). Before starting to collect the communication log corresponding to the relevant port, if the communication log collection function corresponding to the relevant port is closed, the communication log collection function corresponding to the relevant port needs to be turned on.
[0194] S507: When certain conditions are met, the interconnection service sends a communication log collection stop request to the maintenance and testing service through an interface provided by the fault ticket tool.
[0195] Exemplarily, when the fault monitoring module detects that the current communication fault disappears, the interconnection service sends a communication log collection stop request to the maintenance and testing service through an interface provided by the fault ticket tool.
[0196] As another example, when the collection duration of the communication log reaches a preset duration threshold, or when the number of collected bytes of the communication log reaches a preset number, the interconnection service sends a communication log collection stop request to the maintenance service through an interface provided by the fault ticket application.
[0197] Exemplarily, the communication log collection stop request may include, but is not limited to, an application name (or service name), a log collection port number, and the like.
[0198] S508: After receiving the communication log collection stop request, the maintenance and testing service sends a communication log collection stop instruction to the log collection module.
[0199] After receiving the communication log collection stop request, the maintenance and testing service can generate a corresponding communication log collection stop instruction according to the parameters carried in the communication log collection stop request, and send the communication log collection stop instruction to the log collection module to stop the collection of communication logs.
[0200] S509: The log collection module calls the log collection tool to stop the communication log collection operation.
[0201] S510: The log collection tool stops collecting communication logs.
[0202] It should be noted that the stop collecting communication logs mentioned here refers to stopping collecting communication logs corresponding to the relevant port (the port corresponding to the communication log stop collection request or the port included).
[0203] After stopping collecting the communication logs corresponding to the relevant ports, if the electronic device does not have other services that require collecting the communication logs corresponding to the relevant ports, such as a log collection service actively triggered by the user in a fault ticket application, the communication log collection function corresponding to the relevant ports will be turned off.
[0204] In this way, electronic devices with Windows operating systems start collecting communication logs when they detect communication failures, and stop collecting communication logs when certain conditions are met, thereby minimizing the impact on device system load and power consumption. Moreover, the collection and control of communication logs is implemented by business users based on their own scenarios, and the control is relatively weak, and there is no need to support concurrent collection and control of communication logs. Business users only need to send a communication log collection request to the maintenance and testing service through the interface provided by the fault ticket application when collecting communication logs.
[0205] The following uses the strong control method of communication log collection adopted by the electronic device of Android operating system as an example to explain the communication log collection scenario of the electronic device side of Android operating system. Figure 7 The following is a schematic diagram of the interaction between the modules. Figure 7 The process of the log collection method provided in the embodiment of the present application specifically includes:
[0206] S601, the fault monitoring module detects that the application 1 has a communication fault, or predicts that the application 1 is about to have a communication fault, and sends the fault monitoring result to the log collection decision module.
[0207] S602: After receiving the fault monitoring result, the log collection decision module determines that communication logs need to be collected.
[0208] In this scenario, the control of whether to allow the collection of communication logs is implemented by the log capture capability provider, not by the business user. After the log collection decision module receives the fault monitoring results, it can determine that the communication log needs to be collected at present, and then the interconnection service can send a communication log collection request to the maintenance and testing service.
[0209] S603: The interconnection service sends a communication log collection request to the maintenance and testing service through an interface provided by the maintenance and testing service.
[0210] In this scenario (i.e., the communication log collection strong control scenario), the maintenance and testing service is an independent service that provides a service request interface to the interconnection service (i.e., the business user). The interconnection service sends a communication log collection request to the maintenance and testing service through the interface.
[0211] Exemplarily, the communication log collection request may include but is not limited to the application name (or service name), log collection port number, log collection byte length, file information for saving logs (such as file name, storage path, number of files, etc.), etc.
[0212] S604, the log collection control module in the maintenance and testing service determines whether to allow the collection of communication logs according to the preset strong control policy, and if so, executes S605.
[0213] Among them, the strong control strategy is configurable.
[0214] After receiving the communication log collection request, the maintenance and testing service determines whether to allow the collection of communication logs through the log collection control module. The log collection control module can determine whether to allow the collection of communication logs according to the preset strong control policy.
[0215] Exemplarily, the strong control strategy may include, but is not limited to, one or more of business whitelist control, execution scheduling control, log collection quota control, system load control, etc.
[0216] Among them, business whitelist control means that only communication log collection requests initiated by businesses in the business whitelist are allowed to collect relevant communication logs, while communication log collection requests initiated by businesses not in the business whitelist are not allowed to collect relevant communication logs.
[0217] Execution scheduling control refers to the control of the execution of starting or stopping communication log collection based on information such as timeout duration and task records. For example, after starting to execute a communication log operation corresponding to a communication log collection request, if the communication log collection duration reaches the timeout duration corresponding to the communication log collection request, the communication log collection operation corresponding to the communication log collection request is terminated. For another example, before starting a communication log collection operation corresponding to a communication log collection request, or before stopping a communication log collection operation corresponding to a communication log collection request, it can be determined based on the task record whether the corresponding communication log start collection operation or stop collection operation is an invalid operation, such as repeatedly starting or repeatedly stopping the communication log collection operation.
[0218] Log collection quota control refers to the control of whether communication log collection is allowed based on the collection frequency configuration, collection traffic quota, etc. Communication log collection is only allowed within the valid collection frequency and collection quota. Among them, the log collection control module can save information such as collection frequency configuration, collection traffic quota, and communication log collection information in the current statistical period (such as collection records, collection traffic data, collection times, etc.).
[0219] For example, after receiving a communication log collection request, the maintenance and testing service determines whether there is repeated collection within a set time period (for example, 10 minutes before the current moment), and if so, the collection of the communication log corresponding to the request is not allowed. For another example, after receiving a communication log collection request, the maintenance and testing service determines whether the number of communication log collections within a set time period (for example, 1 hour before the current moment) exceeds a threshold value (for example, 3 times), and if so, the collection of the communication log corresponding to the request is not allowed. For another example, after receiving a communication log collection request, the maintenance and testing service determines whether the communication log collection flow within the current statistical period (the statistical period is, for example, 24 hours) is greater than the flow threshold value, and if so, the collection of the communication log corresponding to the request is not allowed.
[0220] System load control refers to the control of whether communication log collection is allowed based on the system load monitoring configuration. Communication log collection is allowed only when the system load value is lower than the set value. If the current system load value exceeds the set value, communication log collection is no longer allowed.
[0221] In this way, the log collection control module determines whether to allow the collection of communication logs based on the preset strong control strategy, which can avoid the problem of excessive load on the entire machine.
[0222] If the log collection control module determines that the communication log collection is not allowed at present according to the preset strong control policy, the subsequent steps will not be executed, that is, the maintenance and testing service will not start the communication log collection operation corresponding to the corresponding communication log collection request. Exemplarily, when the log collection control module determines that the communication log collection is not allowed at present according to the preset strong control policy, the maintenance and testing service can feedback the communication log collection refusal response information to the business user (such as the Internet service).
[0223] S605: The log collection control module verifies the parameters of the communication log collection request.
[0224] After the log collection control module determines that the communication log collection is allowed according to the preset strong control policy, the log collection control module also needs to verify the parameters of the communication log collection request, such as legality verification.
[0225] If the parameters of the communication log collection request are verified, the subsequent steps will be continued; if the parameters of the communication log collection request are verified and failed, the relevant communication log collection operation cannot be started. Exemplarily, when the log collection control module determines that the parameters of the communication log collection request have not passed the verification, the maintenance service can feedback an error message to the business user (such as the interconnection service) to indicate that the relevant communication log cannot be successfully collected.
[0226] In some cases, users can actively trigger the collection of communication logs in the form of a fault ticket through the fault ticket application in the Android device. That is, the fault ticket application can act as a client of the maintenance and testing service and request the maintenance and testing service to collect communication logs. When a communication fault is monitored, the interconnection service will also act as another client of the maintenance and testing service and request the maintenance and testing service to collect communication logs. At this time, there may be a conflict with the communication log collection requested by the fault ticket application, such as a conflict with the log file (i.e., the file that stores the log), thereby affecting the communication log collection requested by the fault ticket application, and then affecting the user experience of the fault ticket application.
[0227] In order to resolve such conflicts, the maintenance and testing service responds to the received communication log collection request and executes the communication log collection operation corresponding to the communication log collection request. It can maintain the log file directory, for example, detect whether there are conflicts in the log files and whether there are conflicts in the log file storage paths, and make relevant adjustments when conflicts are detected to avoid affecting the communication log collection requested by the fault ticket application.
[0228] S606: After the parameter verification of the communication log collection request passes, the maintenance and testing service sends a communication log collection instruction to the maintenance and testing module.
[0229] The maintenance and testing module can be used to support the functional implementation of the maintenance and testing service in the application framework layer. For example, the log collection module can be called to perform communication log collection operations under the instruction of the maintenance and testing service.
[0230] If the log collection control module determines that the communication log corresponding to the communication log collection request is allowed to be collected, the maintenance and testing service sends a communication log collection instruction to the maintenance and testing module through the interface provided by the maintenance and testing module to start collecting the communication log.
[0231] Exemplarily, if the log collection control module determines that the collection of communication logs corresponding to the communication log collection request is allowed, the maintenance and testing service can create a request executor corresponding to the communication log collection request, and send a communication log collection instruction to the maintenance and testing module through the request executor to start collecting communication logs.
[0232] After the parameter verification of the communication log collection request is passed, before the communication log collection starts, if the communication log collection function of the electronic device is not enabled, the communication log collection function of the electronic device needs to be enabled first.
[0233] S607: The maintenance and testing module calls the log collection module to start collecting communication logs.
[0234] Exemplarily, the log collection module may be a tcpdump log collection service.
[0235] S608: The log collection module starts collecting communication logs.
[0236] After the log collection module is called, it starts to collect the communication logs and stores the collected communication logs in the corresponding log files.
[0237] It should be noted that the start of communication log collection mentioned here refers to the start of communication log collection corresponding to the relevant port (the port corresponding to the communication log collection request or the port included). Before starting to collect the communication log corresponding to the relevant port, if the communication log collection function corresponding to the relevant port is closed, the communication log collection function corresponding to the relevant port needs to be turned on.
[0238] In this scenario (i.e., the communication log collection strong control scenario), the maintenance and testing service also supports concurrent processing of multiple services. That is, the maintenance and testing service can respond to multiple communication log collection requests and collect communication logs for multiple faulty applications in the same time period.
[0239] After each communication log collection request is received by the maintenance and testing service, the log collection control module determines whether to respond to the communication log collection request according to the preset strong control policy, that is, whether to allow the collection of the communication log corresponding to the communication log collection request. If the log collection control module determines that the collection of the communication log corresponding to the communication log collection request is allowed, the maintenance and testing service can create a request executor corresponding to the communication log collection request to execute the communication log collection operation corresponding to the communication log collection request. In this way, the maintenance and testing service can process the communication log collection operations triggered by multiple services in parallel, and the communication log collection operation triggered by each service can be performed independently.
[0240] In addition, when the maintenance and testing service processes the communication log collection operations triggered by multiple businesses in parallel, it also needs to handle various possible conflict issues, such as log file directory conflicts, log file conflicts, log file update conflicts, and process-related conflicts, so as to ensure that the communication log collection operations triggered by each business can proceed smoothly.
[0241] S609: When certain conditions are met, the interconnection service sends a communication log stop collection request to the maintenance and testing service through an interface provided by the maintenance and testing service.
[0242] Exemplarily, when the fault monitoring module detects that the current communication fault disappears, the interconnection service sends a communication log collection stop request to the maintenance and testing service through an interface provided by the maintenance and testing service.
[0243] As another example, when the collection duration of the communication log reaches a preset duration threshold, or when the number of collected bytes of the communication log reaches a preset number, the interconnection service sends a communication log collection stop request to the maintenance and testing service through an interface provided by the maintenance and testing service.
[0244] Exemplarily, the communication log collection stop request may include, but is not limited to, an application name (or service name), a log collection port number, and the like.
[0245] S610: The maintenance and testing service sends a communication log stop collection instruction to the maintenance and testing module.
[0246] After receiving the communication log collection stop request, the maintenance and measurement service sends a communication log collection stop instruction to the maintenance and measurement module through the interface provided by the maintenance and measurement module to stop the collection of relevant communication logs.
[0247] Optionally, after receiving the communication log stop collection request, the log collection control module can determine whether the communication log stop collection request has been responded to based on the task record to avoid repeated stop log collection operations. If the log collection control module determines that the communication log stop collection request has not been responded to based on the task record, a communication log stop collection instruction associated with the communication log stop collection request is sent to the maintenance module to stop the collection operation of the relevant communication log.
[0248] S611: The maintenance and testing module calls the log collection module to stop collecting related communication logs.
[0249] S612: The log collection module stops collecting communication logs.
[0250] It should be noted that the stop collecting communication logs mentioned here refers to stopping collecting communication logs corresponding to the relevant port (the port corresponding to the communication log stop collection request or the port included).
[0251] After stopping collecting the communication logs corresponding to the relevant ports, if the electronic device does not have other services that require collecting the communication logs corresponding to the relevant ports, such as a log collection service actively triggered by the user in a fault ticket application, the communication log collection function corresponding to the relevant ports will be turned off.
[0252] In this scenario (i.e., the communication log collection strong control scenario), the communication log collection stop may also be triggered by the log collection control module in the maintenance and testing service based on the strong control policy. Figure 8 The following is a schematic diagram of the interaction between the modules. Figure 8 The process of the log collection method provided in the embodiment of the present application specifically includes:
[0253] S701, the fault monitoring module detects that the application 1 has a communication fault, or predicts that the application 1 is about to have a communication fault, and sends the fault monitoring result to the log collection decision module.
[0254] S702: After receiving the fault monitoring result, the log collection decision module determines that communication logs need to be collected.
[0255] S703, the interconnection service sends a communication log collection request 1 to the maintenance and testing service through the interface provided by the maintenance and testing service.
[0256] Exemplarily, communication log collection request 1 may include but is not limited to the name of application 1 (or the business name of application 1), the log collection port number corresponding to application 1, the log collection byte length, the file information for saving the log (such as file name, storage path, number of files, etc.), etc.
[0257] S704, the log collection control module in the maintenance and testing service determines whether to allow the collection of the communication log corresponding to the communication log collection request 1 according to the preset strong control policy, and if so, execute S605.
[0258] If the log collection control module determines that the communication log collection is not allowed at present according to the preset strong control policy, the subsequent steps will not be executed, that is, the maintenance and testing service will not start the communication log collection operation corresponding to the corresponding communication log collection request. Exemplarily, when the log collection control module determines that the communication log collection is not allowed at present according to the preset strong control policy, the maintenance and testing service can feedback the communication log collection refusal response information to the business user (such as the Internet service).
[0259] S705: The log collection control module verifies the parameters of the communication log collection request.
[0260] S706: After the parameter verification of the communication log collection request passes, the maintenance and testing service sends a communication log collection instruction to the maintenance and testing module.
[0261] S707: The maintenance and testing module calls the log collection module to start collecting communication logs.
[0262] S708: The log collection module starts collecting communication logs.
[0263] It should be noted that the start of communication log collection mentioned here refers to the start of communication log collection corresponding to the relevant port (the port corresponding to the communication log collection request or the port included). Before starting to collect the communication log corresponding to the relevant port, if the communication log collection function corresponding to the relevant port is closed, the communication log collection function corresponding to the relevant port needs to be turned on.
[0264] S709, the log collection control module determines whether it is necessary to stop collecting the communication log corresponding to the communication log collection request 1 according to the preset strong control strategy, if so, execute S710, if not, continue to execute S709.
[0265] Exemplarily, after the maintenance and testing service starts to execute the communication log collection operation according to a communication log collection request, if the log collection control module detects that the communication log collection time corresponding to the communication log collection request has timed out, the maintenance and testing service can also send a communication log stop collection instruction to the maintenance and testing module to stop the collection of relevant communication logs.
[0266] As another example, after the maintenance and testing service starts to execute the communication log collection operation according to a communication log collection request, if the log collection control module monitors that the device system load exceeds the set upper limit, the maintenance and testing service can also send a communication log stop collection instruction to the maintenance and testing module to stop the collection of relevant communication logs.
[0267] S710: The maintenance and testing service sends a communication log stop collection instruction to the maintenance and testing module.
[0268] S711, the maintenance and testing module calls the log collection module to stop collecting related communication logs.
[0269] S712: The log collection module stops collecting communication logs.
[0270] It should be noted that the stop collecting communication logs mentioned here refers to stopping collecting communication logs corresponding to the relevant port (the port corresponding to the communication log stop collection request or the port included).
[0271] After stopping collecting the communication logs corresponding to the relevant ports, if the electronic device does not have other services that require collecting the communication logs corresponding to the relevant ports, such as a log collection service actively triggered by the user in a fault ticket application, the communication log collection function corresponding to the relevant ports will be turned off.
[0272] For details not explained in this process, please refer to Figure 7 The process shown will not be repeated here.
[0273] In this way, the electronic device of the Android operating system starts collecting communication logs when it detects a communication failure, and stops collecting communication logs when certain conditions are met, thereby minimizing the impact on the device system load and power consumption. In addition, the collection and control of communication logs is implemented by the log capture capability provider, and the control is relatively strong. It supports concurrent collection and control of communication logs, and can solve conflicts related to concurrent collection of communication logs.
[0274] The technical solution provided in the embodiments of the present application can automatically enable the communication log collection function according to communication failures for electronic devices with different operating systems, and provide accurate and configurable management and control strategies to enable the collection of communication logs on demand, thereby minimizing the impact on system load and power consumption.
[0275] Moreover, the log collection solution provided by the embodiment of the present application can also provide a unified entrance for electronic devices of different systems, and establish a general technical means to solve the risks of power consumption, performance, security, privacy, etc. involved in the communication log collection process. Among them, the maintenance service can be abstracted as an instantiated service, which receives communication log collection requests initiated by different services or applications in electronic devices of different operating systems, and processes them layer by layer from top to bottom.
[0276] For example, refer to Figure 9a and Figure 9b ,The maintenance and testing service can be divided into the adaptation layer, the service layer and the maintenance layer in the logical level. Among them, the adaptation layer can include the service adaptation module, the service layer can include the service construction module, the service management module, the external setting module, etc. , and the maintenance layer can include the operation scheduling module, the state maintenance module, the execution management module, etc.
[0277] The service adaptation module can be used to adapt the received communication log collection request and construct a corresponding service request.
[0278] The service construction module can be used to parse the service definition file, build external services and control strategies. Among them, the service definition file can be used to describe the specifications of the supported third-party maintenance tools (such as Tcpdump, Windump, etc.).
[0279] The operation scheduling module can be used to schedule service requests. The service management module can be used to build service processes and determine whether to accept service requests according to management and control strategies.
[0280] The external settings module can be used to check the external settings of the maintenance and testing service, such as the switch status information of the "communication log capture" function in the fault ticket application.
[0281] The state maintenance module can be used to maintain and manage the state of the application that is currently using the service, such as state setting, state recovery, etc. It can also be used for periodic inspections, fault reporting, and service exception handling. For example, the state maintenance module can trigger an inspection operation every 24 hours. The inspection operation may include but is not limited to maintaining the log file directory, restoring the communication log collection quota, canceling service suppression, and other exception handling. Among them, when the state maintenance module maintains the log file directory, it can check the log files, delete expired log files, aging files, etc. For example, the state maintenance module can count and report related faults of the maintenance and testing service, and the same type of faults can be reported only once within a set time period (such as 24 hours).
[0282] The execution management module can be used to manage the execution of operations such as starting and stopping communication log collection to avoid invalid operation execution, etc.
[0283] It should be pointed out that, from the perspective of management and control, the functional modules related to management and control in the above hierarchical structure can be understood as components of the log collection management and control module. This embodiment limits the framework structure of the maintenance and testing service.
[0284] Continue to refer to Figure 9a and Figure 9b The maintenance and testing service provides a unified calling interface IF (Interface)-1, as well as related configuration query interfaces IF-2, IF-3, and IF-4.
[0285] Among them, IF-1 is the unified entrance provided by the maintenance and testing service to the outside world, which can be used to receive communication log collection requests initiated by other services or applications. IF-1 can also be used for operations such as initializing the maintenance and testing service. IF-2 can be used to receive the switch status information of the "communication log capture" function in the fault ticket application. IF-3 can be used to query the switch status information of the "communication log capture" function in the fault ticket application, which can replace IF-2. IF-4 can be used to query other related setting information, such as the switch status of the user experience improvement plan, etc.
[0286] Take the Android system electronic device as an example, continue to refer to Figure 9a, the above maintenance and testing service can be integrated into the Android maintenance and testing service, and the Android maintenance and testing service provides an interface IF-5 for calling the above maintenance and testing service. When the Android interconnection service detects that a communication failure occurs in a certain application, it can send a communication log collection request to the Android maintenance and testing service through IF-5. After receiving the communication log collection request, the Android maintenance and testing service submits it to the service adapter module through IF-1 for processing. The service adapter module receives the communication log collection request, constructs a service request (Request), and submits the service request to the service management module for processing through the running scheduling module. The service management module constructs a service process according to the service request, and determines whether to accept the service request according to the strong control strategy. Among them, the service management module can also determine whether to accept the service request according to the relevant status information queried by the external setting module. If the service management module accepts the service request, it creates a request executor (Request Executor) corresponding to the service request, and submits the request executor to the execution management module through the running scheduling module. The execution management module initiates a communication log collection command to the maintenance and testing module based on the status information of the request executor, so that the maintenance and testing module can call the tcpdump log collection service to start collecting communication logs.
[0287] When the Android interconnection service detects that a communication failure of an application disappears, or when the communication log collection times out, it can also send a communication log stop collection request to the Android maintenance and testing service through IF-5. After receiving the communication log stop collection request, the Android maintenance and testing service submits it to the service adapter module through IF-1 for processing. The service adapter module receives the communication log collection request, constructs a service stop request, and submits the service stop request to the service management module for processing through the running scheduling module. Optionally, the service stop request can also be actively generated by the service management module based on a strong control strategy, which is not limited in this embodiment. The service management module submits the service stop request to the execution management module through the running scheduling module. The execution management module initiates a communication log stop collection command to the maintenance and testing module based on the status information of the request executor, so that the maintenance and testing module can call the tcpdump log collection service to stop collecting communication logs.
[0288] The state information of the request executor is maintained by the state maintenance module according to the processing situation of the request executor. The state maintenance module can set and restore the state of the request executor. The state information may include, for example, initialization state, start state, stop state, etc.
[0289] The execution management module can also avoid the migration of illegal states of the request executor and organize invalid execution (such as repeated stop, repeated start, etc.) according to the status information of the request executor. If the status of the request executor is the start status, the execution management module will no longer repeatedly initiate the communication log collection command to the maintenance and measurement module to avoid the illegal change of the status of the request executor from the start status to the start status, thereby avoiding invalid repeated start operations. If the status of the request executor is the stop status, the execution management module will no longer repeatedly initiate the communication log stop collection command to the maintenance and measurement module to avoid the illegal change of the status of the request executor from the stop status to the stop status, thereby avoiding invalid repeated stop operations.
[0290] Take the electronic device with Windows system as an example, continue to refer to Figure 9b The above-mentioned maintenance and testing service can be integrated into the Windows fault ticket application, and the Windows fault ticket application provides an interface IF-6 for calling the above-mentioned maintenance and testing service. When the Windows interconnected service detects that a communication failure has occurred in a certain application, it can send a communication log collection request to the Windows fault ticket application through IF-6. After receiving the communication log collection request, the Windows fault ticket application submits it to the service adapter module through IF-1 for processing. The service adapter module receives the communication log collection request, builds a service request (Request), and submits the service request to the service management module for processing by running the scheduling module. The service management module builds a service process according to the service request, creates a request executor (Request Executor) corresponding to the service request, and submits the request executor to the execution management module through the running scheduling module. The execution management module calls the third-party tcpdump log collection tool based on the status information of the request executor to start collecting tcpdump logs.
[0291] When the Windows interconnected service detects that a communication failure in an application disappears, or when the communication log collection times out, or when it is determined according to the weak control policy that the communication log collection needs to be stopped, it can also send a communication log stop collection request to the Windows fault ticket application through IF-6. After receiving the communication log stop collection request, the Windows fault ticket application submits it to the service adapter module through IF-1 for processing. The service adapter module receives the communication log collection request, constructs a service stop request, and passes the service stop request to the service management module for processing through the running scheduling module. The service management module submits the service stop request to the execution management module through the running scheduling module. The execution management module initiates a communication log stop collection command to the maintenance and measurement module based on the status information of the request executor, so that the maintenance and measurement module can call the tcpdump log collection service to stop collecting communication logs.
[0292] For the explanation of the status information of the request executor, please refer to the previous text and will not be repeated here.
[0293] In the log collection method provided in the embodiment of the present application, the electronic device performs communication fault monitoring, starts collecting tcpdump logs only when a communication fault occurs or is expected to occur, sets a timeout, stops collecting tcpdump logs after the scene is reproduced, and collects relevant tcpdump logs and stores them in relevant log files. When the user needs to file a fault ticket, these communication logs collected based on fault monitoring can be packaged and uploaded to the cloud for professionals to locate the fault of the electronic device.
[0294] This embodiment further provides a computer storage medium, in which computer instructions are stored. When the computer instructions are executed on an electronic device, the electronic device executes the above-mentioned related method steps to implement the log collection method in the above-mentioned embodiment.
[0295] This embodiment further provides a computer program product. When the computer program product is run on a computer, the computer is caused to execute the above-mentioned related steps to implement the log collection method in the above-mentioned embodiment.
[0296] In addition, an embodiment of the present application also provides a device, which may specifically be a chip, component or module, and the device may include a connected processor and memory; wherein the memory is used to store computer execution instructions, and when the device is running, the processor may execute the computer execution instructions stored in the memory so that the chip executes the log collection method in the above-mentioned method embodiments.
[0297] Among them, the electronic device (such as a mobile phone, etc.), computer storage medium, computer program product or chip provided in this embodiment is used to execute the corresponding method provided above. Therefore, the beneficial effects that can be achieved can refer to the beneficial effects in the corresponding method provided above, and will not be repeated here.
[0298] Through the description of the above implementation methods, technical personnel in the relevant field can understand that for the convenience and simplicity of description, only the division of the above-mentioned functional modules is used as an example. In actual applications, the above-mentioned functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.
[0299] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic, for example, the division of modules or units is only a logical function division, and there may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another device, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0300] As described above, the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present application.
Claims
1. A log collection method, characterized in that: Applied in an electronic device, the electronic device includes a service user and a log collection function provider, and the method includes: Monitor applications for communication failures; When a communication failure of the first application is detected or a communication failure of the first application is predicted to occur, judging whether to allow collection of communication logs corresponding to the first port based on a preset management and control policy; the first port is a port used by the first application to execute services; When the determination result indicates that collection is allowed, starting to collect the communication log corresponding to the first port; After starting to collect the communication log corresponding to the first port, judging whether it is necessary to stop collecting the communication log corresponding to the first port based on a preset management and control strategy; When the judgment result indicates that collection needs to be stopped, stop collecting the communication log corresponding to the first port; Wherein, judging whether to allow the collection of the communication log corresponding to the first port based on the preset management and control policy, and starting to collect the communication log corresponding to the first port when the judgment result indicates that the collection is allowed, includes: The service user determines whether to allow the collection of communication logs corresponding to the first port based on a preset first management and control policy; when the judgment result indicates that the collection is allowed, the service user sends a first log collection request to the log collection function provider; the log collection function provider starts collecting the communication logs corresponding to the first port according to the first log collection request; or, The service user sends a second log collection request to the log collection function provider, where the second log collection request is used to request collection of communication logs corresponding to the first port; the log collection function provider determines whether to allow response to the second log collection request based on a preset second management and control policy; when the judgment result indicates that response to the second log collection request is allowed, the log collection function provider starts collecting communication logs corresponding to the first port according to the second log collection request; Among them, the control strength of the first control strategy is lower than the control strength of the second control strategy.
2. The method according to claim 1, characterized in that In a case where the service user determines whether to allow collection of communication logs corresponding to the first port based on a preset first control policy, the determining whether to stop collecting communication logs corresponding to the first port based on the preset control policy includes: The service user determines whether it is necessary to stop collecting the communication log corresponding to the first port based on the first management and control strategy; When the judgment result indicates that collection needs to be stopped, stopping collection of the communication log corresponding to the first port includes: When the judgment result indicates that the collection needs to be stopped, the service user sends a first log collection stop request to the log collection function provider; The log collection function provider stops collecting the communication log corresponding to the first port according to the first log collection stop request.
3. The method according to claim 1, characterized in that The first control strategy includes at least one of the following: Log collection timing control, log collection timeout control, and log collection permission control.
4. The method according to claim 1, characterized in that When the service user determines whether to allow the collection of the communication log corresponding to the first port based on the preset first management and control policy, the operating system of the electronic device is the Windows operating system.
5. The method according to claim 1, characterized in that In a case where the service user sends a second log collection request to the log collection function provider, judging whether it is necessary to stop collecting the communication log corresponding to the first port based on a preset management and control policy, and stopping collecting the communication log corresponding to the first port when the judgment result indicates that it is necessary to stop collecting, includes: The service user determines whether it is necessary to stop collecting the communication log corresponding to the first port based on a preset third control strategy; When the judgment result indicates that the collection needs to be stopped, the service user sends a second log collection stop request to the log collection function provider; The log collection function provider stops collecting the communication log corresponding to the first port according to the second log collection stop request; wherein the control strength of the third control strategy is lower than the control strength of the second control strategy.
6. The method according to claim 1, characterized in that In a case where the service user sends a second log collection request to the log collection function provider, judging whether it is necessary to stop collecting the communication log corresponding to the first port based on a preset management and control policy, and stopping collecting the communication log corresponding to the first port when the judgment result indicates that it is necessary to stop collecting, includes: The log collection function provider determines whether it is necessary to stop collecting the communication log corresponding to the first port based on the second management and control strategy; When the judgment result indicates that collection needs to be stopped, the log collection function provider stops collecting the communication log corresponding to the first port.
7. The method according to claim 1, characterized in that The log collection function provider determines whether to allow responding to the second log collection request based on a preset second management and control policy, including at least one of the following: If the service corresponding to the second log collection request is not included in the service whitelist, the log collection function provider determines that it is not allowed to respond to the second log collection request; If the current system load exceeds the load threshold, the log collection function provider determines that it is not allowed to respond to the second log collection request; If the currently counted communication log collection frequency is higher than the frequency threshold, or the currently counted communication log collection frequency is higher than the number threshold, the log collection function provider determines that it is not allowed to respond to the second log collection request; If the currently counted communication log collection flow rate is higher than the flow threshold, the log collection function provider determines that it is not allowed to respond to the second log collection request; If there is no remaining communication log collection quota, the log collection function provider determines that it is not allowed to respond to the second log collection request; If there is a repeated collection phenomenon corresponding to the second log collection request, the log collection function provider determines that it is not allowed to respond to the second log collection request.
8. The method according to claim 1, characterized in that In the case where the service user sends a second log collection request to the log collection function provider, the method further includes: When a communication failure of the second application is detected or a communication failure of the second application is predicted to occur, the service user sends a third log collection request to the log collection function provider, where the third log collection request is used to request collection of communication logs corresponding to the second port; the second port is a port used by the second application to execute services; The log collection function provider determines whether to allow responding to the third log collection request based on the second management and control policy; When the judgment result indicates that the third log collection request is allowed to be responded to, the log collection function provider starts collecting the communication log corresponding to the second port according to the third log collection request.
9. The method according to claim 1, characterized in that: When the service user sends a second log collection request to the log collection function provider, the operating system of the electronic device is an Android operating system.
10. The method according to any one of claims 1 to 9, characterized in that: Before starting to collect the communication log corresponding to the first port, the method further includes: If the log collection function corresponding to the first port is not enabled, enabling the log collection function corresponding to the first port; After stopping collecting the communication log corresponding to the first port, the method further includes: If the first target service does not currently exist, the log collection function corresponding to the first port is closed; wherein the first target service is used to collect communication logs corresponding to the first port, and the first target service is actively triggered by the user.
11. The method according to any one of claims 1 to 9, characterized in that: Before starting to collect the communication log corresponding to the first port, the method further includes: Determine whether the storage operation of the communication log corresponding to the first port conflicts with a second target service; wherein the second target service is used to collect communication logs, and the second target service is actively triggered by a user; If a conflict exists, the relevant parameters are adjusted to resolve the conflict.
12. The method according to any one of claims 1 to 9, characterized in that: Also includes: In response to the user operation, the collected communication logs corresponding to the first port are packaged and uploaded to the cloud server.
13. The method according to any one of claims 1 to 9, characterized in that: The communication log includes a tcpdump log.
14. An electronic device, characterized in that: include: one or more processors; Memory; and one or more computer programs, wherein the one or more computer programs are stored in the memory, and when the computer programs are executed by the one or more processors, the electronic device executes the log collection method as described in any one of claims 1-13.
15. A computer-readable storage medium comprising a computer program, characterized in that: When the computer program runs on an electronic device, the electronic device executes the log collection method according to any one of claims 1 to 13.
Citation Information
Patent Citations
Log information management and control method and device and computer readable storage medium
CN112347067A
Message tracking method, system and equipment
CN113810250A
Fault detection system and method and storage medium
CN116033466A