Log generation method and device, electronic equipment and storage medium
By dynamically generating dictionary table configuration files in the cloud and replacing the log function declaration prefix with identifiers, the problem of log file size and storage efficiency is solved, real-time optimization and efficient transmission of log files are achieved.
Patent Information
- Application Number
- CN202510564297.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-29
- Publication Date
- 2025-08-29
AI Technical Summary
In the prior art, the log file size cannot be effectively reduced during the log generation process, resulting in low storage space and transmission efficiency. Especially when the vehicle hardware storage space is difficult to expand after the vehicle side is fixed, the challenge of compressing logs is difficult to optimize during the generation process.
By scanning the new version of the software in the cloud, dynamically generate the dictionary table configuration file corresponding to the new version, use identifiers to replace the log function to declare prefix, reduce redundant characters, generate short identifiers, reduce log file size, and replace the dictionary table by downloading the new version of the dictionary table in the cloud.
Improves the real-time nature of the dictionary table, reduces log storage space, improves log transmission efficiency, and avoids the need for developers to manually maintain configuration files.
Smart Images

Figure CN120560964A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing technology, and more specifically, to a log generation method, device, electronic device, and storage medium. Background Art
[0002] Due to the high complexity of running applications or server-side programs, and the need to write specific log information to files in real time for troubleshooting and status monitoring, logging technology has become an indispensable foundational capability in production environments. This technology not only effectively supports fault diagnosis and system status monitoring, but also provides data support for business analysis. As log data volumes continue to grow, the need for log compression has emerged to reduce storage costs. Summary of the Invention
[0003] In view of this, embodiments of the present application propose a log generation method, device, electronic device, and storage medium to improve the above-mentioned problems.
[0004] In a first aspect, an embodiment of the present application provides a log generation method, the method comprising: receiving a second dictionary table corresponding to an upgraded version of a first software code sent by a cloud, wherein the second dictionary table is obtained by the cloud obtaining the changed content of the first software code compared to the second software code of the original version, and updating the first dictionary table corresponding to the second software code according to the changed content, the change including at least one of modification, addition and deletion, the changed content including at least one of a code file, a function declaration and a function definition, the table entries in the dictionary table including a combination name obtained by combining a function declaration with the code file where the function declaration is located, and an identifier corresponding to the combination name; in the process of generating the log generated when running the first software code, the combination name corresponding to the identifier is replaced based on the identifier in the second dictionary table to obtain the generated Log An embodiment of the present application provides a log generation method, the method comprising: receiving a second dictionary table corresponding to an upgraded version of a first software code sent by a cloud, wherein the second dictionary table is obtained by the cloud obtaining the changed content of the first software code compared to the original version of the second software code, and updating the first dictionary table corresponding to the second software code according to the changed content, the change including at least one of modification, addition and deletion, the changed content including at least one of a code file, a function declaration and a function definition, the table entries in the dictionary table including a combination name obtained by combining a function declaration with the code file where the function declaration is located, and an identifier corresponding to the combination name; in the process of generating the log generated when running the first software code, the combination name corresponding to the identifier is replaced based on the identifier in the second dictionary table to obtain the generated log.
[0005] In a second aspect, an embodiment of the present application provides a log generation method, the method comprising: receiving a second dictionary table corresponding to an upgraded version of a first software code sent by a cloud, wherein the second dictionary table is obtained by the cloud obtaining the changed content of the first software code compared to the original version of the second software code, and updating the first dictionary table corresponding to the second software code according to the changed content, the change including at least one of modification, addition and deletion, the changed content including at least one of a code file, a function declaration and a function definition, the table entries in the dictionary table including a combination name obtained by combining a function declaration with the code file where the function declaration is located, and an identifier corresponding to the combination name; in the process of generating the log generated when running the first software code, the combination name corresponding to the identifier is replaced based on the identifier in the second dictionary table to obtain the generated log.
[0006] In a third aspect, an embodiment of the present application provides a log generation device, which includes: a dictionary table receiving module and a log generation module. The dictionary table receiving module is used to receive a second dictionary table corresponding to an upgraded version of a first software code sent by the cloud, wherein the second dictionary table is obtained by the cloud obtaining the changed content of the first software code compared to the original version of the second software code, and updating the first dictionary table corresponding to the second software code according to the changed content, wherein the change includes at least one of modification, addition and deletion, and the changed content includes at least one of a code file, a function declaration and a function definition, and the table entry in the dictionary table includes a combination name obtained by combining the function declaration with the code file where the function declaration is located, and an identifier corresponding to the combination name; the log generation module is used to replace the combination name corresponding to the identifier based on the identifier in the second dictionary table in the process of generating the log generated when running the first software code, to obtain the generated log.
[0007] In a fourth aspect, an embodiment of the present application provides a log generation device, which includes: a change content acquisition module, a dictionary table update module, and a dictionary table sending module. The change content acquisition module is used to obtain the change content of the upgraded version of the first software code compared to the original version of the second software code, wherein the change includes at least one of modification, addition and deletion, and the change content includes at least one of code files, function declarations and function definitions; the dictionary table update module is used to update the first dictionary table corresponding to the second software code according to the change content, and obtain the second dictionary table corresponding to the first software code, the table entries in the first dictionary table and the second dictionary table include the combination name obtained by combining the function declaration and the code file where the function declaration is located, and the identifier corresponding to the combination name; the dictionary table sending module is used to send the second dictionary table to the vehicle, so that the vehicle replaces the combination name corresponding to the identifier based on the identifier in the second dictionary table in the process of generating the log generated when running the first software code, and obtains the generated log.
[0008] In a fifth aspect, an embodiment of the present application provides an electronic device comprising a memory and a processor, wherein the memory is coupled to the processor, and the memory stores instructions. When the instructions are executed by the processor, the processor executes the log generation method provided in the first aspect and the log generation method provided in the second aspect.
[0009] In a sixth aspect, an embodiment of the present application provides a computer-readable storage medium, in which program code is stored. The program code can be called by a processor to execute the log generation method provided in the first aspect and the log generation method provided in the second aspect.
[0010] In the solution of the present application, a second dictionary table corresponding to an upgraded version of a first software code is received from a cloud, wherein the second dictionary table is obtained by obtaining changes in the first software code compared to the original version of the second software code from the cloud, and updating the first dictionary table corresponding to the second software code based on the changes, wherein the changes include at least one of modification, addition, and deletion, and the changes include at least one of a code file, a function declaration, and a function definition. The entries in the dictionary table include a combination name obtained by combining the function declaration with the code file containing the function declaration, and an identifier corresponding to the combination name. In the process of generating a log generated when running the first software code, the combination name corresponding to the identifier is replaced based on the identifier in the second dictionary table to obtain the generated log. Thus, by scanning the new software version in the cloud, a dictionary table configuration file corresponding to the new version is dynamically generated, eliminating the need for developers to manually maintain the dictionary table configuration file, thereby improving the real-time performance of the dictionary table. By downloading the new version of the dictionary table from the cloud, the corresponding combination name is replaced based on the identifier included in the dictionary of the new version when the new software version is run, so that a large number of repeated log function declaration prefixes are replaced with short identifiers, reducing the size of the generated log, reducing the storage space of the log, and improving the efficiency of log transmission. BRIEF DESCRIPTION OF THE DRAWINGS
[0011] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present application. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.
[0012] Figure 1 A flow chart of a log generation method provided by an embodiment of the present application is shown;
[0013] Figure 2 A flow chart of a log generation method provided by an embodiment of the present application is shown;
[0014] Figure 3 A flow chart of a log generation method provided by an embodiment of the present application is shown;
[0015] Figure 4 A flow chart of a log generation method provided by an embodiment of the present application is shown;
[0016] Figure 5 A module block diagram of a log generation device provided by an embodiment of the present application is shown;
[0017] Figure 6 A module block diagram of a log generation device provided by an embodiment of the present application is shown;
[0018] Figure 7 A block diagram of an electronic device provided by an embodiment of the present application is shown;
[0019] Figure 8 A storage unit for storing or carrying program codes for implementing the log generation method according to an embodiment of the present application is shown. DETAILED DESCRIPTION
[0020] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application.
[0021] In order to better understand the solutions of the embodiments of the present application, the technical terms used in the embodiments of the present application are explained below.
[0022] The webhook mechanism is a lightweight communication mechanism based on HTTP callbacks that allows one application to automatically notify another application when a specific event occurs.
[0023] Over-The-Air (OTA) is a technology that remotely updates device firmware, software, or applications via wireless networks (such as 2G / 3G / 4G / WiFi).
[0024] GitLab is an open source version control system and DevOps platform based on Git, designed to help development teams with software development, version control, continuous integration (CI), continuous deployment (CD), project management, and other tasks.
[0025] The following is a detailed description of the implementation details of the technical solution of the embodiment of the present application:
[0026] Currently, in terms of log storage, the cloud can easily expand storage space by continuously adding servers and storage devices. The scale can be flexibly adjusted according to demand, and in the case of large-scale operations, the unit storage cost can be effectively reduced. However, after the design and manufacturing of the vehicle-side hardware equipment, its storage space is basically fixed and cannot be expanded as easily as the cloud. If the vehicle-side storage space is to be increased, it may be necessary to replace the entire hardware equipment or use more expensive storage chips, which will undoubtedly significantly increase costs. Therefore, there is a challenge in related technologies to compress logs.
[0027] Related technologies have proposed log compression algorithms such as Gzip, Deflate, and LZ77. The Gzip compression algorithm is an encapsulation of the Deflate algorithm, a lossless compression algorithm widely used for ZIP file compression and PNG image compression. Deflate combines LZ77 and Huffman coding. The LZ77 algorithm compresses raw data using the correlation between adjacent data. This module takes raw data as input and outputs literal and distance-length data pairs. Huffman coding performs statistical analysis on the LZ77 results to generate a Huffman table, which is then Huffman-encoded to achieve a high compression ratio. Alternatively, some methods first determine the length and probability of occurrence of each string in historical log files, then use the Huffman coding algorithm to determine the corresponding encoding element for each string. Based on the relationship between the string and the encoding element, the uncompressed log file is compressed. However, these methods are applied to the log file after it has been generated and cannot initially reduce the size of the generated log file. Therefore, related technologies present the challenge of optimizing log size during log generation.
[0028] In response to the above problems, the inventors have discovered after long-term research and proposed the log generation method, device and electronic device provided in the embodiments of the present application. By scanning the new version of the software in the cloud, the dictionary table configuration file corresponding to the new version is dynamically generated, eliminating the need for developers to manually maintain the dictionary table configuration file, thereby improving the real-time performance of the dictionary table. By downloading the new version of the dictionary table from the cloud, when running the new version of the software, the corresponding combination name is replaced based on the identifier included in the dictionary of the new version, so that a large number of repeated log function declaration prefixes are replaced by short identifiers, reducing the size of the generated log, reducing the storage space of the log, and improving the efficiency of log transmission. Among them, the specific log generation method is described in detail in the subsequent embodiments.
[0029] The embodiments of the present application will be described below with reference to the accompanying drawings.
[0030] See also Figure 1 , Figure 1 The flow chart of the log generation method provided by an embodiment of the present application is shown in FIG. In a specific embodiment, the log generation method can be applied to Figure 5 The log generating device 200 and the electronic device 100 ( Figure 7 ). The following will take electronic equipment as an example to illustrate the specific process of this embodiment. Of course, it can be understood that the electronic equipment used in this embodiment can include vehicles, vehicle-mounted terminals and other equipment, which are not limited here. Figure 1 The process shown is described in detail, and the log generation method may include the following steps:
[0031] Step S110: Receive a second dictionary table corresponding to the upgraded version of the first software code sent by the cloud, wherein the second dictionary table is obtained by the cloud obtaining the changed content of the first software code compared to the original version of the second software code, and updating the first dictionary table corresponding to the second software code according to the changed content, the change includes at least one of modification, addition and deletion, the changed content includes at least one of a code file, a function declaration and a function definition, and the table entries in the dictionary table include a combined name obtained by combining the function declaration and the code file where the function declaration is located, and an identifier corresponding to the combined name.
[0032] In some embodiments, the electronic device may receive a second dictionary table corresponding to an upgraded version of a first software code sent from the cloud. The second dictionary table may be obtained by obtaining from the cloud the changes in the first software code compared to the original version of the second software code, and updating the first dictionary table corresponding to the second software code based on the changes. The changes may include at least one of modification, addition, and deletion, and the changes may include at least one of a code file, a function declaration, and a function definition. The entries in the dictionary table may include a combined name obtained by combining a function declaration with the code file containing the function declaration, and an identifier corresponding to the combined name.
[0033] After obtaining the second dictionary table corresponding to the upgraded version of the first software code, the cloud can send upgrade information including a download address for the first software code to the electronic device. Alternatively, after receiving the upgrade information, the electronic device can, in response to the upgrade information, request the first software code and the second dictionary table corresponding to the first software code from the cloud. Alternatively, the electronic device can download the first software code from an associated cloud or electronic device.
[0034] For example, the cloud may include an upgrade package, which may include a first software code and a second dictionary table corresponding to the first software code. Accordingly, the electronic device may request the upgrade package from the cloud, execute the first software code included in the upgrade package, obtain operation data, and replace the combination name included in the operation data based on the identifier included in the second dictionary table to generate a log.
[0035] Step S120: In the process of generating a log generated when the first software code is run, the combination name corresponding to the identifier is replaced based on the identifier in the second dictionary table to obtain a generated log.
[0036] Among them, after obtaining the second dictionary table, the electronic device can replace the combination name corresponding to the identifier based on the identifier in the second dictionary table in the process of generating the log generated when running the first software code to obtain the generated log, so that a large number of repeated log function declarations are replaced by short identifiers, reducing the size of the formed log file and reducing the storage space of the log.
[0037] Step S130: In response to the log query instruction, based on the second dictionary table, the identifier included in the log is replaced with the combination name corresponding to the identifier and then output.
[0038] In some embodiments, the electronic device can receive a log query instruction and can, in response to the log query instruction, replace the identifier included in the obtained log with the combination name corresponding to the identifier based on the second dictionary table and then output it. Therefore, when querying the log and outputting the log, the second dictionary table is queried based on the identifier to obtain the combination name of the corresponding code file and function declaration, and the output log is assembled, that is, the identifier in the log is replaced with the corresponding combination name, thereby ensuring the integrity of the log.
[0039] An embodiment of the present application provides a log generation method, which receives a second dictionary table corresponding to an upgraded version of first software code sent by a cloud, wherein the second dictionary table is obtained by obtaining changes in the first software code compared to the original version of the second software code from the cloud, and updating the first dictionary table corresponding to the second software code based on the changes, wherein the changes include at least one of modification, addition, and deletion, and the changes include at least one of a code file, a function declaration, and a function definition. The entries in the dictionary table include a combination name obtained by combining the function declaration with the code file containing the function declaration, and an identifier corresponding to the combination name. Furthermore, during the process of generating a log generated when running the first software code, the combination name corresponding to the identifier is replaced based on the identifier in the second dictionary table to obtain the generated log. Thus, by scanning the new software version in the cloud, a dictionary table configuration file corresponding to the new version is dynamically generated, eliminating the need for developers to manually maintain the dictionary table configuration file, thereby improving the real-time performance of the dictionary table. Furthermore, by downloading the new version of the dictionary table from the cloud, the corresponding combination name is replaced based on the identifier included in the dictionary of the new version when the new software version is running, so that a large number of repeated log function declaration prefixes are replaced with short identifiers, reducing the size of the generated log, reducing the storage space of the log, and improving the efficiency of log transmission.
[0040] Among them, after obtaining the generated log, this embodiment can also respond to the log query instruction and, based on the second dictionary table, replace the identifier included in the log with the combination name corresponding to the identifier and then output it, thereby improving the integrity of the output log.
[0041] See also Figure 2 , Figure 2 The flow chart of the log generation method provided by an embodiment of the present application is shown in FIG. In a specific embodiment, the log generation method can be applied to Figure 6 The log generating device 300 and the electronic device 100 equipped with the log generating device 300 are shown. Figure 7 ). The following will take electronic equipment as an example to illustrate the specific process of this embodiment. Of course, it can be understood that the electronic equipment used in this embodiment can include computers, servers, vehicles, vehicle-mounted terminals and other equipment, which are not limited here. Figure 2 The process shown is described in detail, and the log generation method may include the following steps:
[0042] Step S210: Obtain the changed content of the upgraded version of the first software code compared to the original version of the second software code, wherein the change includes at least one of modification, addition and deletion, and the changed content includes at least one of code files, function declarations and function definitions.
[0043] In some embodiments, the electronic device may pre-store an original version of the second software code, and after obtaining the upgraded version of the first software code, the electronic device may obtain the changes in the upgraded version of the first software code compared to the original version of the second software code. The changes may include at least one of modification, addition, and deletion, and the changes may include at least one of a code file, a function declaration, and a function definition.
[0044] Among them, the electronic device can store the software code in a preset code repository, and can use the webhook mechanism of the code repository to trigger the code scanning program when the code repository manager adds a version tag to the stable branch, and scan out the newly added or modified code file names, function definitions and declarations in the project in the code repository. For example, after the development of the first software code of the upgraded version is completed, the vehicle-side developer can submit the first software code to the code repository of the electronic device, such as GitLab, etc. When the vehicle-side software has undergone a complete testing process and finally forms a stable version code, the electronic device can tag the stable version branch to indicate that this submission of this branch corresponds to the release of a version, and after tagging, the code repository's webhook mechanism can be used to trigger the code scanning program, and the code scanning program can be used to obtain the first software code from the code repository and scan and analyze it to obtain the newly added or modified code files, function declarations and definitions of the first software code compared to the previous old version code (the original version of the second software code).
[0045] Step S220: Update the first dictionary table corresponding to the second software code according to the changed content, and obtain the second dictionary table corresponding to the first software code, the table entries in the first dictionary table and the second dictionary table include a combined name obtained by combining the function declaration and the code file where the function declaration is located, and an identifier corresponding to the combined name.
[0046] In some embodiments, after obtaining the changes in the first software code compared to the second software code, the electronic device can update the first dictionary table corresponding to the second software code based on the changes to obtain the second dictionary table corresponding to the first software code. The entries in the first and second dictionary tables may include a combined name obtained by combining a function declaration with the code file containing the function declaration, and an identifier corresponding to the combined name. The identifier is unique and may include a code, a character, etc.
[0047] Among them, considering that the vehicle-side code has a fixed log format when outputting logs, for the function call log, the corresponding log will be output before requesting the function and after exiting the function. Usually there will be a fixed prefix character, that is, a combination of the code file name and the function declaration. For the call of the same function, this prefix is fixed. When a single function is called many times, there will be a lot of redundant log prefix characters, which will waste storage space. However, this part of the log is very helpful for troubleshooting problems with electronic equipment and cannot be removed. Based on this, this embodiment compresses and stores this part of the redundant log prefix. The combined name obtained by combining the function declaration with the code file where the function declaration is located is represented by an identifier to compress the log, reduce the storage cost of the vehicle side, and reduce the cost of log transmission.
[0048] For example, the identifier may be a code, and the function declaration code snippet of the demofile.c file is as follows:
[0049]
[0050] Accordingly, the electronic device scans the above code to form a dictionary table as follows:
[0051]
[0052] Here, "functiona" is a function declaration, "demofile.functiona" is the combined name obtained by combining the function declaration "functiona" with the code file "demofile.c" containing the function declaration, and "1" is the encoding of the combined name "demofile.functiona." This dictionary table allows us to determine the mapping between function declarations, the code file containing the function declaration, and identifiers.
[0053] In some embodiments, the changed content may include newly identified code files and function declarations. Accordingly, the electronic device can assign new identifiers to the newly identified code files and function declarations, form table entries of a new dictionary table configuration file, and save the newly compiled dictionary table configuration file to the configuration file repository corresponding to the first dictionary table to obtain a second dictionary table corresponding to the first software code.
[0054] Step S230: Send the second dictionary table to the vehicle so that the vehicle replaces the combination name corresponding to the identifier based on the identifier in the second dictionary table during the process of generating the log generated when running the first software code to obtain the generated log.
[0055] In some embodiments, after the electronic device obtains the second dictionary table corresponding to the first software code, it can send the second dictionary table to the vehicle so that the vehicle can replace the combination name corresponding to the identifier based on the identifier in the second dictionary table in the process of generating the log generated when running the first software code, and obtain the generated log. The electronic device can send the second dictionary table to the vehicle based on OTA technology; accordingly, the vehicle can install and run the first software code. Before and after the execution of the first software code, there will be corresponding operation data output, and the vehicle can output the log based on the operation data. Before the log is output, the vehicle can obtain the function declaration included in the operation data and the combination name of the code file where the function declaration is located, and query the second dictionary table based on the combination name to obtain the corresponding identifier, and replace the prefix of the lengthy combination name in the operation data with the identifier for log output, thereby effectively reducing the size of the log file. For example, when the log volume is large, the log output volume can be significantly reduced, reducing the space for log storage.
[0056] Exemplarily, before the vehicle installs and runs the first software code and replaces the combination name included in the running data, the log obtained is:
[0057]
[0058] After the vehicle replaces the combination name included in the operation data based on the identifier in the second dictionary, the log obtained is:
[0059]
[0060] Therefore, the dictionary table is used to replace a large number of redundant function declaration prefixes in the call log with short identifiers, which reduces the size of the log, saves log storage space, and improves log transmission efficiency.
[0061] A log generation method provided by an embodiment of the present application obtains the changes in the upgraded version of the first software code compared to the original version of the second software code, assigns a new identifier and dictionary table entry to the combined name obtained by combining the changed function declaration with the code file where the function declaration is located, updates the first dictionary table corresponding to the second software code, obtains the second dictionary table corresponding to the first software code and sends it to the vehicle, so that in the process of generating the log generated when the vehicle runs the first software code, the combination name corresponding to the identifier is replaced based on the identifier in the second dictionary table to obtain the generated log, thereby updating the dictionary table corresponding to the original version of the software code based on the changes in the new version of the software code compared to the original version of the software code, eliminating the need for developers to manually maintain the dictionary table configuration file, thereby improving the real-time performance of the dictionary table, and replacing the long and repeated prefixes of the log with short identifiers before the log is generated, thereby reducing the size of the log and the storage space of the log.
[0062] See also Figure 3 , Figure 3 The flow chart of the log generation method provided by an embodiment of the present application is shown. The method is applied to the above electronic device. Figure 3 The process shown is described in detail, and the log generation method may specifically include the following steps:
[0063] Step S310: Scan the second software code to obtain the function declaration included in the second software code and the code file where the function declaration is located.
[0064] In some embodiments, a code repository may be pre-set in the electronic device. Accordingly, the electronic device may obtain the second software code from the code repository and may scan and analyze the second software code to obtain the function declaration included in the second software code, the code file where the function declaration is located, the function definition, and other contents.
[0065] Step S320: Combine the function declaration included in the second software code and the code file where the function declaration is located to obtain a combination name corresponding to the second software code.
[0066] In some embodiments, after obtaining the function declaration included in the second software code and the code file containing the function declaration, the electronic device may combine the function declaration included in the second software code and the code file containing the function declaration to obtain a combined name corresponding to the second software code. It is understood that logs have a fixed log format and typically have a fixed prefix string, namely, a combination of the code file name and the function declaration. Based on this, in this embodiment, the combined name obtained by combining the function declaration and the code file containing the function declaration can be determined as the prefix string.
[0067] Step S330: Generate an identifier corresponding to the combination name corresponding to the second software code.
[0068] In some embodiments, after the electronic device determines the combination name corresponding to the second software code, it may generate an identifier corresponding to the combination name corresponding to the second software code. The number of combination names may be one or more, and different combination names correspond to different identifiers, i.e., the identifier is unique. The identifier may include content such as a code and characters.
[0069] Step S340: Use the combination name corresponding to the second software code and the identifier corresponding to the combination name corresponding to the second software code as table entries to generate the first dictionary table, wherein the first dictionary table includes the mapping relationship between the combination name corresponding to the second software code and the identifier corresponding to the combination name corresponding to the second software code.
[0070] In some embodiments, after obtaining the combination name corresponding to the second software code and the identifier corresponding to the combination name, the electronic device may use the combination name and the identifier corresponding to the combination name as table entries to generate a first dictionary table. The first dictionary table includes a mapping relationship between the combination name corresponding to the second software code and the identifier corresponding to the combination name corresponding to the second software code. The combination name and the identifier may have a one-to-one correspondence.
[0071] In some embodiments, after obtaining the first dictionary table, the electronic device may transmit the first dictionary table to the vehicle. This allows the vehicle to replace the combination name corresponding to the identifier in the first dictionary table with the identifier when generating a log generated when running the second software code, thereby generating the generated log. Alternatively, the electronic device may also embed the first dictionary table into the software package corresponding to the second software code during packaging. This allows the log dictionary table configuration file dynamically generated by code scanning to be transmitted to the vehicle along with the software package. This effectively optimizes the size of the log generated during software execution and log output on the vehicle.
[0072] Step S350: Obtain the changed content of the upgraded version of the first software code compared to the original version of the second software code, wherein the change includes at least one of modification, addition and deletion, and the changed content includes at least one of code files, function declarations and function definitions.
[0073] For the detailed description of step S350, please refer to the above description of step S210, which will not be repeated here.
[0074] Step S360: Update the first dictionary table corresponding to the second software code according to the changed content, and obtain the second dictionary table corresponding to the first software code. The table entries in the first dictionary table and the second dictionary table include a combined name obtained by combining the function declaration and the code file where the function declaration is located, and an identifier corresponding to the combined name.
[0075] As an implementable method, in a process in which an electronic device updates a first dictionary table corresponding to a second software code based on changes in the first software code compared to the second software code, if it is detected that the changes include a newly added function declaration, the electronic device can combine the newly added function declaration and the code file containing the newly added function declaration to obtain a newly added combination name, generate a new identifier corresponding to the newly added combination name, and add the new identifier and the new combination name as table entries to the first dictionary table. This assigns a new code and dictionary entry to the newly added function declaration, thereby improving the effectiveness of the log.
[0076] As another possible implementation, if the electronic device detects that the changed content includes a modified code file, it can modify the combination name corresponding to the modified code file in the first dictionary table based on the name of the modified code file. This allows the dictionary table entries to be modified in real time, ensuring the accuracy and validity of the dictionary table contents. This streamlines the dictionary table contents, avoids wasting storage space due to invalid content in the dictionary table, and improves the effectiveness of the log.
[0077] As another possible implementation, if the electronic device detects that the changed content includes a modified function declaration, it can modify the combination name corresponding to the modified function declaration in the first dictionary table based on the modified function declaration. This allows the dictionary table entries to be modified in real time, ensuring the accuracy and validity of the dictionary table contents, streamlining the dictionary table contents, avoiding wasted storage space due to invalid entries in the dictionary table, and improving the effectiveness of the log.
[0078] As another feasible method, if the electronic device detects that the changed content includes a deleted function declaration, it can delete the identifier and combination name corresponding to the deleted function declaration in the first dictionary table, thereby ensuring the accuracy and validity of the dictionary table content, streamlining the dictionary table content, avoiding wasting storage space due to invalid content in the dictionary table, and improving the validity of the log.
[0079] As an implementable method, if the electronic device detects that the changed content includes a deleted code file, the identifier and combination name corresponding to the deleted code file in the first dictionary table can be deleted, thereby ensuring the accuracy and validity of the dictionary table content, streamlining the dictionary table content, avoiding the waste of storage space due to invalid content in the dictionary table, and improving the validity of the log.
[0080] Step S370: Based on the first software code and the second dictionary table, an upgrade software package is generated, and the upgrade software package is sent to the vehicle, so that when the vehicle generates a log generated when running the first software code, the combination name corresponding to the identifier is replaced based on the identifier in the second dictionary table to obtain the generated log.
[0081] In some embodiments, after the electronic device obtains the second dictionary table corresponding to the first software code, it can generate an upgrade software package based on the first software code and the second dictionary table, and send the upgrade software package to the vehicle, so that when the vehicle generates a log generated when running the first software code, it replaces the combination name corresponding to the identifier based on the identifier in the second dictionary table to obtain the generated log. In particular, the electronic device can use a sustainable integration tool to pull the first software code from the code repository for compilation and packaging, and can pull the dictionary table configuration file of the second dictionary table from the dictionary table configuration file repository during the compilation and packaging process, and can use the sustainable integration tool to embed the second dictionary table into the software package corresponding to the first software code and store it in the vehicle-side software package repository.
[0082] For example, see Figure 4 , which shows a flow chart of the log generation method provided by an embodiment of the present application. Among them, the electronic device can be understood as the cloud, and the electronic device can include a code repository, a configuration file repository, and a vehicle-side software package repository. Among them, the cloud can receive the upgraded version of the first software code submitted to the code repository (such as GitLab, etc.) by the vehicle-side developer after the code development is completed. Among them, the original version of the second software code can be pre-stored in the code repository. Among them, the cloud can also receive the tag that the code repository manager puts on the stable version branch when the second software code has undergone a complete testing process and finally forms a stable version code; wherein, the tag can be used to indicate that this submission of this branch corresponds to the release of a version.
[0083] After obtaining the tag corresponding to the first software code, the cloud can use the webhook mechanism of the code repository to trigger the code scanning program. The code scanning program obtains the first software code from the code repository and scans and analyzes it, obtaining the code files, function declarations, and definitions that are newly added or modified in the first software code compared to the second software code, and assigning new codes to these newly identified code files and function declarations to form new entries in the dictionary table configuration file, and save the newly compiled dictionary table configuration file to the configuration file repository. The configuration file repository can pre-store the configuration file of the first dictionary table corresponding to the second software code.
[0084] The cloud can also use a sustainable integration tool to pull the second software code from the code repository for compilation and packaging. During the compilation and packaging process, the dictionary table configuration file corresponding to the first dictionary table can be pulled from the dictionary table configuration file repository. Based on the code packaging program, the first dictionary table can be built-in and stored in the vehicle-side software package corresponding to the second software code. Finally, the new version of the software package (upgraded software package) is saved to the vehicle-side software package repository. In this way, the cloud uses a code scanning program to scan the new version of the vehicle-side software code, dynamically allocates the code file name combined with the identifier of the function declaration, and uses this as the key value to add a new dictionary table item, ultimately forming a new version of the dictionary table configuration file.
[0085] Among them, after the cloud stores the upgrade software package in the vehicle-side software package warehouse, it can publish the upgrade information including the download address of the upgrade software package to the vehicle-side through the cloud-based OTA server. After receiving the upgrade information, the vehicle-side can request the cloud-based OTA server to download the upgrade software package, install and run the upgrade software package, obtain the operation data corresponding to the second software code, and replace the combination name included in the operation data based on the identifier in the second dictionary table to generate a log, so that the vehicle-side can use the built-in dictionary table of the software to map and replace the log prefix when the function call log is output, thereby reducing the output of the function log, saving the storage space of the log file, and improving the transmission efficiency of the log file.
[0086] Compared with the log generation method provided by an embodiment of the present application, Figure 2In the log generation method shown, this embodiment can also scan the second software code to obtain function declarations included in the second software code and the code files containing the function declarations before updating the first dictionary table corresponding to the second software code based on the changes to obtain the second dictionary table corresponding to the first software code; combine the function declarations included in the second software code and the code files containing the function declarations to obtain a combination name corresponding to the second software code; generate an identifier corresponding to the combination name corresponding to the second software code; and use the combination name corresponding to the second software code and the identifier corresponding to the combination name corresponding to the second software code as table entries to generate a first dictionary table, wherein the first dictionary table includes a mapping relationship between the combination name corresponding to the second software code and the identifier corresponding to the combination name corresponding to the second software code. Therefore, before updating the dictionary table corresponding to the original version of the software code based on the changes between the new version of the software code and the original version of the software code and obtaining the dictionary table configuration of the new version, the dictionary table corresponding to the original version of the software code is obtained, thereby improving the validity of the dictionary table content. Dictionary table entries can be added and the dictionary table configuration file can be distributed to the vehicle without the need for developers to manually maintain the dictionary table configuration file, thereby improving the user experience. At the same time, this embodiment can also generate an upgrade software package based on the first software code and the second dictionary table, and send the upgrade software package to the vehicle, so that in the process of packaging the second software code, the second dictionary table is built into the software package, so that when the vehicle-side software runs the second software code to output the log, by querying the second dictionary table, the long and repeated prefixes of the log are replaced with short identifiers before the log is output, which effectively reduces the size of the log file and improves the data transmission efficiency and effectiveness.
[0087] See also Figure 5 , Figure 5 The module block diagram of the log generation device provided by an embodiment of the present application is shown. The log generation device 200 is applied to the above electronic device. Figure 5 The process shown in FIG. 1 is described in detail. The log generating device 200 includes: a dictionary table receiving module 210 and a log generating module 220, wherein:
[0088] The dictionary table receiving module 210 is used to receive a second dictionary table corresponding to an upgraded version of a first software code sent by the cloud, wherein the second dictionary table is obtained by the cloud obtaining the changed content of the first software code compared to the original version of the second software code, and updating the first dictionary table corresponding to the second software code according to the changed content, the change includes at least one of modification, addition and deletion, the changed content includes at least one of a code file, a function declaration and a function definition, and the table entries in the dictionary table include a combined name obtained by combining the function declaration and the code file where the function declaration is located, and an identifier corresponding to the combined name.
[0089] The log generating module 220 is configured to replace the combination name corresponding to the identifier based on the identifier in the second dictionary table during the process of generating the log generated when the first software code is run, to obtain the generated log.
[0090] Furthermore, after obtaining the generated log, the log generating device 200 may further include a log output unit, wherein:
[0091] The log output unit is configured to, in response to a log query instruction, replace the identifier included in the log with a combination name corresponding to the identifier based on the second dictionary table and then output the replaced identifier.
[0092] See also Figure 6 , Figure 6 The module block diagram of the log generation device provided by an embodiment of the present application is shown. The log generation device 300 is applied to the above electronic device. Figure 6 The process shown in FIG. 1 is described in detail. The log generating device 300 includes: a change content obtaining module 310, a dictionary table updating module 320, and a dictionary table sending module 330, wherein:
[0093] The change content acquisition module 310 is used to obtain the change content of the upgraded version of the first software code compared to the original version of the second software code, wherein the change includes at least one of modification, addition and deletion, and the change content includes at least one of code files, function declarations and function definitions.
[0094] The dictionary table update module 320 is used to update the first dictionary table corresponding to the second software code according to the changed content, and obtain the second dictionary table corresponding to the first software code. The table entries in the first dictionary table and the second dictionary table include a combined name obtained by combining the function declaration and the code file where the function declaration is located, and an identifier corresponding to the combined name.
[0095] The dictionary table sending module 330 is used to send the second dictionary table to the vehicle so that the vehicle can replace the combination name corresponding to the identifier based on the identifier in the second dictionary table to obtain the generated log when generating the log generated when running the first software code.
[0096] Furthermore, the dictionary table updating module 320 may include: a first updating unit, and / or a second updating unit, and / or a third updating unit, and / or a fourth updating unit, wherein:
[0097] The first update unit is used to combine the newly added function declaration and the code file where the newly added function declaration is located to obtain a newly added combination name if the changed content includes a newly added function declaration, and generate a new identifier corresponding to the newly added combination name, and add the new identifier and the new combination name as table entries to the first dictionary table.
[0098] The second updating unit is configured to modify the combination name corresponding to the modified code file in the first dictionary table according to the name of the modified code file if the changed content includes a modified code file.
[0099] The third updating unit is configured to modify the combination name corresponding to the modified function declaration in the first dictionary table according to the modified function declaration if the changed content includes the modified function declaration.
[0100] The fourth updating unit is configured to delete the identifier and the combination name corresponding to the deleted function declaration in the first dictionary table if the changed content includes a deleted function declaration.
[0101] Furthermore, before updating the first dictionary table corresponding to the second software code according to the changed content and obtaining the second dictionary table corresponding to the first software code, the log generating device 300 may further include: a second software code scanning unit, a combination name obtaining unit, an identifier generating unit, and a first dictionary table generating unit, wherein:
[0102] The second software code scanning unit is configured to scan the second software code to obtain the function declaration included in the second software code and the code file where the function declaration is located.
[0103] The combination name obtaining unit is configured to combine the function declaration included in the second software code and the code file where the function declaration is located to obtain a combination name corresponding to the second software code.
[0104] The identifier generating unit is configured to generate an identifier corresponding to the combination name corresponding to the second software code.
[0105] The first dictionary table generating unit is used to generate the first dictionary table by taking the combination name corresponding to the second software code and the identifier corresponding to the combination name corresponding to the second software code as table entries, wherein the first dictionary table includes a mapping relationship between the combination name corresponding to the second software code and the identifier corresponding to the combination name corresponding to the second software code.
[0106] Furthermore, the dictionary table sending module 330 may include: an upgrade software package sending unit, wherein:
[0107] An upgrade software package sending unit is configured to generate an upgrade software package based on the first software code and the second dictionary table, and send the upgrade software package to the vehicle.
[0108] Those skilled in the art will clearly understand that, for the convenience and brevity of description, the specific working processes of the above-described devices and modules can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0109] In several embodiments provided in this application, the coupling between modules may be electrical, mechanical or other forms of coupling.
[0110] In addition, the functional modules in the various embodiments of the present application may be integrated into a processing module, or each module may exist physically separately, or two or more modules may be integrated into a single module. The above-mentioned integrated modules may be implemented in the form of hardware or software functional modules.
[0111] See also Figure 7 , which shows a structural block diagram of an electronic device provided in an embodiment of the present application. The electronic device 100 can be a device with processing capabilities, such as a vehicle, an on-board terminal, a server, a computer, etc. The electronic device 100 in the present application may include one or more of the following components: a processor 110, a memory 120, and one or more application programs, wherein the one or more application programs can be stored in the memory 120 and configured to be executed by one or more processors 110, and the one or more programs are configured to execute the method described in the aforementioned method embodiment.
[0112] The processor 110 may include one or more processing cores. The processor 110 utilizes various interfaces and circuits to connect various components within the electronic device 100. It executes instructions, programs, code sets, or instruction sets stored in the memory 120, as well as accesses data stored in the memory 120, to perform various functions of the electronic device 100 and process data. Optionally, the processor 110 may be implemented using at least one of the following hardware forms: a digital signal processing (DSP), a field-programmable gate array (FPGA), or a programmable logic array (PLA). The processor 110 may integrate one or a combination of a central processing unit (CPU), a graphics processing unit (GPU), and a modem. The CPU primarily processes the operating system, user interface, and application programs; the GPU is responsible for rendering and drawing displayed content; and the modem handles wireless communications. It is understood that the modem may not be integrated into the processor 110 and may be implemented separately via a communications chip.
[0113] The memory 120 may include a random access memory (RAM) or a read-only memory (ROM). The memory 120 may be used to store instructions, programs, codes, code sets, or instruction sets. The memory 120 may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for implementing at least one function (such as a touch function, a sound playback function, an image playback function, etc.), instructions for implementing the following various method embodiments, etc. The data storage area may also store data created by the electronic device 100 during use (such as a phone book, audio and video data, chat history data, etc.).
[0114] See also Figure 8 , which shows a block diagram of a computer-readable storage medium provided in an embodiment of the present application. The computer-readable medium 400 stores program code, which can be called by a processor to execute the method described in the above method embodiment.
[0115] The computer-readable storage medium 400 can be an electronic memory such as a flash memory, an EEPROM (Electrically Erasable Programmable Read-Only Memory), an EPROM, a hard disk, or a ROM. Alternatively, the computer-readable storage medium 400 includes a non-transitory computer-readable storage medium. The computer-readable storage medium 400 has storage space for program code 410 for executing any of the method steps in the above method. These program codes can be read from or written to one or more computer program products. The program code 410 can be compressed, for example, in a suitable form.
[0116] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present application.
Claims
1. A log generation method, characterized in that: The method comprises: Receiving a second dictionary table corresponding to an upgraded version of a first software code sent by a cloud, wherein the second dictionary table is obtained by obtaining, by the cloud, changes in the first software code compared to an original version of a second software code, and updating the first dictionary table corresponding to the second software code according to the changes, the changes including at least one of modification, addition, and deletion, the changes including at least one of a code file, a function declaration, and a function definition, and entries in the dictionary table including a combined name obtained by combining a function declaration and a code file containing the function declaration, and an identifier corresponding to the combined name; In the process of generating the log generated when the first software code is run, the combination name corresponding to the identifier is replaced based on the identifier in the second dictionary table to obtain the generated log.
2. The method according to claim 1, characterized in that After obtaining the generated log, the method further includes: In response to the log query instruction, based on the second dictionary table, the identifier included in the log is replaced with the combined name corresponding to the identifier and then output.
3. A log generation method, characterized in that: The method comprises: Obtaining changes in the upgraded version of the first software code compared to the original version of the second software code, wherein the changes include at least one of modification, addition, and deletion, and the changes include at least one of a code file, a function declaration, and a function definition; updating a first dictionary table corresponding to the second software code according to the changed content to obtain a second dictionary table corresponding to the first software code, wherein entries in the first dictionary table and the second dictionary table include a combined name obtained by combining a function declaration and a code file containing the function declaration, and an identifier corresponding to the combined name; The second dictionary table is sent to the vehicle so that the vehicle replaces the combination name corresponding to the identifier based on the identifier in the second dictionary table during the process of generating the log generated when the first software code is run, to obtain the generated log.
4. The method according to claim 3, characterized in that The updating of the first dictionary table corresponding to the second software code according to the changed content includes: If the changed content includes a newly added function declaration, combining the newly added function declaration and the code file containing the newly added function declaration to obtain a newly added combination name, generating a new identifier corresponding to the newly added combination name, and adding the new identifier and the newly added combination name as table entries to the first dictionary table; and / or If the changed content includes a modified code file, modifying the combination name corresponding to the modified code file in the first dictionary table according to the name of the modified code file; and / or If the changed content includes a modified function declaration, modifying the combination name corresponding to the modified function declaration in the first dictionary table according to the modified function declaration; and / or If the changed content includes a deleted function declaration, the identifier and the combination name corresponding to the deleted function declaration in the first dictionary table are deleted.
5. The method according to claim 3, characterized in that Before updating the first dictionary table corresponding to the second software code according to the changed content to obtain the second dictionary table corresponding to the first software code, the method further includes: Scanning the second software code to obtain a function declaration included in the second software code and a code file where the function declaration is located; combining the function declaration included in the second software code and the code file containing the function declaration to obtain a combination name corresponding to the second software code; generating an identifier corresponding to the combination name corresponding to the second software code; The first dictionary table is generated by taking the combination name corresponding to the second software code and the identifier corresponding to the combination name corresponding to the second software code as table entries, wherein the first dictionary table includes the mapping relationship between the combination name corresponding to the second software code and the identifier corresponding to the combination name corresponding to the second software code.
6. The method according to any one of claims 3 to 5, characterized in that: The sending the second dictionary table to the vehicle includes: An upgrade software package is generated based on the first software code and the second dictionary table, and the upgrade software package is sent to the vehicle.
7. A log generation device, characterized in that: The device comprises: a dictionary table receiving module, configured to receive a second dictionary table corresponding to an upgraded version of a first software code sent by a cloud, wherein the second dictionary table is obtained by obtaining, by the cloud, changes in the first software code compared to an original version of a second software code, and updating the first dictionary table corresponding to the second software code according to the changes, wherein the changes include at least one of modification, addition, and deletion, and the changes include at least one of a code file, a function declaration, and a function definition; an entry in the dictionary table includes a combined name obtained by combining a function declaration with the code file containing the function declaration, and an identifier corresponding to the combined name; The log generation module is used to replace the combination name corresponding to the identifier based on the identifier in the second dictionary table in the process of generating the log generated when the first software code is run, so as to obtain the generated log.
8. A log generation device, characterized in that: The device comprises: a change content acquisition module, configured to acquire change content of the upgraded version of the first software code compared to the original version of the second software code, wherein the change includes at least one of modification, addition, and deletion, and the change content includes at least one of a code file, a function declaration, and a function definition; a dictionary table updating module, configured to update a first dictionary table corresponding to the second software code according to the changed content, and obtain a second dictionary table corresponding to the first software code, wherein entries in the first dictionary table and the second dictionary table include a combined name obtained by combining a function declaration with a code file containing the function declaration, and an identifier corresponding to the combined name; The dictionary table sending module is used to send the second dictionary table to the vehicle so that the vehicle can replace the combination name corresponding to the identifier based on the identifier in the second dictionary table to obtain the generated log when generating the log generated when running the first software code.
9. An electronic device, characterized in that: include: one or more processors; Memory; One or more application programs, wherein the one or more application programs are stored in the memory and configured to be executed by the one or more processors, and the one or more programs are configured to execute the method according to any one of claims 1 to 6.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores program code, which can be called by a processor to execute the method according to any one of claims 1 to 6.