Log management method, log management device, storage medium and electronic equipment
By compressing and storing the parameter information and variable values of log information in the embedded log management system, the problem of large space occupancy of log files is solved and more efficient log file storage is achieved.
Patent Information
- Application Number
- CN202311576268.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-11-23
- Publication Date
- 2025-05-23
AI Technical Summary
The existing embedded log management system uses plain text strings when storing log files, which consumes a large amount of storage space and cannot effectively save a large number of log files, affecting the system's operation efficiency.
By determining the parameter information of the log function corresponding to the log information to be managed, the variable value is determined according to the number of parameters, and the parameter information and variable value are compressed to obtain the compressed log and store the compressed log.
It effectively reduces the storage space occupied by log files, increases the number of stored log files, reduces the number of erases, and improves the storage efficiency of log files.
Smart Images

Figure CN120029971A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technology, and in particular to a log management method, a log management device, a storage medium, and an electronic device. Background Art
[0002] Network devices, system platforms, and service programs running in network devices and system platforms will generate an event record called a log when they are in operation, also known as a log file. When users perform some operations on service programs, these log files usually record some relevant content of the operations, which is very useful for system security personnel, such as being able to trace the source. Therefore, log files are usually stored so that when problems occur in subsequent service programs, the source of the problem can be traced.
[0003] At present, embedded log management systems store log files in the form of strings in storage media. As the service program runs longer, more and more log files are generated, which increases the storage space occupied, resulting in the storage medium being unable to save more log files. Summary of the invention
[0004] The purpose of the present disclosure is to provide a log management method, a log management device, a storage medium and an electronic device to solve the technical problems existing in the related art.
[0005] In order to achieve the above object, the present disclosure provides a log management method in a first aspect, the log management method comprising:
[0006] Determine parameter information of a log function corresponding to the log information to be managed, wherein the parameter information includes at least the number of parameters;
[0007] According to the number of the parameters, determining the variable value corresponding to each of the parameters;
[0008] Compressing the parameter information and the variable value corresponding to each parameter to obtain a compressed log;
[0009] The compressed log is stored.
[0010] Optionally, storing the compressed log includes:
[0011] Determining whether the compressed log meets a preset storage condition;
[0012] If it is determined that the storage condition is met, storing the compressed log in a preset database;
[0013] Accordingly, the log management method further includes:
[0014] If it is determined that the storage condition is not met, the compressed log is parsed to obtain a plaintext log, and the plaintext log is output.
[0015] Optionally, the log management method is applied to a log system, the log system includes a front end, a first buffer and a back end, and the storing of the compressed log further includes:
[0016] The front end stores the compressed log in a first buffer;
[0017] The determining whether the compressed log meets a preset storage condition includes:
[0018] The backend determines whether the compressed log stored in the first buffer area meets a preset storage condition.
[0019] Optionally, if it is determined that the storage condition is met, storing the compressed log in a preset database includes:
[0020] If it is determined that the storage condition is met, storing the compressed log in the second buffer;
[0021] Counting the number of the compressed logs stored in the second buffer;
[0022] When the number is greater than or equal to a first preset threshold, all compressed logs stored in the second buffer are transferred to a preset database.
[0023] Optionally, if it is determined that the storage condition is met, storing the compressed log in a second buffer zone includes:
[0024] If it is determined that the storage condition is met, converting the format of the compressed log so that the converted format is consistent with the storage format of the preset database;
[0025] The compressed log after format conversion is stored in the second buffer.
[0026] Optionally, the parameter includes an address parameter, and accordingly, the compressed log includes the address of the log information to be managed.
[0027] Optionally, determining, according to the number of the parameters, a variable value corresponding to each parameter includes:
[0028] If the number of the parameters is greater than or equal to a second preset threshold, determining the variable values corresponding to the second preset threshold parameters;
[0029] The compressing the parameter information and the variable value corresponding to each parameter to obtain a compressed log includes:
[0030] The number of the parameters is updated to the second preset threshold, and the updated number of parameters, the variable values corresponding to the second preset threshold parameters, and the position information of the log information in the encoded file are compressed to obtain a compressed log.
[0031] Optionally, the log management method further includes:
[0032] Obtain the compressed log to be played back from the stored compressed logs;
[0033] Parsing the compressed log to be replayed to obtain a plaintext log to be replayed;
[0034] Output the plaintext log to be replayed for replay.
[0035] A second aspect of the present disclosure provides a log management device, the log management device comprising:
[0036] A first determining module, used to determine parameter information of a log function corresponding to the log information to be managed, wherein the parameter information at least includes the number of parameters;
[0037] A second determination module, used for determining a variable value corresponding to each parameter according to the number of the parameters;
[0038] A compression module, used for compressing the parameter information and the variable value corresponding to each parameter to obtain a compressed log;
[0039] A storage module is used to store the compressed log.
[0040] A third aspect of the present disclosure provides a non-temporary computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the log management method described in any one of the first aspects of the present disclosure.
[0041] A fourth aspect of the present disclosure provides an electronic device, including:
[0042] a memory having a computer program stored thereon;
[0043] A processor is used to execute the computer program in the memory to implement the steps of any method described in the first aspect of the present disclosure.
[0044] By adopting the above technical solution, first, the parameter information of the log function corresponding to the log information to be managed is determined, the parameter information at least includes the number of parameters, then, according to the number of parameters, the variable value corresponding to each parameter is determined, and then the parameter information and the variable value corresponding to each parameter are compressed to obtain a compressed log, and the compressed log is stored. In this way, the storage space occupied by the log file is effectively reduced, and the number of stored log files is increased. In addition, the number of erasures is reduced, thereby improving the storage efficiency of the log file.
[0045] Other features and advantages of the present disclosure will be described in detail in the following detailed description. BRIEF DESCRIPTION OF THE DRAWINGS
[0046] The accompanying drawings are used to provide a further understanding of the present disclosure and constitute a part of the specification. Together with the following specific embodiments, they are used to explain the present disclosure but do not constitute a limitation of the present disclosure. In the accompanying drawings:
[0047] Figure 1 The figure is a flow chart of a log management method according to an exemplary embodiment.
[0048] Figure 2 The figure is a flow chart showing another log management method according to an exemplary embodiment.
[0049] Figure 3 The figure is a flow chart of a log playback method according to an exemplary embodiment.
[0050] Figure 4 The figure is a block diagram of a log management device according to an exemplary embodiment.
[0051] Figure 5 It is a block diagram of an electronic device according to an exemplary embodiment. DETAILED DESCRIPTION
[0052] The specific implementation of the present disclosure is described in detail below in conjunction with the accompanying drawings. It should be understood that the specific implementation described herein is only used to illustrate and explain the present disclosure, and is not used to limit the present disclosure.
[0053] It should be noted that all actions of acquiring signals, information or data in the present disclosure are carried out in compliance with the relevant data protection laws and policies of the country where the device is located and with the authorization given by the owner of the corresponding device.
[0054] At present, embedded log management systems store log files in the form of plaintext strings in storage media. Since plaintext strings require a large amount of space on the storage medium, it may not be possible to save too many log files for embedded platforms with limited storage resources, which may result in the loss of some key log files. For example, in order to save more log files, more frequent media erasure operations are required, which may affect the efficiency of normal operation of the system and the storage efficiency of log files. Even in order to reduce the occupied space of log files, the plaintext strings can be compressed, but due to the unsatisfactory compression rate, the effect of reducing the occupied space is not obvious. In addition, in the related art, in order not to save the plaintext strings, the records of log files can also be reduced by modifying the source code, but since modifying the source code may cause the log interface to discover changes, the log interface is no longer a universal interface, resulting in limited scope of application.
[0055] In view of this, the present disclosure provides a log management method, a log management device, a storage medium and an electronic device, which compresses parameter information and variable values corresponding to each parameter to obtain a compressed log, and stores the compressed log, thereby effectively reducing the storage space occupied by the log file and increasing the number of stored log files. In addition, the number of erasures is reduced, thereby improving the storage efficiency of the log file.
[0056] Figure 1 FIG. 1 is a flow chart of a log management method according to an exemplary embodiment. Figure 1 As shown, the log management method may include the following steps.
[0057] In step S11, parameter information of the log function corresponding to the log information to be managed is determined.
[0058] In the present disclosure, the log function corresponding to the log information to be managed refers to the log function called to generate the log information to be managed. The parameter information includes at least the number of parameters. In addition, the parameter information may also include the location information of the log information in the encoded file, the log information printing level and the identification of the log module, wherein the printing level may include overall printing, partial printing, etc.
[0059] For example, the log management method can be applied to a log system, which can obtain the log information to be managed through a log interface, and then determine the parameter information of the log function corresponding to the log information to be managed. When the log interface receives the log information to be managed, it uses macro definitions to parse the log information, and then determines the parameter information of the log function corresponding to the log information.
[0060] In the present disclosure, the log interface of the log system is completely consistent with the ordinary printf interface. Users do not need to modify the code, and there is no additional workload in the program compilation and linking stages. That is, the log management method can be transplanted and used on multiple platforms, and is universal and portable.
[0061] In one embodiment, the number of parameters of the log function can be obtained through macro definition. For example, it can be obtained through a parameter macro such as FUN_ARG_EX, which obtains the number of parameters by intercepting and returning the previous preset number of parameters: #define FUN_ARG_EX(_0,_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,_11,_12,N,……)N. Where N represents the total number of parameters of the log function.
[0062] It should be understood that 12 parameters are intercepted and returned here because the maximum number of parameters used by the current SDK statistical log system does not exceed 12. If the SDK has more variable parameters, the parameter macro can be further expanded. For example, more or fewer parameters can be intercepted and returned through macro definition, and this disclosure does not limit this.
[0063] In addition, in order to further reduce the space occupied by the compressed log, more parameter macros can be defined to limit the number of parameters. For example, in order to reduce the space occupied by the compressed log, the maximum number of parameters can be limited to 7. The log information with more than 7 parameters can be output through the serial port, that is, the log information with more than 7 parameters is not stored. In this way, more detailed log output can be seen during the troubleshooting process without increasing storage consumption too much.
[0064] In this way, the parameter information is obtained through sophisticated macro definition parsing, and efficient compression of logs is achieved, which saves compression overhead and has good real-time performance.
[0065] In step S12, the variable value corresponding to each parameter is determined according to the number of parameters.
[0066] For example, the variable value corresponding to each parameter can be obtained by parsing the formatted string. Among them, the parameters of the log function usually include an address parameter, that is, determining the variable value corresponding to each parameter includes determining the address corresponding to the address parameter, and the address is recorded as the address of the log information to be managed. Correspondingly, the compressed log obtained subsequently also includes the address of the log information to be managed. In this way, when decompressing, the address of the formatted string can be obtained according to the address in the compressed log, and then the compressed data can be converted into a readable plaintext string using the snprintf function.
[0067] In step S13, the parameter information and the variable value corresponding to each parameter are compressed to obtain a compressed log.
[0068] In step S14, the compressed log is stored.
[0069] For example, the variable value corresponding to each determined parameter and the above parameter information are compressed and packaged. Thus, compared with the scheme of compressing the entire log information, the present disclosure only compresses the parameter information and the variable value corresponding to each parameter, which can effectively reduce the space occupied by the compressed log.
[0070] By adopting the above technical solution, first, the parameter information of the log function corresponding to the log information to be managed is determined, and the parameter information at least includes the number of parameters. Then, according to the number of parameters, the variable value corresponding to each parameter is determined. After that, the parameter information and the variable value corresponding to each parameter are compressed to obtain a compressed log, and the compressed log is stored. In this way, the storage space occupied by the log file is effectively reduced, and the number of stored log files is increased. In addition, the number of erasures is reduced, thereby improving the storage efficiency of the log file.
[0071] In one embodiment, the specific implementation of step S12 is: if the number of parameters is greater than or equal to the second preset threshold, then the variable values corresponding to the second preset threshold parameters are determined. Accordingly, step S13 compresses the parameter information and the variable values corresponding to each parameter to obtain the compressed log. The specific implementation of the compressed log is: the number of parameters is updated to the second preset threshold, and the updated number of parameters, the variable values corresponding to the second preset threshold parameters, and the position information of the log information in the encoded file are compressed to obtain the compressed log.
[0072] In order to reduce the space occupied by the compressed log, the number of parameters can be limited. For example, if the number of parameters is greater than or equal to the second preset threshold, the second preset threshold number of parameters can be determined from multiple parameters, and the variable values corresponding to each of the second preset threshold number of parameters can be determined, the number of parameters can be updated to the second preset threshold, and the updated number of parameters, the variable values corresponding to each of the second preset threshold number of parameters, and the location information of the log information in the encoded file can be compressed to obtain a compressed log, thereby achieving the purpose of reducing the space occupied by the compressed log.
[0073] The specific implementation of storing the compressed log in the above step S14 is described below.
[0074] In one embodiment, the specific implementation of storing the compressed log in step S14 is: determining whether the compressed log meets the preset storage condition; if it is determined that the storage condition is met, storing the compressed log in a preset database. The preset storage condition may be that the parameter type is a numerical parameter, and / or the parameter type is a string type and the parameter address is read-only data.
[0075] If the parameter type of the compressed log is a numerical parameter, or the parameter type is a string type and the parameter address is read-only data, that is, rodata data, the compressed log is stored in the database. The database may be a storage medium. In the present disclosure, for compressed logs that meet the preset storage conditions, up to 32 bits may be used for data storage. It should be understood that more bits or fewer bits may also be used for data storage, and the present disclosure does not limit this.
[0076] Accordingly, in this embodiment, the log management method may further include: if it is determined that the storage condition is not met, parsing the compressed log to obtain a plain text log, and outputting the plain text log. The plain text log refers to a string of plain text. Outputting the plain text log may be printing the plain text log.
[0077] For example, if the parameters in the compressed log include a parameter of type string %s, and the parameter address of the parameter is not read-only data, it is not stored in the preset database, but parsed to obtain a plain text log and output. In this way, the space occupied by the compressed log can be further reduced.
[0078] In one embodiment, the log management method can be applied to a log system, which can include a front end, a first buffer and a back end. In this embodiment, when the front end receives the log information to be managed from the log interface, it determines the parameter information of the log function corresponding to the log information to be managed, and determines the variable value corresponding to each parameter, and then compresses the parameter information and the variable value corresponding to each parameter to obtain a compressed log. Step S14 storing the compressed log can also include: the front end stores the compressed log in the first buffer. Accordingly, determining whether the compressed log meets the preset storage conditions includes: the back end determines whether the compressed log stored in the first buffer meets the preset storage conditions.
[0079] Since the front end stores the compressed log in the first buffer, when the system fails and then restarts, the compressed log is still stored in the first buffer. At this time, the compressed log can be transferred to another storage area. In this way, the compressed log can be used to effectively perform fault diagnosis and error analysis, avoiding the problem of being unable to save logs due to system abnormalities.
[0080] In the present disclosure, the front end can store the compressed log in the first buffer in real time, and the back end can read the compressed log from the first buffer at regular intervals and determine whether the read compressed log meets the preset storage condition. Alternatively, the back end can also read the compressed log from the first buffer in real time, which is not specifically limited in the present disclosure.
[0081] Optionally, if it is determined that the storage condition is met, storing the compressed log in a preset database may include:
[0082] If it is determined that the storage conditions are met, the compressed log is stored in the second buffer;
[0083] Count the number of compressed logs stored in the second buffer;
[0084] When the number is greater than or equal to the first preset threshold, all compressed logs stored in the second buffer are transferred to the preset database.
[0085] By way of example, the second buffer is a storage area located between the back end and the preset database.
[0086] In one embodiment, each time a compressed log is stored in the second buffer, the preset database reads a compressed log. This causes the preset database to frequently read compressed logs from the second buffer, increasing the number of times the preset database reads compressed logs.
[0087] In another way, the number of compressed logs stored in the second buffer is counted, and when the number is greater than or equal to a first preset threshold, all compressed logs stored in the second buffer are transferred to a preset database. For example, the first preset threshold may be the maximum number of compressed logs that can be stored in the second buffer, that is, when the second buffer is full, all compressed logs stored in the second buffer are transferred to the preset database. In this way, the problem of the preset database frequently reading compressed logs from the second buffer can be effectively avoided, and the number of times the preset database reads compressed logs can be reduced.
[0088] In addition, the format of the compressed log needs to be consistent with the storage format of the preset database. Therefore, in the present disclosure, if it is determined that the storage conditions are met, storing the compressed log in the second buffer may include: if it is determined that the storage conditions are met, converting the format of the compressed log so that the converted format is consistent with the storage format of the preset database; and storing the compressed log after the converted format in the second buffer.
[0089] For example, when the backend determines that the compressed log meets the preset storage condition, it converts the format of the compressed log so that the converted format is consistent with the storage format of the preset database, and then the backend stores the compressed log after the conversion in the second buffer. In this way, when the number of compressed logs stored in the second buffer reaches the first preset threshold, all compressed logs stored in the second buffer can be directly transferred to the preset database.
[0090] For example, the format of the compressed log stored in the preset database is as follows:
[0091] typedef struct
[0092] {
[0093] uint32_t head:4;
[0094] uint32_t arg_num:4;
[0095] uint32_t id: 8;
[0096] uint32_t line:16;
[0097] uint32_t fmt:24;
[0098] uint32_t func_name_enable:1;
[0099] uint32_t timestamp_enable:1;
[0100] uint32_t level: 3;
[0101] uint32_t log_type: 3;
[0102] }flash_log_head_t;
[0103] typedef struct
[0104] {
[0105] flash_log_head_t head;
[0106] uint32_t data[MAX_NANO_ARG_NUM+2];
[0107] }flash_log_item_t;
[0108] As shown above, the compressed log stored in the preset database includes: head, number of parameters arg_num, module id, line number of log information in the encoded file line, address of log information fmt, whether to print the line name func_name_enable, whether to print the timestamp timestamp_enable, IDE printing level of log information level, log type log_type and variable value MAX_NANO_ARG_NUM corresponding to the parameter. Among them, log types include compressed logs and plain text string logs.
[0109] Figure 2 FIG. 1 is a flow chart of another log management method according to an exemplary embodiment. Figure 2 As shown, the log management method may include the following steps.
[0110] In step S21, the log information to be managed is input through the log interface;
[0111] In step S22, the log information is parsed through macro definition to obtain parameter information of the log function corresponding to the log information;
[0112] In step S23, according to the number of parameters, the variable value corresponding to each parameter is determined;
[0113] In step S24, the parameter information and the variable value corresponding to each parameter are compressed to obtain a compressed log;
[0114] In step S25, the compressed log is stored in the first buffer, and the log thread is run;
[0115] In step S26, it is determined whether the compressed log stored in the first buffer area meets a preset storage condition;
[0116] In step S27, if it is determined that the preset storage condition is not met, the compressed log is parsed to obtain a plain text log, and the plain text log is output using a log thread;
[0117] In step S28, if it is determined that the preset storage condition is met, the compressed log is converted into a format, and the compressed log after the conversion is stored in the second buffer using the log thread;
[0118] In step S29, the number of compressed logs stored in the second buffer is counted;
[0119] In step S210, when the number is greater than or equal to the first preset threshold, all compressed logs stored in the second buffer are transferred to the preset database.
[0120] In addition, the stored compressed logs can also support decompression and playback. For example, the log management method further includes:
[0121] Obtain the compressed log to be played back from the stored compressed logs;
[0122] Parse the compressed log to be replayed to obtain the plaintext log to be replayed;
[0123] Output the plaintext log to be played back for playback.
[0124] Figure 3 FIG. 1 is a flow chart of a log playback method according to an exemplary embodiment. Figure 3 As shown, the log playback method may include the following steps.
[0125] In step S31, the compressed log to be played back is obtained from the stored compressed logs.
[0126] For example, if an exception occurs during the operation of an application, in order to locate the cause and location of the exception, it is necessary to obtain the compressed log to be replayed from the stored compressed log of the application. After that, the compressed log to be replayed is parsed to obtain the plaintext log to be replayed. For example, the implementation method of obtaining the plaintext log to be replayed is shown in steps S32 and S33.
[0127] In step S32, the compressed log to be replayed is decompressed to obtain decompressed log information.
[0128] In step S33, the decompressed log information is formatted to obtain a plain text log.
[0129] The plain text log is a character string indicating the plain text.
[0130] In step S34, the plaintext log to be replayed is output for replay.
[0131] For example, the plaintext log to be replayed may be output to a serial port for printing to achieve replay, or the plaintext log to be replayed may be sent to a mobile terminal for replay through wireless communication technology.
[0132] In this way, the compressed log can support decompression and playback, which is convenient for subsequent log reading to locate the cause and location of the abnormality of the service program, thereby improving the efficiency of service program development and maintenance.
[0133] Based on the same inventive concept, the present disclosure also provides a log management device. Figure 4 FIG. 1 is a block diagram of a log management device according to an exemplary embodiment. Figure 4 As shown, the log management device 400 may include:
[0134] A first determination module 401 is used to determine parameter information of a log function corresponding to the log information to be managed, wherein the parameter information at least includes the number of parameters;
[0135] A second determination module 402, configured to determine a variable value corresponding to each parameter according to the number of the parameters;
[0136] A compression module 403 is used to compress the parameter information and the variable value corresponding to each parameter to obtain a compressed log;
[0137] The storage module 404 is used to store the compressed log.
[0138] Optionally, the storage module 404 includes:
[0139] A first determination submodule, used to determine whether the compressed log meets a preset storage condition;
[0140] A storage submodule, configured to store the compressed log in a preset database if it is determined that the storage condition is met;
[0141] Accordingly, the log management device 400 may further include:
[0142] The parsing submodule is used to parse the compressed log to obtain a plaintext log and output the plaintext log if it is determined that the storage condition is not met.
[0143] Optionally, the log management method is applied to a log system, which includes a front end, a first buffer and a back end, the front end stores the compressed log in the first buffer; the back end determines whether the compressed log stored in the first buffer meets a preset storage condition.
[0144] Optionally, the storage submodule is used to: if it is determined that the storage condition is met, store the compressed log in a second buffer; count the number of compressed logs stored in the second buffer; when the number is greater than or equal to a first preset threshold, transfer all compressed logs stored in the second buffer to a preset database.
[0145] Optionally, the storage submodule is used to: if it is determined that the storage condition is met, convert the format of the compressed log so that the converted format is consistent with the storage format of the preset database; and store the compressed log after the converted format in a second buffer.
[0146] Optionally, the parameter includes an address parameter, and accordingly, the compressed log includes the address of the log information to be managed.
[0147] Optionally, the second determination module 402 is used to: if the number of the parameters is greater than or equal to a second preset threshold, determine the variable value corresponding to each of the second preset threshold parameters;
[0148] The compression module 403 is used to update the number of parameters to the second preset threshold, and compress the updated number of parameters, the variable values corresponding to the second preset threshold parameters, and the location information of the log information in the encoded file to obtain a compressed log.
[0149] Optionally, the log management device 400 may further include:
[0150] An acquisition module, used for acquiring the compressed log to be played back from the stored compressed logs;
[0151] A parsing module, used for parsing the compressed log to be replayed to obtain a plaintext log to be replayed;
[0152] The output module is used to output the plaintext log to be replayed for replay.
[0153] Regarding the device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.
[0154] Figure 5 FIG. 1 is a block diagram of an electronic device according to an exemplary embodiment. Figure 5 As shown, the electronic device 700 may include: a processor 701 and a memory 702. The electronic device 700 may also include one or more of a multimedia component 703, an input / output (I / O) interface 704, and a communication component 705.
[0155] The processor 701 is used to control the overall operation of the electronic device 700 to complete all or part of the steps in the above-mentioned log management method. The memory 702 is used to store various types of data to support the operation of the electronic device 700, and these data may include, for example, instructions for any application or method used to operate on the electronic device 700, and application-related data, such as contact data, sent and received messages, pictures, audio, video, etc. The memory 702 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (Static Random Access Memory, referred to as SRAM), electrically erasable programmable read-only memory (Electrically Erasable Programmable Read-Only Memory, referred to as EEPROM), erasable programmable read-only memory (Erasable Programmable Read-Only Memory, referred to as EPROM), programmable read-only memory (Programmable Read-Only Memory, referred to as PROM), read-only memory (Read-Only Memory, referred to as ROM), magnetic memory, flash memory, disk or optical disk. The multimedia component 703 may include a screen and an audio component. The screen may be, for example, a touch screen, and the audio component is used to output and / or input audio signals. For example, the audio component may include a microphone for receiving external audio signals. The received audio signal may be further stored in the memory 702 or sent through the communication component 705. The audio component also includes at least one speaker for outputting audio signals. The I / O interface 704 provides an interface between the processor 701 and other interface modules, and the other interface modules may be keyboards, mice, buttons, etc. These buttons may be virtual buttons or physical buttons. The communication component 705 is used for wired or wireless communication between the electronic device 700 and other devices. Wireless communication, such as Wi-Fi, Bluetooth, Near Field Communication (NFC), 2G, 3G, 4G, NB-IOT, eMTC, or other 5G, etc., or a combination of one or more of them, is not limited here. Therefore, the corresponding communication component 705 may include: Wi-Fi module, Bluetooth module, NFC module, etc.
[0156] In an exemplary embodiment, the electronic device 700 can be implemented by one or more application specific integrated circuits (ASIC), digital signal processors (DSP), digital signal processing devices (DSPD), programmable logic devices (PLD), field programmable gate arrays (FPGA), controllers, microcontrollers, microprocessors or other electronic components to execute the above-mentioned log management method.
[0157] In another exemplary embodiment, a computer-readable storage medium including program instructions is also provided, and when the program instructions are executed by a processor, the steps of the above-mentioned log management method are implemented. For example, the computer-readable storage medium can be the above-mentioned memory 702 including program instructions, and the above-mentioned program instructions can be executed by the processor 701 of the electronic device 700 to complete the above-mentioned log management method.
[0158] In another exemplary embodiment, a computer program product is further provided. The computer program product includes a computer program that can be executed by a programmable device. The computer program has a code portion for executing the above log management method when executed by the programmable device.
[0159] The preferred embodiments of the present disclosure are described in detail above in conjunction with the accompanying drawings; however, the present disclosure is not limited to the specific details in the above embodiments. Within the technical concept of the present disclosure, a variety of simple modifications can be made to the technical solution of the present disclosure, and these simple modifications all fall within the protection scope of the present disclosure.
[0160] It should also be noted that the various specific technical features described in the above specific embodiments can be combined in any suitable manner without contradiction. In order to avoid unnecessary repetition, the present disclosure will not further describe various possible combinations.
[0161] In addition, various embodiments of the present disclosure may be arbitrarily combined, and as long as they do not violate the concept of the present disclosure, they should also be regarded as the contents disclosed by the present disclosure.
Claims
1. A log management method, It is characterized in that The log management method comprises: Determine parameter information of a log function corresponding to the log information to be managed, wherein the parameter information includes at least the number of parameters; According to the number of the parameters, determining the variable value corresponding to each of the parameters; Compressing the parameter information and the variable value corresponding to each parameter to obtain a compressed log; The compressed log is stored.
2. The log management method according to claim 1, It is characterized in that The storing of the compressed log comprises: Determining whether the compressed log meets a preset storage condition; If it is determined that the storage condition is met, storing the compressed log in a preset database; Accordingly, the log management method further includes: If it is determined that the storage condition is not met, the compressed log is parsed to obtain a plaintext log, and the plaintext log is output.
3. The log management method according to claim 2, It is characterized in that The log management method is applied to a log system, the log system includes a front end, a first buffer and a back end, and the storage of the compressed log also includes: The front end stores the compressed log in a first buffer; The determining whether the compressed log meets a preset storage condition includes: The backend determines whether the compressed log stored in the first buffer area meets a preset storage condition.
4. According to the log management method of claim 2, It is characterized in that If it is determined that the storage condition is met, storing the compressed log in a preset database includes: If it is determined that the storage condition is met, storing the compressed log in the second buffer; Counting the number of the compressed logs stored in the second buffer; When the number is greater than or equal to a first preset threshold, all compressed logs stored in the second buffer are transferred to a preset database.
5. The log management method according to claim 4, It is characterized in that If it is determined that the storage condition is met, storing the compressed log in the second buffer includes: If it is determined that the storage condition is met, converting the format of the compressed log so that the converted format is consistent with the storage format of the preset database; The compressed log after format conversion is stored in the second buffer.
6. The log management method according to any one of claims 1 to 5, It is characterized in that The parameter includes an address parameter, and accordingly, the compressed log includes the address of the log information to be managed.
7. The log management method according to any one of claims 1 to 5, It is characterized in that Determining the variable value corresponding to each parameter according to the number of the parameters includes: If the number of the parameters is greater than or equal to a second preset threshold, determining the variable values corresponding to the second preset threshold parameters; The compressing the parameter information and the variable value corresponding to each parameter to obtain a compressed log includes: The number of the parameters is updated to the second preset threshold, and the updated number of parameters, the variable values corresponding to the second preset threshold parameters, and the position information of the log information in the encoded file are compressed to obtain a compressed log.
8. The log management method according to any one of claims 1 to 5, It is characterized in that The log management method further includes: Obtain the compressed log to be played back from the stored compressed logs; Parsing the compressed log to be replayed to obtain a plaintext log to be replayed; Output the plaintext log to be replayed for replay.
9. A log management device, It is characterized in that The log management device comprises: A first determining module, used to determine parameter information of a log function corresponding to the log information to be managed, wherein the parameter information at least includes the number of parameters; A second determination module, used for determining a variable value corresponding to each parameter according to the number of the parameters; A compression module, used for compressing the parameter information and the variable value corresponding to each parameter to obtain a compressed log; A storage module is used to store the compressed log.
10. A non-transitory computer-readable storage medium having stored thereon a computer program, It is characterized in that When the program is executed by a processor, the steps of the method described in any one of claims 1 to 8 are implemented.
11. An electronic device, It is characterized in that include: a memory having a computer program stored thereon; A processor, configured to execute the computer program in the memory to implement the steps of the method according to any one of claims 1 to 8.