Log file processing method and apparatus, storage medium, and electronic device

By determining the target starting address and virtual address of the log file, and using the mapping relationship to decompress the log file, the problem of being unable to decompress was solved, and the system's locatability was improved.

CN116594970BActive Publication Date: 2026-04-17ZHEJIANG DAHUA TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
ZHEJIANG DAHUA TECH CO LTD
Filing Date
2023-05-12
Publication Date
2026-04-17

AI Technical Summary

Technical Problem

Existing technologies cannot decompress log files integrated with third-party libraries, making it impossible to locate problems.

Method used

By determining the target starting address and target starting virtual address of the compressed log file, and using the first and second mapping relationships, combined with the description information of static and dynamic link libraries, the log file is decompressed.

Benefits of technology

Recording more log files within the same storage space improves system location and enables efficient decompression of log files.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116594970B_ABST
    Figure CN116594970B_ABST
Patent Text Reader

Abstract

This application discloses a method, apparatus, storage medium, and electronic device for processing log files. The method includes: determining the target starting address of a compressed log file and the target starting virtual address of the compressed log file during operation; determining first description information of the compressed log file corresponding to the target starting address based on a first mapping relationship, wherein the first mapping relationship is used to characterize the mapping relationship between the starting address of the log file and the description information of the log file; determining second description information corresponding to the sum of the target starting virtual address and the target starting address based on a second mapping relationship; and decompressing the compressed log file based on the first description information and the second description information to obtain a decompressed log file. This application solves the problem of the inability to decompress log files.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of data processing, and more specifically, to a method and apparatus for processing log files, a storage medium, and an electronic device. Background Technology

[0002] Currently, with the rapid development of the Internet of Things, it is necessary to compress the system's log files according to certain strategies, so that log files can be recorded for a longer period of time within the same storage space. This avoids the phenomenon that the problem cannot be located due to the lack of log files because the recording time is too short.

[0003] In related technologies, a unique identifier is assigned to each log's static information by scanning the source code, and a mapping file is generated. When the log file is recorded, the unique identifier is recorded together with the dynamic information. When the log file is parsed, the corresponding static information is found according to the mapping file, and the obtained static information is combined with the dynamic information to form a complete log memory. However, in practical applications, if a third-party library is integrated, this part of the source code is generally not available, thus making it impossible to decompress the log file.

[0004] This shows that there is a problem with the related technology in that it cannot decompress log files. Summary of the Invention

[0005] This application provides a method and apparatus for processing log files, a storage medium, and an electronic device to at least solve the problem of being unable to decompress log files.

[0006] According to one aspect of the embodiments of this application, a method for processing log files is provided, comprising: determining a target starting address of a compressed log file and a target starting virtual address of the compressed log file during operation; determining first description information of the compressed log file corresponding to the target starting address based on a first mapping relationship, wherein the first mapping relationship is used to characterize the mapping relationship between the starting address of the log file and the description information of the log file; determining second description information corresponding to the sum of the target starting virtual address and the target starting address based on a second mapping relationship, wherein the second mapping relationship is used to characterize the mapping relationship between the sum of the starting virtual address and the starting address of the log file during operation and the description information of the log file; and decompressing the compressed log file based on the first description information and the second description information to obtain a decompressed log file.

[0007] Optionally, the method further includes: obtaining a compressed log file from the log printing interface.

[0008] Optionally, determining the target starting address of the compressed log file and the target starting virtual address of the compressed log file during operation includes: determining the target starting address based on the log printing interface and obtaining the target starting virtual address from the process data table in the compressed log file.

[0009] Optionally, the method further includes: obtaining static link library files and dynamic link library files of multiple clients, wherein the static link library files contain string constants corresponding to the description information of the log files, and the dynamic link library files contain string constants corresponding to the starting address and virtual starting address of the log files; converting the static link library files into executable files; constructing a first mapping relationship based on the executable files, and constructing a second mapping relationship based on the dynamic link library files.

[0010] Optionally, constructing a first mapping relationship based on the executable file includes: determining the mapping relationship between the character constants at each starting address stored in the executable file and the description information as the first mapping relationship.

[0011] Optionally, constructing a second mapping relationship based on the dynamic link library file includes: parsing the dynamic link library file to obtain a third mapping relationship between the starting address and description information of each character constant in the dynamic link library file; obtaining the starting virtual address of the dynamic link library file during runtime, and determining the string constant between the starting address and the starting virtual address; and determining the mapping relationship between the string constant and the description information based on the third mapping relationship to obtain the second mapping relationship.

[0012] Optionally, determining the first description information of the compressed log file corresponding to the target starting address based on the first mapping relationship includes: determining the description information corresponding to the string constant of the target starting address in the first mapping relationship as the first description information.

[0013] Optionally, determining the second description information corresponding to the sum between the target starting virtual address and the target starting address based on the second mapping relationship includes: determining the description information corresponding to the string constant between the target starting virtual address and the target starting address in the second mapping relationship as the second description information.

[0014] Optionally, based on the first description information and the second description information, the compressed log file is decompressed to obtain a decompressed log file, including: combining the first description information, the second description information and the variable information in the compressed file to obtain the decompressed log file.

[0015] According to another aspect of the embodiments of this application, a log file processing apparatus is also provided, comprising: a first determining module, configured to determine a target starting address of a compressed log file and a target starting virtual address of the compressed log file during operation; a second determining module, configured to determine first description information of the compressed log file corresponding to the target starting address based on a first mapping relationship, wherein the first mapping relationship is used to characterize the mapping relationship between the starting address of the log file and the description information of the log file; a third determining module, configured to determine second description information corresponding to the sum of the target starting virtual address and the target starting address based on a second mapping relationship, wherein the second mapping relationship is used to characterize the mapping relationship between the sum of the starting virtual address and the starting address of the log file during operation and the description information of the log file; and a processing module, configured to decompress the compressed log file based on the first description information and the second description information to obtain a decompressed log file.

[0016] According to another aspect of the embodiments of this application, a computer-readable storage medium is also provided, wherein a computer program is stored in the computer program, and the computer program is configured to execute the above-described log file processing method when running.

[0017] According to another aspect of the embodiments of this application, an electronic device is also provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the above-mentioned log file processing method through the computer program.

[0018] In this embodiment, the target starting address of the compressed log file and the target starting virtual address of the compressed log file during operation are determined; based on a first mapping relationship, first description information of the compressed log file corresponding to the target starting address is determined, wherein the first mapping relationship is used to characterize the mapping relationship between the starting address of the log file and the description information of the log file; based on a second mapping relationship, second description information corresponding to the sum of the target starting virtual address and the target starting address is determined, wherein the second mapping relationship is used to characterize the mapping relationship between the sum of the starting virtual address and the starting address of the log file during operation and the description information of the log file; based on the first description information and the second description information, the compressed log file is decompressed to obtain a decompressed log file. That is, in this embodiment of the application, by determining the target starting address of the executable file of the compressed log file and the target starting virtual address of the dynamic link library file of the compressed log file stored during the running process, the first description information and the second description information are further determined. Combined with the variable information, the log is decompressed. At the same time, based on the provided third-party static link library or dynamic link library, more log files can be recorded in the same storage space, thereby improving the system's locatability and achieving the technical effect of efficient decompression of log files. This solves the problem of being unable to decompress log files. Attached Figure Description

[0019] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.

[0020] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0021] Figure 1 This is a flowchart of a log file processing method according to an embodiment of this application;

[0022] Figure 2 This is a schematic diagram of a statically linked program compilation and execution process according to an embodiment of this application;

[0023] Figure 3 This is a schematic diagram of a query target starting address according to an embodiment of this application;

[0024] Figure 4 This is a schematic diagram illustrating the descriptive information corresponding to a target starting address according to an embodiment of this application;

[0025] Figure 5 This is a schematic diagram of a dynamically linked program compilation and execution process according to an embodiment of this application;

[0026] Figure 6 This is a general flowchart of log compression according to an embodiment of this application;

[0027] Figure 7 This is a flowchart illustrating the overall process of log decompression according to an embodiment of this application;

[0028] Figure 8 This is a schematic diagram of a log file processing apparatus according to an embodiment of this application;

[0029] Figure 9 This is a structural block diagram of an optional electronic device according to an embodiment of this application. Detailed Implementation

[0030] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present application, and not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort should fall within the scope of protection of the present application.

[0031] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.

[0032] According to one aspect of the embodiments of this application, a method for processing log files is provided. It should be noted that the steps shown in the flowcharts of the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions. Furthermore, although a logical order is shown in the flowcharts, in some cases, the steps shown or described may be executed in a different order than that shown here.

[0033] Figure 1 This is a flowchart of a log file processing method according to an embodiment of this application, such as... Figure 1As shown, the process of this method may include the following steps:

[0034] Step S102: Determine the target starting address of the compressed log file and the target starting virtual address of the compressed log file during operation.

[0035] In the technical solution provided in step S102 of this application, obtaining the compressed log file allows for the identification of the static link library file and the dynamic link library file within the compressed log file. The static link library file is then converted into an executable file, and the target starting address of the compressed log file is determined based on the executable file. Furthermore, the target starting virtual address stored during runtime is determined based on the dynamic link library file. Here, the target starting address can be an input parameter address, and the target starting virtual address can be the starting virtual memory address stored in the dynamic link library file of the compressed log file during runtime.

[0036] Optionally, the compressed log file includes static link library files and dynamic link library files. Static link library files can be converted into executable files, and the target starting address in the executable file can be determined based on the conversion rules of the static link description information. Similarly, the target starting virtual address in the dynamic link library can be determined based on the conversion rules of the dynamic link description information. The conversion rules for static link description information can be pre-set conversion rules. The conversion rules for dynamic link description information can also be pre-set conversion rules.

[0037] For example, to obtain a compressed log file, you can use a query command (e.g., "objdump -s executable filename|grep.rodata -A number of lines displayed") to process the executable file of the compressed log file. Since the executable file has already stored the string constant corresponding to the description information in the read-only data area, you can determine the starting address of the string constant and thus obtain the target starting address.

[0038] For example, by obtaining a compressed log file, one can determine the starting virtual memory address where the dynamic link library file of the compressed log file is stored during runtime, thereby obtaining the target starting virtual address.

[0039] Step S104: Determine the first description information of the compressed log file corresponding to the target starting address based on the first mapping relationship, wherein the first mapping relationship is used to characterize the mapping relationship between the starting address of the log file and the description information of the log file.

[0040] In the technical solution provided in step S104 of this application, the first mapping relationship can be used to characterize the mapping relationship between the starting address of the log file and the description information of the log file. Based on the first mapping relationship, the first description information of the executable file of the compressed log file corresponding to the target starting address can be determined. The description information of the log file can be represented in the form of a string constant, and the first description information can be the description information corresponding to the string constant of the target starting address.

[0041] Optionally, a first mapping relationship can be determined, which can be used to characterize the mapping relationship between the starting address of the log file and the description information of the log file. Based on the determined first mapping relationship, the first description information corresponding to the string constant of the target starting address can be determined.

[0042] For example, to obtain a compressed log file, you can use a query command to process the executable file of the compressed log file. Since the executable file stores the string constant corresponding to the description information in the read-only constant area, you can determine that the starting address of the string constant is the target starting address. You can further determine the first description information corresponding to the content of the target starting address by using a confirmation command (e.g., x / s$rdi).

[0043] Step S106: Determine the second description information corresponding to the sum of the target starting virtual address and the target starting address based on the second mapping relationship, wherein the second mapping relationship is used to characterize the mapping relationship between the sum of the starting virtual address and the starting address during the log file operation and the description file of the log file.

[0044] In the technical solution provided by step S106 of this application, the second mapping relationship is used to characterize the mapping relationship between the sum of the starting virtual address and the starting address of the log file during the operation process and the description file of the log file. Based on the second mapping relationship, the second description information corresponding to the sum of the target starting virtual address and the target starting address can be determined. The second description information can be the description information corresponding to the string constant of the sum of the target starting virtual address and the target starting address.

[0045] Optionally, a second mapping relationship can be determined, which is used to characterize the mapping relationship between the starting virtual address and the sum of the starting addresses of the log file during the operation process and the description file of the log file. Based on the determined second mapping relationship, a second description information corresponding to the string constant of the sum of the target starting virtual address and the target starting address can be determined.

[0046] For example, when obtaining a compressed log file, the dynamic link library file of the compressed log file is processed using a query command. Since the dynamic link library file has already stored the string constants corresponding to the description information in the read-only constant area, the target starting address of the string constant can be determined. It can also be determined that the starting virtual memory address of the dynamic link library file stored during the runtime is obtained, thus obtaining the target starting virtual address. Through a confirmation command, the string constant between the target starting virtual address and the target starting address can be determined. Based on the second mapping relationship, the second description information corresponding to the string constant between the two can be determined.

[0047] Step S108: Based on the first description information and the second description information, decompress the compressed log file to obtain a decompressed log file.

[0048] In the technical solution provided by step S108 of this application, the compressed log file is decompressed based on the determined first description information and second description information. The decompressed log file can be obtained by combining the determined first description information and second description information with the variable information.

[0049] Optionally, the compressed log file can be decompressed based on the determined first and second description information, and the determined first and second description information can be combined with variable information to generate a complete log file.

[0050] For example, by processing the executable file of the compressed log file using a query command, the starting address of the string constant corresponding to the description information can be determined as the target starting address. Further confirmation can confirm that the content at this target starting address is the first description information. Similarly, by processing the dynamic link library file of the compressed log file using a query command, the target starting address of the string constant corresponding to the description information can be determined, as well as the target starting virtual address stored in the dynamic link library file during runtime. Further confirmation can confirm that the sum of the target starting virtual address and the target starting address is the second description information. Based on the determined first and second description information, combined with variable information, a complete log file can be generated.

[0051] Through steps S102 to S108, by determining the target starting address of the executable file of the compressed log file and the target starting virtual address of the dynamic link library file of the compressed log file during operation, the first description information and the second description information are further determined. Combined with the variable information, the log decompression is completed. At the same time, based on the provided third-party static link library or dynamic link library, more log files can be recorded in the same storage space, improving the system's locatability and achieving the technical effect of efficient decompression of log files, thereby solving the problem of being unable to decompress log files.

[0052] The method described in this embodiment will be further described below.

[0053] In one exemplary embodiment, the method further includes: obtaining a compressed log file from a log printing interface.

[0054] In this embodiment, a compressed log file containing descriptive information and variable information to be printed can be generated at the log printing interface, and the compressed log file can be obtained from the log printing interface.

[0055] Optionally, a compressed log file can be generated at the log printing interface, and the compressed log file at the log printing interface can be obtained. The obtained compressed log file can be processed to obtain the first description information and the second description information. Combined with the variable information, the decompressed complete log file can be obtained.

[0056] This embodiment allows for the generation and acquisition of compressed log files from the log printing interface.

[0057] In another exemplary embodiment, determining the target starting address of the compressed log file and the target starting virtual address of the compressed log file during operation includes: determining the target starting address based on the log printing interface and obtaining the target starting virtual address from the process data table in the compressed log file.

[0058] In this embodiment, a compressed log file can be generated from the log printing interface, and the compressed log file at the log printing interface can be obtained. Based on the compressed log file obtained from the log printing interface, the target starting address can be determined, and the target starting virtual address can be determined from the process data table in the obtained compressed log file.

[0059] Optionally, during log compression, the target starting address corresponding to the first description information can be recorded in the log printing interface instead of recording the complete first description information, while variable information is also recorded. The starting virtual memory addresses of each dynamic link library file in the process data (maps) table can be recorded during program runtime, thus achieving the purpose of recording the target starting virtual address. Since the target starting address and target starting virtual address are recorded during compression, during log decompression, the target starting address of the compressed log file can be determined based on the executable file of the obtained compressed log file, and the target starting virtual address of the dynamic link library file stored during runtime can be determined. Furthermore, through the first mapping relationship with the target starting address and the second mapping relationship with the target starting virtual address, the first description information and the second description information are determined. Based on the determined first and second description information, the obtained compressed log file is decompressed, and combined with the variable information, the decompressed log file is obtained, thus completing the process of compressing and decompressing the log file.

[0060] Optionally, during the compression process, for integrated third-party libraries, a request can be made to have the third-party libraries provide a log registration interface (also known as a log printing interface). The interface implementing log compression can be registered with the third-party libraries, which then call the registered interface to achieve unified log compression. Alternatively, the logging interface of the third-party libraries can be rewritten, calling the logging interface to implement log compression. Furthermore, by adjusting the linking order of processes, the third-party libraries can use the rewritten interface to record information, thereby achieving the goal of unified compression.

[0061] For example, the target starting address corresponding to the first description information is recorded in the log printing interface instead of the complete first description information. Simultaneously, the target starting virtual address of each dynamic link library file in the process maps table is recorded during program runtime. By recording the sum of the target starting virtual address and the starting address, the complete second description information is replaced. Combined with the recorded variable information, log compression can be achieved. Since the log printing interface contains description information and variable information to be printed, a compressed log file can be obtained from the log printing interface. By processing the executable file of the compressed log file using query commands, the starting address of the string constant corresponding to the first description information can be determined. This determined starting address is the target starting address. Furthermore, the starting virtual memory address of the dynamic link library file in the process maps table during program runtime can also be determined, thus achieving the purpose of determining the target starting virtual address.

[0062] In this embodiment, a compressed log file can be obtained from the log printing interface. Based on the obtained compressed log file, the target starting address of the executable file of the compressed log file and the target starting virtual address of the dynamic link library file in the process maps table during program runtime can be determined.

[0063] In one exemplary embodiment, the method further includes: obtaining static link library files and dynamic link library files of multiple clients, wherein the static link library files contain string constants corresponding to the description information of the log files, and the dynamic link library files contain string constants corresponding to the starting address and virtual starting address of the log files; converting the static link library files into executable files; constructing a first mapping relationship based on the executable files, and constructing a second mapping relationship based on the dynamic link library files.

[0064] In this embodiment, multiple static and dynamic link library files from various clients can be obtained, and these static link library files can be converted into a single executable file. A first mapping relationship can be constructed based on the executable file, and a second mapping relationship can be constructed based on the dynamic link library files. The static link library files contain string constants corresponding to the description information of the log files, and the dynamic link library files contain string constants corresponding to the starting address and virtual starting address of the log files. The clients can be third-party information databases.

[0065] Optionally, after multiple static link library files are converted into an executable file, the string constants corresponding to the description information in the executable file can be stored in a read-only constant area beforehand. A query command can determine the starting address of this string constant, which is then designated as the target starting address. This establishes a relationship between the target starting address and the string constants corresponding to the description information, resulting in a first mapping relationship. Alternatively, the string constants corresponding to the description information in the dynamic link library files can be stored in a read-only constant area. A query command can determine the target starting address of these string constants. Simultaneously, during program runtime, the target starting virtual address of the dynamic link library file in the process maps table is determined. Based on the target starting address and the sum of the target starting virtual addresses, a relationship is established between their sum and the string constants corresponding to the description information, resulting in a second mapping relationship.

[0066] For example, the target starting address of a string constant stored in the read-only constant area of ​​the executable file can be used instead of the descriptive information to record it, thereby achieving the purpose of building a first mapping relationship based on the executable file. This target starting address is passed as a parameter when calling the logging interface and is obtained directly without any additional operations. The compression process is simple; the target starting address is recorded instead of the specific descriptive information. During decompression, the corresponding descriptive information is found in the output of the query command using this target starting address, and then combined with the recorded variable information to generate complete log information.

[0067] For example, during program runtime, the target starting address of a string constant stored in the read-only constant area can be used instead of the descriptive information to record it, thereby achieving the purpose of constructing a second mapping relationship based on the dynamic link library file. This target starting address is passed as a parameter when calling the logging interface and is obtained directly without any additional operations. The compression process is simple; it simply records the target starting address instead of the specific descriptive information. In addition, the target starting virtual address of the dynamic link library file in the program's runtime process maps table also needs to be recorded. During decompression, the target starting address is obtained through a query command, and then the recorded target starting virtual address is added to find the corresponding descriptive information. Combined with the recorded variable information, complete log information is generated.

[0068] In this embodiment, a first mapping relationship is constructed based on the executable files of multiple clients, and a second mapping relationship is constructed based on the dynamic link library files of multiple clients. When the target starting virtual address and the target starting address are summed in the second mapping relationship, the description information corresponding to the string constant of the sum is determined as the second description information.

[0069] In an exemplary embodiment, constructing a first mapping relationship based on an executable file includes: determining the mapping relationship between character constants at various starting addresses stored in the executable file and description information as the first mapping relationship.

[0070] In this embodiment, after obtaining the executable files of multiple clients, the mapping relationship between the character constants of each starting address and the description information stored in the obtained executable files is constructed as a first mapping relationship.

[0071] For example, after obtaining executable files from multiple clients, since the executable files store the string constants corresponding to the description information in the read-only constant area, the target starting address of the string constant can be determined by querying the command. The mapping relationship between the character constant at the determined target starting address and the description information is constructed as the first mapping relationship.

[0072] In this embodiment, a first mapping relationship is constructed based on the mapping relationship between the character constants of the target starting address stored in the determined executable file and the description information.

[0073] In an exemplary embodiment, constructing a second mapping relationship based on a dynamic link library file includes: parsing the dynamic link library file to obtain a third mapping relationship between the starting address and description information of each character constant in the dynamic link library file; obtaining the starting virtual address of the dynamic link library file during runtime, and determining a string constant that sums the starting address and the starting virtual address; and determining the mapping relationship between the string constant and the description information based on the third mapping relationship to obtain the second mapping relationship.

[0074] In this embodiment, the dynamic link library file is first parsed to obtain the mapping relationship between the target starting address and the description information of each character constant in the dynamic link library file. The obtained mapping relationship is determined as the third mapping relationship. Next, the starting virtual memory address stored in the dynamic link library file during runtime is obtained to determine the target starting virtual address. Based on the determined target starting address and target starting virtual address, the string constant of the sum of the two is further determined. Finally, based on the determined third mapping relationship, the mapping relationship between the determined target starting address and the string constant of the sum of the target starting virtual address and the description information is determined as the second mapping relationship.

[0075] For example, when parsing a dynamic link library (DLL) file, since the DLL file stores the string constants corresponding to its description information in the read-only constant area, the target starting address of these string constants can be determined using a query command. The mapping relationship between the determined starting address and the description information is then constructed as a third mapping relationship. Further, the target starting virtual address of the DLL file is obtained from the program's runtime process maps table. Based on the determined third mapping relationship, the mapping relationship between the determined target starting address, the string constant corresponding to the target starting virtual address, and the description information is determined as a second mapping relationship.

[0076] In this embodiment, the mapping relationship between the target starting address and the description information is constructed as a third mapping relationship. Based on the third mapping relationship, the mapping relationship between the string constant of the sum of the target starting address and the target starting virtual address and the description information is constructed as a second mapping relationship.

[0077] In an exemplary embodiment, determining the first description information of the compressed log file corresponding to the target starting address based on the first mapping relationship includes: determining the description information corresponding to the string constant of the target starting address in the first mapping relationship as the first description information.

[0078] In this embodiment, the first mapping relationship may include first description information corresponding to the string constant of the target starting address. The first description information may be determined based on the first mapping relationship. For example, the description information corresponding to the string constant of the target starting address may be determined from the first mapping relationship, and the first description information of the executable file that is a compressed log file may be determined.

[0079] For example, the executable file of the compressed log file stores the string constant corresponding to the description information in the read-only constant area. The target starting address of the string constant can be determined by querying the command. The mapping relationship between the determined target starting address and the description information is determined as the first mapping relationship. Based on the determined first mapping relationship, the description information corresponding to the string constant at the determined target starting address is determined as the first description information.

[0080] In this embodiment, the first description information is determined based on the description information corresponding to the string constant at the determined target starting address.

[0081] In an exemplary embodiment, determining the second description information corresponding to the sum of the target starting virtual address and the target starting address based on the second mapping relationship includes: determining the description information corresponding to the string constant of the sum of the target starting virtual address and the target starting address in the second mapping relationship as the second description information.

[0082] In this embodiment, the second mapping relationship may include second description information corresponding to a string constant that is the sum of the target starting virtual address and the target starting address. The second description information may be determined based on the second mapping relationship. For example, the description information corresponding to the string constant that is the sum of the target starting virtual address and the target starting address may be determined from the second mapping relationship, and the second description information of the dynamic link library file of the compressed log file may be determined.

[0083] For example, in a compressed log file, the dynamic link library (DLL) stores the string constant corresponding to the description information in the read-only constant area. A query command can determine the target starting address of this string constant. Further, the target starting virtual address of the DLL file in the program's runtime process maps table is obtained. The mapping relationship between the determined target starting address and the sum of the target starting virtual address and the description information is determined as the second mapping relationship. Based on this second mapping relationship, the description information corresponding to the string constant representing the sum of the determined target starting address and the target starting virtual address is determined as the second description information.

[0084] In this embodiment, the second description information is determined based on the description information corresponding to the string constant of the sum of the determined target starting address and the target starting virtual address.

[0085] In one exemplary embodiment, decompressing a compressed log file based on first description information and second description information to obtain a decompressed log file includes: combining the first description information, the second description information, and variable information in the compressed file to obtain the decompressed log file.

[0086] In this embodiment, based on the determined first mapping relationship and the second mapping relationship, the first description information and the second description information are determined from the determined first mapping relationship and the second mapping relationship. The determined first description information and the second description information are then combined with the variable information in the compressed file to obtain the decompression log file.

[0087] For example, the executable file of the compressed log file stores the string constants corresponding to the description information in the read-only constant area. A query command can determine the target starting address of this string constant. The mapping relationship between the determined target starting address and the description information is defined as the first mapping relationship. Based on the determined first mapping relationship, the description information corresponding to the string constant at the determined target starting address is defined as the first description information. The dynamic link library file of the compressed log file stores the string constants corresponding to the description information in the read-only constant area. A query command can determine the target starting address of this string constant. Further, the target starting virtual address of the dynamic link library file is obtained from the process maps table at runtime. The mapping relationship between the sum of the determined target starting address and the target starting virtual address and the description information is defined as the second mapping relationship. Based on the determined second mapping relationship, the description information corresponding to the string constant at the sum of the determined target starting address and the target starting virtual address is defined as the second description information. Based on the determined first and second description information, and combined with the recorded variable information, the log file is decompressed to obtain the decompressed log file.

[0088] In this embodiment, based on the determined first and second description information, and combined with variable information, a decompressed log file is obtained.

[0089] The following explanation, with reference to optional examples, illustrates the log file processing method in the embodiments of this application.

[0090] With the rapid development of the Internet of Things (IoT), more edge devices are running operating systems to achieve more intelligent functions. However, some devices have limited storage space due to their size, cost, and other factors, resulting in limited storage space allocated for log files. Within the same storage space, if the system needs to record too many log files, the recording time period will be relatively short. If the output log files are compressed according to a certain strategy, less information can be stored, allowing for a longer recording time range within the same storage space. Therefore, it is necessary to compress system log files according to a certain strategy to ensure that a longer recording time range can be achieved within the same storage space, thus avoiding the situation where insufficient log files prevent problem localization due to short recording periods.

[0091] In related technologies, a unique identifier is assigned to each log's static information by scanning the source code, and a mapping file is generated. During log recording, the unique identifier is recorded along with dynamic information. During log parsing, the corresponding static information is found based on the mapping file, and then combined with the dynamic information to form a complete log file. However, in practical applications, if a third-party library is integrated, this part of the source code is generally unavailable, resulting in the inability to decompress the log file. Therefore, it is evident that related technologies suffer from the problem of being unable to decompress log files.

[0092] However, this application proposes a log file processing method that, in the absence of access to the source code of a third-party library, can record more information within the same storage space by providing a third-party static or dynamic link library, thereby improving the system's locatability.

[0093] In this embodiment, the overall approach to compressing log files is as follows: the log printing interface contains descriptive information and variable information to be printed. Without compression, the descriptive information to be recorded in the log is typically a long string constant. If the descriptive information is converted into a number according to certain conversion rules, the information to be recorded consists of the corresponding numerical value and variable information. This overall approach to log file compression can compress the storage used for the descriptive information in each log record to within 8 bytes or 4 bytes. Since the descriptive information is generally quite long, the overall compression efficiency is considerable.

[0094] Figure 2 This is a schematic diagram of a statically linked program compilation and execution process according to an embodiment of this application, as shown below. Figure 2As shown, the process is as follows: the source code is compiled into object files by the compiler; multiple object files are merged into a static link library file using the backup compression command (AR command); and multiple static link library files are then linked by the linker to generate an executable file. During program execution, the loader loads the executable file into memory. The Central Processing Unit (CPU) reads instructions and data from memory to begin actually executing the program.

[0095] The static link description information conversion rule in this embodiment is as follows: the target starting address of the string constant stored in the executable file is used to replace the first description information. This target starting address is passed as a parameter when calling the logging interface and is obtained directly without any additional operations. The compression process is simple; the target starting address is recorded instead of the first description information. During decompression, the first description information corresponding to the target starting address can be found in the output of the query command through the target starting address. This information is then combined with the recorded variable information to generate a complete log file.

[0096] For example, the description information of a log interface is usually a string constant, such as "log data%s,len=%d\n". This string constant is stored in the read-only constant area when multiple static libraries are linked into an executable file. Therefore, you can view the information of the executable file's read-only constant area using the query command ("objdump -s executable filename|grep.rodata -A number of lines displayed").

[0097] For example, the executable file (process_a) is an executable file linked from a static library that calls the interface (logapi("log data%s,len=%d\n",data,len)). By using the query command ("objdump-sprocess_a|grep.rodata-A5"), we can see that the executable file (process_a) stores the string constant ("log data%s,len=%d\n") in the read-only constant area. Figure 3 This is a schematic diagram of a query target starting address according to an embodiment of this application, such as... Figure 3 As shown, the target starting address of this string constant is 0x400e18. When the process calls the interface (logapi("log data%s,len=%d\n",data,len)) at runtime, the value of the first parameter passed to the interface (logapi) is the target starting address of this string constant, 0x400e18.

[0098] For example, Figure 4 This is a schematic diagram illustrating the descriptive information corresponding to a target starting address according to an embodiment of this application, such as... Figure 4 As shown, taking a process compiled on an x86_64-bit CPU as an example, when debugging with a debugger (GNU symbolic debugger, abbreviated as gdb), it is confirmed that when calling the interface (logapi), the first parameter is passed through the destination index (rdi register), and its value is the target start address 0x400e18. It can be confirmed by the confirmation command (x / s$rdi) that its content is indeed the description information ("log data%s,len=%d\n").

[0099] For example, during decompression, the executable file is parsed using a parsing command (such as the objdump command). For instance, the output of the parsing command ("objdump -s process_a|grep.rodata -A5") yields the target starting address for each string constant. Based on the recorded target starting address 0x400e18, the corresponding first descriptive information ("logdata%s,len=%d\n") can be found. This information, combined with variable information, generates a complete log file.

[0100] Figure 5 This is a schematic diagram illustrating a dynamically linked program compilation and execution process according to an embodiment of this application, such as... Figure 5 As shown, the process is as follows: the source code is compiled into object files by the compiler, and the linker links multiple object files into a dynamic link library file. When compiling and linking the executable file, the name of the dynamic link library and the linker's search path are specified, allowing the dynamic link library file to be linked at runtime. At runtime, the loader loads the executable file into memory, loads the dynamic link library into the program using a lazy loading mechanism, and the CPU reads instructions and data from memory to begin actually executing the program.

[0101] The dynamic link description information conversion rule in this embodiment is as follows: the starting address of the string constant stored in the read-only constant area at process runtime is used to replace the second description information. This starting address is passed as a parameter when calling the logging interface and is obtained directly without any additional operations. The compression process is simple; the starting address is recorded instead of the second description information. Unlike the static link conversion rule, it is also necessary to read the maps table information at process runtime to obtain and record the starting virtual memory address after loading each dynamic link library. During decompression, the starting address of each constant can be obtained by querying the output of the command. Adding this to the recorded starting virtual memory address after loading the dynamic link library gives a correspondence with the target starting virtual address saved during compression. The corresponding second description information can then be found based on the recorded target starting virtual address, and combined with the recorded variable information, a complete log file is generated.

[0102] In this embodiment, dynamic linking differs from static linking. Dynamic linking uses a Global Offset Table (GOT) and a Procedure Link Table (PLT) to ensure that function code segments are shared across processes, while data segments are unique across different processes. The final addresses of constants in the read-only constant area of ​​the dynamic link library are determined only at runtime. Although the starting addresses of constants in the read-only constant area of ​​the dynamic link library are not the final addresses at runtime, the final addresses can be obtained by adding the starting addresses of the constants to the starting virtual memory address after the dynamic link library is loaded at runtime.

[0103] For example, the dynamic link library file (libtest.so) is a dynamic link library file that calls the interface (logapi("logdata%s,len=%d\n",data,len)), which can be accessed via query commands.

[0104] The command `objdump -s libtest.so|grep.rodata -A5` shows that the dynamic link library file (libtest.so) stores the string constant ("log data %s, len = %d\n") in its read-only constant area. The starting address of this string constant is 0xc36. The runtime maps table ( / proc / <process id> / maps file) of the process that linked the dynamic link library (libtest.so) shows that the starting virtual memory address after loading the dynamic link library file (libtest.so) is 0x7ffff79d6000. However, gdb debugging shows that the final address of the string constant in the input interface (logapi) is 0x7ffff79d6c36. Therefore, it can be confirmed that the final address is the starting address plus the starting virtual memory address. Thus, in a dynamic link library, the final address of each constant in the read-only constant area during process runtime is equal to the starting address of each constant in the read-only constant area of ​​the dynamic link library plus the starting virtual memory address after the dynamic link library is loaded during program runtime.

[0105] Figure 6 This is a general flowchart of log compression according to an embodiment of this application, such as... Figure 6 As shown, the process may include the following steps:

[0106] S602, process started.

[0107] S604, the log interface records the input parameter address and variable information of the description information.

[0108] Optionally, after the process starts, the input parameter address of the description information is recorded in the log interface instead of the complete description information, and the information of each variable is also recorded.

[0109] S606 records the starting virtual memory address and dynamic library name of each dynamic library in the process maps table when the process is running.

[0110] Optionally, the program also records the starting virtual memory address of each dynamic library in the process maps table ( / proc / <process id> / maps file) during runtime, which is used to determine the description information and dynamic library name.

[0111] The overall compression process described in this application is simple and highly reliable. For integrated third-party libraries, a request can be made to have them provide a log registration interface. The interface for implementing log compression can then be registered with the third-party library, which can then call this interface to achieve unified log compression. Alternatively, the logging interface of the third-party library can be rewritten, in which case the rewritten interface will call the logging interface to achieve log compression. Adjusting the linking order of processes allows the third-party library to use the rewritten interface to record information, thereby achieving the goal of unified compression.

[0112] Figure 7 This is a flowchart illustrating the overall process of log decompression according to an embodiment of this application, as follows: Figure 7 As shown, the process may include the following steps:

[0113] S701 parses the executable file and outputs the first mapping relationship between the target starting address and description information of each constant in the executable file obtained by linking static libraries.

[0114] Optionally, the executable file can be parsed using a parsing command ("objdump -s executable file|grep.rodata -A number of lines displayed"), and the output will obtain the first mapping relationship between the target starting address and description information of each constant in the executable file linked from static libraries.

[0115] S702 parses dynamic link library files and outputs the mapping relationship between the starting address and description information of each constant in each dynamic library.

[0116] Optionally, the dynamic link library file can be parsed using a parsing command. The parsing command ("objdump -s dynamic link library name|grep.rodata -A number of lines displayed") outputs the mapping relationship between the starting address and description information of each constant in each dynamic library.

[0117] S703, during the process of obtaining log records, reads the starting virtual memory addresses of each dynamic library after loading, which are recorded in the maps table during process runtime.

[0118] Optionally, during the log recording process, the starting virtual memory addresses of each dynamic library after loading are obtained from the maps table ( / proc / <process id> / maps file) recorded during process runtime.

[0119] S704, the starting address of each constant in each dynamic library and the starting address in the mapping relationship of the description information are uniformly added to the starting virtual memory address to obtain the second mapping relationship.

[0120] Optionally, the starting addresses in the mapping relationship between the starting addresses and description information of each constant in each dynamic library are uniformly added to the starting virtual memory addresses after loading of each dynamic library, which are recorded in the maps table during the process of reading the log records, to obtain the final address. The second mapping relationship between the final address and the description information can then be obtained.

[0121] S705 reads the compressed log file, finds the corresponding first description information and second description information in the first mapping relationship and the second mapping relationship according to the stored address information, and then combines the variable information to generate a complete log file.

[0122] According to another aspect of the embodiments of this application, a log file processing apparatus is also provided. Figure 8 This is a schematic diagram of a log file processing apparatus according to an embodiment of this application. Figure 8 As shown, the log file processing device 800 may include: a first determining module 802, a second determining module 804, a third determining module 806, and a processing module 808.

[0123] The first determining module 802 is used to determine the target starting address of the compressed log file and the target starting virtual address of the compressed log file during operation.

[0124] The second determining module 804 is used to determine the first description information of the compressed log file corresponding to the target starting address based on the first mapping relationship, wherein the first mapping relationship is used to characterize the mapping relationship between the starting address of the log file and the description information of the log file.

[0125] The third determining module 806 is used to determine the second description information corresponding to the sum of the target starting virtual address and the target starting address based on the second mapping relationship, wherein the second mapping relationship is used to characterize the mapping relationship between the sum of the starting virtual address and the starting address of the log file during the running process and the description information of the log file.

[0126] The processing module 808 is used to decompress the compressed log file based on the first description information and the second description information to obtain a decompressed log file.

[0127] In one exemplary embodiment, the apparatus further includes an acquisition module for acquiring a compressed log file from a log printing interface.

[0128] In an exemplary embodiment, the first determining module includes: a determining unit, configured to determine the target starting address based on the log printing interface, and obtain the target starting virtual address from the process data table in the compressed log file.

[0129] In one exemplary embodiment, the apparatus further includes: an acquisition module, configured to acquire static link library files and dynamic link library files of multiple clients, wherein the static link library files contain string constants corresponding to the description information of the log files, and the dynamic link library files contain string constants corresponding to the starting address and virtual starting address of the log files;

[0130] The conversion module is used to convert static link library files into executable files;

[0131] The building module is used to construct a first mapping relationship based on the executable file and a second mapping relationship based on the dynamic link library file.

[0132] In one exemplary embodiment, the building module includes:

[0133] The first determining unit is used to determine the mapping relationship between the character constants at each starting address stored in the executable file and the description information as the first mapping relationship.

[0134] In one exemplary embodiment, the building module further includes:

[0135] The parsing unit is used to parse dynamic link library files and obtain the third mapping relationship between the starting address and description information of each character constant in the dynamic link library file.

[0136] The second determining unit is used to obtain the starting virtual address of the dynamic link library file during runtime, and to determine the string constant between the starting address and the starting virtual address.

[0137] The third determining unit is used to determine the mapping relationship between the string constants and the description information based on the third mapping relationship, and to obtain the second mapping relationship.

[0138] In one exemplary embodiment, the second determining module includes:

[0139] The determining unit is used to determine the description information corresponding to the string constant of the target starting address in the first mapping relationship as the first description information.

[0140] In one exemplary embodiment, the third determining module includes:

[0141] The determining unit is used to determine the description information corresponding to the string constant that is the sum of the target starting virtual address and the target starting address in the second mapping relationship as the second description information.

[0142] In one exemplary embodiment, the processing module includes:

[0143] The combination unit is used to combine the first description information, the second description information, and the variable information in the compressed file to obtain the decompressed log file.

[0144] According to another aspect of the embodiments of this application, a storage medium is also provided. Optionally, in this embodiment, the storage medium can be used to execute program code for any of the log file processing methods described above in the embodiments of this application.

[0145] Optionally, in this embodiment, the storage medium may be located on at least one of the network devices in the network shown in the above embodiment.

[0146] Optionally, in this embodiment, the storage medium is configured to store program code for performing the following steps:

[0147] S1, determine the target starting address of the compressed log file, and the target starting virtual address of the compressed log file during operation;

[0148] S2, determine the first description information of the compressed log file corresponding to the target start address based on the first mapping relationship, wherein the first mapping relationship is used to characterize the mapping relationship between the start address of the log file and the description information of the log file;

[0149] S3, determine the second description information corresponding to the sum of the target starting virtual address and the target starting address based on the second mapping relationship, wherein the second mapping relationship is used to characterize the mapping relationship between the sum of the starting virtual address and the starting address of the log file during the running process and the description information of the log file;

[0150] S4. Based on the first description information and the second description information, decompress the compressed log file to obtain a decompressed log file.

[0151] Optionally, specific examples in this embodiment can refer to the examples described in the above embodiments, and will not be repeated in this embodiment.

[0152] Optionally, in this embodiment, the storage medium may include, but is not limited to, various media capable of storing program code, such as USB flash drives, ROMs, RAMs, portable hard drives, magnetic disks, or optical disks.

[0153] According to another aspect of the embodiments of this application, an electronic device for implementing the above-described log file processing method is also provided. The electronic device may be a server, a terminal, or a combination thereof.

[0154] Figure 9 This is a structural block diagram of an optional electronic device according to an embodiment of this application, such as... Figure 9 As shown, it includes a processor 902, a communication interface 904, a memory 906, and a communication bus 908. The processor 902, communication interface 904, and memory 906 communicate with each other via the communication bus 908.

[0155] Memory 906 is used to store computer programs;

[0156] When processor 902 executes a computer program stored in memory 906, it performs the following steps:

[0157] S1, determine the target starting address of the compressed log file, and the target starting virtual address of the compressed log file during operation;

[0158] S2, determine the first description information of the compressed log file corresponding to the target start address based on the first mapping relationship, wherein the first mapping relationship is used to characterize the mapping relationship between the start address of the log file and the description information of the log file;

[0159] S3, determine the second description information corresponding to the sum of the target starting virtual address and the target starting address based on the second mapping relationship, wherein the second mapping relationship is used to characterize the mapping relationship between the sum of the starting virtual address and the starting address of the log file during the running process and the description information of the log file;

[0160] S4. Based on the first description information and the second description information, decompress the compressed log file to obtain a decompressed log file.

[0161] Optionally, in this embodiment, the communication bus can be a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus, etc. This communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, Figure 9 The symbol is represented by a single thick line, but this does not indicate that there is only one bus or one type of bus. The communication interface is used for communication between the aforementioned electronic device and other devices.

[0162] The memory may include RAM, or non-volatile memory, such as at least one disk storage device. Optionally, the memory may also be at least one storage device located remotely from the aforementioned processor.

[0163] As an example, the memory 906 described above may include, but is not limited to, the first determining module 802, the second determining module 804, the third determining module 806, and the processing module 808 from the log file processing device described above. Furthermore, it may include, but is not limited to, other module units from the log file processing device described above, which will not be elaborated upon in this example.

[0164] The processors mentioned above can be general-purpose processors, including but not limited to: CPU (Central Processing Unit), NP (Network Processor), etc.; they can also be DSP (Digital Signal Processor), ASIC (Application Specific Integrated Circuit), FPGA (Field-Programmable Gate Array), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components.

[0165] Optionally, specific examples in this embodiment can refer to the examples described in the above embodiments, and will not be repeated here.

[0166] Those skilled in the art will understand that Figure 9 The structure shown is for illustrative purposes only. The device implementing the above log file processing method can be a terminal device, such as a smartphone (e.g., Android phone, iOS phone), tablet computer, PDA, mobile Internet Devices (MID), PAD, etc. Figure 9 This does not limit the structure of the aforementioned electronic device. For example, the electronic device may also include components that are more... Figure 9 The more or fewer components shown (such as network interfaces, display devices, etc.), or having the same Figure 9 The different configurations shown.

[0167] Those skilled in the art will understand that all or part of the steps in the various methods of the above embodiments can be implemented by a program instructing the hardware related to the terminal device. The program can be stored in a computer-readable storage medium, which may include: flash drive, ROM, RAM, disk or optical disk, etc.

[0168] The sequence numbers of the embodiments in this application are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.

[0169] If the integrated units in the above embodiments are implemented as software functional units and sold or used as independent products, they can be stored in the aforementioned computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause one or more computer devices (which may be personal computers, servers, or network devices, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application.

[0170] In the above embodiments of this application, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments.

[0171] In the several embodiments provided in this application, it should be understood that the disclosed client can be implemented in other ways. The device embodiments described above are merely illustrative; for example, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces, indirect coupling or communication connection between units or modules, and may be electrical or other forms.

[0172] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of the solution provided in this embodiment, depending on actual needs.

[0173] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.

[0174] The above description is merely a preferred embodiment of this application and is not intended to limit this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the principles of this application should be included within the protection scope of this application.

Claims

1. A method for processing log files, characterized in that, include: Determine the target starting address of the compressed log file, and the target starting virtual address of the compressed log file during runtime; The first description information of the compressed log file corresponding to the target start address is determined based on the first mapping relationship, wherein the first mapping relationship is used to characterize the mapping relationship between the start address of the log file and the description information of the log file; Based on the second mapping relationship, second description information corresponding to the sum of the target starting virtual address and the target starting address is determined, wherein the second mapping relationship is used to characterize the mapping relationship between the sum of the starting virtual address and the starting address of the log file during operation and the description information of the log file; Based on the first description information and the second description information, the compressed log file is decompressed to obtain a decompressed log file.

2. The method according to claim 1, characterized in that, The method further includes: Obtain the compressed log file from the log printing interface.

3. The method according to claim 2, characterized in that, Determining the target starting address of the compressed log file, and the target starting virtual address of the compressed log file during runtime, includes: The target starting address is determined based on the log printing interface, and the target starting virtual address is obtained from the process data table in the compressed log file.

4. The method according to claim 1, characterized in that, The method further includes: Obtain static link library files and dynamic link library files from multiple clients, wherein the static link library files contain string constants corresponding to the description information of the log files, and the dynamic link library files contain string constants corresponding to the starting address and the starting virtual address of the log files; Convert the static link library file into an executable file; The first mapping relationship is constructed based on the executable file, and the second mapping relationship is constructed based on the dynamic link library file.

5. The method according to claim 4, characterized in that, Constructing the first mapping relationship based on the executable file includes: The mapping relationship between the character constants at each starting address stored in the executable file and the description information is determined as the first mapping relationship.

6. The method according to claim 4, characterized in that, Constructing the second mapping relationship based on the dynamic link library file includes: Parse the dynamic link library file to obtain a third mapping relationship between the starting address of each character constant in the dynamic link library file and the description information; Obtain the starting virtual address of the dynamic link library file during runtime, and determine a string constant that is the sum of the starting address and the starting virtual address; Based on the third mapping relationship, the mapping relationship between the string constants of and and the description information is determined, and the second mapping relationship is obtained.

7. The method according to claim 1, characterized in that, Based on the first mapping relationship, the first description information of the compressed log file corresponding to the target starting address is determined, including: The description information corresponding to the string constant of the target starting address in the first mapping relationship is determined as the first description information.

8. The method according to claim 1, characterized in that, Based on the second mapping relationship, the second description information corresponding to the sum of the target starting virtual address and the target starting address is determined, including: The description information corresponding to the string constant that is the sum of the target starting virtual address and the target starting address in the second mapping relationship is determined as the second description information.

9. The method according to claim 1, characterized in that, Based on the first description information and the second description information, the compressed log file is decompressed to obtain a decompressed log file, including: The decompressed log file is obtained by combining the first description information, the second description information, and the variable information in the compressed log file.

10. A log file processing apparatus, characterized in that, include: The first determining module is used to determine the target starting address of the compressed log file, and the target starting virtual address of the compressed log file during operation; The second determining module is used to determine the first description information of the compressed log file corresponding to the target starting address based on the first mapping relationship, wherein the first mapping relationship is used to characterize the mapping relationship between the starting address of the log file and the description information of the log file; The third determining module is used to determine second description information corresponding to the sum of the target starting virtual address and the target starting address based on the second mapping relationship, wherein the second mapping relationship is used to characterize the mapping relationship between the sum of the starting virtual address and the starting address of the log file during operation and the description information of the log file; The processing module is used to decompress the compressed log file based on the first description information and the second description information to obtain a decompressed log file.

11. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, wherein the computer program, when executed by a processor, implements the steps of the method described in any one of claims 1 to 9.

12. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the steps of the method described in any one of claims 1 to 9.

Citation Information

Patent Citations

  • Method for writing program log into file, storage medium, electronic device and system

    CN109426496A

  • Log message transmission method and device of terminal equipment, equipment and medium

    CN113672482A