WO2020173377A1 - Log information generating method and apparatus, and electronic device - Google Patents

Log information generating method and apparatus, and electronic device Download PDF

Info

Publication number
WO2020173377A1
WO2020173377A1 PCT/CN2020/076020 CN2020076020W WO2020173377A1 WO 2020173377 A1 WO2020173377 A1 WO 2020173377A1 CN 2020076020 W CN2020076020 W CN 2020076020W WO 2020173377 A1 WO2020173377 A1 WO 2020173377A1
Authority
WO
WIPO (PCT)
Prior art keywords
thread
tracking identifier
call
link
identifier
Prior art date
Application number
PCT/CN2020/076020
Other languages
French (fr)
Chinese (zh)
Inventor
张烽
张瑞荣
李翠琴
Original Assignee
华为技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 华为技术有限公司 filed Critical 华为技术有限公司
Publication of WO2020173377A1 publication Critical patent/WO2020173377A1/en

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/34Recording or statistical evaluation of computer activity, e.g. of down time, of input/output operation ; Recording or statistical evaluation of user activity, e.g. usability assessment
    • G06F11/3466Performance evaluation by tracing or monitoring
    • G06F11/3476Data logging
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/34Recording or statistical evaluation of computer activity, e.g. of down time, of input/output operation ; Recording or statistical evaluation of user activity, e.g. usability assessment

Definitions

  • This application relates to the field of terminal technologies, and in particular, to a method, device, and electronic device for generating log information. Background technique
  • the analysis and resolution of functional and performance problems depend on the information output by the log and the performance trace log (systrace).
  • the flow log of the Android system outputs the information in business processing through the log system.
  • the log output format of the Android system includes timestamp, process ID, thread ID, level, and content.
  • This application provides a method, device and electronic equipment for generating log information, which are used to generate log information including tracking identification, so that developers can screen information related to the business according to the tracking identification of each business, and reduce the ability requirements for developers , Improve problem solving efficiency.
  • an embodiment of the present application provides a method for generating log information.
  • the method is applicable to an electronic device.
  • the method includes: the electronic device receives a user's first operation, and in response to the first operation, the electronic device enters the service startup portal Add a unique tracking identifier corresponding to the service, and transfer the tracking identifier in the entire call link of the service, and then the electronic device stores the tracking identifier in the call of each thread of each process of the call link In the recording, log information including the tracking identifier is generated.
  • the tracking identifier may be generated according to the identifier of the electronic device and the occurrence time of the first operation.
  • the embodiment of the application can realize that the calling link of a service carries a unique tracking identifier, so that developers can quickly locate the time-consuming thread by calling the log information corresponding to the tracking identifier, thereby Locate the cause of the fault.
  • the log information includes the call timestamp of the thread, the call service name, and the call relationship of other threads.
  • the electronic device can also generate the call time stamp, the call service name, and the call relationship in the log information. Report that the call link is abnormal. In this way, the analysis process of the developer can be saved and the problem solving efficiency can be improved.
  • the electronic device After the electronic device generates the unique tracking identifier corresponding to the service, it writes the tracking identifier into the context of the first thread corresponding to the service portal, and then uses the communication message to transfer the tracking identifier from the first thread.
  • the thread is passed to the second thread, and the tracking identifier is written into the context of the second thread. If the second thread is not the most In the latter thread, the tracking identifier is transferred from the second thread to the third thread through the communication message, and the tracking identifier is written into the context of the third thread until the last thread of the call link is repeatedly executed. It can be seen that this method can realize the transfer of the tracking identifier in the call link.
  • the electronic device obtains the trace identifier from the context of each thread of the call link; and then writes the character string obtained by the conversion of the trace identifier into each process of the call link In the call record of each thread, finally generate log information including the tracking identifier.
  • the log includes at least one of a running log, a kernel log, and a performance tracking log.
  • an embodiment of the present application provides an electronic device, including a processor and a memory.
  • the memory is used to store one or more computer programs; when the one or more computer programs stored in the memory are executed by the processor, the electronic device can implement any one of the possible design methods in any of the foregoing aspects.
  • an embodiment of the present application also provides a device, which includes a module/unit that executes any possible design method of any of the above aspects.
  • modules/units can be realized by hardware, or by hardware executing corresponding software.
  • an embodiment of the present application also provides a computer-readable storage medium, where the computer-readable storage medium includes a computer program, and when the computer program runs on an electronic device, the electronic device executes any of the above aspects. Any one of the possible design methods.
  • the embodiments of the present application also provide a method that includes a computer program product, which when the computer program product runs on a terminal, causes the electronic device to execute any one of the possible designs in any of the foregoing aspects.
  • Figure 1 is a schematic diagram of an existing log screening method provided by an embodiment of the application.
  • Figure 2 is a schematic diagram of an application scenario provided by an embodiment of the application
  • FIG. 3 is a schematic structural diagram of a mobile phone provided by an embodiment of the application.
  • FIG. 4 is a schematic structural diagram of an Android operating system provided by an embodiment of the application.
  • FIG. 5 is a schematic structural diagram of an improved Android operating system provided by an embodiment of the application.
  • FIG. 6 is a schematic flowchart of a method for generating log information according to an embodiment of the application
  • FIG. 7 is a schematic diagram of the tracking identification transfer of the binder communication mechanism provided by an embodiment of the application.
  • FIG. 8 is a schematic diagram of the tracking identification transfer of the handler communication mechanism provided by an embodiment of the application.
  • FIG. 9 is a schematic diagram of a tracking identification transfer interaction flow based on binder synchronization calls provided by an embodiment of the application.
  • FIG. 10 is a schematic diagram of a log automatic screening method provided by an embodiment of the application;
  • Figure 11a and Figure lib are schematic diagrams of a fault location method for a performance tracking log provided in an embodiment of the application.
  • FIG. 12 is a schematic diagram of a device provided by an embodiment of this application.
  • FIG. 13 is a schematic structural diagram of an electronic device provided by an embodiment of the application. detailed description
  • the flow log of the Android system outputs information in business processing through the log system.
  • the log output format of the Android system includes timestamp, process ID, thread ID, level, and content.
  • the output log information includes different businesses, different processes, and different threads, so it is difficult to distinguish and extract parts related to its own business. It can only be distinguished manually.
  • the part marked by the black dot shown in Figure 1 is the part that is manually marked and related to its own business.
  • the information output by the existing flow log may involve cross-process or cross-thread call relationships. If you want to obtain the call link information of a certain business, you rely on manual distinction, and failure analysis depends entirely on the developer's business capabilities and code familiarity. degree.
  • the current performance tracing (systrace) log of the Android system also has similar problems to the flow log.
  • the systrace log can only provide the relationship between the various layers of a thread, and it cannot provide the relationship between the cross-process or cross-thread call processing.
  • a timeout operation may involve cross-process or cross-thread calls. If the cause of the timeout is to be found, it is completely dependent on the developer's business ability. Obviously, this is time-consuming and labor-intensive, and the efficiency of problem solving is low.
  • the embodiment of the present application provides a method for generating log information.
  • the method is mainly executed by an electronic device.
  • the electronic device receives a user's first operation, it responds to the first operation.
  • the electronic device will The unique tracking identifier corresponding to the service is automatically generated, and this tracking identifier will be transmitted in the entire call link of the service.
  • the electronic device can store the tracking identifier in each call link.
  • log information including the tracking identifier is generated. Therefore, developers can obtain log information related to the business by searching for the tracking identifier, and analyze the cause of the failure.
  • the mobile phone when it detects a user's touch operation on the camera control in the camera application, it will respond to the touch operation, that is, add force at the start of the camera service corresponding to the control P—a unique tracking identifier Then, the tracking identifier will be passed down to the framework layer and the driver layer, and finally log information corresponding to the tracking identifier can be generated. Assuming that the mobile phone freezes when responding to the operation of taking a picture at this time, the developer can quickly locate the time-consuming thread by calling the log information corresponding to the tracking mark, thereby locating the cause of the failure. .
  • the log information generation method provided by the embodiment of the present application can be applied to the scenario shown in FIG. 2.
  • the electronic device when the user performs an operation on the electronic device 100, the electronic device generates a log, which includes log information corresponding to the tracking identifier, and then the electronic device can be uploaded to the cloud through the communication network, and then the developer operates the terminal device 200 from The cloud obtains the log of the electronic device, obtains the log information of the target business through the tracking identifier, and analyzes the cause of the failure.
  • the electronic device 100 and the terminal device 200 may also be directly connected through the development tool, that is, the terminal device 200 directly obtains the log information of the electronic device 100 through the development tool, analyzes it, and obtains the cause of the failure.
  • the electronic device 100 shown in FIG. 2 may be a portable electronic device that also includes other functions such as a personal digital assistant and/or a music player function, such as a mobile phone, a tablet computer, and a wireless communication function.
  • Wearable devices such as smart watches, etc.
  • Exemplary embodiments of portable electronic devices include but are not limited to portable electronic devices equipped with iOS®, android®, microsoft® or other operating systems.
  • the terminal device 200 may be a personal computer.
  • FIG. 3 shows a schematic structural diagram of the mobile phone 100.
  • the mobile phone 100 may include a processor 110, an external memory interface 120, an internal memory 121, a 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, and a wireless communication module 160, Audio module 170, speaker 170A, receiver 170B, microphone 170C, earphone interface 170D, sensor module 180, button 190, motor 191, indicator 192, camera 193, display screen 194, and SIM card interface 195, etc.
  • a processor 110 an external memory interface 120, an internal memory 121, a 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, and a wireless communication module 160, Audio module 170, speaker 170A, receiver 170B, microphone 170C, earphone interface 170D, sensor module 180, button 190, motor 191, indicator 192, camera 193, display screen 194, and SIM card interface 195, etc
  • the structure illustrated in the embodiment of the present invention does not constitute a specific limitation on the mobile phone 100.
  • the mobile phone 100 may include more or fewer components than shown, or combine certain components, or disassemble certain components, or arrange different components.
  • the illustrated components can be implemented in hardware, software, or a combination of software and hardware.
  • the processor 110 may include one or more processing units.
  • the processor 110 may include an application processor (AP), a modem processor, a graphics processing unit (GPU), and an image signal processor. (image signal processor, ISP), controller, memory, video codec, digital signal processor (DSP), baseband processor, and/or neural network processor (Neural-network Processing Unit, NPU), etc.
  • AP application processor
  • ISP image signal processor
  • controller memory
  • video codec digital signal processor
  • DSP digital signal processor
  • NPU neural network processor
  • different processing units may be independent devices, or may be integrated in one or more processors.
  • the controller may be the nerve center and command center of the mobile phone 100.
  • the controller can generate operation control signals according to the instruction operation code and timing signals to complete the control of fetching and executing instructions.
  • a memory may also be provided in the processor 110 to store instructions and data.
  • the memory in the processor 110 is a cache memory.
  • the memory can store instructions or data that the processor 110 has just used or used cyclically. If the processor 110 needs to use the instruction or data again, it can be directly called from the memory. Repeated accesses are avoided, the waiting time of the processor 110 is reduced, and the efficiency of the system is improved.
  • the processor 110 may run the log information generation method provided in the embodiment of the present application to generate log information corresponding to the tracking identifier.
  • the processor 110 integrates different devices, such as integrated CPU and GI ⁇ U, the CPU and GPU can cooperate to execute the method provided in the embodiment of the present application, for example, some algorithms are executed by the CPU, and another part of the algorithms are executed by the GPU to obtain faster The processing efficiency.
  • the display screen 194 is used to display images, videos, etc.
  • the display screen 194 includes a display panel.
  • the display panel can use liquid crystal display (LCD), organic light-emitting diode (OLED), active matrix organic light-emitting diode or active-matrix organic light-emitting diode (active-matrix organic light-emitting diode).
  • Emitting diode, AMOLED organic light-emitting diode
  • flexible light-emitting diode flex light-emitting diode, FLED
  • Miniled MicroLed, Micro-oLed, quantum dot light emitting diodes (QLED), etc.
  • the mobile phone 100 may include one or N display screens 194, and N is a positive integer greater than one.
  • the display screen 194 receives a user's touch operation, and in response to the touch operation, the processor 110 adds a unique tracking identifier corresponding to the service at the service start entry.
  • Camera 193 front camera or rear camera, or a camera can be used as a front camera or a rear camera for capturing still images or videos.
  • the camera 193 may include a photosensitive element such as a lens group and an image sensor, where the lens group includes a plurality of lenses (convex lens or concave lens) for collecting light signals reflected by the object to be photographed, and transmitting the collected light signals to the image sensor .
  • the image sensor generates an original image of the object to be photographed according to the light signal.
  • the internal memory 121 may be used to store computer executable program code, where the executable program code includes instructions.
  • the processor 110 executes various functional applications and data processing of the mobile phone 100 by running instructions stored in the internal memory 121.
  • the internal memory 121 may include a program storage area and a data storage area.
  • the storage program area can store codes of the operating system and application programs (such as camera applications, WeChat applications, etc.).
  • the data storage area can store data created during the use of the mobile phone 100 (such as images and videos captured by a camera application) and the like.
  • the internal memory 121 can also store the code of the anti-mistouch algorithm provided in the embodiment of the present application.
  • the code of the anti-mistouch algorithm stored in the internal memory 121 is run by the processor 110, the touch operation during the folding or unfolding process can be shielded.
  • 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 magnetic disk storage device, a flash memory device, a universal flash storage (UFS), and the like.
  • a non-volatile memory such as at least one magnetic disk storage device, a flash memory device, a universal flash storage (UFS), and the like.
  • the code of the anti-mistouch algorithm provided in the embodiment of the present application can also be stored in an external memory.
  • the processor 110 can run the code of the anti-mistouch algorithm stored in the external memory through the external memory interface 120, so as to realize the shielding of the touch operation during the folding or unfolding process.
  • the sensor module 180 may include a gyroscope sensor, an acceleration sensor, a proximity sensor, a fingerprint sensor, a touch sensor, a hinge sensor, etc.
  • the mobile phone 100 may also include other sensors, such as a temperature sensor, a pressure sensor, a distance sensor, and a magnetic sensor. , Ambient light sensor, air pressure sensor, bone conduction sensor, etc., X is not shown in the figure
  • the display screen 194 of the mobile phone 100 displays a main interface, and the main interface includes icons of multiple applications (such as a camera application, a Google app, etc.).
  • the display screen 194 displays the interface of the camera application, such as the viewfinder interface.
  • the wireless communication function of the mobile phone 100 can be realized by the antenna 1, the antenna 2, the mobile communication module 151, the wireless communication module 152, the modem processor, and the baseband processor.
  • Antenna 1 and Antenna 2 are used to transmit and receive electromagnetic wave signals.
  • Each antenna in the terminal device 100 can be used to cover a single or multiple communication frequency bands. Different antennas can also be reused to improve antenna utilization.
  • Antenna 1 can be multiplexed as a diversity antenna for wireless LAN.
  • the antenna can be used in combination with a tuning switch.
  • the mobile communication module 151 can provide a wireless communication solution including 2G/3G/4G/5G and the like applied to the terminal device 100.
  • the mobile communication module 151 may include at least one filter, a switch, a power amplifier, a low noise amplifier (LNA), and the like.
  • the mobile communication module 151 can receive electromagnetic waves by the antenna 1, and perform processing such as filtering and amplifying the received electromagnetic waves, and then transmitting them to the modem processor for demodulation.
  • the mobile communication module 150 can also amplify the signal modulated by the modem processor, and convert it into electromagnetic waves through the antenna 1 for radiation.
  • at least part of the functional modules of the mobile communication module 151 may be provided in the processor 110.
  • at least part of the functional modules of the mobile communication module 151 and at least part of the modules of the processor 110 may be provided in the same device.
  • the modem processor may include a modulator and a demodulator.
  • the modulator is used to modulate the low frequency baseband signal to be sent into a medium and high frequency signal.
  • the demodulator is used to demodulate the received electromagnetic wave signal into a low-frequency baseband signal. Then the demodulator 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 sound signals through audio equipment (not limited to speakers 170A, receiver 170B, etc.), or displays images or videos through the display 194.
  • the modem processor may be an independent device. In other embodiments, the modem processor may be independent of the processor 110 and be provided in the same device as the mobile communication module 150 or other functional modules.
  • the wireless communication module 152 can provide applications on the terminal device 100 including wireless local area networks (WLAN) (such as wireless fidelity (Wi-Fi) networks), bluetooth (BT), and global navigation satellites.
  • WLAN wireless local area networks
  • BT wireless fidelity
  • GNSS global navigation satellite system
  • FM frequency modulation
  • NFC near field communication technology
  • infrared technology infrared, IR
  • the wireless communication module 152 may be one or more devices integrating at least one communication processing module.
  • the wireless communication module 152 receives electromagnetic waves via the antenna 2, frequency modulates and filters the electromagnetic wave signals, and sends the processed signals to the processor 110.
  • the wireless communication module 152 can also receive the signal to be sent from the processor 110, perform frequency modulation, amplify it, and convert it into electromagnetic waves through the antenna 2 for radiation.
  • the mobile phone 100 can implement audio functions through an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, a headphone interface 170D, and an application processor. For example, music playback, recording, etc.
  • the mobile phone 100 can receive key 190 input, and generate key signal input related to the user settings and function control of the mobile phone 100.
  • the mobile phone 100 can use the motor 191 to generate a vibration notification (for example, an incoming call vibration notification).
  • the indicator 192 in the mobile phone 100 may be an indicator light, which may be used to indicate a charging state, a change in power level, and may also be used to indicate a message, a missed call, a notification, and the like.
  • the SIM card interface 195 in the mobile phone 100 is used to connect to the SIM card. The SIM card can be inserted into the SIM card interface 195 or pulled out from the SIM card interface 195 to achieve contact and separation with the mobile phone 100.
  • the mobile phone 100 may include more or less components than those shown in FIG. 1, which is not limited in the embodiment of the present application.
  • the mobile phone software system can adopt a layered architecture, event-driven architecture, micro-core architecture, micro-service architecture, or cloud architecture.
  • the embodiment of the present invention takes a layered Android system as an example to illustrate the software structure of a mobile phone.
  • FIG. 4 is a block diagram of the software structure of the electronic device 100 according to an embodiment of the present application.
  • the layered architecture divides the software into thousands of layers, and each layer has a clear role and division of labor. Communication between layers through software interface.
  • the Android system is divided into four layers, from top to bottom, the application layer, the application framework layer, the Android runtime and system libraries, and the kernel layer.
  • the application layer can include a series of application packages.
  • the application package can include applications such as camera, gallery, calendar, call, map, navigation, WLAN, Bluetooth, music, video, short message and so on.
  • the application framework layer provides an application programming interface (API) and a programming framework for applications in the application layer.
  • API application programming interface
  • the application framework layer includes some predefined functions.
  • the application framework layer may include a window manager, a content provider, a view system, a phone manager, a resource manager, a notification manager, and so on.
  • the window manager is used to manage window programs.
  • the window manager can obtain the size of the display screen, determine whether there is a status bar, lock the screen, capture the screen, etc.
  • the content provider is used to store and retrieve data, and make these data accessible to applications.
  • the data may include video, image, audio, dialed and received calls, browsing history and bookmarks, phone book, etc.
  • the view system includes visual controls, such as controls that display text, controls that display pictures, and so on.
  • the view system can be used to build applications.
  • the display interface can be composed of one or more views.
  • a display interface including a short message notification icon may include a view displaying text and a view displaying pictures.
  • the phone manager is used to provide the communication function of the mobile phone.
  • the management of call status (including connected, hang-up, etc.) X resource manager provides various resources for the application, such as localized strings, icons, pictures, layout files, video files and so on.
  • the notification manager enables the application to display notification information in the status bar, which can be used to convey notification-type messages, and it can automatically disappear after a short stay without user interaction.
  • the notification manager is used to notify that the download is complete, message reminders, and so on.
  • the notification manager can also be a notification that appears in the status bar at the top of the system in the form of a chart or scroll bar text, such as a notification of an application running in the background, or a notification that appears on the screen in the form of a dialog window.
  • text messages are displayed in the status bar, prompt sounds are emitted, electronic devices vibrate, and indicator lights flash.
  • Android Runtime includes core libraries and virtual machines. Android runtime is responsible for the scheduling and management of the Android system.
  • the core library consists of two parts: one part is the function functions that the java language needs to call, and the other part is the core library of Android.
  • the application layer and the application framework layer run in a virtual machine.
  • the virtual machine executes the java files in the application layer and 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.
  • the system library can include multiple functional modules. For example: surface manager (surface manager), media library (Media Libraries), 3D graphics processing library (for example: OpenGL ES), 2D graphics engine (for example: SGL), etc.
  • surface manager surface manager
  • media library Media Libraries
  • 3D graphics processing library for example: OpenGL ES
  • 2D graphics engine for example: SGL
  • the surface manager is used to manage the display subsystem and provides a combination of 2D and 3D layers for multiple applications.
  • the media library supports playback and recording of a variety of commonly used audio and video formats, as well as still image files.
  • the media library can support multiple audio and video encoding formats, such as: MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, etc.
  • the 3D graphics processing library is used to implement 3D graphics drawing, image rendering, synthesis, and layer processing.
  • the 2D graphics engine is a graphics engine for 2D drawing.
  • the kernel layer is the layer between hardware and software.
  • the kernel layer contains at least display driver, camera driver, audio driver, and sensor driver.
  • the embodiment of the application improves the Android operating system shown in FIG. 4, as shown in FIG. 5, a tracking for implementing the call link tracking function is added to the Android system.
  • System HwTrace.
  • the HwTrace system provides interfaces in the application layer (App), the framework layer (Framework), the system library (Native) and the kernel layer (Kernel) to support the functions of starting and stopping the tracking of business processes. Then modify the current communication mechanism (including binder, hwbinder, handler, socket, and system call).
  • the communication mechanism of these processes, threads, user mode, and kernel mode is used to realize the transmission of the trace identification.
  • the embodiment of the present application improves the existing communication mechanism.
  • the improved modules mainly involve the message (message java) of the Framework layer, the cross-process communication library (Binder lib) of the Native layer and the message and Kernel layer.
  • the tracking system has a Java language tracking system library (HwTrace lib) in Framework, a C/C++ language tracking system library (HwTrace lib) in Native, and a tracking system library (HwTrace lib) in the kernel layer.
  • Kernel language tracking system library HwTrace lib.
  • FIG. 6 the flow of a method for generating log information provided by an embodiment of the present application is exemplarily shown, and the method is executed by an electronic device.
  • Step 301 The electronic device receives the user's first operation, and in response to the first operation, the electronic device generates a unique tracking identifier corresponding to the service, and transmits the tracking identifier in the entire invocation link of the service.
  • the first operation may be a touch operation, or a voice command, etc.
  • the entire call link includes at least one process, and the at least one process includes at least one thread.
  • the call link includes more than two processes, then the call link includes cross-process calls and cross-thread calls.
  • Step 302 The electronic device stores the tracking identifier in the call record of each thread of each process of the call link, and generates log information including the tracking identifier.
  • the log output format includes timestamp, process ID, thread ID, level, trace ID and content, and each piece of information in the final output log includes a trace ID.
  • the mobile phone when it detects the user's touch operation on the camera control in the camera application, it responds to the touch operation, that is, adds a unique tracking identifier to the entrance of the camera service corresponding to the control, Then the tracking identifier will be passed down to the framework layer and the driver layer, and finally log information corresponding to the tracking identifier can be generated. Since the call link may involve different layers and different communication mechanisms, in order to realize that the tracking identification can be accurately transmitted downwards, after the electronic device generates a unique tracking identification corresponding to the business, it writes the tracking identification to the first corresponding to the business entry.
  • the tracking identifier is then transferred from the first thread to the second thread through a communication message, and the tracking identifier is written into the context of the second thread. If the second thread is not the last thread of the call link, repeat the communication message to transfer the trace identifier from the second thread to the third thread, and write the trace identifier into the context of the third thread until the call The last thread of the link.
  • the first thread, the second thread, and the third thread may be threads of the same process or threads of different processes, and the call link may involve different communication methods.
  • Step 303 the electronic device generates a report that causes an abnormality in the call link according to the call timestamp of the thread, the call service name, and the call relationship with other threads in the log information.
  • the electronic device calculates the calling time of each thread in the calling link according to the calling timestamp, and then generates a report that causes the calling link to be abnormal according to the calling time, calling relationship, and calling server name . For example, once a thread takes a long time, a report that the thread caused a timeout will be generated.
  • the embodiment of the application can realize that the calling link of a service carries a unique tracking identifier, so that the developer can quickly locate the time-consuming thread by calling the log information corresponding to the tracking identifier. , So as to locate the cause of the fault.
  • the above-mentioned method of tracing the calling link through the tracking identifier is not limited to generating log information, and can also be used to generate other output information related to the business, for example, generating business information including the tracking identifier.
  • the embodiments of this application provide specific delivery methods for the tracking identifier. It should be noted that TracelD will be used below to refer to the tracking identifier, which may be generated based on the identifier of the electronic device and the actual time of the user’s operation.
  • the identification of the electronic device may be the identification of the processor.
  • Figure 7 includes the following steps:
  • Step 1 Process 1 sends the communication data to the Binder driver through the command word BC_Transaction.
  • Step 2. The Binder driver forwards the communication data to process 2 for processing through the command word BR_Transaction.
  • Step 3. Process 2 sends the returned result back to the Binder driver through the command word BC_REPLY.
  • Step 4 The Binder driver forwards the returned result to the process through the command word BR_REPLY: L
  • the basic method of transferring TracelD during binder communication is: (1) When process 1 sends data, write TmcelD into the context of the process; (2) when process 2 receives data, first save the context of the current thread Then, it obtains TracelD from the context, and writes the TracelD into the context of its own process; after the processing ends, it returns to the context of the current process.
  • the first implementation mode the lib layer of the binder and the driver cooperate to complete the transfer and removal
  • the TraceID field is added to the lib layer data structure and the driver layer data structure of the binder, where the data structure includes binder_transaction_data, binder_transaction
  • BC_TRANSACTION/BC_REPLY is used to obtain TracelD from the thread context and write it into binder_transaction_data.
  • BR_TRANS ACTION is used to save the current thread context first, and then set the TracelD in binder_transaction_data to the thread context; after processing, the thread context is restored.
  • BC_TRANSACTION/BC_REPLY/BC_TRANSACTION_SG/BC_REPLY_SG used to realize the TracelD in the lib layer binder_transaction_data, save it in the driver layer binder_transaction.
  • BR_TRANSACTION/BR_REPLY is used to save TraceID in the binder_transaction of the driver layer to binder_transaction_data in the lib layer.
  • the second way to implement complete transfer and clearing in the driver
  • BC_TRANSACTION/BC_REPLY/BC_TRANSACTION_SG/BC_REPLY_SG are used to obtain TraceID from the thread context corresponding to the system call and save it in binder_transaction.
  • BR_TRANSACTION/BR_REPLY is used to set TraceID in binder_transaction to the thread context corresponding to the system call.
  • BR_TRANSACTION_COMPLETE used to clear the TraceID in the thread context corresponding to the system call (among which, oneway does not clear X
  • the second implementation method needs to support TracelD that accesses the thread context in the kernel mode and transfer, if the other process is not associated with the TracelD space, kernel allocation and association are required, but the second implementation method cannot achieve kernel allocation and association. Therefore, the first implementation can be preferred.
  • the transmission method of the tracking mark is the same as the first communication method.
  • Handle communication is based on the producer-consumer model.
  • the basic way to pass TracelD in the handle communication process is: before message sending: write the data in the thread context into the message; before message processing: set the data in the message to the thread In context; after message processing: clear thread context
  • the first step is to add a TracelD field to the message class.
  • the thread context TracelD is written into the msg message.
  • the third step news Process the dispatchHandler entry and write TracelD in the message to the thread context.
  • the fourth step message processing enqueuepost exit, clear thread context TracelD.
  • the TraceID field is added to the structure struct MessageEnvelope; in the second step, in the message sending Looper::sendMessageAtTime, the thread context TraceID is written into the messageEnvelope message.
  • the third step before the message processing handler->handleMessage (message), write TraceID in the message into the thread context.
  • the thread context TraceID is cleared.
  • the basic way to pass TracelD in the socket communication process is: before message sending: write the data in the thread context into the socket sending message; before message processing: set the data in the socket message to the thread context; after message processing: Clear the context of the thread.
  • the specific process of the log information generation method is further described in detail in conjunction with the process synchronization invocation process shown in FIG. 9.
  • the specific process of the method process may include:
  • Step a Start call chain tracking in a certain business process of the application, generate TraceID according to the combination of CPUID and timestamp, and set it in the thread context (tls).
  • step b the process in the process synchronously calls other processes through the command word binder transact.
  • Step c The process sending side obtains the current TraceID from the thread context, and writes the TraceID into the context.
  • Step d carry TraceID in the BC_TRANSACTION/BR_TRANSATION transfer of the binder message.
  • Thread 1 of the system service that is, the Binder receiving side
  • Thread 1 of the system service obtains TraceID from the data structure, and sets the passed TraceID to the current thread context, and processes it through the command word binder onTransact.
  • Step f the thread 1 serviced by the system returns the result through the command word BC_REPLY, and then clears TraceID in the thread context.
  • step g the App side continues processing until the Trace call chain tracing ends, and the TraceID in the thread context is cleared.
  • the embodiment of the application can realize the transfer of TracelD in the Android communication mechanism (binder, hwbinder, message, socket, syscall, etc.), and can realize high-performance access based on thread context technology, that is, save TracelD in process processing
  • the relevant output information can be obtained from the thread context and saved in the content. Therefore, the embodiment of the present application can realize the transmission of TraceID in the call link.
  • the electronic device obtains the tracking identifier from the context of each thread, converts the tracking identifier into a character string, writes it into the print information, and generates log information. In addition, the electronic device The log information corresponding to the tracking identifier is filtered out.
  • the correlation method is: in the user mode log printing interface, determine the current thread context Whether TracelD is valid in the middle, whether to set the user mode log associated switch, if so, convert TracelD into a string and insert it into the print information.
  • the flow log is mainly modified at the bottom level, which has less impact on performance.
  • the bottom layer of the current log is written to logd through sockets, using the vector write writev interface (multiple buffers), so when writing, a TracelD string buffer is added before the message string buffer, so that the socket on the receiving side is automatically spliced.
  • the correlation method is: in the kernel mode printing interface, it is determined that the current system call context ( Non-interrupting context), whether TracelD in the current thread context is valid, whether to set the kernel state log correlation switch, if so, convert TracelD into a string and insert it into the print information.
  • the kernel mode log is uniformly modified in the underlying interface, mainly involving the modification of the printk function.
  • systrace For the performance trace log (systrace), systrace obtains TracelD from the thread context, and connects the systrace of the entire business process through TracelD. In order to obtain the log information corresponding to the tracking identifier through the tracking identifier, it is necessary to first associate systrace with the tracking system.
  • the association method is: In user mode systrace printing, determine whether TracelD is valid in the current thread context and whether to set systrace association Switch, if yes, add TracelD parameters to the output content according to the systrace format specification. Among them, the systrace output is modified as far as possible in the bottom layer, while considering the efficiency.
  • the current systarce output is written to the /sys/kernel/debug/tracing/trace_marker interface at the bottom layer through multiple atrace interfaces, and the WRITE_MSG macro interface is used to convert the parameters to strings. Therefore, the output is in accordance with the format required by systrace, and TracelD is added as an addition The args parameter is inserted at the end of the string.
  • the use of the call link tracking technology provided by the embodiment of the present application can solve the problem of log output information correlation in the business process.
  • the black shadow corresponds to TraceID93921d2463.
  • the electronic device can automatically identify the log output information of a complete business process by searching for the TracelD, that is, through the TracelD, a cross-process, cross-thread, and multi-level
  • the output information of the business process is filtered and extracted. Reduce the ability to rely on developers, improve the efficiency of fault analysis, and quickly locate faults.
  • the UI Thread thread binder calls transact[35] to increase the Args parameter identifier "3fOfcalal3", which is the same as the Args parameter of the Binder: 1060_4 thread in Figure lib, which directly clarifies the cross-process binder calling relationship. That is, it can be determined through TracelD that the main time-consuming call of the UI Thread thread binder is due to the blocking of the called process.
  • the embodiment of the present application also provides a method and device for generating log information. As shown in FIG. 12, the device includes a receiving module 1201 and a processing module 1202.
  • the receiving module 1201 is configured to receive the first operation of the user.
  • the relevant content involved in the method embodiments in Figure 6 to Figure lib can all be quoted from the functional description of the receiving module 1101, which will not be repeated here.
  • the processing module 1202 is configured to, in response to the first operation, add a unique tracking identifier corresponding to the service at the service start entry, and transfer the tracking identifier in the entire invocation link of the service, where
  • the entire call link includes at least one process, and the at least one process includes at least one thread; and the trace identifier is stored in the call record of each thread of each process of the call link to generate Describe the log information of the tracking mark.
  • the related content involved in the method embodiments of Figure 6 to Figure lib can all be quoted from the functional description of the processing module 1202, which will not be repeated here.
  • the switching device of the application icon of the electronic device has the function of realizing the electronic device in the above method design.
  • These unit modules can be implemented by hardware in the terminal, or can be implemented by hardware in the terminal executing corresponding software, which is not limited in the embodiment of the present application.
  • the embodiment of the present application can generate log information including the tracking identifier, which is convenient for developers to extract information related to problems, reduces the ability requirements for developers, and improves problem solving efficiency.
  • An embodiment of the present application also provides a computer-readable storage medium.
  • the computer-readable storage medium includes a computer program.
  • the computer program runs on an electronic device, the electronic device executes any one of the aforementioned information processing methods. A possible realization.
  • the embodiments of the present application also provide a computer program product, which when the computer program product runs on an electronic device, causes the electronic device to execute any one possible implementation of the foregoing information processing method.
  • the embodiments of the present application disclose an electronic device.
  • the electronic device may include: a processor 1301; a memory 1302; and one or more computer programs 1303, as described above Each device can be connected through one or more communication buses 1304.
  • the one or more computer programs 1303 are stored in the above-mentioned memory 1302 and are configured to be invoked and executed by the processor 1301, and the one or more computer programs 1303 include instructions, and the above-mentioned instructions can be used for execution as shown in FIG. 6 to FIG. Each step in the corresponding embodiment.
  • the functional units in the various embodiments of the embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units may be integrated into one unit.
  • the above-mentioned integrated unit can be realized in the form of hardware or software functional unit.
  • the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer readable storage medium.
  • a computer readable storage medium includes several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) or a processor to execute all or part of the steps of the methods described in the various embodiments of the present application.
  • the aforementioned storage media include: flash memory, mobile hard disk, read-only memory, random access memory, magnetic disk or optical disk and other media that can store program codes.

Landscapes

  • Engineering & Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Debugging And Monitoring (AREA)

Abstract

A log information generating method and apparatus, and an electronic device. The method comprises: an electronic device receiving a first operation of a user; and in response to the first operation, the electronic device generating a tracing identifier that uniquely corresponds to a service, and transmitting the tracing identifier in a whole calling link of the service (301); and the electronic device storing the tracing identifier in a calling record of each thread of each process of the calling link, and generating log information comprising the tracing identifier (302). The method facilitates a developer in screening, according to the tracing identifier of each service, log information related to the service, reduces the requirements for the capability of the developer, and improves the problem solving efficiency.

Description

一种日志信息生成方法、 装置及电子设备 本申请要求在 2019年 2月 28 日提交中国国家知识产权局、 申请号为 201910151968.7、 发明名称为 “一种日志信息生成方法、 装置及电子设备” 的中国专利申请的优先权, 其全部 内容通过引用结合在本申请中。 技术领域 A log information generation method, device and electronic equipment This application requires that it be submitted to the State Intellectual Property Office of China on February 28, 2019, the application number is 201910151968.7, and the invention title is "a log information generation method, device and electronic equipment" The priority of the Chinese patent application, the entire content of which is incorporated in this application by reference. Technical field
本申请涉及终端技术领域, 尤其涉及一种日志信息生成方法、 装置及电子设备。 背景技术 This application relates to the field of terminal technologies, and in particular, to a method, device, and electronic device for generating log information. Background technique
目前在智能手机的安卓操作系统开发过程中, 功能类和性能类问题的分析和解决依赖于 日志、 性能跟踪日志 ( systrace )输出的信息。 现有技术中, 安卓系统的流水日志是将业务处 理中的信息通过日志系统输出。 例如, 安卓系统的日志输出格式包括时间戳、 进程 ID、 线程 ID、 级别、 内容。 实际应用中可能出现一些问题 (如: 拍照慢) 经常涉及到安卓系统的多个 服务和多个层次, 所以日志信息包括不同的业务、 不同的进程、 不同的线程, 所以难以区分 与某个业务相关的部分, 只能依赖人工区分。 由于安卓系统本身设计多个层, 较为复杂, 一 个开发人员一般仅熟悉其中某个业务或者业务的某个层次。 所以开发人员为了排查问题经常 需要从大量日志信息中人工过滤有用的信息, 也就是提取与该问题的业务处理流程相关的部 分, 对开发人员的能力要求较高, 且该方法解决问题的效率较低。 发明内容 At present, in the development process of the Android operating system of the smartphone, the analysis and resolution of functional and performance problems depend on the information output by the log and the performance trace log (systrace). In the prior art, the flow log of the Android system outputs the information in business processing through the log system. For example, the log output format of the Android system includes timestamp, process ID, thread ID, level, and content. Some problems (such as slow taking pictures) in practical applications often involve multiple services and multiple levels of the Android system. Therefore, the log information includes different businesses, different processes, and different threads, so it is difficult to distinguish from a certain business. The relevant parts can only be distinguished manually. Since the Android system itself has multiple layers and is relatively complicated, a developer is generally only familiar with a certain business or a certain level of the business. Therefore, in order to troubleshoot problems, developers often need to manually filter useful information from a large amount of log information, that is, to extract the parts related to the business processing process of the problem, which requires a higher ability of the developer, and the method is more efficient in solving the problem. low. Summary of the invention
本申请提供一种日志信息生成方法、 装置及电子设备, 用以生成包括追踪标识的日志信 息, 便于开发人员根据每个业务的追踪标识筛选与该业务相关的信息, 减轻对开发人员的能 力要求, 提高问题解决效率。 This application provides a method, device and electronic equipment for generating log information, which are used to generate log information including tracking identification, so that developers can screen information related to the business according to the tracking identification of each business, and reduce the ability requirements for developers , Improve problem solving efficiency.
第一方面, 本申请实施例提供了一种日志信息生成方法, 所述方法适用于电子设备, 该 方法包括: 电子设备接收用户的第一操作, 响应于第一操作, 电子设备在业务启动入口添加 与该业务对应的唯一的追踪标识, 并且在业务的整个调用链路中传递该追踪标识, 然后电子 设备将所述追踪标识存储到所述调用链路的每个进程的每个线程的调用记录中, 生成包括所 述追踪标识的日志信息。 其中, 追踪标识可以是 4艮据所述电子设备的标识和所述第一操作的 发生时间生成的。 In a first aspect, an embodiment of the present application provides a method for generating log information. The method is applicable to an electronic device. The method includes: the electronic device receives a user's first operation, and in response to the first operation, the electronic device enters the service startup portal Add a unique tracking identifier corresponding to the service, and transfer the tracking identifier in the entire call link of the service, and then the electronic device stores the tracking identifier in the call of each thread of each process of the call link In the recording, log information including the tracking identifier is generated. Wherein, the tracking identifier may be generated according to the identifier of the electronic device and the occurrence time of the first operation.
本申请实施例可以实现一个业务的调用链路携带有唯一的一个追踪标识, 这样开发人员 就可以通过调取与该追踪标识对应的日志信息, 可以快速地定位出耗时较长的线程, 从而定 位出故障出现的原因。 The embodiment of the application can realize that the calling link of a service carries a unique tracking identifier, so that developers can quickly locate the time-consuming thread by calling the log information corresponding to the tracking identifier, thereby Locate the cause of the fault.
在一种可能的设计中, 日志信息包括线程的调用时间戳、 调用服务名、 和其他线程的调 用关系, 电子设备还可以根据该日志信息中的调用时间戳、 调用服务名和调用关系, 生成导 致该调用链路发生异常的报告。 这样, 可以节省开发人员的分析过程, 提高问题解决效率。 In a possible design, the log information includes the call timestamp of the thread, the call service name, and the call relationship of other threads. The electronic device can also generate the call time stamp, the call service name, and the call relationship in the log information. Report that the call link is abnormal. In this way, the analysis process of the developer can be saved and the problem solving efficiency can be improved.
在一种可能的设计中, 电子设备生成与业务对应的唯一的追踪标识之后, 将追踪标识写 入到在业务入口对应的第一线程的上下文中, 然后通过通信消息将该追踪标识从第一线程传 递到第二线程, 并将该追踪标识写入到第二线程的上下文中。 若第二线程不是调用链路的最 后一个线程, 则重复执行通过通信消息将所述追踪标识从第二线程传递到第三线程, 并将追 踪标识写入到第三线程的上下文中, 直至调用链路的最后一个线程。 可见, 这一方法可以实 现将追踪标识在调用链路中传递。 In a possible design, after the electronic device generates the unique tracking identifier corresponding to the service, it writes the tracking identifier into the context of the first thread corresponding to the service portal, and then uses the communication message to transfer the tracking identifier from the first thread. The thread is passed to the second thread, and the tracking identifier is written into the context of the second thread. If the second thread is not the most In the latter thread, the tracking identifier is transferred from the second thread to the third thread through the communication message, and the tracking identifier is written into the context of the third thread until the last thread of the call link is repeatedly executed. It can be seen that this method can realize the transfer of the tracking identifier in the call link.
在一种可能的设计中, 电子设备从所述调用链路的各个线程的上下文中获取所述追踪标 识; 然后将所述追踪标识转换得到的字符串写入到调用链路的每个进程中的每个线程的调用 记录中, 最终生成包括所述追踪标识的日志信息。 其中, 日志包括流水日志、 内核日志和性 能追踪日志中的至少一种。 In a possible design, the electronic device obtains the trace identifier from the context of each thread of the call link; and then writes the character string obtained by the conversion of the trace identifier into each process of the call link In the call record of each thread, finally generate log information including the tracking identifier. Wherein, the log includes at least one of a running log, a kernel log, and a performance tracking log.
第二方面, 本申请实施例提供一种电子设备, 包括处理器和存储器。 其中, 存储器用于 存储一个或多个计算机程序; 当存储器存储的一个或多个计算机程序被处理器执行时, 使得 该电子设备能够实现上述任一方面的任意一种可能的设计的方法。 In a second aspect, an embodiment of the present application provides an electronic device, including a processor and a memory. The memory is used to store one or more computer programs; when the one or more computer programs stored in the memory are executed by the processor, the electronic device can implement any one of the possible design methods in any of the foregoing aspects.
第三方面, 本申请实施例还提供一种装置, 该装置包括执行上述任一方面的任意一种可 能的设计的方法的模块 /单元。这些模块 /单元可以通过硬件实现,也可以通过硬件执行相应的 软件实现。 In a third aspect, an embodiment of the present application also provides a device, which includes a module/unit that executes any possible design method of any of the above aspects. These modules/units can be realized by hardware, or by hardware executing corresponding software.
第四方面, 本申请实施例中还提供一种计算机可读存储介质, 所述计算机可读存储介质 包括计算机程序, 当计算机程序在电子设备上运行时, 使得所述电子设备执行上述任一方面 的任意一种可能的设计的方法。 In a fourth aspect, an embodiment of the present application also provides a computer-readable storage medium, where the computer-readable storage medium includes a computer program, and when the computer program runs on an electronic device, the electronic device executes any of the above aspects. Any one of the possible design methods.
第五方面, 本申请实施例还提供一种包含计算机程序产品, 当所述计算机程序产品在终 端上运行时, 使得所述电子设备执行上述任一方面的任意一种可能的设计的方法。 In a fifth aspect, the embodiments of the present application also provide a method that includes a computer program product, which when the computer program product runs on a terminal, causes the electronic device to execute any one of the possible designs in any of the foregoing aspects.
本申请的这些方面或其他方面在以下实施例的描述中会更力 P筒明易懂。 附图说明 These and other aspects of the present application will be more easily understood in the description of the following embodiments. Description of the drawings
图 1为本申请实施例提供的一种现有日志筛选方法示意图; Figure 1 is a schematic diagram of an existing log screening method provided by an embodiment of the application;
图 2为本申请实施例提供的一种应用场景示意图; Figure 2 is a schematic diagram of an application scenario provided by an embodiment of the application;
图 3为本申请实施例提供的一种手机的结构示意图; FIG. 3 is a schematic structural diagram of a mobile phone provided by an embodiment of the application;
图 4为本申请实施例提供的安卓操作系统结构示意图; FIG. 4 is a schematic structural diagram of an Android operating system provided by an embodiment of the application;
图 5为本申请实施例提供的一种安卓操作系统改进后的结构示意图; FIG. 5 is a schematic structural diagram of an improved Android operating system provided by an embodiment of the application;
图 6为本申请实施例提供的一种日志信息生成方法流程示意图; FIG. 6 is a schematic flowchart of a method for generating log information according to an embodiment of the application;
图 7为本申请实施例提供的 binder通信机制的追踪标识传递示意图; FIG. 7 is a schematic diagram of the tracking identification transfer of the binder communication mechanism provided by an embodiment of the application;
图 8为本申请实施例提供的 handler通信机制的追踪标识传递示意图; FIG. 8 is a schematic diagram of the tracking identification transfer of the handler communication mechanism provided by an embodiment of the application;
图 9为本申请实施例提供的基于 binder同步调用的追踪标识传递交互流程示意图; 图 10为本申请实施例提供的一种日志自动筛选方法示意图; FIG. 9 is a schematic diagram of a tracking identification transfer interaction flow based on binder synchronization calls provided by an embodiment of the application; FIG. 10 is a schematic diagram of a log automatic screening method provided by an embodiment of the application;
图 11a和图 lib为本申请实施例提供的性能追踪日志的故障定位方式示意图。 Figure 11a and Figure lib are schematic diagrams of a fault location method for a performance tracking log provided in an embodiment of the application.
图 12为本申请实施例提供的一种装置示意图; FIG. 12 is a schematic diagram of a device provided by an embodiment of this application;
图 13为本申请实施例提供的一种电子设备结构示意图。 具体实施方式 FIG. 13 is a schematic structural diagram of an electronic device provided by an embodiment of the application. detailed description
现有技术中, 安卓系统的流水日志是将业务处理中的信息通过日志系统输出。 例如, 安 卓系统的日志输出格式包括时间戳、 进程 ID、 线程 ID、 级别、 内容, 输出日志信息包括不同 的业务、 不同的进程、 不同的线程, 所以难以区分和提取与自身业务相关的部分, 只能依赖 人工区分,例如图 1所示的黑色圆点标记的部分为人工标记的与自身业务相关的部分。可见, 现有的流水日志所输出的信息可能涉及到跨进程或跨线程的调用关系, 想要获取某一个业务 的调用链路的信息依赖人工区分,故障分析完全依赖于开发人员的业务能力和代码熟悉程度。 In the prior art, the flow log of the Android system outputs information in business processing through the log system. For example, the log output format of the Android system includes timestamp, process ID, thread ID, level, and content. The output log information includes different businesses, different processes, and different threads, so it is difficult to distinguish and extract parts related to its own business. It can only be distinguished manually. For example, the part marked by the black dot shown in Figure 1 is the part that is manually marked and related to its own business. visible, The information output by the existing flow log may involve cross-process or cross-thread call relationships. If you want to obtain the call link information of a certain business, you rely on manual distinction, and failure analysis depends entirely on the developer's business capabilities and code familiarity. degree.
同样地, 目前安卓系统的性能追踪 ( systrace )日志也存在与流水日志类似的问题, systrace 日志只能提供一个线程内部各层处理的关系, 没办法提供跨进程或跨线程调用处理的关系。 例如一个超时操作可能涉及到跨进程或跨线程的调用, 如果要找到超时原因, 则完全依赖于 开发人员的业务能力, 显然这样做耗时耗力, 解决问题的效率较低。 Similarly, the current performance tracing (systrace) log of the Android system also has similar problems to the flow log. The systrace log can only provide the relationship between the various layers of a thread, and it cannot provide the relationship between the cross-process or cross-thread call processing. For example, a timeout operation may involve cross-process or cross-thread calls. If the cause of the timeout is to be found, it is completely dependent on the developer's business ability. Obviously, this is time-consuming and labor-intensive, and the efficiency of problem solving is low.
为了解决上述问题, 本申请实施例提供一种日志信息生成方法, 该方法主要由电子设备 执行, 当电子设备接收到用户的第一操作后, 则对第一操作作出响应, 这时电子设备会自动 生成与该业务对应的唯一的追踪标识,并且这一追踪标识会在该业务的整个调用链路中传递, 这样, 电子设备就可以将所述追踪标识存储到所述调用链路的每个进程的每个线程的调用记 录中, 生成包括所述追踪标识的日志信息。 因此开发人员可以通过搜索追踪标识获取到与该 业务相关的日志信息, 从而分析出故障出现的原因。 In order to solve the above problem, the embodiment of the present application provides a method for generating log information. The method is mainly executed by an electronic device. When the electronic device receives a user's first operation, it responds to the first operation. At this time, the electronic device will The unique tracking identifier corresponding to the service is automatically generated, and this tracking identifier will be transmitted in the entire call link of the service. In this way, the electronic device can store the tracking identifier in each call link. In the call record of each thread of the process, log information including the tracking identifier is generated. Therefore, developers can obtain log information related to the business by searching for the tracking identifier, and analyze the cause of the failure.
例如, 当手机检测到用户在相机应用中的拍照控件上的触摸操作时, 则对该触摸操作作 出响应, 即在与该控件所对应的拍照业务启动入口添力 P—个唯一的的追踪标识, 然后该追踪 标识会被向下传递到框架层和驱动层, 最终可以生成与该追踪标识对应的日志信息。 假设说 这时手机在响应拍照这一操作时发生卡顿, 则开发人员通过调取与该追踪标识对应的日志信 息, 可以快速地定位出耗时较长的线程, 从而定位出故障出现的原因。 For example, when the mobile phone detects a user's touch operation on the camera control in the camera application, it will respond to the touch operation, that is, add force at the start of the camera service corresponding to the control P—a unique tracking identifier Then, the tracking identifier will be passed down to the framework layer and the driver layer, and finally log information corresponding to the tracking identifier can be generated. Assuming that the mobile phone freezes when responding to the operation of taking a picture at this time, the developer can quickly locate the time-consuming thread by calling the log information corresponding to the tracking mark, thereby locating the cause of the failure. .
本申请实施例提供的日志信息生成方法可以应用于如图 2所示的场景。 在图 2中, 用户 在电子设备 100上进行操作时,电子设备会生成日志,日志中包括与追踪标识对应日志信息, 然后电子设备可以通过通信网络上传到云端, 然后开发人员操作终端设备 200从云端获取该 电子设备的日志, 通过追踪标识获取目标业务的日志信息, 分析故障原因。 除此之外, 电子 设备 100和终端设备 200也可以通过开发工具直接连接, 也就是终端设备 200直接通过开发 工具获取电子设备 100的日志信息, 对其进行分析, 得到故障原因。 The log information generation method provided by the embodiment of the present application can be applied to the scenario shown in FIG. 2. In FIG. 2, when the user performs an operation on the electronic device 100, the electronic device generates a log, which includes log information corresponding to the tracking identifier, and then the electronic device can be uploaded to the cloud through the communication network, and then the developer operates the terminal device 200 from The cloud obtains the log of the electronic device, obtains the log information of the target business through the tracking identifier, and analyzes the cause of the failure. In addition, the electronic device 100 and the terminal device 200 may also be directly connected through the development tool, that is, the terminal device 200 directly obtains the log information of the electronic device 100 through the development tool, analyzes it, and obtains the cause of the failure.
在本申请一些实施例中, 图 2所示的电子设备 100可以是还包含其他功能诸如个人数字 助理和 /或音乐播放器功能的便携式电子设备, 诸如手机、 平板电脑、 具备无线通讯功能的可 穿戴设备 (如智能手表) 等。 便携式电子设备的示例性实施例包括但不限于搭载 iOS®、 android®、microsoft®或者其他操作系统的便携式电子设备。终端设备 200可以是个人计算机。 In some embodiments of the present application, the electronic device 100 shown in FIG. 2 may be a portable electronic device that also includes other functions such as a personal digital assistant and/or a music player function, such as a mobile phone, a tablet computer, and a wireless communication function. Wearable devices (such as smart watches), etc. Exemplary embodiments of portable electronic devices include but are not limited to portable electronic devices equipped with iOS®, android®, microsoft® or other operating systems. The terminal device 200 may be a personal computer.
以电子设备是手机为例, 图 3示出了手机 100的结构示意图。 Taking the electronic device as a mobile phone as an example, FIG. 3 shows a schematic structural diagram of the mobile phone 100.
手机 100可以包括处理器 110, 外部存储器接口 120, 内部存储器 121, USB接口 130, 充电管理模块 140, 电源管理模块 141, 电池 142, 天线 1, 天线 2, 移动通信模块 150, 无线 通信模块 160, 音频模块 170, 扬声器 170A, 受话器 170B , 麦克风 170C, 耳机接口 170D, 传感器模块 180, 按键 190, 马达 191 , 指示器 192, 摄像头 193 , 显示屏 194, 以及 SIM卡 接口 195等。 The mobile phone 100 may include a processor 110, an external memory interface 120, an internal memory 121, a 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, and a wireless communication module 160, Audio module 170, speaker 170A, receiver 170B, microphone 170C, earphone interface 170D, sensor module 180, button 190, motor 191, indicator 192, camera 193, display screen 194, and SIM card interface 195, etc.
可以理解的是, 本发明实施例示意的结构并不构成对手机 100的具体限定。 在本申请另 一些实施例中, 手机 100可以包括比图示更多或更少的部件, 或者组合某些部件, 或者拆分 某些部件, 或者不同的部件布置。 图示的部件可以以硬件, 软件或软件和硬件的组合实现。 It can be understood that the structure illustrated in the embodiment of the present invention does not constitute a specific limitation on the mobile phone 100. In other embodiments of the present application, the mobile phone 100 may include more or fewer components than shown, or combine certain components, or disassemble certain components, or arrange different components. The illustrated components can be implemented in hardware, software, or a combination of software and hardware.
处理器 110 可以包括一个或多个处理单元, 例如: 处理器 110 可以包括应用处理器 ( application processor, AP),调制解调处理器, 图形处理器 ( graphics processing unit, GPU), 图像信号处理器 ( image signal processor, ISP), 控制器, 存储器, 视频编解码器, 数字信号处 理器 (digital signal processor, DSP), 基带处理器, 和 /或神经网络处理器 ( Neural-network Processing Unit, NPU)等。 其中, 不同的处理单元可以是独立的器件, 也可以集成在一个或多 个处理器中。 其中, 控制器可以是手机 100的神经中枢和指挥中心。 控制器可以根据指令操 作码和时序信号, 产生操作控制信号, 完成取指令和执行指令的控制。 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 processing unit (GPU), and an image signal processor. (image signal processor, ISP), controller, memory, video codec, digital signal processor (DSP), baseband processor, and/or neural network processor (Neural-network Processing Unit, NPU), etc. Among them, different processing units may be independent devices, or may be integrated in one or more processors. The controller may be the nerve center and command center of the mobile phone 100. The controller can generate operation control signals according to the instruction operation code and timing signals to complete the control of fetching and executing instructions.
处理器 110中还可以设置存储器, 用于存储指令和数据。 在一些实施例中, 处理器 110 中的存储器为高速缓冲存储器。 该存储器可以保存处理器 110刚用过或循环使用的指令或数 据。 如果处理器 110需要再次使用该指令或数据, 可从所述存储器中直接调用。 避免了重复 存取, 减少了处理器 110的等待时间, 因而提高了系统的效率。 A memory may also be provided in the processor 110 to store instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. The memory can store instructions or data that the processor 110 has just used or used cyclically. If the processor 110 needs to use the instruction or data again, it can be directly called from the memory. Repeated accesses are avoided, the waiting time of the processor 110 is reduced, and the efficiency of the system is improved.
处理器 110可以运行本申请实施例提供的日志信息生成方法, 以生成与该追踪标识对应 的日志信息。 当处理器 110集成不同的器件, 比如集成 CPU和 GI^U时, CPU和 GPU可以配 合执行本申请实施例提供的方法, 比如部分算法由 CPU执行, 另一部分算法由 GPU执行, 以得到较快的处理效率。 The processor 110 may run the log information generation method provided in the embodiment of the present application to generate log information corresponding to the tracking identifier. When the processor 110 integrates different devices, such as integrated CPU and GI^U, the CPU and GPU can cooperate to execute the method provided in the embodiment of the present application, for example, some algorithms are executed by the CPU, and another part of the algorithms are executed by the GPU to obtain faster The processing efficiency.
显示屏 194用于显示图像, 视频等。 显示屏 194包括显示面板。 显示面板可以采用液晶 显示屏 (liquid crystal display, LCD), 有机发光二极管 (organic light-emitting diode, OLED),有 源矩阵有机发光二极体或主动矩阵有机发光二极体 (active-matrix organic light emitting diode的, AMOLED) ,柔性发光二极管 (flex light-emitting diode, FLED), Miniled, MicroLed, Micro-oLed, 量子点发光二极管 (quantum dot light emitting diodes, QLED)等。 在一些实施例中, 手机 100 可以包括 1个或 N个显示屏 194, N为大于 1的正整数。 The display screen 194 is used to display images, videos, etc. The display screen 194 includes a display panel. The display panel can use liquid crystal display (LCD), organic light-emitting diode (OLED), active matrix organic light-emitting diode or active-matrix organic light-emitting diode (active-matrix organic light-emitting diode). Emitting diode, AMOLED), flexible light-emitting diode (flex light-emitting diode, FLED), Miniled, MicroLed, Micro-oLed, quantum dot light emitting diodes (QLED), etc. In some embodiments, the mobile phone 100 may include one or N display screens 194, and N is a positive integer greater than one.
在本申请实施例中, 显示屏 194接收用户的触摸操作, 处理器 110响应于该触摸操作, 在业务启动入口添加与该业务对应的唯一的追踪标识。 In the embodiment of the present application, the display screen 194 receives a user's touch operation, and in response to the touch operation, the processor 110 adds a unique tracking identifier corresponding to the service at the service start entry.
摄像头 193 (前置摄像头或者后置摄像头, 或者一个摄像头既可作为前置摄像头, 也可 作为后置摄像头)用于捕获静态图像或视频。 通常, 摄像头 193可以包括感光元件比如镜头 组和图像传感器, 其中, 镜头组包括多个透镜 (凸透镜或凹透镜), 用于采集待拍摄物体反射 的光信号, 并将采集的光信号传递给图像传感器。 图像传感器根据所述光信号生成待拍摄物 体的原始图像。 Camera 193 (front camera or rear camera, or a camera can be used as a front camera or a rear camera) for capturing still images or videos. Generally, the camera 193 may include a photosensitive element such as a lens group and an image sensor, where the lens group includes a plurality of lenses (convex lens or concave lens) for collecting light signals reflected by the object to be photographed, and transmitting the collected light signals to the image sensor . The image sensor generates an original image of the object to be photographed according to the light signal.
内部存储器 121可以用于存储计算机可执行程序代码, 所述可执行程序代码包括指令。 处理器 110通过运行存储在内部存储器 121的指令, 从而执行手机 100的各种功能应用以及 数据处理。 内部存储器 121可以包括存储程序区和存储数据区。 其中, 存储程序区可存储操 作系统, 应用程序 (比如相机应用, 微信应用等)的代码等。 存储数据区可存储手机 100使用 过程中所创建的数据 (比如相机应用采集的图像、 视频等)等。 The internal memory 121 may be used to store computer executable program code, where the executable program code includes instructions. The processor 110 executes various functional applications and data processing of the mobile phone 100 by running 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 storage program area can store codes of the operating system and application programs (such as camera applications, WeChat applications, etc.). The data storage area can store data created during the use of the mobile phone 100 (such as images and videos captured by a camera application) and the like.
内部存储器 121还可以存储本申请实施例提供的防误触算法的代码。 当内部存储器 121 中存储的防误触算法的代码被处理器 110运行时, 可以对折叠或者展开过程中的触摸操作进 行屏蔽。 The internal memory 121 can also store the code of the anti-mistouch algorithm provided in the embodiment of the present application. When the code of the anti-mistouch algorithm stored in the internal memory 121 is run by the processor 110, the touch operation during the folding or unfolding process can be shielded.
此外, 内部存储器 121可以包括高速随机存取存储器, 还可以包括非易失性存储器, 例 如至少一个磁盘存储器件, 闪存器件, 通用闪存存储器 (universal flash storage, UFS)等。 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 magnetic disk storage device, a flash memory device, a universal flash storage (UFS), and the like.
当然,本申请实施例提供的防误触算法的代码还可以存储在外部存储器中。这种情况下, 处理器 110可以通过外部存储器接口 120运行存储在外部存储器中的防误触算法的代码, 实 现对折叠或者展开过程中的触摸操作进行屏蔽。 Of course, the code of the anti-mistouch algorithm provided in the embodiment of the present application can also be stored in an external memory. In this case, the processor 110 can run the code of the anti-mistouch algorithm stored in the external memory through the external memory interface 120, so as to realize the shielding of the touch operation during the folding or unfolding process.
其中, 传感器模块 180可以包括陀螺仪传感器, 加速度传感器, 接近光传感器、 指纹传 感器, 触摸传感器、 转轴传感器等, 当然, 手机 100还可以包括其它传感器, 比如温度传感 器, 压力传感器、 距离传感器、 磁传感器、 环境光传感器、 气压传感器、 骨传导传感器等, 图中未示出 X Wherein, the sensor module 180 may include a gyroscope sensor, an acceleration sensor, a proximity sensor, a fingerprint sensor, a touch sensor, a hinge sensor, etc. Of course, the mobile phone 100 may also include other sensors, such as a temperature sensor, a pressure sensor, a distance sensor, and a magnetic sensor. , Ambient light sensor, air pressure sensor, bone conduction sensor, etc., X is not shown in the figure
示例性的,手机 100的显示屏 194显示主界面,主界面中包括多个应用 (比如相机应用、 谷丈信应用等) 的图标。 用户通过触摸传感器 180K点击主界面中相机应用的图标, 触发处理 器 110启动相机应用, 打开摄像头 193。 显示屏 194显示相机应用的界面, 例如取景界面。 Exemplarily, the display screen 194 of the mobile phone 100 displays a main interface, and the main interface includes icons of multiple applications (such as a camera application, a Google app, etc.). The user clicks the icon of the camera application in the main interface through the touch sensor 180K, triggers the processor 110 to start the camera application, and turns on the camera 193. The display screen 194 displays the interface of the camera application, such as the viewfinder interface.
手机 100的无线通信功能可以通过天线 1,天线 2,移动通信模块 151,无线通信模块 152, 调制解调处理器以及基带处理器等实现。 The wireless communication function of the mobile phone 100 can be realized by the antenna 1, the antenna 2, the mobile communication module 151, the wireless communication module 152, the modem processor, and the baseband processor.
天线 1和天线 2用于发射和接收电磁波信号。 终端设备 100中的每个天线可用于覆盖单 个或多个通信频带。 不同的天线还可以复用, 以提高天线的利用率。 例如: 可以将天线 1复 用为无线局域网的分集天线。 在另外一些实施例中, 天线可以和调谐开关结合使用。 Antenna 1 and Antenna 2 are used to transmit and receive electromagnetic wave signals. Each antenna in the terminal device 100 can be used to cover a single or multiple communication frequency bands. Different antennas can also be reused to improve antenna utilization. For example: Antenna 1 can be multiplexed as a diversity antenna for wireless LAN. In other embodiments, the antenna can be used in combination with a tuning switch.
移动通信模块 151可以提供应用在终端设备 100上的包括 2G/3G/4G/5G等无线通信的解 决方案。 移动通信模块 151可以包括至少一个滤波器, 开关, 功率放大器, 低噪声放大器 (low noise amplifier, LNA)等。 移动通信模块 151可以由天线 1接收电磁波, 并对接收的电磁波进 行滤波, 放大等处理, 传送至调制解调处理器进行解调。 移动通信模块 150还可以对经调制 解调处理器调制后的信号放大, 经天线 1转为电磁波辐射出去。 在一些实施例中, 移动通信 模块 151的至少部分功能模块可以被设置于处理器 110中。 在一些实施例中, 移动通信模块 151的至少部分功能模块可以与处理器 110的至少部分模块被设置在同一个器件中。 The mobile communication module 151 can provide a wireless communication solution including 2G/3G/4G/5G and the like applied to the terminal device 100. The mobile communication module 151 may include at least one filter, a switch, a power amplifier, a low noise amplifier (LNA), and the like. The mobile communication module 151 can receive electromagnetic waves by the antenna 1, and perform processing such as filtering and amplifying the received electromagnetic waves, and then transmitting them to the modem processor for demodulation. The mobile communication module 150 can also amplify the signal modulated by the modem processor, and convert it into electromagnetic waves through the antenna 1 for radiation. In some embodiments, at least part of the functional modules of the mobile communication module 151 may be provided in the processor 110. In some embodiments, at least part of the functional modules of the mobile communication module 151 and at least part of the modules of the processor 110 may be provided in the same device.
调制解调处理器可以包括调制器和解调器。 其中, 调制器用于将待发送的低频基带信号 调制成中高频信号。 解调器用于将接收的电磁波信号解调为低频基带信号。 随后解调器将解 调得到的低频基带信号传送至基带处理器处理。 低频基带信号经基带处理器处理后, 被传递 给应用处理器。 应用处理器通过音频设备 (不限于扬声器 170A, 受话器 170B等)输出声音信 号, 或通过显示屏 194显示图像或视频。 在一些实施例中, 调制解调处理器可以是独立的器 件。 在另一些实施例中, 调制解调处理器可以独立于处理器 110, 与移动通信模块 150或其 他功能模块设置在同一个器件中。 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 and high frequency signal. The demodulator is used to demodulate the received electromagnetic wave signal into a low-frequency baseband signal. Then the demodulator 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 sound signals through audio equipment (not limited to speakers 170A, receiver 170B, etc.), or displays images or videos through the display 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 provided in the same device as the mobile communication module 150 or other functional modules.
无线通信模块 152可以提供应用在终端设备 100上的包括无线局域网 (wireless local area networks , WLAN) (如无线保真 (wireless fidelity , Wi-Fi)网络), 蓝牙 (bluetooth, BT) , 全球导 航卫星系统 (global navigation satellite system, GNSS), 调频 (frequency modulation, FM) , 近距 离无线通信技术 (near field communication , NFC) , 红外技术 (infrared, IR)等无线通信的解决 方案。 无线通信模块 152可以是集成至少一个通信处理模块的一个或多个器件。 无线通信模 块 152经由天线 2接收电磁波, 将电磁波信号调频以及滤波处理, 将处理后的信号发送到处 理器 110。 无线通信模块 152还可以从处理器 110接收待发送的信号,对其进行调频,放大, 经天线 2转为电磁波辐射出去。 The wireless communication module 152 can provide applications on the terminal device 100 including wireless local area networks (WLAN) (such as wireless fidelity (Wi-Fi) networks), bluetooth (BT), and global navigation satellites. System (global navigation satellite system, GNSS), frequency modulation (frequency modulation, FM), near field communication technology (near field communication, NFC), infrared technology (infrared, IR) and other wireless communication solutions. The wireless communication module 152 may be one or more devices integrating at least one communication processing module. The wireless communication module 152 receives electromagnetic waves via the antenna 2, frequency modulates and filters the electromagnetic wave signals, and sends the processed signals to the processor 110. The wireless communication module 152 can also receive the signal to be sent from the processor 110, perform frequency modulation, amplify it, and convert it into electromagnetic waves through the antenna 2 for radiation.
另夕卜, 手机 100可以通过音频模块 170, 扬声器 170A, 受话器 170B , 麦克风 170C, 耳 机接口 170D, 以及应用处理器等实现音频功能。 例如音乐播放, 录音等。 手机 100可以接收 按键 190输入, 产生与手机 100的用户设置以及功能控制有关的键信号输入。 手机 100可以 利用马达 191产生振动提示 (比如来电振动提示)。 手机 100中的指示器 192可以是指示灯, 可以用于指示充电状态, 电量变化, 也可以用于指示消息, 未接来电, 通知等。 手机 100中 的 SIM卡接口 195用于连接 SIM卡。 SIM卡可以通过插入 SIM卡接口 195 , 或从 SIM卡接 口 195拔出, 实现和手机 100的接触和分离。 In addition, the mobile phone 100 can implement audio functions through an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, a headphone interface 170D, and an application processor. For example, music playback, recording, etc. The mobile phone 100 can receive key 190 input, and generate key signal input related to the user settings and function control of the mobile phone 100. The mobile phone 100 can use the motor 191 to generate a vibration notification (for example, an incoming call vibration notification). The indicator 192 in the mobile phone 100 may be an indicator light, which may be used to indicate a charging state, a change in power level, and may also be used to indicate a message, a missed call, a notification, and the like. The SIM card interface 195 in the mobile phone 100 is used to connect to the SIM card. The SIM card can be inserted into the SIM card interface 195 or pulled out from the SIM card interface 195 to achieve contact and separation with the mobile phone 100.
应理解, 在实际应用中, 手机 100可以包括比图 1所示的更多或更少的部件, 本申请实 施例不作限定。 手机的软件系统可以采用分层架构, 事件驱动架构,微核架构,微服务架构,或云架构。 本发明实施例以分层架构的 Android系统为例, 示例性说明手机的软件结构。 It should be understood that, in actual applications, the mobile phone 100 may include more or less components than those shown in FIG. 1, which is not limited in the embodiment of the present application. The mobile phone software system can adopt a layered architecture, event-driven architecture, micro-core architecture, micro-service architecture, or cloud architecture. The embodiment of the present invention takes a layered Android system as an example to illustrate the software structure of a mobile phone.
本申请实施例以分层架构的 Android系统为例, 示例性说明电子设备 100的软件结构。 图 4是本申请实施例的电子设备 100的软件结构框图。 The embodiment of the present application takes an Android system with a layered architecture as an example to exemplarily illustrate the software structure of the electronic device 100. FIG. 4 is a block diagram of the software structure of the electronic device 100 according to an embodiment of the present application.
分层架构将软件分成若千个层, 每一层都有清晰的角色和分工。 层与层之间通过软件接 口通信。 在一些实施例中, 将 Android 系统分为四层, 从上至下分别为应用程序层, 应用程 序框架层, 安卓运行时 ( Android runtime )和系统库, 以及内核层。 The layered architecture divides the software into thousands of layers, and each layer has a clear role and division of labor. Communication between layers through software interface. In some embodiments, the Android system is divided into four layers, from top to bottom, the application layer, the application framework layer, the Android runtime and system libraries, and the kernel layer.
应用程序层可以包括一系列应用程序包。 The application layer can include a series of application packages.
如图 4所示, 应用程序包可以包括相机, 图库, 日历, 通话, 地图, 导航, WLAN, 蓝 牙, 音乐, 视频, 短信息等应用程序。 As shown in Figure 4, the application package can include applications such as camera, gallery, calendar, call, map, navigation, WLAN, Bluetooth, music, video, short message and so on.
应用程序框架层为应用程序层的应用程序提供应用编程接口 ( application programming interface, API )和编程框架。 应用程序框架层包括一些预先定义的函数。 The application framework layer provides an application programming interface (API) and a programming framework for applications in the application layer. The application framework layer includes some predefined functions.
如图 4所示, 应用程序框架层可以包括窗口管理器, 内容提供器, 视图系统, 电话管理 器, 资源管理器, 通知管理器等。 As shown in Figure 4, the application framework layer may include a window manager, a content provider, a view system, a phone manager, a resource manager, a notification manager, and so on.
窗口管理器用于管理窗口程序。 窗口管理器可以获取显示屏大小, 判断是否有状态栏, 锁定屏幕, 截取屏幕等。 The window manager is used to manage window programs. The window manager can obtain the size of the display screen, determine whether there is a status bar, lock the screen, capture the screen, etc.
内容提供器用来存放和获取数据, 并使这些数据可以被应用程序访问。 所述数据可以包 括视频, 图像, 音频, 拨打和接听的电话, 浏览历史和书签, 电话簿等。 The content provider is used to store and retrieve data, and make these data accessible to applications. The data may include video, image, audio, dialed and received calls, browsing history and bookmarks, phone book, etc.
视图系统包括可视控件, 例如显示文字的控件, 显示图片的控件等。 视图系统可用于构 建应用程序。显示界面可以由一个或多个视图组成的。例如, 包括短信通知图标的显示界面, 可以包括显示文字的视图以及显示图片的视图。 The view system includes visual controls, such as controls that display text, controls that display pictures, and so on. The view system can be used to build applications. The display interface can be composed of one or more views. For example, a display interface including a short message notification icon may include a view displaying text and a view displaying pictures.
电话管理器用于提供手机的通信功能。 例如通话状态的管理 (包括接通, 挂断等 X 资源管理器为应用程序提供各种资源, 比如本地化字符串, 图标, 图片, 布局文件, 视 频文件等等。 The phone manager is used to provide the communication function of the mobile phone. For example, the management of call status (including connected, hang-up, etc.) X resource manager provides various resources for the application, such as localized strings, icons, pictures, layout files, video files and so on.
通知管理器使应用程序可以在状态栏中显示通知信息, 可以用于传达告知类型的消息, 可以短暂停留后自动消失, 无需用户交互。 比如通知管理器被用于告知下载完成, 消息提醒 等。 通知管理器还可以是以图表或者滚动条文本形式出现在系统顶部状态栏的通知, 例如后 台运行的应用程序的通知, 还可以是以对话窗口形式出现在屏幕上的通知。 例如在状态栏提 示文本信息, 发出提示音, 电子设备振动, 指示灯闪烁等。 The notification manager enables the application to display notification information in the status bar, which can be used to convey notification-type messages, and it can automatically disappear after a short stay without user interaction. For example, the notification manager is used to notify that the download is complete, message reminders, and so on. The notification manager can also be a notification that appears in the status bar at the top of the system in the form of a chart or scroll bar text, such as a notification of an application running in the background, or a notification that appears on the screen in the form of a dialog window. For example, text messages are displayed in the status bar, prompt sounds are emitted, electronic devices vibrate, and indicator lights flash.
Android Runtime包括核心库和虚拟机。 Android runtime负责安卓系统的调度和管理。 核心库包含两部分:一部分是 java语言需要调用的功能函数,另一部分是安卓的核心库。 应用程序层和应用程序框架层运行在虚拟机中。 虚拟机将应用程序层和应用程序框架层 的 java文件执行为二进制文件。虚拟机用于执行对象生命周期的管理,堆栈管理,线程管理, 安全和异常的管理, 以及垃圾回收等功能。 Android Runtime includes core libraries and virtual machines. Android runtime is responsible for the scheduling and management of the Android system. The core library consists of two parts: one part is the function functions that the java language needs to call, and the other part is the core library of Android. The application layer and the application framework layer run in a virtual machine. The virtual machine executes the java files in the application layer and 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.
系统库可以包括多个功能模块。 例如: 表面管理器 ( surface manager ), 媒体库 ( Media Libraries ), 三维图形处理库 (例如: OpenGL ES ), 2D图形引擎 (例如: SGL )等。 The system library can include multiple functional modules. For example: surface manager (surface manager), media library (Media Libraries), 3D graphics processing library (for example: OpenGL ES), 2D graphics engine (for example: SGL), etc.
表面管理器用于对显示子系统进行管理,并且为多个应用程序提供了 2D和 3D图层的融 合。 The surface manager is used to manage the display subsystem and provides a combination of 2D and 3D layers for multiple applications.
媒体库支持多种常用的音频, 视频格式回放和录制, 以及静态图像文件等。 媒体库可以 支持多种音视频编码格式, 例如: MPEG4, H.264, MP3, AAC, AMR, JPG, PNG等。 三维图形处理库用于实现三维图形绘图, 图像渲染, 合成, 和图层处理等。 The media library supports playback and recording of a variety of commonly used audio and video formats, as well as still image files. The media library can support multiple audio and video encoding formats, such as: MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, etc. The 3D graphics processing library is used to implement 3D graphics drawing, image rendering, synthesis, and layer processing.
2D图形引擎是 2D绘图的绘图引擎。 The 2D graphics engine is a graphics engine for 2D drawing.
内核层是硬件和软件之间的层。 内核层至少包含显示驱动, 摄像头驱动, 音频驱动, 传 感器驱动。 The kernel layer is the layer between hardware and software. The kernel layer contains at least display driver, camera driver, audio driver, and sensor driver.
本申请实施例为了实现对调用链路进行追踪的目的, 对图 4所示的安卓操作系统进行了 改进,如图 5所示,在安卓系统中增加了用于实现调用链路追踪功能的跟踪系统 ( HwTrace )。 HwTrace系统在应用层 ( App )、 框架层 ( Framework )、 系统库 ( Native )和内核层 ( Kernel ) 均提供了接口, 以支持业务流程启动跟踪和停止跟踪的功能。 然后再对当前的通信机制 (包 括 binder、 hwbinder、 handler、 socket、 系统调用 )进行修改, 当启动跟踪后根据这些进程、 线程、 用户态、 内核态的通信机制, 实现追踪标识的传递。 In order to achieve the purpose of tracking the call link, the embodiment of the application improves the Android operating system shown in FIG. 4, as shown in FIG. 5, a tracking for implementing the call link tracking function is added to the Android system. System (HwTrace). The HwTrace system provides interfaces in the application layer (App), the framework layer (Framework), the system library (Native) and the kernel layer (Kernel) to support the functions of starting and stopping the tracking of business processes. Then modify the current communication mechanism (including binder, hwbinder, handler, socket, and system call). When the tracking is started, the communication mechanism of these processes, threads, user mode, and kernel mode is used to realize the transmission of the trace identification.
如图 5 所示, 本申请实施例对现有的通信机制进行了改进, 改进的模块主要涉及 Framework层的消息 ( message java )、 Native层的跨进程通信库 ( Binder lib )和消息、 Kernel 层的跨进程通信驱动 ( Binder driver ), 另外追踪系统在 Framework设有 Java语言的跟踪系统 库 ( HwTrace lib ), 在 Native设有 C/C++语言的跟踪系统库 ( HwTrace lib ), 在内核层设有内 核语言的跟踪系统库 ( HwTrace lib )„ 基于图 5所示的改进后的安卓操作系统, 本申请实施例以下将结合附图和应用场景, 对 本申请实施例提供的日志信息生成方法进行详细介绍。 以下实施例均可以在具有上述硬件结 构的电子设备 100实现。 As shown in FIG. 5, the embodiment of the present application improves the existing communication mechanism. The improved modules mainly involve the message (message java) of the Framework layer, the cross-process communication library (Binder lib) of the Native layer and the message and Kernel layer. In addition, the tracking system has a Java language tracking system library (HwTrace lib) in Framework, a C/C++ language tracking system library (HwTrace lib) in Native, and a tracking system library (HwTrace lib) in the kernel layer. Kernel language tracking system library (HwTrace lib). Based on the improved Android operating system shown in Figure 5, the following embodiments of the application will combine the accompanying drawings and application scenarios to introduce the log information generation method provided by the embodiments of the application in detail The following embodiments can all be implemented in the electronic device 100 having the above hardware structure.
参见图 6, 示例性的示出了本申请实施例提供的一种日志信息生成方法的流程, 该方法 由电子设备执行。 Referring to FIG. 6, the flow of a method for generating log information provided by an embodiment of the present application is exemplarily shown, and the method is executed by an electronic device.
步骤 301 , 电子设备接收用户的第一操作, 响应于第一操作, 电子设备生成与该业务对 应的唯一的追踪标识, 并且在业务的整个调用链路中传递该追踪标识。 Step 301: The electronic device receives the user's first operation, and in response to the first operation, the electronic device generates a unique tracking identifier corresponding to the service, and transmits the tracking identifier in the entire invocation link of the service.
其中,第一操作可以是触摸操作,也可以语音指令等,整个调用链路包括至少一个进程, 该至少一个进程包括至少一个线程。 当调用链路包括两个以上进程时, 则该调用链路中会包 括跨进程调用和跨线程调用。 Wherein, the first operation may be a touch operation, or a voice command, etc. The entire call link includes at least one process, and the at least one process includes at least one thread. When the call link includes more than two processes, then the call link includes cross-process calls and cross-thread calls.
步骤 302, 电子设备将所述追踪标识存储到所述调用链路的每个进程的每个线程的调用 记录中, 生成包括所述追踪标识的日志信息。 Step 302: The electronic device stores the tracking identifier in the call record of each thread of each process of the call link, and generates log information including the tracking identifier.
例如, 日志输出格式包括时间戳、 进程 ID、 线程 ID、 级别、 追踪标识和内容, 最终输出 的日志的每一条信息均包括追踪标识。 For example, the log output format includes timestamp, process ID, thread ID, level, trace ID and content, and each piece of information in the final output log includes a trace ID.
举例来说, 当手机检测到用户在相机应用中的拍照控件上的触摸操作时, 则对该触摸操 作作出响应, 即在与该控件所对应的拍照业务的入口添加一个唯一的的追踪标识, 然后该追 踪标识会被向下传递到框架层和驱动层, 最终可以生成与该追踪标识对应的日志信息。 因调 用链路可能涉及不同层、 不同的通信机制, 为了实现追踪标识可以准确地向下传递, 电子设 备生成与业务对应的唯一的追踪标识之后, 将追踪标识写入到在业务入口对应的第一线程的 上下文中, 然后通过通信消息将该追踪标识从第一线程传递到第二线程, 并将该追踪标识写 入到第二线程的上下文中。 若第二线程不是调用链路的最后一个线程, 则重复执行通过通信 消息将所述追踪标识从第二线程传递到第三线程,并将追踪标识写入到第三线程的上下文中, 直至调用链路的最后一个线程。 需要说明的是, 第一线程、 第二线程、 第三线程可以是同一 进程的线程, 也可以是不同进程的线程, 调用链路可能涉及到不同的通信方式。 步骤 303, 可选地, 电子设备根据该日志信息中的线程的调用时间戳、 调用服务名和和 其他线程的调用关系, 生成导致该调用链路发生异常的报告。 For example, when the mobile phone detects the user's touch operation on the camera control in the camera application, it responds to the touch operation, that is, adds a unique tracking identifier to the entrance of the camera service corresponding to the control, Then the tracking identifier will be passed down to the framework layer and the driver layer, and finally log information corresponding to the tracking identifier can be generated. Since the call link may involve different layers and different communication mechanisms, in order to realize that the tracking identification can be accurately transmitted downwards, after the electronic device generates a unique tracking identification corresponding to the business, it writes the tracking identification to the first corresponding to the business entry. In the context of a thread, the tracking identifier is then transferred from the first thread to the second thread through a communication message, and the tracking identifier is written into the context of the second thread. If the second thread is not the last thread of the call link, repeat the communication message to transfer the trace identifier from the second thread to the third thread, and write the trace identifier into the context of the third thread until the call The last thread of the link. It should be noted that the first thread, the second thread, and the third thread may be threads of the same process or threads of different processes, and the call link may involve different communication methods. Step 303: Optionally, the electronic device generates a report that causes an abnormality in the call link according to the call timestamp of the thread, the call service name, and the call relationship with other threads in the log information.
具体地, 电子设备根据调用时间戳计算所述调用链路中的各个线程的调用耗时, 然后根 据所述调用耗时、调用关系和调用服务器名,生成导致所述调用链路发生异常的报告。比如, 一旦某个线程的耗时较长, 则会生成该线程导致超时的报告。 Specifically, the electronic device calculates the calling time of each thread in the calling link according to the calling timestamp, and then generates a report that causes the calling link to be abnormal according to the calling time, calling relationship, and calling server name . For example, once a thread takes a long time, a report that the thread caused a timeout will be generated.
可见, 本申请实施例可以实现一个业务的调用链路携带有唯一的一个追踪标识, 这样开 发人员就可以通过调取与该追踪标识对应的日志信息, 可以快速地定位出耗时较长的线程, 从而定位出故障出现的原因。 需要说明的是, 上述通过追踪标识追踪调用链路的方式不仅限 于生成日志信息, 也可以用于与业务相关的其它输出信息的生成, 例如生成包括追踪标识的 业务信息。 It can be seen that the embodiment of the application can realize that the calling link of a service carries a unique tracking identifier, so that the developer can quickly locate the time-consuming thread by calling the log information corresponding to the tracking identifier. , So as to locate the cause of the fault. It should be noted that the above-mentioned method of tracing the calling link through the tracking identifier is not limited to generating log information, and can also be used to generate other output information related to the business, for example, generating business information including the tracking identifier.
针对不同的通信方式, 本申请实施例提供追踪标识具体的传递方式, 需要说明的是, 下 文将以 TracelD指代追踪标识, 该追踪标识可以是根据电子设备的标识和用户的操作实际时 间生成的, 电子设备的标识可以是处理器的标识。 For different communication methods, the embodiments of this application provide specific delivery methods for the tracking identifier. It should be noted that TracelD will be used below to refer to the tracking identifier, which may be generated based on the identifier of the electronic device and the actual time of the user’s operation. The identification of the electronic device may be the identification of the processor.
首先, 本申请实施例对安卓系统所包括的主要通信方式、 应用场景、 实体、 TracelD传递 方式, 以及线程的上下文设置和清除情况列举如表 1所示。 First of all, the main communication methods, application scenarios, entities, TraceID transfer methods included in the Android system, as well as thread context setting and clearing conditions in the embodiment of the application are listed in Table 1.
表 1 Table 1
Figure imgf000010_0001
具体来说, 针对表 1中的通信方式一和通信方式二
Figure imgf000010_0001
Specifically, for communication mode one and communication mode two in Table 1,
一次完整的 Binder通信过程如图 7所示, 在图 7中包括如下步骤: A complete Binder communication process is shown in Figure 7. Figure 7 includes the following steps:
步骤 1, 进程 1通过命令字 BC_Transaction将通信数据发送到 Binder驱动。 步骤 2, Binder驱动通过命令字 BR_Transaction将通信数据转发给进程 2去处理。 Step 1. Process 1 sends the communication data to the Binder driver through the command word BC_Transaction. Step 2. The Binder driver forwards the communication data to process 2 for processing through the command word BR_Transaction.
步骤 3, 进程 2通过命令字 BC_REPLY的命令将返回结果传回 Binder驱动。 Step 3. Process 2 sends the returned result back to the Binder driver through the command word BC_REPLY.
步骤 4, Binder驱动再通过命令字 BR_REPLY将返回结果转发给进程: L Step 4. The Binder driver forwards the returned result to the process through the command word BR_REPLY: L
针对通信方式一, 在 binder通信过程中传递 TracelD的基本方式是: ( 1)、 进程 1发送数 据时将 TmcelD写入进程的上下文; (2)、 进程 2接收数据时, 先保存当前线程的上下文, 然 后从上下文获取 TracelD, 并将该 TracelD写入自身进程的上下文; 处理结束后恢复至当前进 程的上下文。 For communication method 1, the basic method of transferring TracelD during binder communication is: (1) When process 1 sends data, write TmcelD into the context of the process; (2) when process 2 receives data, first save the context of the current thread Then, it obtains TracelD from the context, and writes the TracelD into the context of its own process; after the processing ends, it returns to the context of the current process.
可选地, 第一种实现方式: binder的 lib层、 driver配合完成传递和清除 Optionally, the first implementation mode: the lib layer of the binder and the driver cooperate to complete the transfer and removal
具体地, 在 binder的 lib层数据结构、 driver层数据结构中增加 TracelD字段, 其中数据 结构包括 binder_transaction_data、 binder_transaction Specifically, the TraceID field is added to the lib layer data structure and the driver layer data structure of the binder, where the data structure includes binder_transaction_data, binder_transaction
1、在 binder的 lib处理流程中传递: BC_TRANSACTION/BC_REPLY用于实现从线程上 下文中获取 TracelD, 写入 binder_transaction_data中。 BR_TRANS ACTION, 用于实现先保存 当前线程上下文, 然后将 binder_transaction_data中的 TracelD设置到线程的上下文中; 处理 结束后恢复线程的上下文。 1. Pass in the binder lib processing flow: BC_TRANSACTION/BC_REPLY is used to obtain TracelD from the thread context and write it into binder_transaction_data. BR_TRANS ACTION is used to save the current thread context first, and then set the TracelD in binder_transaction_data to the thread context; after processing, the thread context is restored.
2、 在 binder的 driver处理流程中传递 2. Pass in the driver processing process of binder
BC_TRANSACTION/BC_REPLY/BC_TRANSACTION_SG/BC_REPLY_SG, 用于实现将 lib层 binder_transaction_data中的 TracelD , 保存到 driver层 binder_transaction中。 BC_TRANSACTION/BC_REPLY/BC_TRANSACTION_SG/BC_REPLY_SG, used to realize the TracelD in the lib layer binder_transaction_data, save it in the driver layer binder_transaction.
BR_TRANSACTION/BR_REPLY, 用于实现将 driver层 binder_transaction中的 TracelD, 保存到 lib层 binder_transaction_data中。 BR_TRANSACTION/BR_REPLY is used to save TraceID in the binder_transaction of the driver layer to binder_transaction_data in the lib layer.
可选地, 第二种实现方式: 在 driver完成传递和清除 Optionally, the second way to implement: complete transfer and clearing in the driver
在 binder的 driver层数据结构 binder_transaction中增加 TracelD字段。 Add the TracelD field to the binder_transaction data structure of the driver layer of the binder.
在 binder的 driver处理流程中传递: Pass in the driver processing flow of binder:
BC_TRANSACTION/BC_REPLY/BC_TRANSACTION_SG/BC_REPLY_SG, 用于实现从 系统调用对应的线程上下文中获取 TracelD, 保存到 binder_transaction中。 BC_TRANSACTION/BC_REPLY/BC_TRANSACTION_SG/BC_REPLY_SG are used to obtain TraceID from the thread context corresponding to the system call and save it in binder_transaction.
BR_TRANSACTION/BR_REPLY, 用于实现将 binder_transaction中的 TracelD,设置到系 统调用对应的线程上下文中。 BR_TRANSACTION/BR_REPLY is used to set TraceID in binder_transaction to the thread context corresponding to the system call.
在 binder的 driver处理流程中清除线程上下文信息: Clear thread context information in the driver processing flow of binder:
BR_TRANSACTION_COMPLETE,用于清除系统调用对应的线程上下文中的 TracelD(其 中, oneway不清除 X BR_TRANSACTION_COMPLETE, used to clear the TraceID in the thread context corresponding to the system call (among which, oneway does not clear X
需要说明的是, 由于第二种实现方式需要支持内核态访问线程上下文的 TracelD和传递 时如果对方进程没有关联 TracelD 空间, 需要内核分配和关联, 但是第二种实现方式无法实 现内核分配和关联, 因此可优选第一种实现方式。 针对通信方式二, 追踪标识的传递方式同 通信方式一。 It should be noted that, because the second implementation method needs to support TracelD that accesses the thread context in the kernel mode and transfer, if the other process is not associated with the TracelD space, kernel allocation and association are required, but the second implementation method cannot achieve kernel allocation and association. Therefore, the first implementation can be preferred. For the second communication method, the transmission method of the tracking mark is the same as the first communication method.
针对表 1的通信方式三 Communication mode 3 for Table 1
Handle(句柄)通信基于生产者-消费者模式, 在 handle通信过程中传递 TracelD的基本 方式是: 消息发送前: 将线程上下文中数据写入 message中; 消息处理前: 将 message中数 据设置到线程上下文中; 消息处理后: 清除线程上下文 Handle communication is based on the producer-consumer model. The basic way to pass TracelD in the handle communication process is: before message sending: write the data in the thread context into the message; before message processing: set the data in the message to the thread In context; after message processing: clear thread context
其中, handle通信需要在 Java、 C层进行处理: Among them, handle communication needs to be processed in Java and C layer:
对于 Java层, 如图 8, 第一步, 在消息类 Message中增加 TracelD字段。 第二步, 消息 被发送到队列 ( MessageQueue) 时, 将线程上下文 TracelD写入 msg消息中。 第三步, 消息 处理 dispatchHandler入口, 将消息中 TracelD写入线程上下文。 第四步, 消 息 处 理 enqueuepost出口, 清除线程上下文 TracelD。 For the Java layer, as shown in Figure 8, the first step is to add a TracelD field to the message class. In the second step, when the message is sent to the queue (MessageQueue), the thread context TracelD is written into the msg message. The third step, news Process the dispatchHandler entry and write TracelD in the message to the thread context. The fourth step, message processing enqueuepost exit, clear thread context TracelD.
对于 C层, 第一步, 在结构 struct MessageEnvelope中增加 TracelD字段; 第二步, 消息 发送 Looper::sendMessageAtTime中, 将线程上下文 TracelD写入 messageEnvelope消息中。 第三步,消息处理 handler->handleMessage(message)之前,将消息中 TracelD写入线程上下文。 第四步, 消息处理 handler- >handleMessage(mes sage)之后, 清除线程上下文 TracelD。 For the C layer, in the first step, the TraceID field is added to the structure struct MessageEnvelope; in the second step, in the message sending Looper::sendMessageAtTime, the thread context TraceID is written into the messageEnvelope message. The third step, before the message processing handler->handleMessage (message), write TraceID in the message into the thread context. In the fourth step, after the message processing handler->handleMessage (message), the thread context TraceID is cleared.
针对表 1中的通信方式四 For communication method four in Table 1
在 socket通信过程中传递 TracelD的基本方式是: 消息发送前: 将线程的上下文中的数 据写入 socket发送消息中; 消息处理前: 将 socket message中数据设置到线程的上下文中; 消息处理后: 清除线程的上下文。 The basic way to pass TracelD in the socket communication process is: before message sending: write the data in the thread context into the socket sending message; before message processing: set the data in the socket message to the thread context; after message processing: Clear the context of the thread.
需要说明的是, TracelD传递过程中可能涉及各种调用, 例如 B inder 同步调用、 B inder 同步调用, callee处理中嵌套 Hwbinder同步调用、 Binder异步调用、 Binder同步调用, Callee 处理中嵌套 msg异步处理。 It should be noted that various calls may be involved in the process of TracelD transmission, such as B inder synchronous call, B inder synchronous call, Hwbinder synchronous call, Binder asynchronous call, Binder synchronous call in callee processing, and msg asynchronous call in Callee processing. deal with.
本申请如下实施例中进一步结合图 9所示的进程同步调用的流程对上述日志信息生成方 法的具体过程进行详细阐述, 该方法流程的具体流程可以包括: In the following embodiments of the present application, the specific process of the log information generation method is further described in detail in conjunction with the process synchronization invocation process shown in FIG. 9. The specific process of the method process may include:
步骤 a,应用的某个业务流程中启动调用链跟踪,根据 CPUID、时间戳组合生成 TracelD, 设置到线程的上下文(tls) 中。 Step a: Start call chain tracking in a certain business process of the application, generate TraceID according to the combination of CPUID and timestamp, and set it in the thread context (tls).
步骤 b, 流程中进程通过命令字 binder transact同步调用其它进程。 In step b, the process in the process synchronously calls other processes through the command word binder transact.
步骤 c, 进程发送侧从线程上下文中获取当前 TracelD, 并将 TracelD写到上下文中。 步骤 d, 在 binder消息 BC_TRANSACTION/BR_TRANSATION传递中携带 TracelD。 步骤 e, 系统服务的线程 1 (也就是 Binder接收侧), 从数据结构中获取 TracelD, 并将 传递过来的 TracelD设置到当前线程上下文中, 通过命令字 binder onTransact进行处理。 Step c: The process sending side obtains the current TraceID from the thread context, and writes the TraceID into the context. Step d, carry TraceID in the BC_TRANSACTION/BR_TRANSATION transfer of the binder message. Step e: Thread 1 of the system service (that is, the Binder receiving side) obtains TraceID from the data structure, and sets the passed TraceID to the current thread context, and processes it through the command word binder onTransact.
步骤 f, 系统服务的线程 1通过命令字 BC_REPLY返回结果, 然后清除线程上下文中的 TracelD。 Step f, the thread 1 serviced by the system returns the result through the command word BC_REPLY, and then clears TraceID in the thread context.
步骤 g, App侧继续处理, 直到结束 Trace调用链跟踪, 清除线程上下文中的 TracelD。 综上可见,本申请实施例可以实现在 Android通信机制( binder、 hwbinder、 message、 socket、 syscall等)中传递 TracelD, 并且可以基于线程的上下文技术实现高性能访问, 也就是流程处 理中将 TracelD保存到线程上下文,相关输出信息可以从线程上下文中获取并保存到内容中。 因此, 本申请实施例可以实现将 TracelD在调用链路中传递。 In step g, the App side continues processing until the Trace call chain tracing ends, and the TraceID in the thread context is cleared. In summary, the embodiment of the application can realize the transfer of TracelD in the Android communication mechanism (binder, hwbinder, message, socket, syscall, etc.), and can realize high-performance access based on thread context technology, that is, save TracelD in process processing To the thread context, the relevant output information can be obtained from the thread context and saved in the content. Therefore, the embodiment of the present application can realize the transmission of TraceID in the call link.
进一步地, 当追踪标识在调用链路中完成传递之后, 电子设备从各个线程的上下文中获 取追踪标识, 并将追踪标识转换为字符串, 写入到打印信息中, 生成日志信息, 另外电子设 备从中筛选包括该追踪标识对应的日志信息。 Further, after the tracking identifier is transferred in the call link, the electronic device obtains the tracking identifier from the context of each thread, converts the tracking identifier into a character string, writes it into the print information, and generates log information. In addition, the electronic device The log information corresponding to the tracking identifier is filtered out.
具体地, 针对流水日志, 为了实现通过追踪标识获取与所述追踪标识对应的日志信息, 需要先将流水日志与追踪系统实现关联, 关联方式是: 在用户态日志打印接口中, 判断当前 线程上下文中 TracelD是否有效、是否设置用户态日志关联开关, 若是, 则将 TracelD转换为 字符串,插入打印信息中。其中, 流水日志主要是底层统一进行修改,这样对性能影响较小。 当前流水日志底层是通过 socket写入 logd, 采用了向量写 writev接口 (多个 buffer), 因此写 时在信息字符串 buffer前增加一个 TracelD字符串 buffer,这样在接收侧 socket就自动拼接起 来了。 针对内核日志, 为了实现通过追踪标识获取与所述追踪标识对应的日志信息, 也需要先 将内核日志与追踪系统实现关联, 关联方式是: 在内核态打印接口中, 判断当前处于系统调 用上下文 (非中断上下文)、 当前线程上下文中 TracelD是否有效、 是否设置内核态日志关联 开关, 若是, 则将 TracelD转换为字符串, 插入打印信息中。 其中, 内核态日志在底层接口 统一修改, 主要是涉及 printk函数的修改。 Specifically, for the flow log, in order to obtain the log information corresponding to the tracking mark through the tracking mark, it is necessary to first associate the flow log with the tracking system. The correlation method is: in the user mode log printing interface, determine the current thread context Whether TracelD is valid in the middle, whether to set the user mode log associated switch, if so, convert TracelD into a string and insert it into the print information. Among them, the flow log is mainly modified at the bottom level, which has less impact on performance. The bottom layer of the current log is written to logd through sockets, using the vector write writev interface (multiple buffers), so when writing, a TracelD string buffer is added before the message string buffer, so that the socket on the receiving side is automatically spliced. Regarding the kernel log, in order to obtain the log information corresponding to the tracking identifier through the tracking identifier, it is also necessary to associate the kernel log with the tracking system first. The correlation method is: in the kernel mode printing interface, it is determined that the current system call context ( Non-interrupting context), whether TracelD in the current thread context is valid, whether to set the kernel state log correlation switch, if so, convert TracelD into a string and insert it into the print information. Among them, the kernel mode log is uniformly modified in the underlying interface, mainly involving the modification of the printk function.
针对性能追踪日志 ( systrace ), systrace从线程上下文获取 TracelD , 并通过 TracelD将整 个业务流程的 systrace 串联起来。 为了实现通过追踪标识获取与所述追踪标识对应的日志信 息, 需要先将 systrace与追踪系统实现关联, 关联方式是: 在用户态 systrace打印中, 判断当 前线程上下文中 TracelD是否有效、 是否设置 systrace关联开关, 若是, 则将 TracelD参数按 照 systrace格式规范增加到输出内容中。 其中, systrace输出尽量在底层统一修改, 同时考虑 效 率 。 当 前 systarce 输 出 在 在 底 层 是 通 过 多 个 atrace 接 口 写 入 /sys/kernel/debug/tracing/trace_marker接口, 采用了 WRITE_MSG宏接口转换参数为字符串, 因此输出时按照 systrace要求格式, 将 TracelD作为增加的 args参数, 插入字符串尾部。 For the performance trace log (systrace), systrace obtains TracelD from the thread context, and connects the systrace of the entire business process through TracelD. In order to obtain the log information corresponding to the tracking identifier through the tracking identifier, it is necessary to first associate systrace with the tracking system. The association method is: In user mode systrace printing, determine whether TracelD is valid in the current thread context and whether to set systrace association Switch, if yes, add TracelD parameters to the output content according to the systrace format specification. Among them, the systrace output is modified as far as possible in the bottom layer, while considering the efficiency. The current systarce output is written to the /sys/kernel/debug/tracing/trace_marker interface at the bottom layer through multiple atrace interfaces, and the WRITE_MSG macro interface is used to convert the parameters to strings. Therefore, the output is in accordance with the format required by systrace, and TracelD is added as an addition The args parameter is inserted at the end of the string.
可见, 采用本申请实施例提供的调用链路追踪技术, 可解决业务流程中日志输出信息关 联的问题。 如图 10所示, 黑色阴影对应的标识为 TraceID93921d2463 , 电子设备通过搜索该 TracelD可以自动标识出一个完整业务流程的日志输出信息, 即通过该 TracelD可以自动将一 个跨进程、 跨线程、 多层次的业务处理流程的输出信息过滤和提取出来。 降低对开发人员的 能力依赖, 提升故障分析效率, 快速进行故障定位。 It can be seen that the use of the call link tracking technology provided by the embodiment of the present application can solve the problem of log output information correlation in the business process. As shown in Figure 10, the black shadow corresponds to TraceID93921d2463. The electronic device can automatically identify the log output information of a complete business process by searching for the TracelD, that is, through the TracelD, a cross-process, cross-thread, and multi-level The output information of the business process is filtered and extracted. Reduce the ability to rely on developers, improve the efficiency of fault analysis, and quickly locate faults.
另夕卜, 采用本申请实施例提供的调用链路追踪技术, 可解决业务流程中 systrace输出信 息关联的问题。 如图 11a 中, UI Thread 线程 binder调用 transact[35]增加 Args 参数标识 “3fOfcalal3”, 与图 lib中 Binder: 1060_4线程的 Args参数相同, 直接明确了跨进程的 binder 调用关系。 即可以通过 TracelD确定 UI Thread线程 binder调用主要耗时是因为被调用进程 的阻塞。 本申请实施例还提供一种日志信息生成方法及装置, 如图 12所示, 该装置包括接收模块 1201和处理模块 1202。 In addition, using the call link tracking technology provided by the embodiments of the present application can solve the problem of systrace output information correlation in the business process. In Figure 11a, the UI Thread thread binder calls transact[35] to increase the Args parameter identifier "3fOfcalal3", which is the same as the Args parameter of the Binder: 1060_4 thread in Figure lib, which directly clarifies the cross-process binder calling relationship. That is, it can be determined through TracelD that the main time-consuming call of the UI Thread thread binder is due to the blocking of the called process. The embodiment of the present application also provides a method and device for generating log information. As shown in FIG. 12, the device includes a receiving module 1201 and a processing module 1202.
其中,在一种可能的实施例中,接收模块 1201, 用于接收用户的第一操作。 图 6至图 lib 方法实施例涉及的相关内容均可以援引到该接收模块 1101的功能描述, 在此不再赘述。 Wherein, in a possible embodiment, the receiving module 1201 is configured to receive the first operation of the user. The relevant content involved in the method embodiments in Figure 6 to Figure lib can all be quoted from the functional description of the receiving module 1101, which will not be repeated here.
处理模块 1202, 用于响应于所述第一操作, 在业务启动入口添力 P与所述业务对应的唯一 的追踪标识, 并且在所述业务的整个调用链路中传递所述追踪标识, 其中所述整个调用链路 包括至少一个进程, 所述至少一个进程包括至少一个线程; 并将所述追踪标识存储到所述调 用链路的每个进程的每个线程的调用记录中, 生成包括所述追踪标识的日志信息。 图 6至图 lib方法实施例涉及的相关内容均可以援引到该处理模块 1202的功能描述, 在此不再赘述。 The processing module 1202 is configured to, in response to the first operation, add a unique tracking identifier corresponding to the service at the service start entry, and transfer the tracking identifier in the entire invocation link of the service, where The entire call link includes at least one process, and the at least one process includes at least one thread; and the trace identifier is stored in the call record of each thread of each process of the call link to generate Describe the log information of the tracking mark. The related content involved in the method embodiments of Figure 6 to Figure lib can all be quoted from the functional description of the processing module 1202, which will not be repeated here.
需要说明的是, 该电子设备的应用图标的切换装置具有实现上述方法设计中的电子设备 的功能。 这些单元模块可以通过终端中的硬件实现, 也可以通过终端中的硬件执行相应的软 件实现, 本申请实施例对此并不作限定。 It should be noted that the switching device of the application icon of the electronic device has the function of realizing the electronic device in the above method design. These unit modules can be implemented by hardware in the terminal, or can be implemented by hardware in the terminal executing corresponding software, which is not limited in the embodiment of the present application.
可见, 本申请实施例可以生成包括所述追踪标识的日志信息, 便于开发人员提取与问题 相关的信息, 减轻对开发人员的能力要求, 提高问题解决效率。 It can be seen that the embodiment of the present application can generate log information including the tracking identifier, which is convenient for developers to extract information related to problems, reduces the ability requirements for developers, and improves problem solving efficiency.
本申请实施例中还提供一种计算机可读存储介质, 所述计算机可读存储介质包括计算机 程序, 当计算机程序在电子设备上运行时, 使得所述电子设备执行上述信息处理方法任意一 种可能的实现。 An embodiment of the present application also provides a computer-readable storage medium. The computer-readable storage medium includes a computer program. When the computer program runs on an electronic device, the electronic device executes any one of the aforementioned information processing methods. A possible realization.
本申请实施例还提供一种计算机程序产品,当所述计算机程序产品在电子设备上运行时, 使得所述电子设备执行上述信息处理方法任意一种可能的实现。 The embodiments of the present application also provide a computer program product, which when the computer program product runs on an electronic device, causes the electronic device to execute any one possible implementation of the foregoing information processing method.
在本申请的另一些实施例中, 本申请实施例公开了一种电子设备, 如图 13所示, 该电子 设备可以包括: 处理器 1301 ; 存储器 1302; 以及一个或多个计算机程序 1303 , 上述各器件 可以通过一个或多个通信总线 1304连接。 In other embodiments of the present application, the embodiments of the present application disclose an electronic device. As shown in FIG. 13, the electronic device may include: a processor 1301; a memory 1302; and one or more computer programs 1303, as described above Each device can be connected through one or more communication buses 1304.
其中该一个或多个计算机程序 1303 被存储在上述存储器 1302 中并被配置为被处理器 1301调用执行, 该一个或多个计算机程序 1303包括指令, 上述指令可以用于执行如图 6至 图 lib相应实施例中的各个步骤。 The one or more computer programs 1303 are stored in the above-mentioned memory 1302 and are configured to be invoked and executed by the processor 1301, and the one or more computer programs 1303 include instructions, and the above-mentioned instructions can be used for execution as shown in FIG. 6 to FIG. Each step in the corresponding embodiment.
通过以上的实施方式的描述, 所属领域的技术人员可以清楚地了解到, 为描述的方便和 筒洁, 仅以上述各功能模块的划分进行举例说明, 实际应用中, 可以根据需要而将上述功能 分配由不同的功能模块完成, 即将装置的内部结构划分成不同的功能模块, 以完成以上描述 的全部或者部分功能。 上述描述的系统, 装置和单元的具体工作过程, 可以参考前述方法实 施例中的对应过程, 在此不再赘述。 Through the description of the above embodiments, those skilled in the art can clearly understand that for the convenience and clarity of the description, only the division of the above-mentioned functional modules is used as an example for illustration. In actual applications, the above-mentioned functions can be changed as required. The allocation is completed by different functional modules, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above. For the specific working process of the above-described system, device, and unit, reference may be made to the corresponding process in the foregoing method embodiment, which is not repeated here.
在本申请实施例各个实施例中的各功能单元可以集成在一个处理单元中, 也可以是各个 单元单独物理存在, 也可以两个或两个以上单元集成在一个单元中。 上述集成的单元既可以 采用硬件的形式实现, 也可以采用软件功能单元的形式实现。 The functional units in the various embodiments of the embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units may be integrated into one unit. The above-mentioned integrated unit can be realized in the form of hardware or software functional unit.
所述集成的单元如果以软件功能单元的形式实现并作为独立的产品销售或使用时, 可以 存储在一个计算机可读取存储介质中。 基于这样的理解, 本申请实施例的技术方案本质上或 者说对现有技术做出贡献的部分或者该技术方案的全部或部分可以以软件产品的形式体现出 来, 该计算机软件产品存储在一个存储介质中, 包括若千指令用以使得一台计算机设备(可 以是个人计算机, 服务器, 或者网络设备等)或处理器执行本申请各个实施例所述方法的全 部或部分步骤。 而前述的存储介质包括: 快闪存储器、 移动硬盘、 只读存储器、 随机存取存 储器、 磁碟或者光盘等各种可以存储程序代码的介质。 If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer readable storage medium. Based on this understanding, the technical solutions of the embodiments of the present application essentially or the part that contributes to the prior art, or all or part of the technical solutions can be embodied in the form of software products, and the computer software products are stored in a storage The medium includes several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) or a processor to execute all or part of the steps of the methods described in the various embodiments of the present application. The aforementioned storage media include: flash memory, mobile hard disk, read-only memory, random access memory, magnetic disk or optical disk and other media that can store program codes.
以上所述, 仅为本申请实施例的具体实施方式, 但本申请实施例的保护范围并不局限于此, 任何在本申请实施例揭露的技术范围内的变化或替换, 都应涵盖在本申请实施例的保护范围 之内。 因此, 本申请实施例的保护范围应以所述权利要求的保护范围为准。 The above are only specific implementations of the embodiments of the present application, but the protection scope of the embodiments of the present application is not limited thereto. Any changes or substitutions within the technical scope disclosed in the embodiments of the present application shall be covered in this application. Within the protection scope of the application embodiments. Therefore, the protection scope of the embodiments of the present application should be subject to the protection scope of the claims.

Claims

权 利 要 求 书 Claims
1、 一种日志信息生成方法, 应用于电子设备, 其特征在于, 所述方法包括: 1. A method for generating log information applied to an electronic device, characterized in that the method includes:
接收用户的第一操作; Receive the user's first operation;
响应于所述第一操作, 生成与业务对应的唯一的追踪标识, 并且在所述业务的整个调用 链路中传递所述追踪标识, 其中所述整个调用链路包括用于执行所述业务的至少一个进程, 所述至少一个进程包括至少一个线程; In response to the first operation, a unique tracking identifier corresponding to the service is generated, and the tracking identifier is transmitted in the entire invocation link of the service, where the entire invocation link includes the information used to execute the service At least one process, where the at least one process includes at least one thread;
将所述追踪标识存储到所述调用链路的每个进程的每个线程的调用记录中, 生成包括所 述追踪标识的日志信息。 The tracking identifier is stored in the call record of each thread of each process of the call link, and log information including the tracking identifier is generated.
2、 如权利要求 1所述的方法, 其特征在于, 将所述追踪标识存储到所述调用链路的每个 进程的每个线程的调用记录中, 包括: 2. The method according to claim 1, wherein storing the tracking identifier in the call record of each thread of each process of the call link comprises:
将所述追踪标识转换得到的字符串存储到所述调用链路的每个进程的每个线程的调用记 录中, 生成包括所述追踪标识的日志信息。 The character string obtained by the conversion of the tracking identifier is stored in the call record of each thread of each process of the call link, and log information including the tracking identifier is generated.
3、根据权利要求 2所述的方法, 其特征在于, 所述电子设备生成与所述业务对应的唯一 的追踪标识, 并且在整个调用链路中传递所述追踪标识, 包括: 3. The method according to claim 2, wherein the electronic device generates a unique tracking identifier corresponding to the service, and transmitting the tracking identifier in the entire invocation link, comprising:
生成与所述业务对应的唯一的追踪标识, 并将所述追踪标识写入到所述业务启动入口对 应的第一线程的上下文中; Generating a unique tracking identifier corresponding to the service, and writing the tracking identifier into the context of the first thread corresponding to the service start entry;
通过通信消息将所述追踪标识从所述第一线程传递到第二线程, 并将所述追踪标识写入 到所述第二线程的上下文中; Transfer the tracking identifier from the first thread to the second thread through a communication message, and write the tracking identifier into the context of the second thread;
若所述第二线程不是所述调用链路的最后一个线程, 则重复执行通过通信消息将所述追 踪标识从所述第二线程传递到第三线程,并将所述追踪标识写入到所述第三线程的上下文中, 直至将所述追踪标识写入到所述调用链路的最后一个线程的上下文中为止。 If the second thread is not the last thread of the call link, repeat the execution of transferring the trace identifier from the second thread to the third thread through a communication message, and write the trace identifier to all threads. In the context of the third thread, until the tracking identifier is written into the context of the last thread of the call link.
4、根据权利要求 2或 3所述的方法, 其特征在于, 所述电子设备将所述追踪标识转换得 到的字符串存储到所述调用链路的每个进程的调用记录中, 生成包括所述追踪标识的日志信 息, 包括: 4. The method according to claim 2 or 3, wherein the electronic device stores the character string converted from the tracking identifier in the call record of each process of the call link, and generates The log information of the tracking mark includes:
从所述调用链路的各个线程的上下文中获取所述追踪标识; Acquiring the tracking identifier from the context of each thread of the call link;
将所述追踪标识转换得到的字符串写入到所述调用链路的每个进程中的每个线程的调用 记录中, 生成包括所述追踪标识的日志信息。 The character string obtained by the conversion of the tracking identifier is written into the call record of each thread in each process of the call link, and log information including the tracking identifier is generated.
5、 根据权利要求 4所述的方法, 其特征在于, 所述日志信息包括流水日志、 内核日志和 性能追踪日志中的至少一种。 5. The method according to claim 4, wherein the log information includes at least one of a running log, a kernel log, and a performance tracking log.
6、根据权利要求 1至 5任一项所述的方法, 其特征在于, 所述日志信息包括线程的调用 时间戳、 调用服务名、 和其他线程的调用关系; 6. The method according to any one of claims 1 to 5, wherein the log information includes the call timestamp of the thread, the call service name, and the call relationship of other threads;
所述方法还包括: The method also includes:
根据所述调用时间戳计算所述调用链路中的各个线程的调用耗时; Calculating the calling time of each thread in the calling link according to the calling timestamp;
根据所述调用耗时、调用关系和调用服务器名,生成导致所述调用链路发生异常的报告。 According to the calling time, the calling relationship and the calling server name, a report that causes the abnormality of the calling link is generated.
7、根据权利要求 1至 6任一项所述的方法, 其特征在于, 所述追踪标识是根据所述电子 设备的标识和所述第一操作的发生时间生成的。 7. The method according to any one of claims 1 to 6, wherein the tracking identifier is generated based on the identifier of the electronic device and the occurrence time of the first operation.
8、 一种日志信息生成装置, 其特征在于, 所述装置包括: 8. A log information generating device, characterized in that the device includes:
接收模块, 用于接收用户的第一操作; A receiving module, configured to receive the first operation of the user;
处理模块, 用于响应于所述第一操作, 生成与业务对应的唯一的追踪标识, 并且在所述 业务的整个调用链路中传递所述追踪标识, 其中所述整个调用链路包括用于执行所述业务的 至少一个进程, 所述至少一个进程包括至少一个线程; The processing module is configured to generate a unique tracking identifier corresponding to the service in response to the first operation, and in the The tracking identifier is transferred in the entire invocation link of the service, where the entire invocation link includes at least one process for executing the service, and the at least one process includes at least one thread;
生成模块, 用于将所述追踪标识存储到所述调用链路的每个进程的每个线程的调用记录 中, 生成包括所述追踪标识的日志信息。 The generating module is configured to store the tracking identifier in the call record of each thread of each process of the call link, and generate log information including the tracking identifier.
9、 根据权利要求 8所述的装置, 其特征在于, 所述处理模块具体用于: 9. The device according to claim 8, wherein the processing module is specifically configured to:
将所述追踪标识转换得到的字符串存储到所述调用链路的每个进程的每个线程的调用记 录中, 生成包括所述追踪标识的日志信息。 The character string obtained by the conversion of the tracking identifier is stored in the call record of each thread of each process of the call link, and log information including the tracking identifier is generated.
10、 根据权利要求 9所述的装置, 其特征在于, 所述处理模块具体用于: 10. The device according to claim 9, wherein the processing module is specifically configured to:
生成与所述业务对应的唯一的追踪标识, 并将所述追踪标识写入到所述业务启动入口对 应的第一线程的上下文中; Generating a unique tracking identifier corresponding to the service, and writing the tracking identifier into the context of the first thread corresponding to the service start entry;
通过通信消息将所述追踪标识从所述第一线程的传递到第二线程, 并将所述追踪标识写 入到所述第二线程的上下文中; Transfer the tracking identifier from the first thread to the second thread through a communication message, and write the tracking identifier into the context of the second thread;
若所述第二线程不是所述调用链路的最后一个线程, 则重复执行通过通信消息将所述追 踪标识从所述第二线程传递到第三线程,并将所述追踪标识写入到所述第三线程的上下文中, 直至将所述追踪标识写入到所述调用链路的最后一个线程的上下文中为止。 If the second thread is not the last thread of the call link, repeat the execution of transferring the trace identifier from the second thread to the third thread through a communication message, and write the trace identifier to all threads. In the context of the third thread, until the tracking identifier is written into the context of the last thread of the call link.
11、 根据权利要求 9或 10所述的装置, 其特征在于, 所述生成模块具体用于: 从所述调用链路的各个线程的上下文中获取所述追踪标识; 11. The device according to claim 9 or 10, wherein the generating module is specifically configured to: obtain the tracking identifier from the context of each thread of the call link;
将所述追踪标识转换得到的字符串写入到所述调用链路的每个进程中的每个线程的调用 记录中, 生成包括所述追踪标识的日志信息。 The character string obtained by the conversion of the tracking identifier is written into the call record of each thread in each process of the call link, and log information including the tracking identifier is generated.
12、 根据权利要求 11所述的装置, 其特征在于, 所述日志信息包括流水日志、 内核日志 和性能追踪日志中的至少一种。 12. The device according to claim 11, wherein the log information includes at least one of a running log, a kernel log, and a performance tracking log.
13、根据权利要求 8至 12任一项所述的装置, 其特征在于, 所述日志信息包括线程的调 用时间戳、 调用服务名、 和其他线程的调用关系; 13. The device according to any one of claims 8 to 12, wherein the log information includes thread call timestamp, call service name, and call relationship of other threads;
所述装置还包括: The device also includes:
根据所述调用时间戳计算所述调用链路中的各个线程的调用耗时; Calculating the calling time of each thread in the calling link according to the calling timestamp;
根据所述调用耗时、调用关系和调用服务器名,生成导致所述调用链路发生异常的报告。 According to the calling time, the calling relationship and the calling server name, a report that causes the abnormality of the calling link is generated.
14、根据权利要求 9至 13任一项所述的装置, 其特征在于, 所述追踪标识是根据所述电 子设备的标识和所述第一操作的发生时间生成的。 14. The apparatus according to any one of claims 9 to 13, wherein the tracking identifier is generated based on the identifier of the electronic device and the occurrence time of the first operation.
15、 一种电子设备, 其特征在于, 包括一个或多个处理器和一个或多个存储器; 所述一个或多个存储器与所述一个或多个处理器接合, 所述一个或多个存储器用于存储 计算机程序代码, 所述计算机程序代码包括计算机指令, 当所述一个或多个处理器执行所述 计算机指令时, 所述电子设备执行如权利要求 1至 7任一项所述的日志信息生成方法。 15. An electronic device, comprising one or more processors and one or more memories; where the one or more memories are connected to the one or more processors, and the one or more memories Used to store computer program code, where the computer program code includes computer instructions, and when the one or more processors execute the computer instructions, the electronic device executes the log according to any one of claims 1 to 7 Information generation method.
16、一种计算机可读存储介质,其特征在于,所述计算机可读存储介质包括计算机程序, 当计算机程序在电子设备上运行时, 使得所述电子设备执行如权利要求 1至 7任一项所述的 日志信息生成方法。 16. A computer-readable storage medium, wherein the computer-readable storage medium includes a computer program, which when the computer program runs on an electronic device, causes the electronic device to execute any one of claims 1 to 7 The method for generating log information.
PCT/CN2020/076020 2019-02-28 2020-02-20 Log information generating method and apparatus, and electronic device WO2020173377A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201910151968.7 2019-02-28
CN201910151968.7A CN111625431B (en) 2019-02-28 2019-02-28 Log information generation method and device and electronic equipment

Publications (1)

Publication Number Publication Date
WO2020173377A1 true WO2020173377A1 (en) 2020-09-03

Family

ID=72239105

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2020/076020 WO2020173377A1 (en) 2019-02-28 2020-02-20 Log information generating method and apparatus, and electronic device

Country Status (2)

Country Link
CN (1) CN111625431B (en)
WO (1) WO2020173377A1 (en)

Cited By (16)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112134739A (en) * 2020-09-24 2020-12-25 平安科技(深圳)有限公司 Link state tracking method and device, electronic equipment and computer storage medium
CN112202608A (en) * 2020-09-28 2021-01-08 亚信科技(中国)有限公司 Log processing method and device, electronic equipment and computer readable storage medium
CN112256658A (en) * 2020-10-16 2021-01-22 海尔优家智能科技(北京)有限公司 Log record shunting method and device, storage medium and electronic device
CN112394939A (en) * 2020-10-30 2021-02-23 迅鳐成都科技有限公司 Automatic user contract deployment method and device based on alliance chain and storage medium
CN112463563A (en) * 2020-11-25 2021-03-09 银盛支付服务股份有限公司 Full link tracking method, computer equipment and storage medium
CN112702191A (en) * 2020-12-11 2021-04-23 福建天晴在线互动科技有限公司 Link tracking method and terminal
CN113064750A (en) * 2021-04-26 2021-07-02 山东英信计算机技术有限公司 Tracking method, device and medium for BIOS log information
CN114257502A (en) * 2020-09-21 2022-03-29 华为终端有限公司 Log reporting method and device
CN114339574A (en) * 2021-12-29 2022-04-12 锐迪科创微电子(北京)有限公司 Earphone operation method and device and electronic equipment
CN114629929A (en) * 2022-03-16 2022-06-14 北京奇艺世纪科技有限公司 Log recording method, device and system
CN114884807A (en) * 2022-05-20 2022-08-09 远景智能国际私人投资有限公司 Link log generation method and device, Internet of things platform and storage medium
CN115562913A (en) * 2022-04-21 2023-01-03 荣耀终端有限公司 Hardware state analysis method, device and system
CN116016646A (en) * 2022-11-07 2023-04-25 中国工商银行股份有限公司 Service access control method, device, equipment and medium
CN116225855A (en) * 2023-05-10 2023-06-06 荣耀终端有限公司 Log generation method, electronic equipment and storage medium
CN117290164A (en) * 2023-11-22 2023-12-26 荣耀终端有限公司 Information recording method at restarting, electronic device and readable storage medium
CN116016646B (en) * 2022-11-07 2024-05-28 中国工商银行股份有限公司 Service access control method, device, equipment and medium

Families Citing this family (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112286776A (en) * 2020-11-04 2021-01-29 中国电力财务有限公司 Method and system for tracking micro-service link
CN113301397A (en) * 2021-02-19 2021-08-24 阿里巴巴集团控股有限公司 CDN-based audio and video transmission, playing and delay detection method and device
CN115314542A (en) * 2021-04-21 2022-11-08 深圳联友科技有限公司 Link tracking method and system based on Socket communication protocol
CN115272399A (en) * 2021-04-30 2022-11-01 华为技术有限公司 Data tracking method and related device
CN113094166B (en) * 2021-05-10 2023-08-04 杭州网易云音乐科技有限公司 Link tracking method, device, medium and computing equipment
CN113849331B (en) * 2021-09-22 2023-09-29 网易(杭州)网络有限公司 Anomaly tracking method, system, device, equipment and medium of hybrid technology stack
CN114115746A (en) * 2021-12-02 2022-03-01 北京乐讯科技有限公司 Full link tracking device of user mode storage system
CN114745153B (en) * 2022-03-10 2024-02-27 北京汇元网科技股份有限公司 Link tracking method combining WCF and log4net
CN115294203A (en) * 2022-10-09 2022-11-04 智道网联科技(北京)有限公司 Log processing method, apparatus and computer-readable storage medium for electronic map
CN115629951B (en) * 2022-12-20 2023-03-28 北京蔚领时代科技有限公司 Task full-link tracking method, first node, link system and medium
CN116049115B (en) * 2023-01-13 2023-12-01 深圳安科百腾科技有限公司 Software log processing method

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20050203952A1 (en) * 2004-03-11 2005-09-15 Microsoft Corporation Tracing a web request through a web server
CN103684898A (en) * 2012-09-14 2014-03-26 阿里巴巴集团控股有限公司 Method and device for monitoring operation of user request in distributed system
CN105391772A (en) * 2015-10-16 2016-03-09 百度在线网络技术(北京)有限公司 Service request processing method, log processing method and service request processing device
CN108038145A (en) * 2017-11-23 2018-05-15 携程旅游网络技术(上海)有限公司 Distributed Services tracking, system, storage medium and electronic equipment
CN108173706A (en) * 2017-11-29 2018-06-15 阿里巴巴集团控股有限公司 Service marker method, apparatus and equipment under a kind of multiservice system

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7512954B2 (en) * 2002-07-29 2009-03-31 Oracle International Corporation Method and mechanism for debugging a series of related events within a computer system
JP2014081811A (en) * 2012-10-17 2014-05-08 Hitachi Solutions Ltd Log management system and log management method
CN106326099B (en) * 2015-07-01 2019-10-29 阿里巴巴集团控股有限公司 A kind of method, apparatus and electronic equipment for program tracking
CN106487596B (en) * 2016-10-26 2019-12-13 宜人恒业科技发展(北京)有限公司 Distributed service tracking implementation method
CN106790718A (en) * 2017-03-16 2017-05-31 北京搜狐新媒体信息技术有限公司 Service call link analysis method and system

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20050203952A1 (en) * 2004-03-11 2005-09-15 Microsoft Corporation Tracing a web request through a web server
CN103684898A (en) * 2012-09-14 2014-03-26 阿里巴巴集团控股有限公司 Method and device for monitoring operation of user request in distributed system
CN105391772A (en) * 2015-10-16 2016-03-09 百度在线网络技术(北京)有限公司 Service request processing method, log processing method and service request processing device
CN108038145A (en) * 2017-11-23 2018-05-15 携程旅游网络技术(上海)有限公司 Distributed Services tracking, system, storage medium and electronic equipment
CN108173706A (en) * 2017-11-29 2018-06-15 阿里巴巴集团控股有限公司 Service marker method, apparatus and equipment under a kind of multiservice system

Cited By (26)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114257502A (en) * 2020-09-21 2022-03-29 华为终端有限公司 Log reporting method and device
CN114257502B (en) * 2020-09-21 2023-08-22 华为终端有限公司 Log reporting method and device
CN112134739A (en) * 2020-09-24 2020-12-25 平安科技(深圳)有限公司 Link state tracking method and device, electronic equipment and computer storage medium
CN112134739B (en) * 2020-09-24 2022-07-08 平安科技(深圳)有限公司 Link state tracking method and device, electronic equipment and computer storage medium
CN112202608A (en) * 2020-09-28 2021-01-08 亚信科技(中国)有限公司 Log processing method and device, electronic equipment and computer readable storage medium
CN112256658A (en) * 2020-10-16 2021-01-22 海尔优家智能科技(北京)有限公司 Log record shunting method and device, storage medium and electronic device
CN112256658B (en) * 2020-10-16 2023-08-18 海尔优家智能科技(北京)有限公司 Log record distribution method and device, storage medium and electronic device
CN112394939B (en) * 2020-10-30 2023-06-13 迅鳐成都科技有限公司 User contract automatic deployment method, device and storage medium based on alliance chain
CN112394939A (en) * 2020-10-30 2021-02-23 迅鳐成都科技有限公司 Automatic user contract deployment method and device based on alliance chain and storage medium
CN112463563A (en) * 2020-11-25 2021-03-09 银盛支付服务股份有限公司 Full link tracking method, computer equipment and storage medium
CN112702191A (en) * 2020-12-11 2021-04-23 福建天晴在线互动科技有限公司 Link tracking method and terminal
CN112702191B (en) * 2020-12-11 2023-07-21 福建天晴在线互动科技有限公司 Link tracking method and terminal
CN113064750A (en) * 2021-04-26 2021-07-02 山东英信计算机技术有限公司 Tracking method, device and medium for BIOS log information
CN113064750B (en) * 2021-04-26 2023-03-28 山东英信计算机技术有限公司 Tracking method, device and medium for BIOS log information
CN114339574A (en) * 2021-12-29 2022-04-12 锐迪科创微电子(北京)有限公司 Earphone operation method and device and electronic equipment
CN114629929A (en) * 2022-03-16 2022-06-14 北京奇艺世纪科技有限公司 Log recording method, device and system
CN114629929B (en) * 2022-03-16 2024-03-08 北京奇艺世纪科技有限公司 Log recording method, device and system
CN115562913A (en) * 2022-04-21 2023-01-03 荣耀终端有限公司 Hardware state analysis method, device and system
CN115562913B (en) * 2022-04-21 2023-11-14 荣耀终端有限公司 Hardware state analysis method, device and system
CN114884807A (en) * 2022-05-20 2022-08-09 远景智能国际私人投资有限公司 Link log generation method and device, Internet of things platform and storage medium
CN116016646A (en) * 2022-11-07 2023-04-25 中国工商银行股份有限公司 Service access control method, device, equipment and medium
CN116016646B (en) * 2022-11-07 2024-05-28 中国工商银行股份有限公司 Service access control method, device, equipment and medium
CN116225855A (en) * 2023-05-10 2023-06-06 荣耀终端有限公司 Log generation method, electronic equipment and storage medium
CN116225855B (en) * 2023-05-10 2023-09-12 荣耀终端有限公司 Log generation method, electronic equipment and storage medium
CN117290164A (en) * 2023-11-22 2023-12-26 荣耀终端有限公司 Information recording method at restarting, electronic device and readable storage medium
CN117290164B (en) * 2023-11-22 2024-05-10 荣耀终端有限公司 Information recording method at restarting, electronic device and readable storage medium

Also Published As

Publication number Publication date
CN111625431A (en) 2020-09-04
CN111625431B (en) 2022-04-22

Similar Documents

Publication Publication Date Title
WO2020173377A1 (en) Log information generating method and apparatus, and electronic device
WO2021121052A1 (en) Multi-screen cooperation method and system, and electronic device
WO2021027630A1 (en) Patching method, related apparatus, and system
WO2021147406A1 (en) Audio output method and terminal device
CN110865837B (en) Method and terminal for system upgrade
CN114968384B (en) Function calling method and device
WO2021185352A1 (en) Version upgrade method and related apparatus
CN111713176B (en) Data transmission method and terminal
CN114489529A (en) Screen projection method of electronic device, medium thereof and electronic device
CN114442969A (en) Inter-device screen cooperation method and device
CN113608753A (en) Application uninstalling method, application recovery method, electronic device and storage medium
CN116028148B (en) Interface processing method and device and electronic equipment
CN114741256A (en) Sensor monitoring method and device and terminal equipment
CN116048833B (en) Thread processing method, terminal equipment and chip system
WO2023016059A1 (en) Data transmission control method and related apparatus
WO2022017244A1 (en) Application installation method and electronic device
WO2021052489A1 (en) Method for determining fault computing core in multi-core processor and electronic device
WO2023061014A1 (en) Task management method and apparatus
CN116662270B (en) File analysis method and related device
CN116662150B (en) Application starting time-consuming detection method and related device
CN117097883B (en) Frame loss fault cause determining method, electronic equipment and storage medium
US20240036891A1 (en) Sub-application running method and apparatus, electronic device, program product, and storage medium
WO2024104137A1 (en) Data recovery method capable of supporting data fusion and apparatus
WO2023241544A1 (en) Component preview method and electronic device
CN117632534A (en) Inter-process communication method and electronic equipment

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 20762070

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 20762070

Country of ref document: EP

Kind code of ref document: A1