CN116150119A - Log processing method, system, electronic equipment and computer readable storage medium - Google Patents

Log processing method, system, electronic equipment and computer readable storage medium Download PDF

Info

Publication number
CN116150119A
CN116150119A CN202310091513.7A CN202310091513A CN116150119A CN 116150119 A CN116150119 A CN 116150119A CN 202310091513 A CN202310091513 A CN 202310091513A CN 116150119 A CN116150119 A CN 116150119A
Authority
CN
China
Prior art keywords
character string
target character
address
log
storage space
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202310091513.7A
Other languages
Chinese (zh)
Inventor
江志军
汪勋
何秋明
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shandong Yunhai Guochuang Cloud Computing Equipment Industry Innovation Center Co Ltd
Original Assignee
Shandong Yunhai Guochuang Cloud Computing Equipment Industry Innovation Center Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shandong Yunhai Guochuang Cloud Computing Equipment Industry Innovation Center Co Ltd filed Critical Shandong Yunhai Guochuang Cloud Computing Equipment Industry Innovation Center Co Ltd
Priority to CN202310091513.7A priority Critical patent/CN116150119A/en
Publication of CN116150119A publication Critical patent/CN116150119A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/18File system types
    • G06F16/1805Append-only file systems, e.g. using logs or journals to store data
    • G06F16/1815Journaling file systems
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/34Recording or statistical evaluation of computer activity, e.g. of down time, of input/output operation ; Recording or statistical evaluation of user activity, e.g. usability assessment
    • G06F11/3466Performance evaluation by tracing or monitoring
    • G06F11/3476Data logging
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/17Details of further file system functions
    • G06F16/172Caching, prefetching or hoarding of files
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/17Details of further file system functions
    • G06F16/178Techniques for file synchronisation in file systems
    • G06F16/1794Details of file format conversion
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/245Query processing
    • G06F16/2455Query execution
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/25Integrating or interfacing systems involving database management systems
    • G06F16/258Data format conversion from or to a database
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/903Querying
    • G06F16/90335Query processing
    • G06F16/90344Query processing by using string matching techniques
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Data Mining & Analysis (AREA)
  • Computational Linguistics (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The application discloses a log processing method, a system, electronic equipment and a computer readable storage medium, and relates to the field of storage, wherein the log processing method comprises the following steps: acquiring log information and extracting a format control character string in the log information; determining an address and a conversion description of the format control character string; obtaining variable parameters in the log information based on the conversion description; and splicing the address and the variable parameters to obtain a first target character string, packaging the first target character string, and storing the first target character string in a corresponding storage space. According to the method and the device, occupation of storage space by each piece of log information can be reduced, and the log information can be recorded as much as possible in a limited memory.

Description

Log processing method, system, electronic equipment and computer readable storage medium
Technical Field
The present disclosure relates to the field of storage, and in particular, to a log processing method, system, electronic device, and computer readable storage medium.
Background
Software logging is used to record data related to software running, and has become a necessary means in the reliability protection mechanism of many software systems. With the large-scale development of software, the number of logs is rapidly increased, and the space occupied by the logs recorded in the memory is also increased. However, in an embedded system with limited memory resources, sufficient memory space cannot be provided for the log, so how to record log information in limited memory as much as possible is a problem that needs to be solved by those skilled in the art.
Disclosure of Invention
The purpose of the present application is to provide a log processing method, a system, an electronic device and a computer readable storage medium, which can reduce the occupation of storage space by each piece of log information, and record the log information as much as possible in a limited memory.
In order to solve the above technical problems, the present application provides a log processing method, including:
acquiring log information and extracting a format control character string in the log information;
determining the address and the conversion description of the format control character string;
obtaining variable parameters in the log information based on the conversion description;
and splicing the address and the variable parameters to obtain a first target character string, packaging the first target character string, and storing the first target character string in a corresponding storage space.
Optionally, when the conversion description is multiple, the process of splicing the address and the variable parameter to obtain the first target character string includes:
determining the arrangement sequence of a plurality of variable parameters according to the sequence of a plurality of conversion descriptions;
and splicing the address and the variable parameters based on the arrangement order to obtain a first target character string.
Optionally, the storage space is a ring buffer.
Optionally, the process of storing the first target character string in the corresponding storage space after packaging includes:
packaging a first identification character at the head part of the first target character string, and packaging a second identification character at the tail part of the first target character string to obtain a second target character string;
and storing the second target character string into a corresponding storage space.
Optionally, the process of storing the first target character string in the corresponding storage space after packaging includes:
determining a module identifier corresponding to the log information;
determining a corresponding storage space based on the module identifier;
searching whether the history character string which is the same as the first target character string exists in the storage space;
if yes, enabling the first target character string to cover the history character string, so that the first target character string is stored in a corresponding storage space;
and if not, storing the first target character string into a corresponding storage space.
Optionally, the log processing method further includes:
when a reading instruction is received, determining a target storage space based on the reading instruction;
acquiring the first target character string corresponding to the reading instruction from the target storage space;
extracting the address and variable parameters of the first target character string;
and generating log printing information corresponding to the reading instruction based on the address and the variable parameter.
Optionally, the process of generating the log hint information corresponding to the read instruction based on the address and the variable parameter includes:
converting the address into a 16-system target address, and assigning the target address to the format control character string;
and processing the format control character string and each variable parameter by using a format output function to obtain log prompt information corresponding to the reading instruction.
In order to solve the above technical problem, the present application further provides a log processing system, including:
the processing module is used for acquiring log information and extracting a format control character string in the log information;
a first determining module, configured to determine an address and a conversion specification of the format control string;
the second determining module is used for obtaining variable parameters in the log information based on the conversion description;
and the compression module is used for splicing the address and the variable parameter to obtain a first target character string, and storing the first target character string in a corresponding storage space after packaging.
In order to solve the above technical problem, the present application further provides an electronic device, including:
a memory for storing a computer program;
a processor for implementing the steps of the log processing method as claimed in any one of the preceding claims when executing the computer program.
To solve the above technical problem, the present application further provides a computer readable storage medium, on which a computer program is stored, which when executed by a processor, implements the steps of the log processing method as described in any one of the above.
The application provides a log processing method, after log information is obtained, format control character strings in the log information are firstly extracted, and because the content in the format control character strings is in a code segment, the application only records the address of the format control character strings, meanwhile, variable parameters in the log information are determined according to conversion description in the format control character strings, the first target character strings obtained after the variable parameters and the address are spliced are packaged and stored in a storage space, the constant parameters in the log information and the content in the format control character strings are not required to be recorded, the occupation of each piece of log information to the storage space is reduced, and thus, the log information is recorded in a limited memory as much as possible. The application also provides a log processing system, electronic equipment and a computer readable storage medium, which have the same beneficial effects as the log processing method.
Drawings
For a clearer description of the embodiments of the present application, the drawings that are needed in the embodiments will be briefly described, it being apparent that the drawings in the following description are only some embodiments of the present application, and that other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
FIG. 1 is a schematic diagram of a management system according to the present disclosure;
FIG. 2 is a flowchart illustrating a log processing method according to the present application;
FIG. 3 is a schematic diagram of a data structure of a log processing module provided in the present application;
fig. 4 is a schematic structural diagram of a log processing system provided in the present application.
Detailed Description
The core of the application is to provide a log processing method, a system, an electronic device and a computer readable storage medium, which can reduce the occupation of each piece of log information to the storage space and record the log information in a limited memory as much as possible.
For the purposes of making the objects, technical solutions and advantages of the embodiments of the present application more clear, the technical solutions of the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is apparent that the described embodiments are some embodiments of the present application, but not all embodiments. All other embodiments, which can be made by one of ordinary skill in the art without undue burden from the present disclosure, are within the scope of the present disclosure.
In order to facilitate understanding of a log processing method provided by the present application, a management system to which the log processing method is applied will be described below, referring to fig. 1, fig. 1 is a schematic structural diagram of a management system provided by the present application, in which each module for generating a log interacts with a log processing module, and the generated log is sent to the log processing module for subsequent processing. It will be appreciated that the log processing module provides a call interface that each module calls to provide log information generated by itself to the log processing module. Specifically, the following form of function may be called to transmit log information to the log processing module:
Voidlog(constcharmodule,char*fmt,…);
illustratively, log_record (1, "My name is% s, I am% d yes old,%4.2fhigh |", "ZhangShan",28,1.725).
The log processing method in this embodiment may be implemented by the log processing module, referring to fig. 2, fig. 2 is a flowchart of steps of the log processing method provided in this application, where the log processing method includes:
s101: acquiring log information and extracting a format control character string in the log information;
s102: determining an address and a conversion description of the format control character string;
it will be appreciated that the log information obtained based on the above function is obtained, assuming that the received log information is as follows:
para0=moduleId=1
para1=fmt=“My name is%s,I am%d years old,%4.2f high!”
para2=“ZhangShan”
para3=28
para4=1.725
the format control character string, that is, fmt character string, in the log information is extracted, and it is understood that fmt character string contains two types of objects, namely, common characters and conversion descriptions, wherein the common characters are copied to standard output as they are, the conversion descriptions are not directly output but are used for conversion and printing of control parameters, and each conversion description is started by one percent character% and ended by the conversion description, thereby describing the type, width, precision and the like of output data. Considering that the fmt parameter is a constant string, the content thereof is in the code segment, so that only the address of fmt needs to be recorded in the memory, in this embodiment, the address of the character string represented by para1, that is, fmt is taken, assuming that the address of para1 is 0xA1234567, the converted address is a1234567, and then the conversion description of the fmt character string, that is, "%s%d%4.2f", is determined.
S103: obtaining variable parameters in the log information based on the conversion description;
s104: and splicing the address and the variable parameters to obtain a first target character string, packaging the first target character string, and storing the first target character string in a corresponding storage space.
It can be understood that the log information includes variable parameters and non-variable parameters, in order to further reduce data to be compressed and stored, the embodiment obtains the variable parameters in the log information, that is, parameter values of para2, para3, and para4, based on the above conversion description, and then splices the variable parameters and addresses according to the above conversion description, where the process is a compression process of the log information, and stores the first target character string after compression process in a storage space corresponding to the module id in para 0.
The format of the compressed log information, i.e., the first target string, is as follows:
FmtAddrStr VariablePartStr
wherein FmtAddrStr is a character string address represented by fmt in printf or log.info, and VariablePartStr is a character string composed of values of various variable parameters.
Therefore, in this embodiment, after the log information is obtained, the format control string in the log information is first extracted, and since the content in the format control string is in the code segment, the application records only the address of the format control string, and meanwhile, determines the variable parameter in the log information according to the conversion description in the format control string, encapsulates the first target string obtained after splicing the variable parameter and the address, and stores the first target string in the storage space, without recording the unchanged parameter in the log information and the content in the format control string, so that occupation of each log information to the storage space is reduced, and thus, the log information is recorded in a limited memory as much as possible.
Based on the above embodiments:
as an optional embodiment, when the conversion description is multiple, the process of splicing the address and the variable parameter to obtain the first target character string includes:
determining the arrangement sequence of a plurality of variable parameters according to the sequence of a plurality of conversion descriptions;
and splicing the addresses and the variable parameters based on the arrangement order to obtain a first target character string.
Referring to the log information shown above, when there are a plurality of conversion descriptions, when the first target character string is spliced, the splicing order of each variable parameter needs to be determined according to the sequence of the conversion descriptions, for example, "%s% d%4.2f" is converted, and then the first target character string is obtained as a1234567, zhan san,28,1.72.
As an alternative embodiment, the corresponding storage space is a ring buffer.
Referring to fig. 3, g_buffer in fig. 3 is a global array describing the buffer management mechanism of all modules, and each element of the array has the following fields:
fields Interpretation of the drawings
buffer Pointer to ring buffer
total_size Annular buffer space size
start_write_pos Writing the starting position of the current log
As an alternative embodiment, the process of storing the first target character string in the corresponding storage space after packaging includes:
packaging a first identification character at the head part of the first target character string, and packaging a second identification character at the tail part of the first target character string to obtain a second target character string;
and storing the second target character string into a corresponding storage space.
When the ring buffer is used as the storage space of the log information, the log information is written into the ring buffer, if the current ring buffer is fully written, the oldest log information is covered by the latest log information, and in order to ensure the validity and reliability of log information storage, the first embodiment encapsulates the first target character string, which includes a first identification character of which the head of the first target character string is encapsulated by one byte, wherein the first identification character may be an unprintable character (SOH), the ASCII code value of which is 0x1, and encapsulates the tail of the first target character string by a second identification character of which the tail of the first target character string is encapsulated by one byte, and the second identification character is an unprintable character (EOT), and the ASCII code value of which is 0x4, wherein the first identification character and the second identification character are used for distinguishing each log information.
It can be understood that the head and tail of the first target character string are packaged with the identification characters to obtain a second target character string, and the second target character string is stored in the corresponding storage space.
As an alternative embodiment, the process of storing the first target character string in the corresponding storage space after packaging includes:
determining a module identifier corresponding to the log information;
determining a corresponding storage space based on the module identifier;
searching whether the history character string which is the same as the first target character string exists in the corresponding storage space;
if yes, enabling the first target character string to cover the history character string, so that the first target character string is stored in a corresponding storage space;
if not, the first target character string is stored in the corresponding storage space.
It can be understood that each module in the system has a corresponding ring buffer, after receiving log information sent by a certain module, determining the ring buffer corresponding to the module based on the id of the module, comparing the log entry to be saved currently, i.e. the first target character string, with the existing log of the buffer one by one, if there is duplication, selecting an overlay storage scheme, i.e. the first target character string to be saved currently overlays the duplicated history character string, further reducing occupation of memory space, and if there is no history character string identical to the first target character string to be saved currently in the buffer, directly storing the first target character string to a corresponding position.
As an alternative embodiment, the log processing method further includes:
when a reading instruction is received, determining a target storage space based on the reading instruction;
acquiring a first target character string corresponding to a reading instruction from a target storage space;
extracting the address and variable parameters of the first target character string;
log print information corresponding to the read instruction is generated based on the address and the variable parameter.
As an alternative embodiment, the process of generating log hint information corresponding to a read instruction based on an address and a variable parameter includes:
converting the address into a 16-system target address, and assigning the target address to a format control character string;
and processing the format control character string and each variable parameter by using the format output function to obtain log prompt information corresponding to the reading instruction.
Specifically, when a certain module needs to print corresponding log information, determining a module id corresponding to the read instruction according to the read instruction output by the certain module, determining a ring buffer area for storing the log information to be printed based on the module id, scanning the ring buffer area, extracting a character string beginning with SOH and ending with EOT, converting an address character string of fmt in the character string into numbers, analyzing the character string converted by variable parameters into single parameters, and then transmitting the parameters into a print function in a printf, log.
Illustratively, assume that the compressed string taken from the ring buffer after SOH and EOT removal is as follows: a1234567, zhan san,28,1.72, resolving the address of a1234567 to a 16-ary address 0x a1234567, assigning it to fmt, resolving zhan san,28,1.72 to "zhan san",28,1.72.
In a second aspect, referring to fig. 4, fig. 4 is a schematic structural diagram of a log processing system provided in the present application, where the log processing system includes:
a processing module 41, configured to obtain log information, and extract a format control character string in the log information;
a first determining module 42 for determining an address and a translation specification of the format control string;
a second determining module 43, configured to obtain variable parameters in the log information based on the conversion description;
the compression module 44 is configured to splice the address and the variable parameter to obtain a first target string, package the first target string, and store the first target string in a corresponding storage space.
Specifically, it is assumed that the received log information is as follows:
para0=moduleId=1
para1=fmt=“My name is%s,I am%d years old,%4.2f high!”
para2=“ZhangShan”
para3=28
para4=1.725
the format control character string, that is, fmt character string, in the log information is extracted, and it is understood that fmt character string contains two types of objects, namely, common characters and conversion descriptions, wherein the common characters are copied to standard output as they are, the conversion descriptions are not directly output but are used for conversion and printing of control parameters, and each conversion description is started by one percent character% and ended by the conversion description, thereby describing the type, width, precision and the like of output data. Considering that the fmt parameter is a constant string, the content thereof is in the code segment, so that only the address of fmt needs to be recorded in the memory, in this embodiment, the address of the character string represented by para1, that is, fmt is taken, assuming that the address of para1 is 0xA1234567, the converted address is a1234567, and then the conversion description of the fmt character string, that is, "%s%d%4.2f", is determined.
It can be understood that the log information includes variable parameters and non-variable parameters, in order to further reduce data to be compressed and stored, the embodiment obtains the variable parameters in the log information, that is, parameter values of para2, para3, and para4, based on the above conversion description, and then splices the variable parameters and addresses according to the above conversion description, where the process is a compression process of the log information, and stores the first target character string after compression process in a storage space corresponding to the module id in para 0.
The format of the compressed log information, i.e., the first target string, is as follows:
FmtAddrStr VariablePartStr
wherein FmtAddrStr is a character string address represented by fmt in printf or log.info, and VariablePartStr is a character string composed of values of various variable parameters.
Therefore, in this embodiment, after the log information is obtained, the format control string in the log information is first extracted, and since the content in the format control string is in the code segment, the application records only the address of the format control string, and meanwhile, determines the variable parameter in the log information according to the conversion description in the format control string, encapsulates the first target string obtained after splicing the variable parameter and the address, and stores the first target string in the storage space, without recording the unchanged parameter in the log information and the content in the format control string, so that occupation of each log information to the storage space is reduced, and thus, the log information is recorded in a limited memory as much as possible.
As an optional embodiment, when the conversion description is multiple, the process of splicing the address and the variable parameter to obtain the first target character string includes:
determining the arrangement sequence of a plurality of variable parameters according to the sequence of a plurality of conversion descriptions;
and splicing the addresses and the variable parameters based on the arrangement order to obtain a first target character string.
Referring to the log information shown above, when there are a plurality of conversion descriptions, when the first target character string is spliced, the splicing order of each variable parameter needs to be determined according to the sequence of the conversion descriptions, for example, "%s% d%4.2f" is converted, and then the first target character string is obtained as a1234567, zhan san,28,1.72.
As an alternative embodiment, the corresponding storage space is a ring buffer.
As an alternative embodiment, the process of storing the first target character string in the corresponding storage space after packaging includes:
packaging a first identification character at the head part of the first target character string, and packaging a second identification character at the tail part of the first target character string to obtain a second target character string;
and storing the second target character string into a corresponding storage space.
When the ring buffer is used as the storage space of the log information, the log information is written into the ring buffer, if the current ring buffer is fully written, the oldest log information is covered by the latest log information, and in order to ensure the validity and reliability of log information storage, the first embodiment encapsulates the first target character string, which includes a first identification character of which the head of the first target character string is encapsulated by one byte, wherein the first identification character may be an unprintable character (SOH), the ASCII code value of which is 0x1, and encapsulates the tail of the first target character string by a second identification character of which the tail of the first target character string is encapsulated by one byte, and the second identification character is an unprintable character (EOT), and the ASCII code value of which is 0x4, wherein the first identification character and the second identification character are used for distinguishing each log information.
It can be understood that the head and tail of the first target character string are packaged with the identification characters to obtain a second target character string, and the second target character string is stored in the corresponding storage space.
As an alternative embodiment, the process of storing the first target character string in the corresponding storage space after packaging includes:
determining a module identifier corresponding to the log information;
determining a corresponding storage space based on the module identifier;
searching whether the history character string which is the same as the first target character string exists in the corresponding storage space;
if yes, enabling the first target character string to cover the history character string, so that the first target character string is stored in a corresponding storage space;
if not, the first target character string is stored in the corresponding storage space.
It can be understood that each module in the system has a corresponding ring buffer, after receiving log information sent by a certain module, determining the ring buffer corresponding to the module based on the id of the module, comparing the log entry to be saved currently, i.e. the first target character string, with the existing log of the buffer one by one, if there is duplication, selecting an overlay storage scheme, i.e. the first target character string to be saved currently overlays the duplicated history character string, further reducing occupation of memory space, and if there is no history character string identical to the first target character string to be saved currently in the buffer, directly storing the first target character string to a corresponding position.
As an alternative embodiment, the log processing system further comprises:
the query module is used for determining a target storage space based on the read instruction when the read instruction is received;
the first extraction module is used for acquiring a first target character string corresponding to the reading instruction from the target storage space;
the second extraction module is used for extracting the address and the variable parameter of the first target character string;
and the printing module is used for generating log printing information corresponding to the reading instruction based on the address and the variable parameter.
As an alternative embodiment, the process of generating log hint information corresponding to a read instruction based on an address and a variable parameter includes:
converting the address into a 16-system target address, and assigning the target address to a format control character string;
and processing the format control character string and each variable parameter by using the format output function to obtain log prompt information corresponding to the reading instruction.
Specifically, when a certain module needs to print corresponding log information, determining a module id corresponding to the read instruction according to the read instruction output by the certain module, determining a ring buffer area for storing the log information to be printed based on the module id, scanning the ring buffer area, extracting a character string beginning with SOH and ending with EOT, converting an address character string of fmt in the character string into numbers, analyzing the character string converted by variable parameters into single parameters, and then transmitting the parameters into a print function in a printf, log.
Illustratively, assume that the compressed string taken from the ring buffer after SOH and EOT removal is as follows: a1234567, zhan san,28,1.72, resolving the address of a1234567 to a 16-ary address 0x a1234567, assigning it to fmt, resolving zhan san,28,1.72 to "zhan san",28,1.72.
In a third aspect, the present application further provides an electronic device, including:
a memory for storing a computer program;
a processor for implementing the steps of the log processing method as described in any one of the embodiments above when executing a computer program.
Specifically, the memory includes a nonvolatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and computer readable instructions, and the internal memory provides an environment for the operating system and the execution of the computer readable instructions in the non-volatile storage medium. When the processor executes the computer program stored in the memory, the following steps may be implemented: acquiring log information and extracting a format control character string in the log information; determining an address and a conversion description of the format control character string; obtaining variable parameters in the log information based on the conversion description; and splicing the address and the variable parameters to obtain a first target character string, packaging the first target character string, and storing the first target character string in a corresponding storage space.
Therefore, in this embodiment, after the log information is obtained, the format control string in the log information is first extracted, and since the content in the format control string is in the code segment, the application records only the address of the format control string, and meanwhile, determines the variable parameter in the log information according to the conversion description in the format control string, encapsulates the first target string obtained after splicing the variable parameter and the address, and stores the first target string in the storage space, without recording the unchanged parameter in the log information and the content in the format control string, so that occupation of each log information to the storage space is reduced, and thus, the log information is recorded in a limited memory as much as possible.
As an alternative embodiment, the processor may implement the following steps when executing the computer subroutine stored in the memory: determining the arrangement sequence of a plurality of variable parameters according to the sequence of a plurality of conversion descriptions; and splicing the addresses and the variable parameters based on the arrangement order to obtain a first target character string.
As an alternative embodiment, the processor may implement the following steps when executing the computer subroutine stored in the memory: and splicing the address and the variable parameters to obtain a first target character string, packaging the first target character string, and storing the first target character string in a corresponding storage space which is an annular buffer area.
As an alternative embodiment, the processor may implement the following steps when executing the computer subroutine stored in the memory: packaging a first identification character at the head part of the first target character string, and packaging a second identification character at the tail part of the first target character string to obtain a second target character string; and storing the second target character string into a corresponding storage space.
As an alternative embodiment, the processor may implement the following steps when executing the computer subroutine stored in the memory: determining a module identifier corresponding to the log information; determining a corresponding storage space based on the module identifier; searching whether the history character string which is the same as the first target character string exists in the corresponding storage space; if yes, enabling the first target character string to cover the history character string, so that the first target character string is stored in a corresponding storage space; if not, the first target character string is stored in the corresponding storage space.
As an alternative embodiment, the processor may implement the following steps when executing the computer subroutine stored in the memory: when a reading instruction is received, determining a target storage space based on the reading instruction; acquiring a first target character string corresponding to a reading instruction from a target storage space; extracting the address and variable parameters of the first target character string; log print information corresponding to the read instruction is generated based on the address and the variable parameter.
As an alternative embodiment, the processor may implement the following steps when executing the computer subroutine stored in the memory: converting the address into a 16-system target address, and assigning the target address to a format control character string; and processing the format control character string and each variable parameter by using the format output function to obtain log prompt information corresponding to the reading instruction.
On the basis of the above embodiment, as a preferred implementation manner, the electronic device further includes:
the input interface is connected with the processor and used for acquiring the externally imported computer programs, parameters and instructions, and the externally imported computer programs, parameters and instructions are controlled by the processor and stored in the memory. The input interface may be coupled to an input device for receiving parameters or instructions manually entered by a user. The input device can be a touch layer covered on a display screen, or can be a key, a track ball or a touch pad arranged on a terminal shell.
And the display unit is connected with the processor and used for displaying the data sent by the processor. The display unit may be a liquid crystal display or an electronic ink display, etc.
And the network port is connected with the processor and used for carrying out communication connection with external terminal equipment. The communication technology adopted by the communication connection can be a wired communication technology or a wireless communication technology, such as a mobile high definition link technology (MHL), a Universal Serial Bus (USB), a High Definition Multimedia Interface (HDMI), a wireless fidelity technology (WiFi), a Bluetooth communication technology with low power consumption, a communication technology based on IEEE802.11s, and the like.
In a fourth aspect, the present application also provides a computer-readable storage medium having stored thereon a computer program which, when executed by a processor, implements the steps of the log processing method as described in any one of the embodiments above.
Wherein the computer-readable storage medium may comprise: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a random access Memory (Random Access Memory, RAM), a magnetic disk, or an optical disk, or other various media capable of storing program codes. The storage medium has stored thereon a computer program which, when executed by a processor, performs the steps of: acquiring log information and extracting a format control character string in the log information; determining an address and a conversion description of the format control character string; obtaining variable parameters in the log information based on the conversion description; and splicing the address and the variable parameters to obtain a first target character string, packaging the first target character string, and storing the first target character string in a corresponding storage space.
Therefore, in this embodiment, after the log information is obtained, the format control string in the log information is first extracted, and since the content in the format control string is in the code segment, the application records only the address of the format control string, and meanwhile, determines the variable parameter in the log information according to the conversion description in the format control string, encapsulates the first target string obtained after splicing the variable parameter and the address, and stores the first target string in the storage space, without recording the unchanged parameter in the log information and the content in the format control string, so that occupation of each log information to the storage space is reduced, and thus, the log information is recorded in a limited memory as much as possible.
As an alternative embodiment, the following steps may be implemented in particular when a computer subroutine stored in a computer readable storage medium is executed by a processor: determining the arrangement sequence of a plurality of variable parameters according to the sequence of a plurality of conversion descriptions; and splicing the addresses and the variable parameters based on the arrangement order to obtain a first target character string.
As an alternative embodiment, the following steps may be implemented in particular when a computer subroutine stored in a computer readable storage medium is executed by a processor: and splicing the address and the variable parameters to obtain a first target character string, packaging the first target character string, and storing the first target character string in a corresponding storage space which is an annular buffer area.
As an alternative embodiment, the following steps may be implemented in particular when a computer subroutine stored in a computer readable storage medium is executed by a processor: packaging a first identification character at the head part of the first target character string, and packaging a second identification character at the tail part of the first target character string to obtain a second target character string; and storing the second target character string into a corresponding storage space.
As an alternative embodiment, the following steps may be implemented in particular when a computer subroutine stored in a computer readable storage medium is executed by a processor: determining a module identifier corresponding to the log information; determining a corresponding storage space based on the module identifier; searching whether the history character string which is the same as the first target character string exists in the corresponding storage space; if yes, enabling the first target character string to cover the history character string, so that the first target character string is stored in a corresponding storage space; if not, the first target character string is stored in the corresponding storage space.
As an alternative embodiment, the following steps may be implemented in particular when a computer subroutine stored in a computer readable storage medium is executed by a processor: when a reading instruction is received, determining a target storage space based on the reading instruction; acquiring a first target character string corresponding to a reading instruction from a target storage space; extracting the address and variable parameters of the first target character string; log print information corresponding to the read instruction is generated based on the address and the variable parameter.
As an alternative embodiment, the following steps may be implemented in particular when a computer subroutine stored in a computer readable storage medium is executed by a processor: converting the address into a 16-system target address, and assigning the target address to a format control character string; and processing the format control character string and each variable parameter by using the format output function to obtain log prompt information corresponding to the reading instruction.
It should also be noted that in this specification, relational terms such as first and second, and the like are used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Moreover, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.
The previous description of the disclosed embodiments is provided to enable any person skilled in the art to make or use the present application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other embodiments without departing from the spirit or scope of the application. Thus, the present application is not intended to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims (10)

1. A log processing method, comprising:
acquiring log information and extracting a format control character string in the log information;
determining the address and the conversion description of the format control character string;
obtaining variable parameters in the log information based on the conversion description;
and splicing the address and the variable parameters to obtain a first target character string, packaging the first target character string, and storing the first target character string in a corresponding storage space.
2. The log processing method according to claim 1, wherein when the conversion description is plural, the process of splicing the address and the variable parameter to obtain the first target character string includes:
determining the arrangement sequence of a plurality of variable parameters according to the sequence of a plurality of conversion descriptions;
and splicing the address and the variable parameters based on the arrangement order to obtain a first target character string.
3. The log processing method as defined in claim 1, wherein the storage space is a ring buffer.
4. The log processing method as claimed in claim 3, wherein the process of storing the first target character string in the corresponding storage space after packaging comprises:
packaging a first identification character at the head part of the first target character string, and packaging a second identification character at the tail part of the first target character string to obtain a second target character string;
and storing the second target character string into a corresponding storage space.
5. The log processing method as claimed in claim 1, wherein the process of storing the first target character string in the corresponding storage space after packaging comprises:
determining a module identifier corresponding to the log information;
determining a corresponding storage space based on the module identifier;
searching whether the history character string which is the same as the first target character string exists in the storage space;
if yes, enabling the first target character string to cover the history character string, so that the first target character string is stored in a corresponding storage space;
and if not, storing the first target character string into a corresponding storage space.
6. The log processing method as defined in claim 5, further comprising:
when a reading instruction is received, determining a target storage space based on the reading instruction;
acquiring the first target character string corresponding to the reading instruction from the target storage space;
extracting the address and variable parameters of the first target character string;
and generating log printing information corresponding to the reading instruction based on the address and the variable parameter.
7. The log processing method as defined in claim 6, wherein generating log hint information corresponding to the read instruction based on the address and the variable parameter comprises:
converting the address into a 16-system target address, and assigning the target address to the format control character string;
and processing the format control character string and each variable parameter by using a format output function to obtain log prompt information corresponding to the reading instruction.
8. A log processing system, comprising:
the processing module is used for acquiring log information and extracting a format control character string in the log information;
a first determining module, configured to determine an address and a conversion specification of the format control string;
the second determining module is used for obtaining variable parameters in the log information based on the conversion description;
and the compression module is used for splicing the address and the variable parameter to obtain a first target character string, and storing the first target character string in a corresponding storage space after packaging.
9. An electronic device, comprising:
a memory for storing a computer program;
a processor for implementing the steps of the log processing method according to any one of claims 1-7 when executing said computer program.
10. A computer readable storage medium, characterized in that the computer readable storage medium has stored thereon a computer program which, when executed by a processor, implements the steps of the log processing method according to any of claims 1-7.
CN202310091513.7A 2023-02-03 2023-02-03 Log processing method, system, electronic equipment and computer readable storage medium Pending CN116150119A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310091513.7A CN116150119A (en) 2023-02-03 2023-02-03 Log processing method, system, electronic equipment and computer readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310091513.7A CN116150119A (en) 2023-02-03 2023-02-03 Log processing method, system, electronic equipment and computer readable storage medium

Publications (1)

Publication Number Publication Date
CN116150119A true CN116150119A (en) 2023-05-23

Family

ID=86338546

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310091513.7A Pending CN116150119A (en) 2023-02-03 2023-02-03 Log processing method, system, electronic equipment and computer readable storage medium

Country Status (1)

Country Link
CN (1) CN116150119A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116910000A (en) * 2023-06-30 2023-10-20 荣耀终端有限公司 Log processing method, log storage method and embedded equipment

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116910000A (en) * 2023-06-30 2023-10-20 荣耀终端有限公司 Log processing method, log storage method and embedded equipment

Similar Documents

Publication Publication Date Title
CN109086199B (en) Method, terminal and storage medium for automatically generating test script
JP4685348B2 (en) Efficient collating element structure for handling large numbers of characters
CN116150119A (en) Log processing method, system, electronic equipment and computer readable storage medium
CN111803917A (en) Resource processing method and device
CN116028022A (en) Java technology-based zero code Excel data importing method, device and medium
CN111125008A (en) Dynamic repairing method and system of abnormal inode and related components
CN110874216B (en) Complete code generation method, device, equipment and storage medium
CN107169057B (en) Method and device for detecting repeated pictures
CN111506747B (en) File analysis method, device, electronic equipment and storage medium
CN113064556A (en) BIOS data storage method, device, equipment and storage medium
CN112000589A (en) Data writing method, data reading device and electronic equipment
CN111241096A (en) Text extraction method, system, terminal and storage medium for EXCEL document
CN102567210B (en) Method and device for reorganizing data analysis environment of flash memory chip
CN115390847A (en) Log processing method and device, computer readable storage medium and terminal
CN115269532A (en) Log file, log storage method and device, wearable device and storage medium
JP5409090B2 (en) Information processing apparatus, information processing method, program, and storage medium
KR20020024235A (en) The method for conversion and transmission of user data between a different kind of mobile phone
CN107818136B (en) Method and device for recycling garbage object data
CN110825376B (en) Method, storage medium and device for analyzing annotated JSON file
JP2003533924A (en) Method and system for improving printing performance of file containing bitmap
CN116431082B (en) Method, apparatus, computer device and storage medium for data storage
CN112559478B (en) Log generation method and device, terminal equipment and storage medium
CN102110082B (en) Method and system for outputting complementary word of galley proof file
US20240045701A1 (en) Method, device and system for loading page data
CN111181948B (en) Method and device for driving existing functions by non-standard message

Legal Events

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