Log processing method and electronic equipment

By performing dual compression on the logs of embedded devices and parsing on computer devices, the problems of large log space consumption and low execution efficiency are solved, achieving efficient storage and retention of parameter information, which facilitates operation and maintenance analysis.

CN121209770APending Publication Date: 2025-12-26SHANGHAI LONGSYS DIGITAL TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410835662.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-25
Publication Date
2025-12-26

AI Technical Summary

Technical Problem

In existing technologies, embedded device logs occupy a large amount of space, have low execution efficiency, and lose original log parameter information.

Method used

By using technical means based on the correspondence between preset identifiers and strings, and through detection of log levels and output capabilities, dual compression of logs is performed, including compression of static and dynamic information, and then parsing is performed on computer devices to restore the initial logs.

Benefits of technology

It effectively reduces the space occupied by logs, improves storage density and execution efficiency, while retaining important parameter information for easy operation and maintenance analysis.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121209770A_ABST
    Figure CN121209770A_ABST
Patent Text Reader

Abstract

The invention relates to the field of data processing, and provides a log processing method and electronic equipment. The method comprises the following steps: compressing static information in an initial log based on a corresponding relationship between a preset identifier and a character string to obtain a first compressed log; and compressing the target dynamic information in the first compressed log to obtain a second compressed log. According to the method, the storage density and transmission efficiency of the compressed log can be improved, and the technical problem of losing parameter information in the initial log can be solved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of data, in particular to a log processing method and an electronic device. BACKGROUND

[0002] At present, in order to facilitate the analysis and troubleshooting of embedded devices, the running state, operation behavior, error information and the like of the application program installed in the embedded device are usually recorded in the form of logs based on the logging mechanism. However, with the development of the Internet, the functions of the application program are becoming more and more complex, and therefore the instructions recorded in the logs also increase, resulting in a large amount of space occupied by the logs in the embedded device and affecting the execution efficiency of the embedded device on the logs.

[0003] In order to solve the problem of large space occupied by the logs, in the related art, a digital identifier is usually used to replace all the text information in the output logs, but this way of obtaining compressed logs results in the loss of parameter information in the original logs, which is not conducive to the viewing and analysis of the logs by the operation and maintenance user. SUMMARY

[0004] In view of the above, it is necessary to provide a log processing method and an electronic device, which can solve the technical problems of large space occupied by logs, low execution efficiency and loss of parameter information in original logs.

[0005] In one aspect, the present application provides a log processing method applied to an embedded device, which comprises: compressing static information in an initial log based on a correspondence relationship between a preset identifier and a string to obtain a first compressed log; and compressing target dynamic information in the first compressed log to obtain a second compressed log.

[0006] According to the embodiments of the present application, before the static information in the initial log is compressed based on the correspondence relationship between the preset identifier and the string to obtain the first compressed log, the method further comprises: determining whether the initial log satisfies an output condition through detection of a log level and an output capability.

[0007] According to the embodiments of the present application, the determination of whether the initial log satisfies the output condition through the detection of the log level and the output capability comprises: if a first level of the initial log satisfies a preset global level requirement, detecting whether a module corresponding to the initial log has an output capability; if the module corresponding to the initial log has the output capability, detecting whether a second level of the initial log satisfies a preset module level requirement; and if the second level satisfies the module level requirement, determining that the initial log satisfies the output condition.

[0008] According to an embodiment of the present application, the compressing the target dynamic information in the first compressed log to obtain a second compressed log comprises: obtaining dynamic information with a preset value from the first compressed log as the target dynamic information; and compressing the target dynamic information based on a bitmap mode to obtain the second compressed log.

[0009] According to an embodiment of the present application, after the compressing the target dynamic information in the first compressed log to obtain a second compressed log, the method further comprises: obtaining a target address from an idle address list corresponding to a cache area; storing the second compressed log according to the target address; and moving the target address into a data address list corresponding to the cache area after the storing of the second compressed log into the target address is completed.

[0010] According to an embodiment of the present application, the method further comprises: if the idle address list is empty, obtaining a tail address from the data address list; outputting a compressed log stored in the tail address; and deleting the tail address from the data address list and adding the tail address to the idle address list after the output of the compressed log stored in the tail address is completed.

[0011] In another aspect, the present application further provides a log processing method applied to a computer device, the log processing method comprising: if a boot code in a compressed log is a preset encoding, determining a compression type and an identifier of the compressed log; and based on the compression type and the identifier, analyzing the compressed log to obtain an initial log.

[0012] According to an embodiment of the present application, the analyzing the compressed log based on the compression type and the identifier to obtain an initial log comprises: if the compression type is not a preset type, analyzing parameter compression information in the compressed log to obtain target dynamic information; and generating the initial log according to the target dynamic information, target parameter information in the compressed log, and the identifier.

[0013] According to an embodiment of the present application, the generating the initial log according to the target dynamic information, the target parameter information in the compressed log, and the identifier comprises: obtaining static information corresponding to the identifier; determining dynamic information in the compressed log that does not include a preset value as the target parameter information; and filling the target dynamic information and the target parameter information into the static information to obtain the initial log.

[0014] In another aspect, the application further provides a log processing device running on an embedded device, the log processing device comprising: a compression unit configured to compress static information in an initial log based on a preset correspondence between identifiers and strings to obtain a first compressed log; and the compression unit is further configured to compress target dynamic information in the first compressed log to obtain a second compressed log.

[0015] In another aspect, the application further provides a log processing system running on a computer device, the log processing system comprising: a determination module configured to determine a compression type and an identifier of a compressed log if a guide code in the compressed log is a preset code; and an analysis module configured to analyze the compressed log based on the compression type and the identifier to obtain an initial log.

[0016] In another aspect, the application further provides a storage medium having computer readable instructions stored therein, the computer readable instructions being executed by a processor in an electronic device to implement a log processing method.

[0017] In another aspect, the application further provides an electronic device, comprising: a memory storing computer readable instructions; and a processor executing the computer readable instructions stored in the memory to implement a log processing method.

[0018] The embodiments of the application improve the compression rate of the initial log by double compression of the initial log, thereby greatly saving the occupied space of the initial log and improving the storage density of the log, and also improve the execution efficiency of the initial log by the embedded device. In addition, when compressing the initial log, the embodiments of the application only compress the static information and the target dynamic information, which can achieve compression of the initial log while avoiding loss of dynamic information without preset values in the second compressed log. Since the dynamic information without preset values is usually valid information, the second compressed log can reflect important parameter information, thereby facilitating the viewing and analysis of the log by the operation and maintenance user.

[0019] In another aspect, the embodiments of the application analyze the parameter compression information when the compression type is not a preset type, which can obtain the target dynamic information in the compressed log and avoid invalid analysis of the parameter compression information, and then in combination with the target dynamic information, the identifier and the target parameter information in the compressed log, a complete initial log can be obtained. In addition, the initial log is obtained by decompression of the computer device, and since the execution performance of the computer device is better than that of the embedded device, the efficiency of obtaining the initial log is improved. BRIEF DESCRIPTION OF DRAWINGS

[0020] Figure 1 FIG. 1 is a structural schematic diagram of an electronic device for implementing a log processing method according to an embodiment of the present application.

[0021] Figure 2 FIG. 2 is a flowchart of a log processing method applied to an embedded device according to an embodiment of the present application.

[0022] Figure 3 FIG. 3 is a schematic diagram of the relationship between a compression type, a compression width, and a compression bit number according to an embodiment of the present application.

[0023] Figure 4 FIG. 4 is a schematic diagram of a second compressed log according to an embodiment of the present application.

[0024] Figure 5 FIG. 5 is a flowchart of a log processing method according to another embodiment of the present application.

[0025] Figure 6 FIG. 6 is a flowchart of a log processing method according to another embodiment of the present application.

[0026] Figure 7 FIG. 7 is a schematic diagram of address exchange in a cache area according to an embodiment of the present application.

[0027] Figure 8 FIG. 8 is a schematic diagram of address exchange in a cache area according to another embodiment of the present application.

[0028] Figure 9 FIG. 9 is a flowchart of a log processing method applied to a computer device according to an embodiment of the present application.

[0029] Figure 10 FIG. 10 is an interactive flowchart of a log processing method according to an embodiment of the present application.

[0030] Figure 11 FIG. 11 is a functional module diagram of a log processing apparatus running on an embedded device according to an embodiment of the present application.

[0031] Figure 12 FIG. 12 is a functional module diagram of a log processing apparatus running on a computer device according to an embodiment of the present application. DETAILED DESCRIPTION

[0032] In order to make the objects, technical solutions, and advantages of the present application clearer, the present application will be described in detail below with reference to the accompanying drawings and specific embodiments.

[0033] It should be noted that, in the present application, "at least one" means one or more, and "multiple" means two or more than two. The "and / or" describes the association between the associated objects, which means that there can be three kinds of relationships, for example, A and / or B can represent: A exists alone, A and B exist together, and B exists alone, where A and B can be singular or plural. The terms "first", "second", "third", "fourth" and the like (if any) in the specification and claims of the present application and the drawings are used to distinguish similar objects, and are not used to describe a specific order or sequence.

[0034] In the embodiments of the present application, the words such as "exemplary" or "for example" are used to mean an example, illustration, or description. Any embodiment or design solution described as "exemplary" or "for example" in the embodiments of the present application should not be interpreted as more preferred or more advantageous than other embodiments or design solutions. Rather, the use of "exemplary" or "for example" is intended to present relevant concepts in a specific manner. The embodiments described below and the features in the embodiments can be combined with each other without conflict, if necessary.

[0035] As shown in FIG. 1, it is a structural schematic diagram of an electronic device for implementing a log processing method provided by the embodiments of the present application. Figure 1

[0036] In the embodiments of the present application, the log processing method is applied to one or more electronic devices 1. The electronic device 1 is a device capable of automatically performing numerical calculation and / or information processing according to pre-set or stored computer readable instructions. The hardware thereof includes but is not limited to microprocessors, application specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), digital signal processors (DSPs), embedded devices, etc.

[0037] The electronic device 1 can be any kind of electronic product that can interact with the user, such as a personal computer, a tablet computer, a smart phone, a personal digital assistant (PDA), a game console, an interactive Internet Protocol Television (IPTV), a smart wearable device, etc.

[0038] ​The electronic device 1 can include a network device and / or a user device. The network device includes, but is not limited to, a single network electronic device, a group of electronic devices composed of multiple network electronic devices, or a cloud composed of a large number of hosts or network electronic devices based on cloud computing.

[0039] The network in which the electronic device 1 is located includes, but is not limited to, the Internet, a wide area network, a metropolitan area network, a local area network, a virtual private network (VPN), and the like.

[0040] In the embodiments of the present application, the electronic device 1 includes, but is not limited to, a memory 12, a processor 13, and computer readable instructions stored in the memory 12 and executable on the processor 13, such as a log processing program.

[0041] Those skilled in the art can understand that the schematic diagram is only an example of the electronic device 1 and does not constitute a limitation on the electronic device 1, and can include more or fewer components than the diagram, or combine certain components, or different components, for example, the electronic device 1 can also include an input / output device, a network access device, a bus, and the like.

[0042] The processor 13 can be a central processing unit (CPU), and can also be other general-purpose processors, digital signal processors (DSPs), application specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, and the like. The general-purpose processor can be a microprocessor or a processor, and can be any conventional processor, and the like. The processor 13 is the operation core and control center of the electronic device 1, and connects various parts of the entire electronic device 1 through various interfaces and lines, and executes the operating system of the electronic device 1 and various application programs, program codes, and the like installed.

[0043] The memory 12 can be an external memory and / or an internal memory of the electronic device 1. Further, the memory 12 can be a memory having a physical form, such as a memory stick, a TF card (Trans-flash Card), and the like.

[0044] In combination Figures 2-10 , the memory 12 in the electronic device 1 stores computer readable instructions, and the processor 13 can execute the computer readable instructions stored in the memory 12 to implement, for example Figures 2-10The log processing method shown.

[0045] As shown in Figure 2 FIG. 1 is a flowchart of a log processing method applied to an embedded device according to an embodiment of the present application. The order of the steps in the flowchart can be changed according to different requirements, and some steps can be omitted.

[0046] 201, compressing static information in the initial log based on a preset correspondence between identifiers and strings to obtain a first compressed log.

[0047] In at least one embodiment of the present application, the preset identifier can be information preset for uniquely representing a string, for example, the preset identifier can be set as 0x01, 0x02, etc. The string can be a string of characters composed of numbers, letters or underscores, for example, the string includes rdt_read(), remote_source, etc. The preset identifier and the string have a one-to-one correspondence, for example, the preset identifier 0x01 corresponds to the string rdt_read().

[0048] The initial log records log strings and parameter information. The log string is usually static information in the initial log, and the parameter information is usually dynamic information in the initial log. The parameter information can include parameters of any module in the embedded device, for example, if the embedded device is a smart watch, any module in the embedded device can include a "time" module, a "heart rate" module and a "blood pressure" module, and the corresponding parameter information can include time, heart rate and blood pressure, etc. Each module corresponds to a sensor, and the sensor is used to monitor the parameter information of the corresponding module, for example, the "heart rate" module corresponds to a heart rate sensor, and the heart rate sensor can monitor the heart rate of a user.

[0049] In at least one embodiment of the present application, the embedded device compresses the static information in the initial log based on the preset correspondence between the identifiers and the strings to obtain the first compressed log, including: obtaining an identifier corresponding to the static information from the correspondence, replacing the static information with the obtained identifier to obtain the first compressed log. This embodiment compresses the static information in the initial log based on the obtained identifier, realizes the compression of the initial log, and improves the storage density and transmission efficiency of the initial log.

[0050] 202, compressing target dynamic information in the first compressed log to obtain a second compressed log.

[0051] In at least one embodiment of the present application, the target dynamic information indicates parameter information with a preset numerical value, wherein the preset numerical value can be set as 0. For example, for a parameter "time" occupying 32 bits (4 bytes), if the parameter value corresponding to the parameter "time" is 10:00, since the parameter value corresponding to the parameter "time" has the preset numerical value 0, it is determined that the parameter "time" is the target dynamic information.

[0052] In at least one embodiment of the present application, the embedded device compresses the target dynamic information in the first compressed log to obtain the second compressed log, including: the embedded device obtains dynamic information with a preset numerical value from the first compressed log as the target dynamic information, and compresses the target dynamic information based on a bitmap method to obtain the second compressed log.

[0053] The second compressed log includes log header information and an identifier, and the identifier is used to indicate static information in the initial log. The second compressed log can further include parameter compression information corresponding to the target dynamic information, and / or target parameter information, wherein the target parameter information is dynamic information in the first compressed log except the target dynamic information.

[0054] The parameter compression information indicates information obtained after compression of the target dynamic information, and the number of compressed bits corresponding to the parameter compression information can be determined according to the number of bytes occupied by the parameter. For example, if the parameter value corresponding to the parameter "time" is 11:00, the number of bits occupied by the parameter "time" is 32 bits (corresponding to 4 bytes), wherein the first byte stores the value "1", the second byte stores the value "1", the third byte stores the value "0", and the fourth byte stores the value "0". The number of compressed bits corresponding to the parameter compression information of the parameter "time" can be 4 bits, and the value of each compressed bit can indicate the compression condition of each byte in the parameter "time". For example, the first byte stores the value "1" and the second byte stores the value "1", which indicates that the information stored in the first byte and the second byte does not need to be compressed, so the compressed bits corresponding to the first byte and the second byte can be set to 0. The third byte stores the value "0" and the fourth byte stores the value "0", which indicates that the information stored in the third byte and the fourth byte needs to be compressed, so the compressed bits corresponding to the third byte and the fourth byte can be set to 1. The parameter compression information of the parameter "time" is information obtained after compression of the parameter value stored in the third byte and the fourth byte, and the parameter information in the second compressed information is the information stored in the first byte and the second byte in the parameter "time".

[0055] The log header information can include a preamble, a compression type, a log length, and a check sum. The preamble is used to indicate whether the second compressed log is a compressed log. The compression type is used to indicate a compression width of parameters in the second compressed log. Different compression types indicate different compression widths, and the compression widths corresponding to different compression types can also be different. The compression width can also be determined according to the number of parameters. The log length indicates a length of valid data in the second compressed log. The check sum is used to check information in the second compressed log other than the log header information.

[0056] In combination Figure 3 It is explained that different compression types indicate different numbers of parameters. If the parameter compression information does not set the parameter compression bit, it indicates that the compression width of the parameter is 0 bit, and it indicates that there is no parameter information in the second compressed log. If the compression width of the parameter is 8 bits, it indicates that the number of parameters in the second compressed log does not exceed 2. If the compression width of the parameter is 16 bits, it indicates that the number of parameters in the second compressed log does not exceed 4. If the compression width of the parameter is 32 bits, it indicates that the number of parameters in the second compressed log does not exceed 8. If the compression width of the parameter is 64 bits, it indicates that the number of parameters in the second compressed log does not exceed 16. Figure 3 is an example when the parameter is 32 bits. Actually, the parameter can be 8 bits, 16 bits, or 64 bits. When the parameter is 8 bits, 16 bits, or 64 bits, the relationship between the corresponding compression width and the number of parameters is different from Figure 3 .

[0057] In combination Figure 4 It is explained that the log format of the second compressed log, as shown in Figure 4 , the log header information of the second compressed log corresponds to 4 bytes. The preamble, the compression type, the log length, and the check sum in the log header information each correspond to 1 byte. The identifier of the second compressed log can correspond to 4 bytes. The compression width of the parameter compression information in the second compressed log is 4 bytes, that is, 32 bits. Each target parameter information in the second compressed log can correspond to 1 byte.

[0058] The embodiment of the present application can improve the compression rate and storage density of the second compressed log by compressing the target dynamic information in a bitmap manner, and effectively improves the transmission efficiency of the second compressed log.

[0059] In at least one embodiment of the present application, the embedded device compresses the target dynamic information in a bitmap manner to obtain the second compressed log, including: the embedded device determining a total number of bytes occupied by the dynamic information in the first compressed log, determining a number of compressed bits based on the total number of bytes, setting a parameter compressed bit based on the number of compressed bits, setting the parameter compressed bit corresponding to the parameter value of the target dynamic information taking a preset value as a first value, setting the parameter compressed bit corresponding to the parameter value of the dynamic information not taking the preset value as a second value, and taking the parameter value of the dynamic information not taking the preset value as the target parameter information of the second compressed log.

[0060] wherein the number of compressed bits is equal to the total number of bytes. The first value and the second value are used to distinguish whether the dynamic information is compressed or not, and the first value is not equal to the second value, for example, the first value can be set as 1 and the second value can be set as 0.

[0061] The embodiment can save storage space to a certain extent, and improve the storage density and transmission efficiency of the second compressed log by compressing the target dynamic information taking the preset value.

[0062] In at least one embodiment of the present application, the embedded device calculates the compression rate based on the total number of bytes, the number of compressed bits and the number of bits occupied by the target parameter information. The formula for calculating the compression rate is: y=(8a1-a2-8b) / 8a1, wherein y represents the compression rate, a1 represents the total number of bytes, a2 represents the number of compressed bits, and b represents the number of bytes occupied by the target parameter information. For example, if the total number of bytes corresponding to a certain parameter is 4, the number of compressed bits is 4, and all dynamic information in the first compressed log needs to be compressed, the number of bits occupied by the target parameter information is 0, and the corresponding compression rate is: (32-4-0) / 32=87.5%. For another example, if the total number of bytes corresponding to two parameters is 8, the number of compressed bits is 8, and 4 bytes in the first compressed log are 0 and 4 bytes are non-0, the number of bits occupied by the target parameter information is 8*4=32, and the corresponding compression rate is: (64-8-32) / 64=37.5%. The embodiment of the present application can determine the compression degree of the initial log based on the determined compression rate, so as to determine the improvement degree of the storage density and the transmission efficiency.

[0063] In another embodiment, the log processing program can be integrated into a scanning tool, and the embedded device calls the scanning tool to process the obtained image file to generate a log database, wherein the first compressed log is stored in the log database.

[0064] The embodiment of the present application improves the compression rate of the initial log by double compression of the initial log, thereby greatly saving the occupied space of the initial log, improving the storage density of the log, and improving the execution efficiency of the initial log by the embedded device. In addition, when the initial log is compressed, only the static information and the target dynamic information are compressed, so that the initial log can be compressed while avoiding the loss of dynamic information without a preset value in the second compressed log. Since the dynamic information without a preset value is usually valid information, the second compressed log can reflect important parameter information, thereby facilitating the viewing and analysis of the log by the operation and maintenance user.

[0065] As shown in Figure 5 FIG. 1 is a flowchart of a log processing method according to an embodiment of the present application. The log processing method is applied to an embedded device. The steps in the flowchart can be changed in order according to different requirements, and some steps can be omitted.

[0066] 501, whether the initial log meets the output condition is determined by detecting the log level and the output capability.

[0067] In at least one embodiment of the present application, whether the initial log meets the output condition is determined by the embedded device through detection of the log level and the output capability, including: if the first level of the initial log meets the preset global level requirement, detecting whether the module corresponding to the initial log has output capability; if the module corresponding to the initial log has output capability, detecting whether the second level of the initial log meets the preset module level requirement; and if the second level meets the module level requirement, determining that the initial log meets the output condition.

[0068] The preset global level requirement is a parameter set in the log configuration, and the global level requirement is used to control the output level of the log in the embedded device. The first level can be a global static log level, and the first level can include multiple levels such as ERROR, WARN, INFO, and DEBUG, with the priority decreasing from high to low. For example, if the global level requirement is INFO, the logs of the levels of ERROR, WARN, and INFO will be recorded or output, and the log of the level of DEBUG will be ignored. In a production environment, the global level requirement is usually set to a higher level (such as INFO or WARN) to reduce the number of log outputs and improve the performance and stability of the system. In the development or debugging stage, the global level requirement can be set to a lower level (such as DEBUG) to obtain more detailed debugging information.

[0069] The preset module level requirement is a log level specially set for a certain module or component. By setting the module level requirement, the amount of log output of each module can be controlled to avoid excessive log generation of certain modules causing performance problems. For modules in the development stage or requiring special debugging, a lower module level requirement (such as DEBUG) can be set to obtain more detailed debugging information. For modules that have been running stably, a higher module level requirement (such as INFO or WARN) can be set to reduce unnecessary log output. For example, a higher module level requirement can be set for the "heart rate detection module", and a lower module level requirement can be set for the "step count detection module".

[0070] In this embodiment, if the initial log meets the output condition, step 502 is performed; if the initial log does not meet the output condition, step 504 is performed.

[0071] 502, based on the correspondence between the preset identifier and the string, the static information in the initial log is compressed to obtain a first compressed log.

[0072] 503, the target dynamic information in the first compressed log is compressed to obtain a second compressed log.

[0073] The details of steps 502-503 can be referred to the detailed description of steps 201-202 in the foregoing Figure 2 .

[0074] 504, filtering the initial log.

[0075] The embodiments of the present application can detect whether the initial log meets the global level requirement, realize static filtering of the initial log, reduce unnecessary compression processing of the initial log, and improve efficiency; further, when the initial log meets the global level requirement, detect whether the module corresponding to the initial log is enabled and whether the initial log meets the module level requirement, which can realize dynamic filtering of the initial log, further reduce unnecessary compression processing, and improve compression efficiency to a certain extent.

[0076] As shown in Figure 6 , it is a flowchart of a log processing method provided by another embodiment of the present application. The log processing method is applied in an embedded device, and the order of steps in the flowchart can be changed according to different requirements, and some steps can be omitted.

[0077] 601, based on the correspondence between the preset identifier and the string, the static information in the initial log is compressed to obtain a first compressed log.

[0078] 602, the target dynamic information in the first compressed log is compressed to obtain a second compressed log.

[0079] The details of steps 601-602 can refer to the details of steps 201-202 described above Figure 2 The details of steps 601-602 can refer to the details of steps 201-202 described above

[0080] 603, obtaining a target address from a free address list corresponding to the cache area.

[0081] In at least one embodiment of the present application, the storage space corresponding to the target address is empty, and the target address is any address in the free address list.

[0082] 604, storing the second compressed log according to the target address.

[0083] In at least one embodiment of the present application, the embedded device stores the second compressed log into the storage space corresponding to the target address in the cache area.

[0084] 605, after completing the storage of the second compressed log into the target address, moving the target address into a data address list corresponding to the cache area.

[0085] In at least one embodiment of the present application, the storage space corresponding to any address in the data address list is not empty.

[0086] In combination with Figure 7 Explain the exchange of the target address in the cache area. Obtain the target address add1 from the free address list Free list corresponding to the cache area, and store the second compressed log into the target address add1. If the storage of the second compressed log into the target address add1 is completed, move the target address add1 into the data address list Data list corresponding to the cache area.

[0087] In at least one embodiment of the present application, if the free address list is empty, the embedded device obtains the last address from the data address list corresponding to the cache area, and outputs the compressed log stored in the last address. When the output of the compressed log stored in the last address is completed, delete the last address from the data address list, and add the last address to the free address list.

[0088] In combination with Figure 8 Explain the exchange of the last address, as shown in Figure 8 Obtain the last address add1 from the data address list corresponding to the cache area. If the output of the compressed log in the last address add1 is completed, the embedded device moves the last address add1 into the free address list. This embodiment realizes the output of the compressed log in the cache area after the cache area is full of data, so that the subsequently generated compressed log can be cached, and the utilization rate of the cache area is improved.

[0089] In another embodiment, the compressed log in the cache area is stored in the storage medium of the embedded device.

[0090] The embodiment of the present application first stores the second compressed log into the target address, and then moves the target address into the data address list, which can avoid reading the second compressed log while writing the second compressed log into the target address, thus avoiding concurrent conflicts without setting a locking mechanism, saving running time, and further saving running time without copying the second compressed log when moving the target address.

[0091] As shown in Figure 9 FIG. 1 is a flowchart of a log processing method applied to a computer device according to an embodiment of the present application. The order of steps in the flowchart can be changed according to different requirements, and some steps can be omitted.

[0092] 901, if the guide code in the compressed log is a preset code, determine the compression type and identifier of the compressed log.

[0093] In at least one embodiment of the present application, the preset code is an identification code set by a user in advance, and the preset code indicates that the compressed log is a log after compression. The computer device detects whether the guide code in the compressed log is the preset code. If the guide code in the compressed log is not the preset code, and the guide code in the compressed log is code information indicating plaintext, the compressed log is displayed. If the guide code in the compressed log is not the preset code, and the guide code in the compressed log is not code information indicating plaintext, a prompt information that decompression is not supported is generated to prompt that the computer device cannot decompress the compressed log.

[0094] The compression type indicates the compression mode of the compressed log, and the identifier has a corresponding relationship with a string. The computer device obtains the compression type and identifier from a corresponding position in the compressed log based on the encoding mode of the compressed log.

[0095] 902, based on the compression type and identifier, parse the compressed log to obtain an initial log.

[0096] In at least one embodiment of the present application, the initial log can be obtained in an online manner, and the initial log can also be obtained in an offline manner.

[0097] In at least one embodiment of the present application, the computer device parses the compressed log based on the compression type and identifier to obtain the initial log, including: if the compression type is not a preset type, the computer device parses the parameter compression information in the compressed log to obtain target dynamic information, and the computer device generates the initial log according to the target dynamic information, target parameter information in the compressed log, and the identifier.

[0098] The preset type can indicate that all dynamic information in the compressed log does not have a preset value, which is usually set to 0. For example, the preset type can be set to typt0. The preset type can also indicate that the compressed log does not include target dynamic information. A compression type other than the preset type indicates that the compressed log contains dynamic information with a preset value; that is, the compressed log includes target dynamic information. Parameter compression information includes parameter values ​​with preset values ​​in the dynamic information, while target parameter information includes parameter values ​​without preset values ​​in the dynamic information.

[0099] In at least one embodiment of this application, the computer device generates an initial log based on target dynamic information, target parameter information in the compressed log, and an identifier, including: the computer device acquiring static information corresponding to the identifier; the computer device determining dynamic information in the compressed log that does not include a preset value as target parameter information; and filling the target dynamic information and target parameter information into the static information to obtain the initial log.

[0100] This embodiment can reconstruct the complete initial log by combining target dynamic information, target parameter information, and static information.

[0101] In another embodiment, if the compression type is a preset type, the computer device determines the dynamic information in the compression log that does not include the preset value as the target parameter information, and fills the target parameter information into the static information to obtain the initial log.

[0102] In another embodiment, if the compressed log does not include target parameter information, the computer device generates an initial log based on the target dynamic information and the identifier. Specifically, the computer device obtains the static information corresponding to the identifier and fills the static information with the target dynamic information to obtain the initial log.

[0103] In at least one embodiment of this application, after obtaining the initial log, the computer device displays and stores the initial log.

[0104] In this embodiment, when the compression type is not a preset type, the parameter compression information is parsed to obtain the target dynamic information in the compression log, avoiding invalid parsing of the parameter compression information. Furthermore, by combining the target dynamic information, the identifier, and the target parameter information in the compression log, a complete initial log can be obtained. In addition, the initial log is obtained by decompression from a computer device. Since the execution performance of a computer device is superior to that of an embedded device, the efficiency of obtaining the initial log is improved.

[0105] like Figure 10 The diagram shown is an interactive flowchart of a log processing method provided in one embodiment of this application. Depending on different requirements, the order of the steps in this flowchart can be changed, and some steps can be omitted.

[0106] 1001, the embedded device compresses the static information in the initial log based on the preset correspondence between the identifier and the string, to obtain a first compressed log.

[0107] 1002, the embedded device compresses the target dynamic information in the first compressed log, to obtain a second compressed log.

[0108] The detailed contents of steps 1001-1002 can refer to the detailed description of steps 201-202 in the above Figure 2 , which will not be repeated here.

[0109] 1003, the embedded device obtains a target address from the idle address list corresponding to the cache area.

[0110] 1004, the embedded device stores the second compressed log according to the target address.

[0111] 1005, after completing the storage of the second compressed log to the target address, the embedded device moves the target address into the data address list corresponding to the cache area.

[0112] The detailed contents of steps 1003-1005 can refer to the detailed description of steps 603-605 in the above Figure 6 , which will not be repeated here.

[0113] 1006, if the idle address list is empty, the embedded device obtains a tail address from the data address list.

[0114] 1007, the embedded device outputs the compressed log stored in the tail address to the computer device.

[0115] The detailed contents of steps 1006-1007 can refer to the detailed description of step 605 in the above Figure 6 , which will not be repeated here.

[0116] 1008, the computer device detects whether the boot code in the compressed log is a preset encoding.

[0117] 1009, if the boot code in the compressed log is the preset encoding, the computer device determines the compression type and the identifier of the compressed log.

[0118] 1010, the computer device analyzes the compressed log based on the compression type and the identifier, to obtain an initial log.

[0119] 1011, the computer device displays and stores the initial log.

[0120] The detailed contents of steps 1008-1011 can refer to the detailed description of steps 901-902 in the above Figure 9 , which will not be repeated here.

[0121] The embodiment of the present application improves the compression rate of the initial log by double compression of the initial log, thereby greatly saving the occupied space of the initial log, improving the storage density of the log, and improving the execution efficiency of the embedded device on the initial log. In addition, when compressing the initial log, the embodiment of the present application only compresses the static information and the target dynamic information, which can realize the compression of the initial log while avoiding the loss of dynamic information without preset values in the second compressed log. Since the dynamic information without preset values is usually valid information, the second compressed log can reflect important parameter information, thereby facilitating the viewing and analysis of the log by the operation and maintenance user. On the other hand, when the compression type is not the preset type, the embodiment of the present application analyzes the parameter compression information to obtain the target dynamic information in the compressed log, avoids invalid analysis of the parameter compression information, and then combines the target dynamic information, the identifier and the target parameter information in the compressed log to obtain the complete initial log. In addition, the initial log is obtained by decompression of the computer device. Since the execution performance of the computer device is better than that of the embedded device, the efficiency of obtaining the initial log is improved.

[0122] As shown in Figure 11 , it is a functional module diagram of the log processing device running in the embedded device provided by the embodiment of the present application. The embedded device can be an electronic device 1 as shown in Figure 1 , the log processing device 11 includes a compression unit 111, a detection unit 112, an acquisition unit 113, a storage unit 114, a transfer unit 115 and an output unit 116. The module / unit referred to by the present application refers to a series of computer readable instruction segments capable of being acquired by the processor 13 and capable of completing a fixed function, which is stored in the storage 12.

[0123] In some embodiments, the compression unit 111 is configured to compress the static information in the initial log based on the correspondence between the preset identifier and the string to obtain a first compressed log; and the compression unit 111 is configured to compress the target dynamic information in the first compressed log to obtain a second compressed log.

[0124] In some embodiments, before the compression unit 111 compresses the static information in the initial log based on the correspondence between the preset identifier and the string to obtain a first compressed log, the detection unit 112 is configured to determine whether the initial log meets an output condition through detection of the log level and the output capability.

[0125] In some embodiments, the detection unit 112 is specifically configured to: if the first level of the initial log meets the preset global level requirement, detect whether the module corresponding to the initial log has output capability; if the module corresponding to the initial log has the output capability, detect whether the second level of the initial log meets the preset module level requirement; and if the second level meets the module level requirement, determine that the initial log meets the output condition.

[0126] In some embodiments, the compression unit 111 is specifically configured to: obtain dynamic information with a preset value in the first compressed log as target dynamic information; and compress the target dynamic information based on a bitmap manner to obtain the second compressed log.

[0127] In some embodiments, after the target dynamic information in the first compressed log is compressed to obtain the second compressed log, the obtaining unit 113 is configured to obtain a target address from the idle address list corresponding to the cache area; the storage unit 114 is configured to store the second compressed log according to the target address; and the transfer unit 115 is configured to move the target address into the data address list corresponding to the cache area after the second compressed log is stored to the target address.

[0128] In some embodiments, the obtaining unit 113 is further configured to obtain a tail address from the data address list if the idle address list is empty; the output unit 116 is configured to output the compressed log stored in the tail address; and the transfer unit 115 is further configured to delete the tail address from the data address list and add the tail address to the idle address list when the compressed log stored in the tail address is completed.

[0129] The modules / units integrated in the electronic device 1 are implemented in the form of software function units and sold or used as independent products, which can be stored in a computer readable storage medium. Based on this understanding, all or part of the processes in the above-mentioned embodiment methods can also be completed by computer readable instructions instructing related hardware, and the computer readable instructions can be stored in a computer readable storage medium. When the computer readable instructions are executed by a processor, the steps of the above-mentioned various method embodiments can be implemented.

[0130] The computer readable instructions include computer readable instruction codes, which can be in the form of source code, object code, executable files or some intermediate forms, etc. The computer readable medium can include any entity or device capable of carrying computer readable instruction codes, recording medium, U disk, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM).

[0131] The memory 12 can be configured to store computer readable instructions and / or modules, and the processor 13 can implement various functions of the electronic device 1 by running or executing the computer readable instructions and / or modules stored in the memory 12 and calling data stored in the memory 12. The memory 12 can mainly include a storage program area and a storage data area, where the storage program area can store an operating system, at least one application program (such as a sound playing function, an image playing function, etc.) required by a function, etc.; and the storage data area can store data created according to use of the electronic device, etc. The memory 12 can include a non-volatile and volatile memory, for example, a hard disk, a memory, a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, at least one disk storage device, a flash memory device, or other storage devices.

[0132] For example, the computer readable instructions can be divided into one or more modules / units, which are stored in the memory 12 and executed by the processor 13 to complete the present application. One or more modules / units can be a series of computer readable instruction segments capable of completing a specific function, which are used to describe the execution process of the computer readable instructions in the electronic device 1. For example, the computer readable instructions can be divided into a compression unit 111, a detection unit 112, an acquisition unit 113, a storage unit 114, a transfer unit 115, and an output unit 116.

[0133] The detailed content of the functions of the modules / units can refer to the detailed description of the above Figures 2-8 , which will not be described here again.

[0134] The embodiment of the present application improves the compression rate of the initial log by double compression of the initial log, thereby greatly saving the occupied space of the initial log, improving the storage density of the log, and improving the execution efficiency of the initial log by the embedded device. In addition, when compressing the initial log, the embodiment of the present application only compresses the static information and the target dynamic information, which can realize compression of the initial log while avoiding loss of dynamic information without a preset value in the second compressed log. Since the dynamic information without a preset value is usually valid information, the second compressed log can reflect important parameter information, thereby being beneficial to viewing and analyzing of the log by the operation and maintenance user.

[0135] As Figure 12 shown is a functional module diagram of a log processing system provided by the embodiment of the present application running in a computer device. The computer device can be as Figure 1The electronic device 1 shown, the log processing system 21 includes a determination unit 210 and an analysis module 211. The module / unit referred to in the present application refers to a series of computer readable instruction segments capable of being acquired by the processor 13 and capable of completing a fixed function, which is stored in the memory 12.

[0136] In some embodiments, the determination module 210 is configured to determine the compression type and the identifier of the compressed log if the boot code in the compressed log is the preset encoding; and the analysis module 211 is configured to analyze the compressed log based on the compression type and the identifier to obtain the initial log.

[0137] In some embodiments, the analysis module 211 is specifically configured to: if the compression type is not the preset type, analyze the parameter compression information in the compressed log to obtain the target dynamic information; and generate the initial log according to the target dynamic information, the target parameter information in the compressed log, and the identifier.

[0138] In some embodiments, the analysis module 211 is specifically further configured to: obtain the static information corresponding to the identifier; determine the dynamic information in the compressed log that does not include the preset value as the target parameter information; and fill the target dynamic information and the target parameter information into the static information to obtain the initial log.

[0139] The modules / units integrated in the electronic device 1, if realized in the form of software function units and sold or used as independent products, can be stored in a computer readable storage medium. Based on such understanding, all or part of the processes in the above-mentioned embodiment methods can also be completed by computer readable instructions instructing related hardware, and the computer readable instructions can be stored in a computer readable storage medium. When the computer readable instructions are executed by the processor, the steps of each method embodiment can be implemented.

[0140] The computer readable instructions include computer readable instruction codes, which can be in the form of source code, object code, executable files, or some intermediate forms, etc. The computer readable medium can include any entity or device capable of carrying computer readable instruction codes, recording media, U disks, mobile hard disks, magnetic disks, optical disks, computer memories, read-only memories (ROM), random access memories (RAM).

[0141] The memory 12 can be configured to store computer readable instructions and / or modules, and the processor 13 can realize various functions of the electronic device 1 by running or executing the computer readable instructions and / or modules stored in the memory 12 and calling data stored in the memory 12. The memory 12 can mainly include a storage program area and a storage data area, where the storage program area can store an operating system, at least one application program (such as a sound playing function, an image playing function, etc.) required by a function, etc.; and the storage data area can store data created according to use of the electronic device, etc. The memory 12 can include a non-volatile and volatile memory, for example, a hard disk, a memory, a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, at least one disk storage device, a flash storage device, or other storage devices.

[0142] For example, the computer readable instructions can be divided into one or more modules / units, and the one or more modules / units are stored in the memory 12 and executed by the processor 13 to complete the present application. The one or more modules / units can be a series of computer readable instruction segments capable of completing a specific function, and the computer readable instruction segments are used to describe an execution process of the computer readable instructions in the electronic device 1. For example, the computer readable instructions can be divided into a determination unit 210 and an analysis module 211.

[0143] The detailed content of the functions of the modules / units can refer to the detailed description in the foregoing Figure 9 , which will not be described here again.

[0144] In the embodiments of the present application, when the compression type is not the preset type, the parameter compression information is analyzed, the target dynamic information in the compressed log can be obtained, invalid analysis of the parameter compression information is avoided, and then in combination with the target dynamic information, the identifier and the target parameter information in the compressed log, the complete initial log can be obtained. In addition, the initial log is obtained by decompression of the computer device, and since the execution performance of the computer device is better than that of the embedded device, the obtaining efficiency of the initial log is improved.

[0145] In several embodiments provided in the present application, it should be understood that the disclosed system, device and method can be implemented in other ways. For example, the device embodiments described above are only schematic, for example, the division of the modules is only a logical function division, and other division manners can be used in actual implementation.

[0146] The modules described as separate components may or may not be physically separate, and the components displayed as modules may or may not be physical units, i.e., may be located in one place, or may be distributed to multiple network units. Part or all of the modules can be selected according to actual needs to achieve the purpose of the embodiment.

[0147] In addition, each functional module in each embodiment of the present application can be integrated in one processing unit, or each unit can be physically present alone, or two or more units can be integrated in one unit. The integrated unit can be realized in the form of hardware or in the form of hardware plus software functional modules.

[0148] Therefore, from any point of view, the embodiments should be regarded as exemplary and non-limiting, the scope of the present application is defined by the appended claims rather than the above description, and therefore all changes falling within the meaning and scope of the equivalent elements of the claims are intended to be included in the present application. Any additional reference signs in the claims should not be considered as limiting the claims involved.

[0149] Furthermore, it is clear that the word "comprising" does not exclude other units or steps, and the singular does not exclude the plural. Multiple units or devices can also be implemented by one unit or device through software or hardware. The words first, second, etc. are used to indicate names and not any particular order.

[0150] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application and not to limit it, although the present application has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that the technical solutions of the present application can be modified or replaced by equivalents without departing from the spirit and scope of the technical solutions of the present application.

Claims

1. A log processing method applied to an embedded device, characterized in that, The log processing method comprises: Compressing static information in the initial log based on a preset correspondence between identifiers and strings to obtain a first compressed log; Compressing target dynamic information in the first compressed log to obtain a second compressed log.

2. The log processing method of claim 1, wherein, Before compressing static information in the initial log based on a preset correspondence between identifiers and strings to obtain a first compressed log, the method further comprises: Determining whether the initial log meets an output condition through log level and output capability detection.

3. The log processing method of claim 2, wherein, The determination whether the initial log meets the output condition through log level and output capability detection comprises: If a first level of the initial log meets a preset global level requirement, detecting whether a module corresponding to the initial log has output capability; If the module corresponding to the initial log has output capability, detecting whether a second level of the initial log meets a preset module level requirement; If the second level meets the module level requirement, determining that the initial log meets the output condition.

4. The log processing method of claim 1, wherein, The compression of target dynamic information in the first compressed log to obtain a second compressed log comprises: Obtaining dynamic information with a preset value from the first compressed log as the target dynamic information; Compressing the target dynamic information based on a bitmap method to obtain the second compressed log.

5. The log processing method of claim 1, wherein, After the compression of target dynamic information in the first compressed log to obtain a second compressed log, the method further comprises: Obtaining a target address from an idle address list corresponding to a cache area; Storing the second compressed log according to the target address; After completing the storage of the second compressed log to the target address, moving the target address into a data address list corresponding to the cache area.

6. The log processing method of claim 5, wherein, The method further comprises: If the idle address list is empty, obtaining a tail address from the data address list; Outputting a compressed log stored in the tail address; When the output of the compressed log stored in the tail address is completed, deleting the tail address from the data address list and adding the tail address to the idle address list.

7. A log processing method applied to a computer device, comprising: The log processing method comprises: If a boot code in a compressed log is a preset encoding, determining a compression type and an identifier of the compressed log; Based on the compression type and the identifier, parsing the compressed log to obtain an initial log.

8. The log processing method of claim 7, wherein, The parsing of the compressed log based on the compression type and the identifier to obtain an initial log comprises: If the compression type is not a preset type, parsing parameter compression information in the compressed log to obtain target dynamic information; Generating an initial log according to the target dynamic information, target parameter information in the compressed log, and the identifier.

9. The log processing method of claim 8, wherein, The generation of an initial log according to the target dynamic information, target parameter information in the compressed log, and the identifier comprises: Obtaining static information corresponding to the identifier; Determining dynamic information in the compressed log that does not include a preset value as the target parameter information; Filling the target dynamic information and the target parameter information into the static information to obtain the initial log.

10. An electronic device, comprising: Comprise: a memory storing computer readable instructions; and a processor executing the computer readable instructions stored in the memory to implement the log processing method as claimed in any one of claims 1 to 6, or the log processing method as claimed in any one of claims 7 to 9.