[go: up one dir, main page]
More Web Proxy on the site http://driver.im/

CN117707439A - Log printing method and related device - Google Patents

Log printing method and related device Download PDF

Info

Publication number
CN117707439A
CN117707439A CN202311061359.5A CN202311061359A CN117707439A CN 117707439 A CN117707439 A CN 117707439A CN 202311061359 A CN202311061359 A CN 202311061359A CN 117707439 A CN117707439 A CN 117707439A
Authority
CN
China
Prior art keywords
log
electronic device
file
rule
printing
Prior art date
Legal status (The legal status 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 status listed.)
Pending
Application number
CN202311061359.5A
Other languages
Chinese (zh)
Inventor
许馨雨
罗旗良
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Honor Device Co Ltd
Original Assignee
Honor Device Co Ltd
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 Honor Device Co Ltd filed Critical Honor Device Co Ltd
Priority to CN202311061359.5A priority Critical patent/CN117707439A/en
Publication of CN117707439A publication Critical patent/CN117707439A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/12Digital output to print unit, e.g. line printer, chain printer
    • G06F3/1201Dedicated interfaces to print systems
    • G06F3/1202Dedicated interfaces to print systems specifically adapted to achieve a particular effect
    • G06F3/1203Improving or facilitating administration, e.g. print management
    • G06F3/1205Improving or facilitating administration, e.g. print management resulting in increased flexibility in print job configuration, e.g. job settings, print requirements, job tickets
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/18File system types
    • G06F16/1805Append-only file systems, e.g. using logs or journals to store data
    • G06F16/1815Journaling file systems
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/12Digital output to print unit, e.g. line printer, chain printer
    • G06F3/1201Dedicated interfaces to print systems
    • G06F3/1223Dedicated interfaces to print systems specifically adapted to use a particular technique
    • G06F3/1237Print job management
    • G06F3/1253Configuration of print job parameters, e.g. using UI at the client
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Human Computer Interaction (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The embodiment of the application provides a log printing method and a related device, and relates to the technical field of terminals. The method comprises the following steps: when a certain business module needs to locate a problem, the business module can configure a log printing rule in a configuration file of the business module, can also configure a log printing path, and the electronic equipment can print a relevant log for the business module according to the log printing rule and independently print the log of the business module according to the log printing path configured by the business module. Therefore, the running journal of each business module can be independently printed and stored, and customized journal printing of each business module is realized.

Description

Log printing method and related device
Technical Field
The application relates to the technical field of terminals, in particular to a log printing method and a related device.
Background
The business modules in the electronic equipment can print logs in the running process, and a developer can position problems according to the logs printed by the business modules.
However, the log has more content and may include some logs unrelated to problem positioning of a certain service module, so that waste of memory resources is caused, and difficulty in positioning the service module is increased.
Disclosure of Invention
According to the log printing method and the related device, when a certain service module needs to locate a problem, the service module can configure log printing rules in a configuration file of the service module, can also configure log printing paths, and the electronic equipment can print related logs for the service module according to the log printing rules and independently print the logs of the service module according to the log printing paths configured by the service module. Therefore, the running journal of each business module can be independently printed and stored, and customized journal printing of each business module is realized.
In a first aspect, a log printing method provided in an embodiment of the present application includes:
the first electronic device is provided with a first process in a running mode, the first electronic device pulls up a first landing process, the first landing process is used for printing a log of the first process on a first file path, the first process is configured with a first log rule file, and parameters in the first log rule file comprise: a name of the first process and a first file path; the first electronic device is provided with a second process in an operating mode, the first electronic device pulls up a second tray drop process, the second tray drop process is used for printing a log of the second process on a second file path, the second process is configured with a second log rule file, and parameters in the second log rule file comprise: a name of a second process and a second file path, the first process being different from the second process, the first file path being different from the second file path; a third process is operated in the first electronic equipment, and the first electronic equipment prints a log of the third process on a third file path, wherein the third process is not configured with a log rule file; and a fourth process is operated in the first electronic equipment, the first electronic equipment prints a log of the fourth process on a third file path, wherein the fourth process is not configured with a log rule file, and the third process is different from the fourth process. Therefore, the running log of each process can be printed and stored independently, and customized log printing of each process is realized.
In one possible implementation, the first log rule file includes: the system comprises a log interception rule parameter and a log landing rule parameter, wherein the log interception rule parameter comprises one or more of the following: log label setting parameters, single log printing length setting parameters and log flow setting parameters; the log landing rule parameters include: the name of the first process and the first file path, the log-drop rule parameters further include one or more of: the maximum capacity of the output log files, the maximum number of the compressed log files, the log compression mode, the log reading mode and the path for reading the log. Therefore, each business module can modify the log printing rule of each process according to the need, so that independent printing and storage of each business module log are realized, and personalized customized service is provided.
In a possible implementation, before the first electronic device pulls up the first tray drop process, the method further includes: the first electronic equipment judges that a first process is configured with a first log rule file, and the first electronic equipment acquires a log of the first process from a log buffer area of a log module; the first electronic equipment stores the log of the first process into a log file cache pool; after the first electronic device pulls up the first tray drop process, the method further includes: the first disk drop process acquires a log of the first process from a log file cache pool; the first drop process prints a log of the first process on a first file path. Therefore, the logs can be printed according to the log landing rule, and the logs of each service module can be landed in different output file catalogues, so that independent printing and storage of the logs of each service module are realized, and a convenient log printing mode is provided for each service module.
In one possible implementation, the managing log xlogcat process of the first electronic device includes a target locate process, where the target locate process is configured to obtain a log of the first process from a log buffer of the log module, and print the log of the first process on a first file path, and the first electronic device obtains the log of the first process from the log buffer of the log module, where the first electronic device includes: the target locator process calls a log_read interface and a log_reader interface for acquiring logs, and acquires the logs of the first process from a log buffer area of a log module through a socket channel; the first electronic device stores the log of the first process into a log file cache pool, comprising: the target locator process stores the log of the first process into a log file cache pool; the first electronic device pulls up a first landing process, comprising: the control log xlogcat process pulls up the first drop process; the first drop process obtains a log of the first process from a log file cache pool, and the method comprises the following steps: the first drop process polls and acquires a log of the first process from a log file cache pool based on an interface provided by the target locator process; the first landing process prints a log of the first process on a first file path, including: the first drop process prints a log of the first process on a first file path based on an interface provided by the target locator process. Therefore, the related interface called by the first electronic equipment can conveniently read the log of the first process, so that the log is read and the log is dropped.
In a possible implementation, the method further includes: when a first process is operated in the first electronic equipment, the first electronic equipment intercepts a log of the first process, and the first electronic equipment stores the intercepted log in a log buffer zone of a log module. Therefore, the first process can print the required log according to the service requirement, and a convenient log interception mode is provided for the first process.
In one possible implementation, the intercepting, by the first electronic device, the log of the first process includes: the first electronic device performs first-layer interception on the log of the first process, wherein the first-layer interception comprises one or more of the following: checking the printing format of the log of the first process, intercepting the level of the log of the first process, judging a buffer area stored in the log of the first process, and adding a time stamp for the log of the first process; the first electronic device performs second-layer interception on the log of the first process based on log interception rule parameters, wherein the second-layer interception comprises one or more of the following steps: the method comprises the steps of intercepting a log of a first process according to log tag setting parameters set by the first process, limiting the length of the single log of the first process according to the single log printing length set by the first process, and limiting the length of the log printed per second by the first process according to log flow set by the first process. Thus, the log information of the first process is intercepted twice, and more useful log information can be screened for the first process, so that the efficiency of the positioning problem of the first process can be improved, and the user experience is improved.
In a possible implementation, the first electronic device performs a first layer of interception on a log of a first process, including: the first electronic equipment calls a log_write interface to intercept a log of a first process in a first layer; the first electronic device performs second-layer interception on the log of the first process based on the log interception rule parameter, and the second-layer interception comprises: the first electronic equipment calls a log_wirter interface to intercept a log of the first process in a second layer based on log interception rule parameters; the first electronic device stores the intercepted log in a log buffer zone of a log module, and the method comprises the following steps: the first electronic device stores the intercepted logs in a log buffer zone of the log module through a socket channel. Therefore, by calling the log_write interface and the log_wirter interface related to the log, the day information of the first process can be conveniently intercepted in the process of log storage of the first process, so that information more useful for the positioning problem of the first process is stored.
In one possible implementation, before the first electronic device determines that the first process is configured with the first log rule file, the method further includes: the first electronic equipment receives an upgrade package from the second electronic equipment, wherein the upgrade package comprises a first log rule file of a first process; the first electronic device analyzes a first log rule file of the first process from the upgrade package. Therefore, by pushing the upgrade package by the cloud side, each service module can dynamically configure the log rule file according to service requirements, modify log parameters at any time, and realize flexible printing of the log, so that the expansion capability of log printing is improved.
In one possible implementation, a first electronic device sends a log of a first process to a second electronic device. Therefore, through the big data website of the second electronic equipment, developers can analyze the logs, so that the efficiency of problem analysis and solution is improved.
In a second aspect, an embodiment of the present application provides a log printing apparatus, where the apparatus may be an electronic device, or may be a chip or a chip system in the electronic device. The apparatus may include a processing unit. The processing unit is configured to implement any method related to processing performed by the electronic device in the first aspect or any of the possible implementations of the first aspect. When the apparatus is an electronic device, the processing unit may be a processor. The apparatus may further comprise a storage unit, which may be a memory. The storage unit is configured to store instructions, and the processing unit executes the instructions stored in the storage unit, so that the electronic device implements the method described in the first aspect or any one of the possible implementation manners of the first aspect. When the apparatus is a chip or a system of chips within an electronic device, the processing unit may be a processor. The processing unit executes instructions stored by the storage unit to cause the electronic device to implement the method described in the first aspect or any one of the possible implementations of the first aspect. The memory unit may be a memory unit (e.g., a register, a cache, etc.) within the chip, or a memory unit (e.g., a read-only memory, a random access memory, etc.) within the electronic device that is external to the chip.
The processing unit is used for running a first process and also used for pulling up a first tray drop process; the second process is also used for running and pulling up the second tray drop process; the system is also used for running a third process and printing a log of the third process on a third file path; and is further configured to run a fourth process and to print a log of the fourth process on the third file path.
In one possible implementation, the first log rule file includes: the system comprises a log interception rule parameter and a log landing rule parameter, wherein the log interception rule parameter comprises one or more of the following: log label setting parameters, single log printing length setting parameters and log flow setting parameters; the log landing rule parameters include: the name of the first process and the first file path, the log-drop rule parameters further include one or more of: the maximum capacity of the output log files, the maximum number of the compressed log files, the log compression mode, the log reading mode and the path for reading the log.
In a possible implementation manner, the processing unit is configured to determine that the first process is configured with a first log rule file, and is further configured to obtain a log of the first process from a log buffer area of the log module, and further is configured to store the log of the first process into a log file buffer pool; the method is particularly used for acquiring the log of the first process from the log file cache pool and printing the log of the first process on the first file path.
In a possible implementation manner, the processing unit is configured to call a log_read interface and a log_reader interface for obtaining a log, and further be configured to obtain, through a socket channel, a log of a first process from a log buffer area of a log module; the method is also used for storing the log of the first process into a log file cache pool; the first tray drop process is also used for pulling up the first tray drop process; the method is further used for acquiring the log of the first process from the log file cache pool in a polling mode based on the interface provided by the target locator process, and particularly used for printing the log of the first process on the first file path based on the interface provided by the target locator process.
In a possible implementation manner, the processing unit is configured to intercept the log of the first process, and store the intercepted log in a log buffer of the log module.
In a possible implementation manner, the processing unit is configured to perform a first layer interception on a log of the first process, and further configured to perform a second layer interception on the log of the first process based on a log interception rule parameter.
In a possible implementation manner, the processing unit is configured to invoke the log_write interface to perform first-layer interception on the log of the first process, and further invoke the log_wirter interface to perform second-layer interception on the log of the first process based on the log interception rule parameter, and specifically further is configured to store the intercepted log in a log buffer area of the log module through a socket channel.
In a possible implementation manner, the processing unit is configured to receive an upgrade package from the second electronic device, and is further configured to parse a first log rule file of the first process from the upgrade package.
In a possible implementation manner, the processing unit is configured to send a log of the first process to the second electronic device.
In a third aspect, embodiments of the present application provide a terminal device comprising a processor and a memory, the memory being for storing code instructions, the processor being for executing the code instructions to perform the method described in the first aspect or any one of the possible implementations of the first aspect.
In a fourth aspect, embodiments of the present application provide a computer-readable storage medium having stored therein a computer program or instructions which, when run on a computer, cause the computer to perform the method described in the first aspect or any one of the possible implementations of the first aspect.
In a fifth aspect, embodiments of the present application provide a computer program product comprising a computer program which, when run on a computer, causes the computer to perform the method described in the first aspect or any one of the possible implementations of the first aspect.
In a sixth aspect, the present application provides a chip or chip system comprising at least one processor and a communication interface, the communication interface and the at least one processor being interconnected by wires, the at least one processor being adapted to execute a computer program or instructions to perform the method described in the first aspect or any one of the possible implementations of the first aspect. The communication interface in the chip can be an input/output interface, a pin, a circuit or the like.
In one possible implementation, the chip or chip system described above in the present application further includes at least one memory, where the at least one memory has instructions stored therein. The memory may be a memory unit within the chip, such as a register, a cache, etc., or may be a memory unit of the chip (e.g., a read-only memory, a random access memory, etc.).
It should be understood that, the second aspect to the sixth aspect of the present application correspond to the technical solutions of the first aspect of the present application, and the beneficial effects obtained by each aspect and the corresponding possible embodiments are similar, and are not repeated.
Drawings
Fig. 1 is a schematic structural diagram of an electronic device according to an embodiment of the present application;
Fig. 2 is a schematic software structure of an electronic device according to an embodiment of the present application;
fig. 3 is a schematic diagram of an overall architecture of a log printing method according to an embodiment of the present application;
fig. 4 is a business module interaction diagram of log interception and log landing provided in an embodiment of the present application;
fig. 5 is a schematic diagram of a log printing method according to an embodiment of the present application;
fig. 6 is a schematic structural diagram of a chip according to an embodiment of the present application.
Detailed Description
In order to facilitate the clear description of the technical solutions of the embodiments of the present application, the following simply describes some terms and techniques related to the embodiments of the present application:
1. log level: the log level from low to high may include: verbos grade, debug grade, info grade, warn grade, error grade.
Verbos grade: verbos is of lower level and can be used to print more detailed information when the process is running.
Debug grade: the Debug level may be used to print some of the running information of the process running, the log of this level may be used for developer debugging and grooming processes, and a formal version may not print such log.
Info level: the Info level can be used for printing some important information when the process runs, so that developers can conveniently track the process execution flow, log input is carried out on key links in the process execution flow, and the main execution flow of the process can be restored.
Warning class: the Warning level may be used for information that may be potentially erroneous when the printing process is running. The Warning level may indicate that an unexpected exception occurred, and a log of the level may be printed at the time of exception capture. The Warning level abnormality has little influence on the user and can be automatically recovered.
Error grade: the Error level may be used for Error and anomaly information that occurs when the print process is running. The Error level log may indicate that an anomaly perceptible to the user occurred and that it cannot be automatically recovered.
2. Terminology
In the embodiments of the present application, the words "first," "second," and the like are used to distinguish between identical or similar items that have substantially the same function and effect. For example, the first chip and the second chip are merely for distinguishing different chips, and the order of the different chips is not limited. It will be appreciated by those of skill in the art that the words "first," "second," and the like do not limit the amount and order of execution, and that the words "first," "second," and the like do not necessarily differ.
It should be noted that, in the embodiments of the present application, words such as "exemplary" or "such as" are used to mean serving as an example, instance, or illustration. Any embodiment or design described herein as "exemplary" or "for example" should not be construed as preferred or advantageous over other embodiments or designs. Rather, the use of words such as "exemplary" or "such as" is intended to present related concepts in a concrete fashion.
In the embodiments of the present application, "at least one" means one or more, and "a plurality" means two or more. "and/or", describes an association relationship of an association object, and indicates that there may be three relationships, for example, a and/or B, and may indicate: a alone, a and B together, and B alone, wherein a, B may be singular or plural. The character "/" generally indicates that the context-dependent object is an "or" relationship. "at least one of" or the like means any combination of these items, including any combination of single item(s) or plural items(s). For example, at least one (one) of a, b, or c may represent: a, b, c, a-b, a-c, b-c, or a-b-c, wherein a, b, c may be single or plural.
3. Electronic equipment
The electronic device in the embodiment of the present application may also be any form of terminal device, for example, the electronic device may include: a mobile phone, tablet, palm, notebook, mobile internet device (mobile internet device, MID), wearable device, virtual Reality (VR) device, augmented reality (augmented reality, AR) device, wireless terminal in industrial control (industrial control), wireless terminal in unmanned (self driving), wireless terminal in teleoperation (remote medical surgery), wireless terminal in smart grid (smart grid), wireless terminal in transportation security (transportation safety), wireless terminal in smart city (smart city), wireless terminal in smart home (smart home), cellular phone, cordless phone, session initiation protocol (session initiation protocol, SIP) phone, wireless local loop (wireless local loop, WLL) station, personal digital assistant (personal digital assistant, PDA), handheld device with wireless communication function, public computing device or other processing device connected to wireless modem, vehicle-mounted device, wearable device, electronic device in 5G network or evolving land mobile network (public land mobile network), and the like, without being limited to this embodiment.
By way of example, and not limitation, in embodiments of the present application, the electronic device may also be a wearable device. The wearable device can also be called as a wearable intelligent device, and is a generic name for intelligently designing daily wear by applying wearable technology and developing wearable devices, such as glasses, gloves, watches, clothes, shoes and the like. The wearable device is a portable device that is worn directly on the body or integrated into the clothing or accessories of the user. The wearable device is not only a hardware device, but also can realize a powerful function through software support, data interaction and cloud interaction. The generalized wearable intelligent device includes full functionality, large size, and may not rely on the smart phone to implement complete or partial functionality, such as: smart watches or smart glasses, etc., and focus on only certain types of application functions, and need to be used in combination with other devices, such as smart phones, for example, various smart bracelets, smart jewelry, etc. for physical sign monitoring.
In addition, in the embodiment of the application, the electronic device may also be an electronic device in an internet of things (internet of things, ioT) system, and the IoT is an important component of future information technology development, and the main technical characteristic of the IoT is that the article is connected with a network through a communication technology, so that man-machine interconnection and an intelligent network for internet of things are realized.
The electronic device in the embodiment of the application may also be referred to as: a User Equipment (UE), a Mobile Station (MS), a Mobile Terminal (MT), an access terminal, a subscriber unit, a subscriber station, a mobile station, a remote terminal, a mobile device, a user terminal, a wireless communication device, a user agent, or a user equipment, etc.
In an embodiment of the present application, the electronic device or each network device includes a hardware layer, an operating system layer running above the hardware layer, and an application layer running above the operating system layer. The hardware layer includes hardware such as a central processing unit (central processing unit, CPU), a memory management unit (memory management unit, MMU), and a memory (also referred to as a main memory). The operating system may be any one or more computer operating systems that implement business processes through processes (processes), such as a Linux operating system, a Unix operating system, an Android operating system, an iOS operating system, or a windows operating system. The application layer comprises applications such as a browser, an address book, word processing software, instant messaging software and the like.
By way of example, fig. 1 shows a schematic diagram of an electronic device.
The electronic device may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (universal serial bus, USB) interface 130, a charge management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, an earphone interface 170D, a sensor module 180, keys 190, a motor 191, an indicator 192, a camera 193, a display 194, and a subscriber identity module (subscriber identification module, SIM) card interface 195, etc. The sensor module 180 may include a pressure sensor 180A, a gyro sensor 180B, an air pressure sensor 180C, a magnetic sensor 180D, an acceleration sensor 180E, a distance sensor 180F, a proximity sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, an ambient light sensor 180L, a bone conduction sensor 180M, and the like.
It should be understood that the structure illustrated in the embodiments of the present invention does not constitute a specific limitation on the electronic device. In other embodiments of the present application, the electronic device may include more or less components than illustrated, or certain components may be combined, or certain components may be split, or different arrangements of components. The illustrated components may comprise hardware, software, or a combination of software and hardware implementations.
The processor 110 may include one or more processing units, such as: the processor 110 may include an application processor (application processor, AP), a modem processor, a graphics processor (graphics processing unit, GPU), an image signal processor (image signal processor, ISP), a controller, a video codec, a digital signal processor (digital signal processor, DSP), a baseband processor, and/or a neural network processor (neural-network processing unit, NPU), etc. Wherein the different processing units may be separate devices or may be integrated in one or more processors.
The controller can generate operation control signals according to the instruction operation codes and the time sequence signals to finish the control of instruction fetching and instruction execution.
A memory may also be provided in the processor 110 for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. The memory may hold instructions or data that the processor 110 has just used or recycled. If the processor 110 needs to reuse the instruction or data, it can be called directly from the memory. Repeated accesses are avoided and the latency of the processor 110 is reduced, thereby improving the efficiency of the system.
In some embodiments, the processor 110 may include one or more interfaces. The interfaces may include an integrated circuit (inter-integrated circuit, I2C) interface, an integrated circuit built-in audio (inter-integrated circuit sound, I2S) interface, a pulse code modulation (pulse code modulation, PCM) interface, a universal asynchronous receiver transmitter (universal asynchronous receiver/transmitter, UART) interface, a mobile industry processor interface (mobile industry processor interface, MIPI), a general-purpose input/output (GPIO) interface, a SIM card interface, and/or a USB interface, among others.
It should be understood that the connection relationship between the modules illustrated in the embodiments of the present invention is only illustrative, and does not limit the structure of the electronic device. In other embodiments of the present application, the electronic device may also use different interfacing manners in the foregoing embodiments, or a combination of multiple interfacing manners.
The internal memory 121 may be used to store computer-executable program code that includes instructions. The internal memory 121 may include a storage program area and a storage data area. The storage program area may store an application program (such as a sound playing function, an image playing function, etc.) required for at least one function of the operating system, etc. The storage data area may store data created during use of the electronic device (e.g., audio data, phonebook, etc.), and so forth. In addition, the internal memory 121 may include a high-speed random access memory, and may further include a nonvolatile memory such as at least one magnetic disk storage device, a flash memory device, a universal flash memory (universal flash storage, UFS), and the like. The processor 110 performs various functional applications of the electronic device and data processing by executing instructions stored in the internal memory 121 and/or instructions stored in a memory provided in the processor. For example, the methods of embodiments of the present application may be performed.
Fig. 2 is a software configuration block diagram of an electronic device according to an embodiment of the present application. The layered architecture divides the software into several layers, each with distinct roles and branches. The layers communicate with each other through a software interface. In some embodiments, the Android system is divided into five layers, from top to bottom, an application layer, an application framework layer, an Zhuoyun rows (Android run) and libraries, a hardware abstraction layer (hardware adaptation layer, HAL), and a kernel layer, respectively.
The application layer may also be referred to as an application layer, which may include a series of application packages. As shown in fig. 2, the application package may include Applications (APP) for telephony, music, calendar, camera, games, memos, video, etc. Applications may include system applications and three-way applications.
The application framework layer provides an application programming interface (application programming interface, API) and programming framework for application layer applications. The application framework layer includes a number of predefined functions.
As shown in FIG. 2, the application framework layer may include a window manager, a resource manager, a content provider, and a view system, among others. The application framework layer may also provide a related log interface for application print logs of the application layer.
The window manager is used for managing window programs. The window manager may obtain the display screen size, determine if there is a status bar, lock screen, touch screen, drag screen, intercept screen, etc.
The resource manager provides various resources for the application program, such as localization strings, icons, pictures, layout files, video files, and the like.
The content provider is used for realizing the function of data sharing among different application programs, allowing one program to access the data in the other program, and simultaneously ensuring the safety of the accessed data.
The view system may be responsible for interface rendering and event handling for the application.
Android runtimes include core libraries and virtual machines. Android run time is responsible for control and management of the Android system.
The core library consists of two parts: one part is a function which needs to be called by java language, and the other part is a core library of android.
The application layer and the application framework layer run in a virtual machine. The virtual machine executes java files of the application program layer and the application program framework layer as binary files. The virtual machine is used for executing the functions of object life cycle management, stack management, thread management, security and exception management, garbage collection and the like. For example, in the embodiment of the present application, the virtual machine may be used to perform functions such as log collection, log interception, and log landing.
The system library may also be referred to as Native layer, which may include a plurality of functional modules. For example, in the embodiment of the present application, the Native layer may include: log interception module, parse extensible markup language (extensible markup language, XML) module, log module, locat module, function library (function libraries), and the like.
The log interception module may be configured to intercept the output log according to a log rule.
The parsing XML module may be used to parse log rules configured in an XML file.
The log module may include a log process of the log system that may be used to manage and store logs during operation of the Android system.
On the one hand, the log process can realize the functions of reading, writing, controlling and the like of log information through a socket interface, for example: socket log may be used to transmit control instructions, socket log may be used to write logs, and socket log may be used to read logs. The socket interface may also be understood as a socket channel.
On the other hand, the log process can be used for storing various logs in the Android system. Buffers (buffers) for storing logs may include main buffers, system buffers, crash buffers, events buffers, and the like. The main buffer area may be used to store log information generated by an application program, the system buffer area may be used to store log information of system messages and debugging, the crash buffer area may be used to store log information of abnormal events, and the events buffer area may be used to store log information of system events. The buffer in which the log module stores the log may also be referred to as a log buffer (log buffer).
The locator module may include a locator process that may be understood as a service process provided by the android system to view the log. For example, the locator process may display log information at the console.
The function library provides multiple service API interfaces for the developer, and is convenient for the developer to integrate and realize various functions quickly.
The hardware abstraction layer is a layer of abstracted structure between the kernel layer and the Android run. The hardware abstraction layer may be a package for hardware drivers that provides a unified interface for the invocation of upper layer applications. For example, in the embodiment of the present application, the hardware abstraction layer may encapsulate the log module, and provide a log-related interface for the Native layer.
The kernel layer is a layer between hardware and software. The kernel layer may include a display driver, a camera driver, an audio driver, a battery driver, a bluetooth driver, a central processor driver, a USB driver, etc. In the embodiment of the application, the kernel layer may further include a kernel log module.
It should be noted that, the embodiments of the present application are only illustrated by using an android system, and in other operating systems (such as Windows systems, IOS systems, etc.), the schemes of the present application can also be implemented as long as the functions implemented by the respective functional modules are similar to those of the embodiments of the present application.
The electronic equipment can print a maintenance log in the operation process, and the maintenance log can comprise a log, a kernel log, a voltage log and/or a current log of the electronic equipment and the like, wherein the log is printed to a log buffer area by each service module. The Service module may include an application APP, a Service program Service, and the like.
It can be understood that the log printed by each service module to the log buffer area can also be called a running log, the running log can comprise the log printed by the Android log system, and also can comprise the log printed by the log system developed by a developer, and each service module can perform problem positioning according to the running log.
However, since each service module can call the common interface provided by the electronic device to perform log printing, the running log includes log information printed by each service module. Therefore, the content in the flow log is more, and the flow log possibly comprises logs which are irrelevant to the problem positioning of a certain service module, so that the waste of memory resources is caused, and the difficulty of the service module positioning problem is increased.
In view of this, in the log printing method provided in the embodiment of the present application, when a certain service module needs to locate a problem, the service module may configure a log printing rule in a configuration file of the service module, and may also configure a log printing path, and the electronic device may print a relevant log for the service module according to the log printing rule, and print the log of the service module separately according to the log printing path configured by the service module. Therefore, the running journal of each business module can be independently printed and stored, and customized journal printing of each business module is realized.
In a possible implementation, the setting, by the electronic device, print log permissions for each service module may include: the electronic device may set a default print-permitted log level for each service module, for example, the default print-permitted log level may be an Error level or more. In addition, the electronic device may also set a log of some system services printed, which may also be referred to as a public log.
Fig. 3 shows the overall architecture of the log printing method of the embodiment of the present application.
The overall architecture involves (1) a cloud server and (2) an electronic device. The cloud server may also be referred to as a cloud side, and the electronic device may also be referred to as an end side.
(1) Cloud side.
The cloud side may perform a flow including: the method comprises the steps of (1.1) obtaining a log rule file by a cloud side, (1.2) packaging the log rule file by the cloud side, generating an upgrade package, (1.3) pushing the upgrade package by a Yun Cexiang end side, and (1.4) receiving a log uploaded by the end side by the cloud side.
And (1.1) the cloud side acquires the log rule file.
The cloud side can call related interfaces regularly to obtain log rule files configured by each service module at the end side. Wherein the log rule file may also be referred to as a configuration file. The period of acquiring the log rule file by the cloud side can be set by cloud side user definition, and the embodiment of the application is not limited.
It can be appreciated that when a certain service module in the electronic device needs to locate a problem, the service module may configure log interception rules in a log rule file of the service module. The log rule file may include an XML format file, for example, the log rule file may be an aplogjcontrol_config.
In a possible implementation, the log interception rules may include log tag setting parameters, a single log print length setting, a log traffic setting, and so on.
The log tag setting parameters may include class names, function names, variable names, etc. in the service module, and specific log tag setting parameters may be set by the service module in a self-defined manner, which is not limited in the embodiment of the present application. The service module configuring the log tag setting parameter may further include setting a white list tag and/or a black list tag. For example, if the service module sets a white list tag, the electronic device may print log information related to the white list tag when the service module is running; if the service module sets the blacklist tag, the electronic device may not print log information related to the blacklist tag when the service module operates. It can be understood that if the service module is not provided with the log tag setting parameter, the electronic device can print log information of the service module when the service module operates.
The service module can also allow setting the maximum length of single log printing, limiting the log length can reduce the probability of abnormal occurrence of the log system and save the resources of the memory space.
Log traffic can be understood as the length of log printed per second by the electronic device. It can be understood that the service module performs the current limiting processing on the length of the log printed every second, so that the system load of the electronic device is not too large, and the influence of log printing on the performance and power consumption of the electronic device is reduced.
And (1.2) packaging log rule files at the cloud side to generate an upgrade package.
After the cloud side obtains the log rule files configured by each service module, the cloud side can package the log rule files of each service module to generate an upgrade package. It can be appreciated that, since the upgrade package includes log rule parameters configured by each service module, the upgrade package may also be referred to as a parameter upgrade package.
(1.3) Yun Cexiang end side pushes the upgrade package.
In one possible implementation, the cloud side may periodically push the upgrade package to the end side through a push server, which may also be referred to as a push server. The period of pushing the upgrade package by the cloud side to the end side can be set by cloud side user definition, and the embodiment of the application is not limited.
In another possible implementation, when a certain service module on the end side has a requirement, for example, when the certain service module needs to acquire a log according to a configured log printing rule to locate a problem, or when the certain module needs to perform version upgrade, the developer may operate on the cloud side to push the upgrade package to the end side through the push server. For example, a developer may turn on a switch that pushes the upgrade package from the cloud side, thereby implementing that the upgrade package is pushed from the cloud side to the end side.
It is understood that the cloud side may push the upgrade package to the end side in any possible manner. The implementation manner of pushing the upgrade package to the end side by the cloud side is not limited in this embodiment.
(1.4) receiving the logs uploaded by the cloud side.
After the end side generates the logs of each service module, the end side can upload the logs of each service module to the big data website of the cloud side. The big data website can analyze, locate and optimize the problems of each service module based on the logs uploaded by the end side, so that the user experience is improved.
(2) End side.
The end side may perform a flow including: the method comprises the steps of (1.1) downloading an upgrade package by the end side, analyzing a log rule file, starting a process by the end side according to a log rule, (1.3) collecting logs by the end side, and uploading the logs by the end side to the cloud side.
And (1.1) downloading the upgrade package at the end side, and analyzing the log rule file.
After receiving the pushing information of the cloud side, the terminal side can download the upgrading packet pushed by the cloud side and analyze the log rule file configured by each service module from the upgrading packet. The end side may parse the upgrade package in any possible manner. The manner of parsing the upgrade package is not limited in this embodiment.
(1.2) the end side pulls up the process according to the log rule.
The end side may determine the corresponding service module according to each parsed log rule file, for example, the log rule file may include a name of the service module, and the end side may confirm the corresponding service module according to the name of the service module. And the end side can know which service modules are configured with the log rule file, and the log needs to be dropped according to the log rule file.
Illustratively, assuming process a is configured with a log rule file, the end side may pull up the drop-disk process A1 while process a is running. The landing process A1 may be used to obtain log information of the process a during running, and separately landing the log information of the process a, so that the log information of the process a and the log information of other service modules at the end side may be stored separately. Therefore, because the logs of the process A do not comprise the logs of other service modules, when the process A needs to locate the problem, the logs related to the process A can be obtained, so that the difficulty of locating the problem of the process A is reduced.
And (1.3) collecting logs at the end side.
In one aspect, the acquiring the log at the end side may include acquiring, by the end side, relevant parameters of log interception according to log interception rules configured by each service module, and intercepting log information generated by each service module according to the parameters.
On the other hand, the log collection at the end side can further comprise the end side landing the logs of each service module. The related processes of log interception and log landing performed at the specific end side will be described in detail in the following embodiment corresponding to fig. 4, which is not described herein.
(1.4) uploading the log to the cloud side.
After the logs of each service module are dropped, the dimension measurement service at the end side can periodically upload the dropped logs of each service module to the big data website at the cloud side. Therefore, developers can analyze the logs through the big data website, so that the efficiency of problem analysis and solution is improved.
Fig. 4 shows a business module interaction diagram of log interception and log landing performed by the end-side dimension service.
The end side may be running multiple processes, including for example process 1 and process 2 in fig. 4. The following describes the process of executing log interception and log landing by the dimension measurement service by taking the process 1 as an example.
(1) And (5) log interception.
When process 1 needs to print a log, process 1 may call an interface to write the log, e.g., the interface to write the log may include a log_write interface. The log_write interface can be used for initializing a log module, and can also be used for carrying out validity check on log information of the process 1, adding a time stamp to the log and the like. Wherein the validity check may include: checking a log printing format, intercepting a log level, judging a buffer area in which the log is stored, and the like.
For example, the log_write interface may verify the format of the log print, and may not print into the log for content that does not conform to the log print format. The log printing format is checked, so that log information can be correctly output, the readability of the log is improved, and further the problem location is facilitated.
The log level interception can be understood as that the log_write interface realizes log interception by controlling the level of the print log. For example, when the end side sets the log level of printing to the Debug level, log information of the Debug level, the Info level, the Warn level, the Error level, and more than the Error level in the process can all be printed; when the end side sets the printed log level as the Info level, the end side can print the log information of the Info level, the Warning level, the Error level and more than the Error level in the process without printing the log information of the Debug level; when the end side sets the log level of printing to the Error level, the end side can print log information of the Error level and above in progress without printing log information of the Debug level, the Info level, and the Warn level.
The buffer area for storing the log may include a main buffer area, a system buffer area, a crash buffer area, a events buffer area, etc., and the end side may determine in which buffer area the log information of the process is stored.
In addition, the end side can also add a time stamp for the log information of the process, so that a developer can easily find the log information near the corresponding time point when the problem occurs when the problem is positioned, thereby reducing the difficulty of positioning the problem.
After the log information of the process 1 is processed by the log_write interface, the log_write interface may send the processed log information of the process 1 to the log_write interface. Furthermore, the log_wirter interface can store the log information of the process 1 into a log buffer area of the log module through a socket channel. It may be appreciated that the log_wirter interface may include a log interception module, where the log interception module may be configured to intercept log information output by the process 1 according to log printing rules configured by the process 1. The log interception module may also be referred to as a private log interception module.
(2) And (5) log landing.
After the end side analyzes the log rule file of the process 1, on one hand, the end side can read the log of the process 1 from the log buffer zone of the log module through the xlogcat process and store the log into the log file buffer pool. On the other hand, the end side can pull up the drop process 1 through the xlogcat process, and the drop process 1 can drop the log of the process 1 in the log file cache pool.
It is to be appreciated that the xlogcat process may also be referred to as a managed log xlogcat process. The xlogcat process may be used to manage processes related to the control log, e.g., the xlogcat process may manage a target locate process, may also manage a drop process, and, illustratively, the xlogcat process may pull or close a target locate process, or a drop process, etc. The target locator process can be used for reading the log from the log buffer area of the log module, and can also be used for compressing the log into a file to be stored on a hard disk at the end side.
In a possible implementation, when the xlogcat process reads the log of process 1 from the log buffer of the log module, the xlogcat process may call an interface to read the log based on the target localcat process, e.g., the interface to read the log may include a log_read interface. The log_read interface may further call a log_reader interface, where the log_reader interface may obtain the log of the process 1 from the log buffer of the log module through a socket channel. The target locator process can store the log of the process 1 in the log file cache pool independently, so that the log of the process 1 and the logs of other service modules at the end side can be stored in a distinguishing mode.
When the drop process 1 drops the log of the process 1, the drop process 1 can poll and read the log of the process 1 from the log file cache pool based on the target locator process, and configure a log drop rule in the log rule file according to the process 1 to drop the log of the process 1 independently, so that a log compression file of the process 1 is generated, and independent printing and storage of the log of the process 1 are realized.
It is understood that the log landing rule may include a name of a service module, a chip platform of the service module, a maximum capacity of an output log file, a maximum number of compressed log files, a log compression mode, a log reading mode, a path of reading a log, a log compression landing path, and the like.
Taking process 1 as an example, the service module name of the log-drop rule may include a process name of the process 1 or a process identifier (process identification, PID) of the process 1, which is not limited in this embodiment.
The chip platform of the service module can be configured by the process 1, and the embodiment of the application does not limit the chip platform of the service module.
The maximum capacity of the output log file may be configured by the process 1 in a customized manner, for example, the maximum capacity of the output log file may be set to 4096Kbytes, which is not limited in the embodiment of the present application.
The maximum number of compressed log files may be configured by process 1 in a customized manner, for example, the maximum number of compressed log files may be set to 20, which is not limited in this embodiment.
The log compression mode may include a factory mode and a stream compression mode. The factory mode is understood to be that the log of the process 1 is firstly dropped, and then the log of the process 1 dropped is compressed. The stream compression mode can be understood as compressing the log of the process 1 first and then dropping the compressed log of the process 1. The log compression mode may be configured by process 1 in a customized manner, and embodiments of the present application are not limited.
The log reading mode may include a mode of polling a read log (poll_node) and a mode of a monitor checking a file node at a timing (monitor_node). It will be appreciated that if the process 1 uses a manner of polling the read log, the process 1 may set an interval of polling the read log, for example, the interval of polling the read log may be set to 10 ms, which is not limited in the embodiment of the present application.
Process 1 may set a path of the read log so that the log compression process of the dimension service may determine where to read the log of process 1 from according to the path of the read log set by process 1.
Process 1 may also set the log compression drop path, for example, process 1 may set the log compression drop path to OutputPath1 in FIG. 4. It can be appreciated that different service modules may set different log compression drop paths, and embodiments of the present application are not limited.
The dimension test application at the end side can obtain the landing log from the log compression landing path outputPath1 of the process 1, and periodically upload the landing log of the process 1 to the big data website at the cloud side. Therefore, developers can analyze the logs through the big data website, so that the efficiency of problem analysis and solution is improved.
It can be understood that the flow of log printing and log landing in the embodiment of the present application is different from the flow of log printing and landing in the kernel log. The log printing of the kernel log can write the log into the file dev/kmsg in a node writing manner through a printk function, so that the printing of the kernel log is realized, and the drop disc of the kernel log can be carried out by calling an xlogcat service to read the dev/kmsg node file.
It can be appreciated that the log printing method of the embodiment of the present application may also be applied to fault dotting scenarios. In some implementations, when a certain service module on the end side has a fault event, the service module may send fault dotting information to the cloud side, where the fault dotting information may include: fault event, service module name, fault time point, etc. The developer can find the logs near the fault time point in the flow logs uploaded by the end side according to the fault dotting information, and locate the problems. However, such problem locating processes are complex, and the flow logs include more redundant information, which is detrimental to the developer in problem locating.
In the embodiment of the application, the service module at the end side can dynamically configure the log rule file based on the cloud side. When a certain service module at the end side has a fault event, the end side can generate a log near a fault time point related to the service module according to the log rule file. Therefore, the log related to the service module can be obtained, more redundant information is not included like the running water log, and the difficulty of problem positioning can be reduced.
The method according to the embodiment of the present application will be described in detail by way of specific examples. The following embodiments may be combined with each other or implemented independently, and the same or similar concepts or processes may not be described in detail in some embodiments.
Fig. 5 shows a log printing method of an embodiment of the present application. The method comprises the following steps:
s501, a first process is operated in the first electronic equipment, the first electronic equipment pulls up a first landing process, and the first landing process is used for printing a log of the first process on a first file path, wherein the first process is configured with a first log rule file, and parameters in the first log rule file comprise: the name of the first process and the first file path.
In this embodiment of the present application, the first electronic device may be any terminal device, for example, the electronic device may include an electronic device such as a mobile phone, a tablet, or the like.
The first process may be understood as any running process in the first electronic device. For example, the first process may be a process of a certain application program in the first electronic device, or may be a process of a system service in the first electronic device, which is not limited in the embodiment of the present application.
The first file path may be understood as a path for printing the first process log, and the first file path may be understood as a log compression drop path in the above-described embodiment.
The first log rule file may be understood as a log rule file configured by the first process.
S502, a second process is operated in the first electronic equipment, the first electronic equipment pulls up a second tray process, the second tray process is used for printing a log of the second process on a second file path, the second process is configured with a second log rule file, and parameters in the second log rule file comprise: the name of the second process and the second file path, the first process being different from the second process, the first file path being different from the second file path.
In this embodiment of the present application, the second process may be understood as any running process in the first electronic device. The second file path may be understood as a path for printing the second progress log. The second log rule file may be understood as a log rule file configured by the second process.
S503, a third process is operated in the first electronic equipment, and the first electronic equipment prints a log of the third process on a third file path, wherein the third process is not configured with a log rule file.
In this embodiment of the present application, the third process may be understood as any running process in the first electronic device. The third file path may be understood as a path for printing the third progress log.
S504, a fourth process is operated in the first electronic equipment, the first electronic equipment prints a log of the fourth process in a third file path, wherein the fourth process is not configured with a log rule file, and the third process is different from the fourth process.
In this embodiment of the present application, the fourth process may be understood as any running process in the first electronic device. The fourth file path may be understood as a path for printing the fourth progress log.
It may be understood that the first process, the second process, the third process, and the fourth process may be running synchronously or asynchronously in the first electronic device, and there is no limitation on the running time, and the running time of the first process, the second process, the third process, and the fourth process is not limited in this embodiment.
In the embodiment of the application, each process can be configured with a respective log printing rule, and can be further configured with a log printing path of each process, and the electronic device can print the log for each process according to the log printing rule and independently print the log for each process according to the log printing path. Therefore, the running log of each process can be printed and stored independently, and customized log printing of each process is realized.
Alternatively, on the basis of the embodiment corresponding to fig. 5, the first log rule file may include: the system comprises a log interception rule parameter and a log landing rule parameter, wherein the log interception rule parameter comprises one or more of the following: log label setting parameters, single log printing length setting parameters and log flow setting parameters; the log landing rule parameters include: the name of the first process and the first file path, the log-drop rule parameters further include one or more of: the maximum capacity of the output log files, the maximum number of the compressed log files, the log compression mode, the log reading mode and the path for reading the log.
In this embodiment of the present application, the log interception rules and the related parameters may refer to the related descriptions of the log interception rules in the embodiment corresponding to fig. 3, which are not described in detail. The log-drop rule and the related parameters may refer to the related description of the log-drop rule in the embodiment corresponding to fig. 4, which is not repeated.
The first process can modify the first log rule file according to the need, and each business module can modify the log printing rule of each process according to the need, so that independent printing and storage of each business module log are realized, and personalized customized service is provided.
Optionally, before the first electronic device pulls up the first tray process, on the basis of the embodiment corresponding to fig. 5, the method may further include: the first electronic equipment judges that a first process is configured with a first log rule file, and the first electronic equipment acquires a log of the first process from a log buffer area of a log module; the first electronic equipment stores the log of the first process into a log file cache pool; after the first electronic device pulls up the first tray drop process, the method may further include: the first disk drop process acquires a log of the first process from a log file cache pool; the first drop process prints a log of the first process on a first file path.
In this embodiment of the present application, the first electronic device obtains the log of the first process from the log buffer area of the log module, and stores the log in the log file buffer pool, and the first drop process obtains the log of the first process from the log file buffer pool, and prints the process of the log of the first process on the first file path, which may refer to the related description in the log drop of the embodiment (2) corresponding to fig. 4, and will not be repeated.
The logs can be printed according to the log landing rule, and the logs of each service module can be landed to different output file catalogues, so that independent printing and storage of the logs of each service module are realized, and a convenient log printing mode is provided for each service module.
Optionally, based on the embodiment corresponding to fig. 5, the managing log xlogcat process of the first electronic device includes a target localcat process, where the target localcat process is configured to obtain a log of the first process from a log buffer of the log module, print the log of the first process on the first file path, and obtain the log of the first process from the log buffer of the log module by the first electronic device, where the first electronic device may include: the target locator process calls a log_read interface and a log_reader interface for acquiring logs, and acquires the logs of the first process from a log buffer area of a log module through a socket channel; the first electronic device storing the log of the first process into a log file buffer pool may include: the target locator process stores the log of the first process into a log file cache pool; the first electronic device pulling up the first landing tray process may include: the control log xlogcat process pulls up the first drop process; the first landing process obtains the log of the first process from the log file cache pool, and may include: the first drop process polls and acquires a log of the first process from a log file cache pool based on an interface provided by the target locator process; the first landing process prints a log of the first process on a first file path, and may include: the first drop process prints a log of the first process on a first file path based on an interface provided by the target locator process.
In this embodiment, the specific log-drop process may refer to the description related to the log-drop in the embodiment (2) corresponding to fig. 4, which is not repeated. The related interface called by the first electronic device can conveniently read the log of the first process, so that the log is read and the log is dropped.
Optionally, on the basis of the embodiment corresponding to fig. 5, the method may further include: when a first process is operated in the first electronic equipment, the first electronic equipment intercepts a log of the first process, and the first electronic equipment stores the intercepted log in a log buffer zone of a log module.
In this embodiment of the present application, the first electronic device intercepts the log of the first process and stores the intercepted log in the log buffer of the log module, which may refer to the description related to the log interception in the embodiment (1) corresponding to fig. 4, and will not be described in detail.
The logs are printed according to the log interception rules, so that the first process can print the required logs according to business needs, for example, the first process can print logs related to positioning problems, and a convenient log interception mode can be provided for the first process.
Optionally, on the basis of the embodiment corresponding to fig. 5, the intercepting, by the first electronic device, the log of the first process may include: the first electronic device performs first-layer interception on the log of the first process, wherein the first-layer interception comprises one or more of the following: checking the printing format of the log of the first process, intercepting the level of the log of the first process, judging a buffer area stored in the log of the first process, and adding a time stamp for the log of the first process; the first electronic device performs second-layer interception on the log of the first process based on log interception rule parameters, wherein the second-layer interception comprises one or more of the following steps: the method comprises the steps of intercepting a log of a first process according to log tag setting parameters set by the first process, limiting the length of the single log of the first process according to the single log printing length set by the first process, and limiting the length of the log printed per second by the first process according to log flow set by the first process.
In this embodiment of the present application, the first layer interception performed by the first electronic device on the log of the first process may be understood as log interception performed by the electronic device on the first process when the first process calls the log_write interface for writing the log. The specific checking of the log printing format, interception of the log level, judgment of the buffer area in which the log is stored, adding a timestamp to the log, etc. can refer to the related description in the log interception of the embodiment (1) corresponding to fig. 4, and will not be described in detail.
The second layer interception may be understood as interception of the log of the first process by the first electronic device based on the log interception rule parameter. The second layer interception may also be understood as the interception of the process by the log interception module of the log_wirter interface in the log interception in the embodiment (1) corresponding to fig. 4, which is not described herein.
The log information of the first process is intercepted twice, so that more useful log information can be screened for the first process, the efficiency of the positioning problem of the first process can be improved, and the user experience is improved.
Optionally, on the basis of the embodiment corresponding to fig. 5, the first electronic device performs a first layer interception on the log of the first process, which may include: the first electronic equipment calls a log_write interface to intercept a log of a first process in a first layer; the first electronic device performing second-layer interception on the log of the first process based on the log interception rule parameter may include: the first electronic equipment calls a log_wirter interface to intercept a log of the first process in a second layer based on log interception rule parameters; the first electronic device storing the intercepted log in a log buffer area of the log module may include: the first electronic device stores the intercepted logs in a log buffer zone of the log module through a socket channel.
In this embodiment of the present application, the process of intercepting the log of the first process by the first electronic device may refer to the related description in the log interception of embodiment (1) corresponding to fig. 4, which is not described herein.
By calling the log_write interface and the log_wirter interface related to the log writing, the day information of the first process can be conveniently intercepted in the process of log storage of the first process, so that information more useful for the positioning problem of the first process is stored.
Optionally, before the first electronic device determines that the first process is configured with the first log rule file, on the basis of the embodiment corresponding to fig. 5, the method may further include: the first electronic equipment receives an upgrade package from the second electronic equipment, wherein the upgrade package comprises a first log rule file of a first process; the first electronic device analyzes a first log rule file of the first process from the upgrade package.
In this embodiment of the present application, the second electronic device may be an electronic device capable of transmitting an upgrade package to the first electronic device, for example, the second electronic device may include a cloud server, which is not limited in this embodiment.
The interaction between the first electronic device and the second electronic device may refer to the related description in the cloud side of the embodiment (1) corresponding to fig. 3, which is not repeated. By pushing the upgrade package on the cloud side, each service module can dynamically configure the log rule file according to service requirements, modify log parameters at any time, and realize flexible printing of the log, so that the expansion capability of log printing is improved.
Optionally, on the basis of the embodiment corresponding to fig. 5, the first electronic device sends a log of the first process to the second electronic device.
In this embodiment of the present application, the sending, by the first electronic device, the log of the first process to the second electronic device may be understood as a process in which the dimension measurement application of the first electronic device uploads the log to the big data website of the second electronic device. The specific description that the first electronic device sends the log of the first process to the second electronic device may refer to the relevant description in the uploading log from the end side to the cloud side in the embodiment (1.4) corresponding to fig. 3, which is not repeated.
Through big data website of second electronic equipment, the developer can analyze the log to promote problem analysis and solution's efficiency.
It should be noted that, the user information (including but not limited to user equipment information, user personal information, etc.) and the data (including but not limited to data for analysis, stored data, presented data, etc.) related to the present application are information and data authorized by the user or fully authorized by each party, and the collection, use and processing of the related data need to comply with the related laws and regulations and standards of the related country and region, and provide corresponding operation entries for the user to select authorization or rejection.
The foregoing description of the solution provided in the embodiments of the present application has been mainly presented in terms of a method. To achieve the above functions, it includes corresponding hardware structures and/or software modules that perform the respective functions. Those of skill in the art will readily appreciate that the various illustrative method steps described in connection with the embodiments disclosed herein may be implemented as hardware or a combination of hardware and computer software. Whether a function is implemented as hardware or computer software driven hardware depends upon the particular application and design constraints imposed on the solution. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
The embodiment of the application may divide the functional modules of the apparatus implementing the method according to the above method example, for example, each functional module may be divided corresponding to each function, or two or more functions may be integrated into one processing module. The integrated modules may be implemented in hardware or in software functional modules. It should be noted that, in the embodiment of the present application, the division of the modules is schematic, which is merely a logic function division, and other division manners may be implemented in actual implementation.
Fig. 6 is a schematic structural diagram of a chip according to an embodiment of the present application. Chip 600 includes one or more (including two) processors 601, communication lines 602, communication interfaces 603, and memory 604.
In some implementations, the memory 604 stores the following elements: executable modules or data structures, or a subset thereof, or an extended set thereof.
The methods described in the embodiments of the present application may be applied to the processor 601 or implemented by the processor 601. The processor 601 may be an integrated circuit chip with signal processing capabilities. In implementation, the steps of the above method may be performed by integrated logic circuits of hardware in the processor 601 or instructions in the form of software. The processor 601 may be a general purpose processor (e.g., a microprocessor or a conventional processor), a digital signal processor (digital signal processing, DSP), an application specific integrated circuit (application specific integrated circuit, ASIC), an off-the-shelf programmable gate array (field-programmable gate array, FPGA) or other programmable logic device, discrete gates, transistor logic, or discrete hardware components, and the processor 601 may implement or perform the methods, steps, and logic diagrams related to the processes disclosed in the embodiments of the present application.
The steps of a method disclosed in connection with the embodiments of the present application may be embodied directly in hardware, in a decoded processor, or in a combination of hardware and software modules in a decoded processor. The software modules may be located in a state-of-the-art storage medium such as random access memory, read-only memory, programmable read-only memory, or charged erasable programmable memory (electrically erasable programmable read only memory, EEPROM). The storage medium is located in a memory 604, and the processor 601 reads information in the memory 604 and in combination with its hardware performs the steps of the method described above.
The processor 601, the memory 604 and the communication interface 603 may communicate with each other via a communication line 602.
In the above embodiments, the instructions stored by the memory for execution by the processor may be implemented in the form of a computer program product. The computer program product may be written in the memory in advance, or may be downloaded in the form of software and installed in the memory.
Embodiments of the present application also provide a computer program product comprising one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the processes or functions in accordance with embodiments of the present application are produced in whole or in part. The computer may be a general purpose computer, a special purpose computer, a computer network, or other programmable apparatus. The computer instructions may be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another computer-readable storage medium, for example, the computer instructions may be transmitted from a website, a computer, a server, or a data center of one website, through a wired (e.g., coaxial cable, optical fiber, digital subscriber line (digital subscriber line, DSL), or wireless (e.g., infrared, wireless, microwave, etc.) to the website, computer, server, or data center of another website, the computer-readable storage medium may be any available medium that can be stored by the computer or a data storage device such as a server, data center, etc., that includes an integration of one or more available media.
Embodiments of the present application also provide a computer-readable storage medium. The methods described in the above embodiments may be implemented in whole or in part by software, hardware, firmware, or any combination thereof. Computer readable media can include computer storage media and communication media and can include any medium that can transfer a computer program from one place to another. The storage media may be any target media that is accessible by a computer.
As one possible design, the computer-readable medium may include compact disk read-only memory (CD-ROM), RAM, ROM, EEPROM, or other optical disk memory; the computer readable medium may include disk storage or other disk storage devices. Moreover, any connection is properly termed a computer-readable medium. For example, if the software is transmitted from a website, server, or other remote source using a coaxial cable, fiber optic cable, twisted pair, DSL, or wireless technologies such as infrared, radio, and microwave, then the coaxial cable, fiber optic cable, twisted pair, DSL, or wireless technologies such as infrared, radio, and microwave are included in the definition of medium. Disk and disc, as used herein, includes Compact Disc (CD), laser disc, optical disc, digital versatile disc (digital versatiledisc, DVD), floppy disk and blu-ray disc where disks usually reproduce data magnetically, while discs reproduce data optically with lasers.
Embodiments of the present application are described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the application. It will be understood that each flow and/or block of the flowchart illustrations and/or block diagrams, and combinations of flows and/or blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processing unit of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processing unit of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.

Claims (12)

1. A method of log printing, the method comprising:
the first electronic device is provided with a first process, the first electronic device pulls up a first landing process, the first landing process is used for printing a log of the first process on a first file path, the first process is configured with a first log rule file, and parameters in the first log rule file comprise: the name of the first process and the first file path;
The first electronic device is provided with a second process, the first electronic device pulls up a second tray process, the second tray process is used for printing a log of the second process on a second file path, the second process is configured with a second log rule file, and parameters in the second log rule file comprise: the name of the second process and the second file path, the first process being different from the second process, the first file path being different from the second file path;
a third process is operated in the first electronic equipment, and the first electronic equipment prints a log of the third process on a third file path, wherein the third process is not configured with a log rule file;
and a fourth process is operated in the first electronic equipment, the first electronic equipment prints a log of the fourth process on the third file path, wherein the fourth process is not configured with the log rule file, and the third process is different from the fourth process.
2. The method of claim 1, wherein the first log rule file comprises: log intercept rule parameters and log landing rule parameters,
The log intercept rule parameters include one or more of the following: log label setting parameters, single log printing length setting parameters and log flow setting parameters;
the log landing rule parameters comprise: the name of the first process and the first file path, and the log-drop rule parameter further includes one or more of the following: the maximum capacity of the output log files, the maximum number of the compressed log files, the log compression mode, the log reading mode and the path for reading the log.
3. The method of claim 1 or 2, wherein before the first electronic device pulls up the first landing stage, further comprising:
the first electronic device judges that the first process is configured with the first log rule file, and the first electronic device obtains a log of the first process from a log buffer area of a log module;
the first electronic equipment stores the log of the first process into a log file cache pool;
after the first electronic device pulls up the first tray drop process, the method further includes:
the first drop process acquires a log of the first process from the log file cache pool;
And the first drop process prints the log of the first process on the first file path.
4. The method of claim 3, wherein the first electronic device's managed log xlogcat process comprises a target localcat process for retrieving a log of the first process from a log buffer of the log module and printing the log of the first process on the first file path,
the first electronic device obtaining the log of the first process from the log buffer zone of the log module, including:
the target locator process calls a locator_read interface and a locator_reader interface for obtaining logs, and obtains the logs of the first process from a log buffer area of the log locator module through a socket channel;
the first electronic device stores the log of the first process into a log file cache pool, including:
the target locator process stores the log of the first process into the log file cache pool;
the first electronic device pulls up a first landing process, including:
the control log xlogcat process pulls up the first drop process;
The first drop process obtains the log of the first process from the log file cache pool, and the method comprises the following steps:
the first drop process polls and acquires a log of the first process from the log file cache pool based on an interface provided by the target locator process;
the first drop process prints a log of the first process on the first file path, including:
and the first drop process prints a log of the first process on the first file path based on an interface provided by the target locator process.
5. The method according to claim 3 or 4, characterized in that the method further comprises:
when the first process is operated in the first electronic equipment, the first electronic equipment intercepts the log of the first process, and the first electronic equipment stores the intercepted log in a log buffer zone of the log module.
6. The method of claim 5, wherein the first electronic device intercepting the log of the first process comprises:
the first electronic device performs first-layer interception on the log of the first process, wherein the first-layer interception comprises one or more of the following: checking the printing format of the log of the first process, intercepting the level of the log of the first process, judging a buffer area stored in the log of the first process, and adding a time stamp for the log of the first process;
The first electronic device performs second-layer interception on the log of the first process based on the log interception rule parameter, wherein the second-layer interception comprises one or more of the following steps: the method comprises the steps of intercepting a log of a first process according to a log tag setting parameter set by the first process, limiting the length of the single log of the first process according to the printing length of the single log set by the first process, and limiting the length of the printing log of the first process per second according to the log flow set by the first process.
7. The method of claim 6, wherein the first electronic device performing a first layer of interception of the log of the first process comprises:
the first electronic equipment calls a log_write interface to intercept the log of the first process at the first layer;
the first electronic device performs second-layer interception on the log of the first process based on the log interception rule parameter, including:
the first electronic equipment calls a log_wirter interface to intercept the log of the first process at the second layer based on the log interception rule parameter;
the first electronic device stores the intercepted log in a log buffer area of the log module, including:
And the first electronic equipment stores the intercepted logs in a log buffer zone of the log module through a socket channel.
8. The method of any of claims 3-7, wherein before the first electronic device determines that the first process is configured with the first log rule file, further comprising:
the first electronic device receives an upgrade package from a second electronic device, wherein the upgrade package comprises the first log rule file of the first process;
and the first electronic equipment analyzes the first log rule file of the first process from the upgrade package.
9. The method of any of claims 1-8, wherein the first electronic device sends a log of the first process to a second electronic device.
10. An electronic device, comprising: a memory for storing a computer program and a processor for executing the computer program to perform the method of any of claims 1-9.
11. A computer readable storage medium storing instructions that, when executed, cause a computer to perform the method of any one of claims 1-9.
12. A computer program product comprising a computer program which, when run, causes an electronic device to perform the method of any one of claims 1-9.
CN202311061359.5A 2023-08-22 2023-08-22 Log printing method and related device Pending CN117707439A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311061359.5A CN117707439A (en) 2023-08-22 2023-08-22 Log printing method and related device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311061359.5A CN117707439A (en) 2023-08-22 2023-08-22 Log printing method and related device

Publications (1)

Publication Number Publication Date
CN117707439A true CN117707439A (en) 2024-03-15

Family

ID=90153972

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311061359.5A Pending CN117707439A (en) 2023-08-22 2023-08-22 Log printing method and related device

Country Status (1)

Country Link
CN (1) CN117707439A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN118012732A (en) * 2024-04-08 2024-05-10 合众新能源汽车股份有限公司 Log management method and device and electronic equipment

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103164511A (en) * 2013-02-21 2013-06-19 烽火通信科技股份有限公司 Method for storage event log to automatically filter repeated jitter data
CN111400127A (en) * 2020-02-28 2020-07-10 平安医疗健康管理股份有限公司 Service log monitoring method and device, storage medium and computer equipment
US20210365223A1 (en) * 2018-08-22 2021-11-25 Wangsu Science & Technology Co., Ltd. Log printing method, system and server
CN114116665A (en) * 2021-11-22 2022-03-01 北京海量数据技术股份有限公司 Method for parallel writing transaction log in database to improve processing efficiency
CN114756435A (en) * 2022-05-12 2022-07-15 阿里巴巴(中国)有限公司 Log reading method, server, computer device and storage medium
CN115905154A (en) * 2022-12-29 2023-04-04 北斗星通智联科技有限责任公司 Log data display method and device and electronic equipment

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103164511A (en) * 2013-02-21 2013-06-19 烽火通信科技股份有限公司 Method for storage event log to automatically filter repeated jitter data
US20210365223A1 (en) * 2018-08-22 2021-11-25 Wangsu Science & Technology Co., Ltd. Log printing method, system and server
CN111400127A (en) * 2020-02-28 2020-07-10 平安医疗健康管理股份有限公司 Service log monitoring method and device, storage medium and computer equipment
CN114116665A (en) * 2021-11-22 2022-03-01 北京海量数据技术股份有限公司 Method for parallel writing transaction log in database to improve processing efficiency
CN114756435A (en) * 2022-05-12 2022-07-15 阿里巴巴(中国)有限公司 Log reading method, server, computer device and storage medium
CN115905154A (en) * 2022-12-29 2023-04-04 北斗星通智联科技有限责任公司 Log data display method and device and electronic equipment

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
J 博伊斯等: "《WINDOWS NT 4.0 安装与配置手册》", 31 July 1997, 机械工业出版社, pages: 409 *
隔壁小猿: "Logback不同业务场景日志写入不同单独日志文件", pages 2 - 4, Retrieved from the Internet <URL:《https://blog.csdn.net/sinstar1/article/details/116643815》> *

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN118012732A (en) * 2024-04-08 2024-05-10 合众新能源汽车股份有限公司 Log management method and device and electronic equipment

Similar Documents

Publication Publication Date Title
CN110633090A (en) Patch method, related device and system
CN111931102A (en) Method, device and system for constructing page
CN117707439A (en) Log printing method and related device
CN113672445B (en) Method for recording running state information of target program and electronic equipment
CN117149476B (en) Fault reporting method and related device
CN113050985A (en) Front-end engineering dependence automatic registration method and device
CN116669064B (en) Wireless protocol testing method and electronic equipment
CN117156088B (en) Image processing method and related device
CN116700768B (en) Application processing method and related device
CN117714271B (en) Message processing method and related device
CN115314427A (en) Protocol testing method, electronic equipment and chip system
CN115113898A (en) Dynamic updating method and device for micro application, computer equipment and storage medium
CN114637531A (en) Method and device for dynamically generating application program interface
CN116701320B (en) Log generation method and related device
CN117724880B (en) Fault information processing method, electronic device and storage medium
CN117724937B (en) Log resource management method and related device
CN116737258B (en) Method and related device for unloading application
CN113485923B (en) Project code detection method and device and electronic equipment
CN115202902B (en) Method for controlling process interaction and related device
CN116089563B (en) Log processing method and related device
CN114564413B (en) Synchronous equipment testing method and device
CN116662270B (en) File analysis method and related device
CN114006969B (en) Window starting method and electronic equipment
CN117858279A (en) SIM card service processing method and related device
CN117032770A (en) Application program updating method and device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination