CN114090375A - Log storage method and device and storage medium - Google Patents

Log storage method and device and storage medium Download PDF

Info

Publication number
CN114090375A
CN114090375A CN202111314887.8A CN202111314887A CN114090375A CN 114090375 A CN114090375 A CN 114090375A CN 202111314887 A CN202111314887 A CN 202111314887A CN 114090375 A CN114090375 A CN 114090375A
Authority
CN
China
Prior art keywords
log
storage
target
source code
storage device
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
CN202111314887.8A
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.)
China United Network Communications Group Co Ltd
China Information Technology Designing and Consulting Institute Co Ltd
Original Assignee
China United Network Communications Group Co Ltd
China Information Technology Designing and Consulting Institute 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 China United Network Communications Group Co Ltd, China Information Technology Designing and Consulting Institute Co Ltd filed Critical China United Network Communications Group Co Ltd
Priority to CN202111314887.8A priority Critical patent/CN114090375A/en
Publication of CN114090375A publication Critical patent/CN114090375A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/3003Monitoring arrangements specially adapted to the computing system or computing system component being monitored
    • G06F11/3013Monitoring arrangements specially adapted to the computing system or computing system component being monitored where the computing system is an embedded system, i.e. a combination of hardware and software dedicated to perform a certain function in mobile devices, printers, automotive or aircraft systems
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/3051Monitoring arrangements for monitoring the configuration of the computing system or of the computing system component, e.g. monitoring the presence of processing resources, peripherals, I/O links, software programs
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/3065Monitoring arrangements determined by the means or processing involved in reporting the monitored data
    • G06F11/3072Monitoring arrangements determined by the means or processing involved in reporting the monitored data where the reporting involves data filtering, e.g. pattern matching, time or event triggered, adaptive or policy-based reporting
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0628Interfaces specially adapted for storage systems making use of a particular technique
    • G06F3/0655Vertical data movement, i.e. input-output transfer; data movement between one or more hosts and one or more storage devices
    • G06F3/0659Command handling arrangements, e.g. command buffers, queues, command scheduling
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0668Interfaces specially adapted for storage systems adopting a particular infrastructure
    • G06F3/0671In-line storage system
    • G06F3/0673Single storage device
    • G06F3/0679Non-volatile semiconductor memory device, e.g. flash memory, one time programmable memory [OTP]

Abstract

The application provides a log storage method, a log storage device and a log storage medium, relates to the technical field of computers, and is used for solving the technical problem that an embedded product cannot reasonably store log files. The method comprises the following steps: after receiving the log information sent by the embedded product and extracting the log parameters for identifying the log information from the log information, the log parameters of which the storage occupied space is smaller than that of the log information can be stored in the first storage device corresponding to the embedded product. The method and the device can enable the embedded product to store the log file more reasonably.

Description

Log storage method and device and storage medium
Technical Field
The present application belongs to the field of computer technologies, and in particular, to a log storage method, apparatus, and storage medium.
Background
The log files of embedded products are typically stored in Flash memory. When the embedded product generates a large amount of log files in the operation process, the storage space of the Flash memory cannot meet the storage requirements of the large amount of log files.
In order to solve the above problems, a method of increasing the capacity of a flash memory is generally adopted at present to meet the storage requirement of a large amount of log files.
However, this method of increasing the capacity of the flash memory greatly increases the cost. Therefore, how to make the embedded product store the log file in a reasonable manner becomes an urgent problem to be solved.
Disclosure of Invention
The application provides a log storage method, a log storage device and a log storage medium, which are used for solving the problem that an embedded product cannot reasonably store log files.
In order to achieve the purpose, the technical scheme is as follows:
in a first aspect, a log storage method is provided, including: after receiving the log information sent by the embedded product and extracting the log parameters for identifying the log information from the log information, the log parameters of which the storage occupied space is smaller than that of the log information can be stored in the first storage device corresponding to the embedded product.
Optionally, the log storage method further includes: analyzing the source code file based on the configuration file to obtain log resource information; the configuration file is used for describing configuration information of the source code file; the source code file is used for generating an embedded product; and storing the log resource information in a second storage device.
Optionally, the log storage method further includes: receiving a first request message for acquiring a target log; reading target log parameters corresponding to the target log from the first storage device in response to the first request message; reading target log resource information corresponding to the target log from the second storage device; and generating a target log according to the target log parameters and the target log resource information.
Optionally, the method for analyzing the source code file based on the configuration file to obtain the log resource information specifically includes: determining the name of a source code file and a log macro definition and a log label corresponding to the source code file according to the configuration file; analyzing the source code file, and determining the sequence number and the fixed field of the log record statement in the source code file; the log recording statement is used for generating log information corresponding to the log recording statement; determining the unique log identification of the log recording statement according to the serial number of the log recording statement, the log macro definition and the log label; and generating log resource information according to the fixed field of the log record statement, the unique log identification and the name of the source code file.
Optionally, the log storage method further includes: and updating the source code identification of the log recording statement into a unique log identification.
Optionally, the log parameter includes a unique log identifier, level information, a line number of a source code recorded in a log record statement corresponding to the log parameter, and service data generated by the source code.
Optionally, the embedded product includes at least two storage spaces. The method for storing the log parameters in the first storage device corresponding to the embedded product specifically comprises the following steps: storing the log parameters generated by the embedded product in a first time period in a first storage space; when the storage capacity of the first storage space is smaller than the preset storage capacity, storing the log parameters generated by the embedded product in a second time period in a second storage space; the second time period and the first time period are continuous time periods; the first storage space and the second storage space are any two storage spaces in at least two storage spaces; and when the storage capacity of the first storage space is smaller than the preset storage capacity, or the duration of the first time period is longer than the preset duration, storing the log parameters stored in the first storage space into the first storage device.
Optionally, the log storage method further includes: receiving a second request message for acquiring target log parameters; the second request message comprises a unique log identifier corresponding to the target log parameter; responding to the second request message, and determining a target storage space for storing the target log parameters from at least two storage spaces according to the unique log identifier corresponding to the target log parameters; and reading the target log parameters from the target storage space and outputting the target log parameters.
In a second aspect, a log storage apparatus is provided, including: a receiving unit and a processing unit; the receiving unit is used for receiving the log information sent by the embedded product; a processing unit for extracting a log parameter for identifying the log information from the log information received by the receiving unit; the storage occupation space of the log parameters is smaller than that of the log information; and the processing unit is also used for storing the log parameters in a first storage device corresponding to the embedded product.
Optionally, the processing unit is further configured to analyze the source code file based on the configuration file to obtain log resource information; the processing unit is also used for describing configuration information of the source code file by the configuration file; the processing unit is also used for generating an embedded product by using the source code file; and storing the log resource information in a second storage device.
Optionally, the receiving unit is further configured to receive a first request message for acquiring the target log; the processing unit is also used for responding to the first request message received by the receiving unit and reading target log parameters corresponding to the target log from the first storage device; the processing unit is also used for reading target log resource information corresponding to the target log from the second storage device; and the processing unit is also used for generating a target log according to the target log parameters and the target log resource information.
Optionally, the processing unit is further configured to determine, according to the configuration file, a name of the source code file, and a log macro definition and a log label corresponding to the source code file; the processing unit is also used for analyzing the source code file and determining the sequence number and the fixed field of the log record statement in the source code file; the processing unit is also used for generating log information corresponding to the log recording statement by the log recording statement; the processing unit is also used for determining the unique log identifier of the log recording statement according to the serial number of the log recording statement, the log macro definition and the log label; and the processing unit is also used for generating log resource information according to the fixed field of the log record statement, the unique log identification and the name of the source code file.
Optionally, the processing unit is further configured to update the source code identifier of the log recording statement to a unique log identifier.
Optionally, the log parameter includes a unique log identifier, level information, a line number of a source code recorded in a log record statement corresponding to the log parameter, and service data generated by the source code.
Optionally, the embedded product includes at least two storage spaces. The processing unit is also used for storing the log parameters generated by the embedded product in a first time period in a first storage space; the processing unit is further used for storing the log parameters generated by the embedded product in a second time period in a second storage space when the storage capacity of the first storage space is smaller than the preset storage capacity; the second time period and the first time period are continuous time periods; the first storage space and the second storage space are any two storage spaces in at least two storage spaces; the processing unit is further used for storing the log parameters stored in the first storage space into the first storage device when the storage capacity of the first storage space is smaller than the preset storage capacity or the duration of the first time period is larger than the preset duration.
Optionally, the receiving unit is further configured to receive a second request message for obtaining the target log parameter; the second request message comprises a unique log identifier corresponding to the target log parameter; the processing unit is further used for responding to the second request message received by the receiving unit, and determining a target storage space for storing the target log parameters from at least two storage spaces according to the unique log identifier corresponding to the target log parameters; and the processing unit is also used for reading the target log parameters from the target storage space and outputting the target log parameters.
In a third aspect, a log storage device is provided, comprising a memory and a processor; the memory is used for storing computer execution instructions, and the processor is connected with the memory through a bus; when the log storage device is running, the processor executes the memory-stored computer-executable instructions to cause the log storage device to perform the log storage method as in the first aspect.
The log storage device may be a network device, or may be a part of a device in the network device, such as a system on chip in the network device. The system on chip is configured to support the network device to implement the functions involved in the first aspect and any one of the possible implementations thereof, for example, to receive, determine, and offload data and/or information involved in the data processing method. The chip system includes a chip and may also include other discrete devices or circuit structures.
In a fourth aspect, a computer-readable storage medium is provided, wherein the computer-readable storage medium comprises computer-executable instructions, which when executed on a computer, cause the computer to perform the log storage method of the first aspect.
It should be noted that all or part of the above computer instructions may be stored on the first computer readable storage medium. The first computer readable storage medium may be packaged with a processor of the log storage device, or may be packaged separately from the processor of the log storage device, which is not limited in this application.
In the present application, the names of the log storage means described above do not limit the devices or functional modules themselves, and in actual implementation, the devices or functional modules may appear by other names. Insofar as the functions of the respective devices or functional modules are similar to those of the present application, they fall within the scope of the claims of the present application and their equivalents.
These and other aspects of the present application will be more readily apparent from the following description.
The technical scheme provided by the application at least brings the following beneficial effects:
based on any one of the above aspects, in the present application, after receiving the log information sent by the embedded product, a log parameter for identifying the log information may be extracted from the log information, and the log parameter may be stored in the first storage device corresponding to the embedded product. Because the storage occupation space of the log parameters is smaller than that of the log information, the method and the device can reduce the space occupied by the storage of the log information and enable the first storage device corresponding to the embedded product to store the log file more reasonably.
Drawings
Fig. 1 is a schematic structural diagram of a journal storage system according to an embodiment of the present application;
fig. 2 is a schematic hardware structure diagram of a communication device according to an embodiment of the present disclosure;
fig. 3 is a schematic diagram of another hardware structure of a communication device according to an embodiment of the present disclosure;
fig. 4 is a first flowchart illustrating a log storage method according to an embodiment of the present application;
fig. 5 is a flowchart illustrating a log storage method according to an embodiment of the present application;
fig. 6 is a third schematic flowchart of a log storage method according to an embodiment of the present application;
fig. 7 is a fourth schematic flowchart of a log storage method according to an embodiment of the present application;
fig. 8 is a fifth flowchart illustrating a log storage method according to an embodiment of the present application;
fig. 9 is a schematic structural diagram of a log storage device according to an embodiment of the present application.
Detailed Description
The technical solutions in 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 obvious that the described embodiments are only a part of the embodiments of the present application, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
It should be noted that in the embodiments of the present application, words such as "exemplary" or "for example" are used to indicate examples, illustrations or explanations. Any embodiment or design described herein as "exemplary" or "e.g.," is not necessarily to be construed as preferred or advantageous over other embodiments or designs. Rather, use of the word "exemplary" or "such as" is intended to present concepts related in a concrete fashion.
For the convenience of clearly describing the technical solutions of the embodiments of the present application, in the embodiments of the present application, the terms "first" and "second" are used to distinguish the same items or similar items with basically the same functions and actions, and those skilled in the art can understand that the terms "first" and "second" are not used to limit the quantity and execution order.
Furthermore, the terms "comprising" and "having" in the description of the embodiments and claims of the present application and the drawings are not intended to be exclusive. For example, a process, method, system, article, or apparatus that comprises a list of steps or modules is not limited to only those steps or modules listed, but may include other steps or modules not listed.
As described in the background, a method of increasing the capacity of a flash memory is generally adopted at present to meet the storage requirement of a large amount of log files.
However, this method of increasing the capacity of the flash memory greatly increases the cost. Therefore, how to make the embedded product store the log file in a reasonable manner becomes an urgent problem to be solved.
In view of the above problem, an embodiment of the present application provides a log storage method, which may extract a log parameter for identifying log information from log information after receiving the log information sent by an embedded product, and store the log parameter in a first storage device corresponding to the embedded product. Because the storage occupation space of the log parameters is smaller than that of the log information, the method and the device can reduce the space occupied by the storage of the log information and enable the first storage device corresponding to the embedded product to store the log file more reasonably.
The log storage method is suitable for the log storage system. Fig. 1 shows one configuration of the journal storage system 100. As shown in fig. 1, the log storage system 100 includes: log storage 101, embedded product 102, and server 103. The log storage device 101 can be connected with the embedded product 102 in a communication way and can also be connected with the server 103 in a communication way. The embedded product 102 and the server 103 are communicatively coupled.
Optionally, the log storage device 101 in fig. 1 may be a functional module in the server 103, or may be an electronic device that is provided independently from the server 103 and is used for storing and calling log information.
Alternatively, when the log storage 101 is an electronic device provided independently of the server 103 for realizing storage and retrieval of log information, the electronic device may be a terminal. The terminal is a device that provides voice and/or data connectivity to a user, a handheld device having wireless connection capability, or other processing device connected to a wireless modem. A wireless terminal may communicate with one or more core networks via a Radio Access Network (RAN). The wireless terminal may be a mobile terminal, such as a computer having a mobile terminal, or a portable, pocket, hand-held, computer-embedded mobile device, which exchanges language and/or data with a radio access network, for example, a mobile phone, a tablet computer, a notebook computer, a netbook, a Personal Digital Assistant (PDA). The embodiments of the present application do not set any limit to this.
Alternatively, when the log storage 101 is an electronic device provided independently of the server 103 for realizing storage and retrieval of log information, the electronic device may also be a server. When the electronic device is a server, the electronic device may be a function module for performing log storage inside the server 103, or may be an independent server that is independent from the server 103, which is not specifically limited in this application.
For convenience of understanding, the present application will be described mainly by taking the example in which the log storage device 101 and the server 103 are provided independently.
It is easily understood that, when the log storage device 101 is a functional module inside the server 103, the communication method between the log storage device 101 and the server 103 is communication between the modules inside the server. In this case, the communication flow between the log storage apparatus 101 and the server 103 is the same as the communication flow between the log storage apparatus and the server in the case where they are independent of each other.
Optionally, the embedded product 102 in fig. 1 may be an application-specific embedded Central Processing Unit (CPU), which generally works in a system designed for a specific user group, has the characteristics of low power consumption, small size, high integration level, and the like, and can integrate many tasks completed by boards in a general CPU into a chip.
The server 103 is used for collecting and providing information such as source code of the embedded product to the log storage device 101.
Alternatively, the server 103 may be a single server, or may be a server cluster formed by a plurality of servers. In some embodiments, the server cluster may also be a distributed cluster. The embodiments of the present application do not set any limit to this.
The basic hardware structures of the log storage device 101, the embedded product 102 and the server 103 in the log storage system 100 are similar and all include elements included in the communication device shown in fig. 2 or 3. The hardware structures of the log storage device 101, the embedded product 102, and the server 103 will be described below by taking the communication device shown in fig. 2 and 3 as an example.
Fig. 2 is a schematic diagram of a hardware structure of a communication device according to an embodiment of the present disclosure. The communication device comprises a processor 21, a memory 22, a communication interface 23, a bus 24. The processor 21, the memory 22 and the communication interface 23 may be connected by a bus 24.
The processor 21 is a control center of the communication apparatus, and may be a single processor or a collective term for a plurality of processing elements. For example, the processor 21 may be a general-purpose CPU, or may be another general-purpose processor. Wherein a general purpose processor may be a microprocessor or any conventional processor or the like.
For one embodiment, processor 21 may include one or more CPUs, such as CPU0 and CPU1 shown in FIG. 2.
The memory 22 may be, but is not limited to, a read-only memory (ROM) or other type of static storage device that may store static information and instructions, a Random Access Memory (RAM) or other type of dynamic storage device that may store information and instructions, an electrically erasable programmable read-only memory (EEPROM), a magnetic disk storage medium or other magnetic storage device, or any other medium that can be used to carry or store desired program code in the form of instructions or data structures and that can be accessed by a computer.
In a possible implementation, the memory 22 may exist separately from the processor 21, and the memory 22 may be connected to the processor 21 via a bus 24 for storing instructions or program codes. The processor 21, when calling and executing the instructions or program codes stored in the memory 22, can implement the log storage method provided by the following embodiments of the present application.
In the embodiment of the present application, the log storage device 101, the embedded product 102, and the server 103 implement different functions because the software programs stored in the memory 22 are different. The functions performed by the devices will be described in connection with the following flow charts.
In another possible implementation, the memory 22 may also be integrated with the processor 21.
The communication interface 23 is used for connecting the communication device with other devices through a communication network, which may be an ethernet, a radio access network, a Wireless Local Area Network (WLAN), or the like. The communication interface 23 may include a receiving unit for receiving data, and a transmitting unit for transmitting data.
The bus 24 may be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, an extended ISA (enhanced industry standard architecture) bus, or the like. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one thick line is shown in FIG. 2, but it is not intended that there be only one bus or one type of bus.
It is noted that the configuration shown in fig. 2 does not constitute a limitation of the communication device, which may comprise more or less components than those shown in fig. 2, or a combination of some components, or a different arrangement of components than those shown in fig. 2.
Fig. 3 shows another hardware configuration of the communication apparatus in the embodiment of the present application. As shown in fig. 3, the communication device may include a processor 31 and a communication interface 32. The processor 31 is coupled to a communication interface 32.
The function of the processor 31 may refer to the description of the processor 21 above. The processor 31 also has a memory function and can function as the memory 22.
The communication interface 32 is used to provide data to the processor 31. The communication interface 32 may be an internal interface of the communication device, or may be an external interface (corresponding to the communication interface 23) of the communication device.
It is noted that the configuration shown in fig. 2 (or fig. 3) does not constitute a limitation of the communication apparatus, which may include more or less components than those shown in fig. 2 (or fig. 3), or combine some components, or a different arrangement of components, in addition to the components shown in fig. 2 (or fig. 3).
Fig. 4 is a schematic flowchart of a log storage method according to an embodiment of the present application. The log storage method is applied to a log storage device, and the log storage device belongs to the log storage device shown in fig. 1. The log storage system is composed of the embedded product and the server. The log storage method comprises the following steps: S401-S409.
S401, the log storage device analyzes the source code file based on the configuration file to obtain log resource information.
Specifically, before the source code file is compiled, the log storage device may obtain a configuration file and a source code file about the same embedded product from the server, and parse the source code file based on the configuration file to obtain log resource information.
The configuration file is used for describing configuration information of the source code file. The source code file is used to generate an embedded product.
Optionally, the configuration information may be information such as a name of a source code file, a definition of a log macro, and a log tag.
Optionally, the log storage device may determine the name of the source code file and the configuration information such as the log macro definition by analyzing the configuration file, and may obtain the source code of the log recording statement used for generating the log information in the source code file by analyzing the source code file, and determine the sequence number of the log recording statement.
Next, the log storage device may determine a unique log id of log information generated by the logging statement, based on the configuration information (log macro definition, etc.) of the source code file and the sequence number of the logging statement. The log storage device may determine, as the log resource information, configuration information of the source code file (for example, a name of the source code file), a source code of the log entry statement, and a unique log identifier of the log information.
Optionally, after obtaining the log resource information, the log storage device may record information such as a name and a storage location of the log resource information into the configuration file.
Alternatively, the server may store a source code file for generating the embedded product and a configuration file for describing configuration information of the source code file in advance. When it is necessary to acquire a source code file for generating an embedded product and a configuration file for describing configuration information of the source code file, the log storage may transmit a request message for acquiring the source code file for generating the embedded product and the configuration file for describing configuration information of the source code file to the server.
Then, the server reads a source code file for generating the embedded product and a configuration file for describing configuration information of the source code file in response to the request message, and transmits the source code file for generating the embedded product and the configuration file for describing configuration information of the source code file to the log storage device. Accordingly, the log storage may receive a source code file for generating the embedded product and a configuration file for describing configuration information of the source code file from the server.
S402, the log storage device stores the log resource information in a second storage device.
Specifically, after obtaining the log resource information, the log storage apparatus may store the log resource information in the second storage device.
Optionally, the second storage device may be a function module configured in advance in the server for storing the log resource information.
S403, the log storage device receives the log information sent by the embedded product.
Specifically, after running and generating log information for recording the running process, the embedded product may send the log information to the log storage device. Accordingly, the log storage device can receive the log information sent by the embedded product.
In practical application, when generating log information for recording the running process, the embedded product can actively send the log information to the log storage device by calling the log recording interface.
S404, the log storage device extracts log parameters used for identifying the log information from the log information.
Specifically, after receiving the log information sent by the embedded product, the log storage device may extract a log parameter for identifying the log information from the log information.
The log parameters may include unique log identifiers, level information, line numbers of source codes recorded in log recording statements corresponding to the log parameters, and service data generated by the source codes.
Optionally, the level information may be ERROR, WARNING, INFO, and the like, and is used to indicate the running state of the source code recorded by the logging statement corresponding to the logging parameter.
Optionally, when the source code recorded in the logging statement corresponding to the logging parameter does not generate service data, the service data generated by the source code may be represented by zero.
It will be appreciated that the log information is typically comprised of a log interface, a fixed string, and log parameters for recording run information for different source codes. The storage occupation space of the log parameters is smaller than that of the log information.
Illustratively, the predetermined LOG information A is LIB _ BSP _ LOG (BSP _ LOG _ LEVEL _ ERROR, a, "input para is NULL \ n", b, c). The "LIB _ BSP _ LOG" is a LOG interface, "BSP _ LOG _ LEVEL _ ERROR" is LEVEL information, "a" represents a unique LOG identifier, "input para is NULL \ n" is a fixed character string, "b" is a row number of a source code recorded by a LOG record statement corresponding to a LOG parameter, and "c" is service data generated by the source code.
Next, upon receiving the log information a, the log storage may extract a unique log identifier "a" for identifying the log information, level information "ERROR", a line number "b" of a source code recorded in a log recording statement corresponding to the log parameter, and service data "c" generated by the source code from the log information.
Optionally, after the log parameters for identifying the log information are extracted from the log information, the log storage device may store the log parameters as a text file in a binary format, so as to further reduce a storage space occupied by the log parameters.
For example, if the storage occupation space of one piece of log information is preset to be 100 bytes, the storage occupation space of the fixed character string may reach 58 bytes, and the storage occupation space of the log parameters for recording the running information of different source codes may reach 42 bytes. After the log storage device stores the log parameters as a text file in a binary format, the storage space occupied by the log parameters can be further reduced to 24 bytes.
Therefore, under the condition of storing the same number of pieces of log information, the method for storing the log information based on the log storage device in the embodiment of the application can greatly reduce the consumption of the storage space, so that the consumption of system resources of the embedded product caused by the storage of the log information is reduced.
S405, the log storage device stores the log parameters in a first storage device corresponding to the embedded product.
Specifically, after extracting the log parameter for identifying the log information from the log information, the log storage device may send the log parameter to the embedded product, so that the embedded product receives the log parameter and stores the log parameter in the first storage device corresponding to the embedded product.
Optionally, the first storage device may be a Non-Volatile memory device, such as a Flash memory, having advantages of small size, low cost, and fast reading speed, so as to meet requirements of embedded products, such as high integration and real-time sensing.
S406, the log storage device receives a first request message for acquiring the target log.
Specifically, after the log parameters are stored in the first storage device corresponding to the embedded product, when the target log needs to be consulted to meet the related business requirements (for example, observing the running process, etc.), the worker may input a first request message for acquiring the target log through the input module. Accordingly, the log storage may receive a first request message for retrieving a target log.
Wherein the first request message includes a unique log identification corresponding to the target log.
Optionally, the log storage device may be configured with an input module in advance, so that the staff can input the first request message for obtaining the target log.
S407, in response to the first request message, the log storage device reads the target log parameters corresponding to the target log from the first storage device.
Specifically, after receiving a first request message for obtaining the target log, the log storage device may parse the first request message to determine a unique log identifier corresponding to the target log.
Next, in response to the first request message, the log storage may read a target log parameter corresponding to the target log from the first storage device according to the unique log identifier corresponding to the target log.
Optionally, as for a method for the log storage device to read the target log parameters corresponding to the target log from the first storage device, reference may be made to a method for the log storage device to obtain, from the server, the source code file used for generating the embedded product and the configuration file used for describing the configuration information of the source code file in S401, which is not described herein again.
S408, the log storage device reads target log resource information corresponding to the target log from the second storage device.
Specifically, after receiving a first request message for obtaining the target log and determining a unique log identifier corresponding to the target log, the log storage apparatus may read, in response to the first request message, target log resource information corresponding to the target log from the second storage device.
Optionally, when the second storage device is a functional module in the server, the method for the log storage device to read the target log resource information corresponding to the target log from the second storage device may refer to a method for the log storage device to obtain, from the server, a source code file used for generating the embedded product and a configuration file used for describing configuration information of the source code file in S401, which is not described herein again.
The coding of step S407 and step S408 is merely for convenience of description, and the actual execution order is not limited. For example, S407 may be performed first, and then S408 may be performed; or executing S408 first and then executing S407; s407 and S408 may also be performed simultaneously.
S409, the log storage device generates a target log according to the target log parameters and the target log resource information.
Specifically, after reading the target log parameter corresponding to the target log from the first storage device and reading the target log resource information corresponding to the target log from the second storage device, the log storage device may generate the target log according to the target log parameter and the target log resource information.
It can be understood that the target log parameters include a unique log identifier corresponding to the target log, level information, a line number of a source code recorded in a log recording statement corresponding to the log parameters, and service data generated by the source code, and other parameter information. The target log resource information includes configuration information (for example, a name of a source code file) of a source code file corresponding to the target log, a source code for recording the log, and a unique log identifier of the log information. The log storage device may extract information corresponding to the target log from the target log parameter and the target log resource information according to a preset rule, and reconstruct the target log so as to refer to the target log.
In an implementation manner, with reference to fig. 4 and as shown in fig. 5, in the above S401, the method for the log storage device to parse the source code file based on the configuration file to obtain the log resource information specifically includes: S501-S504.
S501, the log storage device determines the name of the source code file and the log macro definition and the log label corresponding to the source code file according to the configuration file.
Specifically, after the source code file and the configuration file are obtained, the log storage device may determine, according to the configuration file, a name of the source code file, and a log macro definition and a log label corresponding to the source code file.
Optionally, after determining the name of the source code file, the log storage device may open the source code file in a read-write manner according to a path corresponding to the source code file in the log configuration file.
S502, the log storage device analyzes the source code file and determines the sequence number and the fixed field of the log record statement in the source code file.
Specifically, after determining the name of the source code file, the log macro definition and the log tag corresponding to the source code file, the log storage device may parse the source code file, and determine the sequence number and the fixed field of the log record statement in the source code file.
The log recording statement is used for generating log information corresponding to the log recording statement.
S503, the log storage device determines the unique log identification of the log recording statement according to the serial number of the log recording statement, the log macro definition and the log label.
Specifically, after the sequence number and the fixed field of the log recording statement in the source code file are determined, the log storage device may determine the unique log identifier of the log recording statement according to the sequence number of the log recording statement, the log macro definition, and the log tag.
For example, after the preset LOG storage device parses the configuration file, it is determined that the LOG macro corresponding to the source code file is defined as libbsplogid.h, the name of the source code file is abstrationlayer, and the LOG label of the source code file is BSP _ LOG _ abstratt _ BASE:0 × 01.
Then, the LOG storage device parses the source code file, and after determining that the sequence number of the a LOG record statement in the source code file is 1 and the sequence number of the B LOG record statement is 2, it may be determined that the unique LOG identifier of the a LOG record statement with the sequence number of 1 is LIB _ BSP _ LOG (BSP _ LOG _ ABSTRACT _ BASE _0:0 × 10000000), and the unique LOG identifier of the B LOG record statement with the sequence number of 2 is LIB _ BSP _ LOG (BSP _ LOG _ ABSTRACT _ BASE _1:0 × 10000001).
S504, the log storage device generates log resource information according to the fixed field of the log record statement, the unique log identification and the name of the source code file.
Specifically, after determining the unique log identifier of the log record statement, the log storage device may generate the log resource information according to the fixed field of the log record statement, the unique log identifier, and the name of the source code file.
Illustratively, the fixed field of the preset logging statement a is "input para is NULL \ n", the unique LOG id is LIB _ BSP _ LOG (BSP _ LOG _ MAIN _ BASE _0:0 × 10000001), the name of the source code file is bsmain, and the generated LOG resource information is "0 × 10000001bspbspmaininfo.
In an implementation manner, as shown in fig. 6 in conjunction with fig. 5, the log storage method further includes: and S601.
S601, the log storage device updates the source code identification of the log recording statement into a unique log identification.
Specifically, after determining the unique log identifier of the log record statement, the log storage device may update the source code identifier of the log record statement to the unique log identifier, so as to complete the update of the source code file. In this way, after the program code of the embedded product is generated by using the updated source code file, the log information generated by the embedded product for recording the running process may include a unique log identifier.
It should be noted that, in the embodiment of the present application, before the source code is compiled, the log storage device may update the source code identifier of each log record statement to be the unique log identifier, which not only can avoid the occurrence of a situation that the source code identifier of the log record statement is repeatedly used, but also can avoid a situation that the source code identifier of the log record statement is non-sequentially arranged in the source code file when the source code file is modified, such as deletion or supplement, and the like, and improve the accuracy of obtaining the log information.
In one implementation manner, as shown in fig. 7 in conjunction with fig. 4, in S405, the embedded product includes at least two storage spaces. The method for storing the log parameters in the first storage device corresponding to the embedded product by the log storage device specifically comprises the following steps: S701-S703.
S701, the log storage device stores the log parameters generated by the embedded product in the first time period in a first storage space.
Specifically, after extracting the log parameters for identifying the log information from the log information, the log storage device may store the log parameters generated by the embedded product in the first storage space during the first time period.
Optionally, when the system is started, the embedded product may reserve a segment of physical memory on the physical memory, and perform memory mapping by a preset method, so as to map the segment of physical memory into at least two storage spaces.
Alternatively, the physical memory may be a double data rate synchronous dynamic random access memory (DDR SDRAM).
Optionally, after mapping a segment of physical memory into at least two storage spaces, the embedded product may perform initialization operation on the at least two storage spaces, and complete setting of the file header. Definitions of statements such as judgment statements, counting statements, storage rule statements, and timing statements may be included in the header.
Optionally, the judgment statement may judge whether the log parameter exists in the current storage space through magic Word (magic Word). The magic number (magic Word) can be set as a fixed value during initialization, and can be cleared when the log parameters are transferred into the first storage device.
Alternatively, the counting statement may record the number of log pieces stored in the current storage space through logMsgNum. And the logMsgNum is 0 during initialization, 1 is automatically added every time a log parameter is added, and the log parameter can be cleared when being stored in the first storage device.
Optionally, the storage rule statement may store the size end information of the current log parameter during storage in endian, so as to correctly store the log parameter.
Optionally, the timing statement may be used to record the generation time of the log parameter.
Optionally, the preset method may be a mapping method based on the function mmap.
Alternatively, the first period of time may be determined when the number of log parameters recorded by the count statement increases from 0 to a preset number. The preset number may be set according to a size of the first storage space.
And S702, when the storage amount of the first storage space is smaller than the preset storage amount, the log storage device stores the log parameters generated by the embedded product in the second storage space in the second time period.
Specifically, after the log parameters generated by the embedded product in the first time period are stored in the first storage space, when the storage amount of the first storage space is less than the preset storage amount, the log storage device may store the log parameters generated by the embedded product in the second time period in the second storage space.
The second time period and the first time period are continuous time periods. The first storage space and the second storage space are any two storage spaces of the at least two storage spaces.
Optionally, the preset storage amount is a remaining storage amount of the preset first storage space, so that when the storage amount of the first storage space is smaller than the preset storage amount, that is, before the first storage space is completely occupied, the log parameters are stopped being stored in the first storage space.
S703, when the storage amount of the first storage space is smaller than the preset storage amount, or the duration of the first time period is longer than the preset duration, the log storage device stores the log parameters stored in the first storage space into the first storage device.
Specifically, after the log parameters generated by the embedded product in the first time period are stored in the first storage space, when the storage amount of the first storage space is less than the preset storage amount, or the duration of the first time period is greater than the preset duration, the log storage device may store the log parameters stored in the first storage space into the first storage device.
Illustratively, the storage amount of the first storage space is preset to be 0.1MB, and the preset storage amount is 0.2 MB. In this case, if the storage amount of the first storage space is less than the preset storage amount (i.e. 0.1MB is less than 0.2MB), the log storage device stops storing the log parameters into the first storage space, stores the log parameters generated by the embedded product in the first time period into the first storage space, and simultaneously stores the log parameters generated by the embedded product in the second time period into the second storage space.
Optionally, the preset duration may be preset manually and empirically, and stored in the header files of the at least two storage spaces when the initialization operation is performed on the at least two storage spaces.
Optionally, when the log storage device stores the log parameters stored in the first storage space into the first storage device, the log parameters may be stored in the first storage space and in an independent thread between the first storage space and the first storage device, so as to avoid system service jitter caused by a long dump time.
It should be noted that the number of times of erasing and writing of the first storage device (e.g., FLASH memory) corresponding to the embedded product is limited. When a large amount of log information is stored, if a method of storing one log information at a time is adopted, not only the service life of the first storage device is reduced, but also the system performance of the embedded product is seriously reduced.
In the embodiment of the application, the log storage device can store the log parameters generated by the embedded product in the first storage space in the first time period, and when the storage capacity of the first storage space is smaller than the preset storage capacity, or the duration of the first time period is larger than the preset duration, the log parameters of a certain number are stored in the first storage device at one time, so that the erasing times required by storing a large amount of log information can be greatly reduced, the service life of the first storage device is prolonged, and the system performance of the embedded product is improved. Meanwhile, when the restart is caused by an abnormal condition (such as system panic), the log storage device can export log information in a physical memory (such as DDR), so that the abnormal condition is defined.
In an implementation manner, as shown in fig. 8 in conjunction with fig. 4, the log storage method further includes: S801-S803.
S801, receiving a second request message for acquiring target log parameters by the log storage device.
Specifically, after the log parameter is stored in any one of the at least two storage spaces, when the target log parameter needs to be referred to meet the related business requirements (for example, the target log parameter is printed to the foreground, etc.), the worker may input a second request message for acquiring the target log parameter through the input module. Accordingly, the log storage may receive a second request message for obtaining the target log parameter.
Wherein the second request message includes a unique log identification corresponding to the target log parameter.
S802, responding to the second request message, the log storage device determines a target storage space for storing the target log parameter from at least two storage spaces according to the unique log identifier corresponding to the target log parameter.
Specifically, after receiving the second request message for obtaining the target log parameter, the log storage device may parse the second request message to determine the unique log identifier corresponding to the target log parameter.
Then, in response to the first request message, the log storage device may determine a target storage space storing the target log parameter from the at least two storage spaces according to the unique log identifier corresponding to the target log parameter.
And S803, the log storage device reads the target log parameters from the target storage space and outputs the target log parameters.
Specifically, after determining a target storage space for storing the target log parameter from at least two storage spaces, the log storage device may read the target log parameter from the target storage space and output the target log parameter.
Optionally, as for a method for the log storage device to read the target log parameters from the target storage space, reference may be made to a method for the log storage device to obtain, from the server, a source code file used for generating the embedded product and a configuration file used for describing configuration information of the source code file in S401, which is not described herein again.
It should be noted that, in the prior art, when the log information is printed to the foreground (i.e., output to the display device for display) through the system interface such as printk or printf, the log information cannot be stored at the same time, and the CPU resource of the system is greatly consumed, which cannot be applied to the service scenario with high real-time requirement. In the embodiment of the application, the log storage device can output the log parameters for printing while storing the log parameters in at least two storage spaces on the physical memory, thereby overcoming the problem that the storage and the printing can not be performed simultaneously in the prior art.
In the embodiment of the application, after receiving the log information sent by the embedded product, the log storage device can extract the log parameters for identifying the log information from the log information and store the log parameters in the first storage device corresponding to the embedded product. Because the storage occupation space of the log parameters is smaller than that of the log information, the method and the device can reduce the space occupied by the storage of the log information and enable the first storage device corresponding to the embedded product to store the log file more reasonably.
The scheme provided by the embodiment of the application is mainly introduced from the perspective of a method. To implement the above functions, it includes hardware structures and/or software modules for performing the respective functions. Those of skill in the art would readily appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as hardware or combinations of hardware and computer software. Whether a function is performed as hardware or computer software drives hardware depends upon the particular application and design constraints imposed on the solution. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
In the embodiment of the present application, the log storage device may be divided into functional modules according to the above method, for example, each functional module may be divided according to each function, or two or more functions may be integrated into one processing module. The integrated module can be realized in a hardware mode, and can also be realized in a software functional module mode. Optionally, the division of the modules in the embodiment of the present application is schematic, and is only a logic function division, and there may be another division manner in actual implementation.
Fig. 9 is a schematic structural diagram of a log storage device according to an embodiment of the present application. The log storage apparatus may be used to perform the log storage method as shown in fig. 4 to 8. The log storage device shown in fig. 9 includes: a receiving unit 901 and a processing unit 902.
The receiving unit 901 is configured to receive log information sent by an embedded product. For example, in conjunction with fig. 4, the receiving unit 901 may be configured to perform S403.
A processing unit 902, configured to extract a log parameter for identifying log information from the log information received by the receiving unit 901. The storage occupation space of the log parameters is smaller than that of the log information. For example, in conjunction with fig. 4, processing unit 902 may be configured to perform S404.
The processing unit 902 is further configured to store the log parameters in a first storage device corresponding to the embedded product. For example, in conjunction with fig. 4, processing unit 902 may be configured to perform S405.
Optionally, the processing unit 902 is further configured to parse the source code file based on the configuration file to obtain log resource information. The configuration file is used to describe configuration information of the source code file. The source code file is used to generate an embedded product. For example, in conjunction with fig. 4, processing unit 902 may be configured to perform S401.
The processing unit 902 is further configured to store the log resource information in the second storage device. For example, in conjunction with fig. 4, processing unit 902 may be configured to perform S402.
Optionally, the receiving unit 901 is further configured to receive a first request message for obtaining the target log. For example, in conjunction with fig. 4, the receiving unit 901 may be configured to perform S406.
The processing unit 902 is further configured to read, in response to the first request message, a target log parameter corresponding to the target log from the first storage device. For example, in conjunction with fig. 4, processing unit 902 may be configured to perform S407.
The processing unit 902 is further configured to read target log resource information corresponding to the target log from the second storage device. For example, in conjunction with fig. 4, processing unit 902 may be configured to perform S408.
The processing unit 902 is further configured to generate a target log according to the target log parameter and the target log resource information. For example, in conjunction with fig. 4, the processing unit 902 may be configured to execute S409.
Optionally, the processing unit 902 is further configured to determine, according to the configuration file, a name of the source code file, and a log macro definition and a log label corresponding to the source code file. For example, in conjunction with fig. 5, processing unit 902 may be configured to perform S501.
The processing unit 902 is further configured to parse the source code file, and determine a sequence number and a fixed field of a log record statement in the source code file. The logging statement is used to generate log information corresponding to the logging statement. For example, in conjunction with fig. 5, processing unit 902 may be configured to perform S502.
The processing unit 902 is further configured to determine a unique log identifier of the log recording statement according to the sequence number of the log recording statement, the log macro definition, and the log tag. For example, in conjunction with fig. 5, processing unit 902 may be configured to perform S503.
The processing unit 902 is further configured to generate log resource information according to the fixed field of the log record statement, the unique log identifier, and the name of the source code file. For example, in conjunction with fig. 5, processing unit 902 may be configured to perform S504.
Optionally, the processing unit 902 is further configured to update the source code identifier of the logging statement to a unique log identifier. For example, in conjunction with fig. 6, processing unit 902 may be configured to perform S601.
Optionally, the log parameter includes a unique log identifier, level information, a line number of a source code recorded in a log record statement corresponding to the log parameter, and service data generated by the source code.
Optionally, the embedded product includes at least two storage spaces. The processing unit 902 is further configured to store the log parameters generated by the embedded product in the first storage space during the first time period. For example, in conjunction with fig. 7, processing unit 902 may be configured to perform S701.
The processing unit 902 is further configured to store the log parameters generated by the embedded product in the second time period in the second storage space when the storage amount of the first storage space is less than the preset storage amount. The second time period is a continuous time period with the first time period. The first storage space and the second storage space are any two storage spaces of the at least two storage spaces. For example, in conjunction with fig. 7, processing unit 902 may be configured to perform S702.
The processing unit 902 is further configured to store the log parameters stored in the first storage space into the first storage device when the storage amount of the first storage space is less than the preset storage amount, or the duration of the first time period is greater than the preset duration. For example, in conjunction with fig. 7, the processing unit 902 may be configured to execute S703.
Optionally, the receiving unit 901 is further configured to receive a second request message for obtaining the target log parameter. The second request message includes a unique log identification corresponding to the target log parameter. For example, in conjunction with fig. 8, the receiving unit 901 may be configured to perform S801.
The processing unit 902 is further configured to, in response to the second request message, determine a target storage space storing the target log parameter from the at least two storage spaces according to the unique log identifier corresponding to the target log parameter. For example, in conjunction with fig. 8, the processing unit 902 may be configured to perform S802.
The processing unit 902 is further configured to read a target log parameter from the target storage space, and output the target log parameter. For example, in conjunction with fig. 8, the processing unit 902 may be configured to execute S803.
Those skilled in the art will recognize that in one or more of the examples described above, the functions described herein may be implemented in hardware, software, firmware, or any combination thereof. When implemented in software, the functions may be stored on or transmitted over as one or more instructions or code on a computer-readable medium. Computer-readable media includes both computer-readable storage media and communication media including any medium that facilitates transfer of a computer program from one place to another. A storage media may be any available media that can be accessed by a general purpose or special purpose computer.
Through the above description of the embodiments, it is clear to those skilled in the art that, for convenience and simplicity of description, the foregoing division of the functional modules is merely used as an example, and in practical applications, the above function distribution may be completed by different functional modules according to needs, that is, the internal structure of the device may be divided into different functional modules to complete all or part of the above described functions.
In the several embodiments provided in the present application, it should be understood that the disclosed apparatus and method may be implemented in other ways. For example, the above-described apparatus embodiments are merely illustrative, and for example, the division of the modules or units is only one logical function division, and there may be other division ways in actual implementation. For example, various elements or components may be combined or may be integrated into another device, or some features may be omitted, or not implemented. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form. Units described as separate parts may or may not be physically separate, and parts displayed as units may be one physical unit or a plurality of physical units, may be located in one place, or may be distributed to a plurality of different places. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
The above description is only for the specific embodiments of the present application, but the scope of the present application is not limited thereto, and any changes or substitutions that can be easily conceived by those skilled in the art within the technical scope of the present application should be covered within the scope of the present application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.

Claims (18)

1. A method of log storage, comprising:
receiving log information sent by an embedded product;
extracting log parameters for identifying the log information from the log information; the storage occupation space of the log parameters is smaller than that of the log information;
and storing the log parameters in a first storage device corresponding to the embedded product.
2. The log storage method according to claim 1, further comprising, before the receiving the log information sent by the embedded product:
analyzing the source code file based on the configuration file to obtain log resource information; the configuration file is used for describing configuration information of the source code file; the source code file is used for generating the embedded product;
and storing the log resource information in a second storage device.
3. The log storage method according to claim 2, further comprising:
receiving a first request message for acquiring a target log;
reading target log parameters corresponding to the target log from the first storage device in response to the first request message;
reading target log resource information corresponding to the target log from the second storage device;
and generating the target log according to the target log parameters and the target log resource information.
4. The log storage method of claim 2, wherein parsing the source code file based on the configuration file to obtain log resource information comprises:
determining the name of the source code file and a log macro definition and a log label corresponding to the source code file according to the configuration file;
analyzing the source code file, and determining a sequence number and a fixed field of a log record statement in the source code file; the log recording statement is used for generating log information corresponding to the log recording statement;
determining the unique log identifier of the log recording statement according to the serial number of the log recording statement, the log macro definition and the log label;
and generating the log resource information according to the fixed field of the log record statement, the unique log identification and the name of the source code file.
5. The log storage method according to claim 4, further comprising:
and updating the source code identification of the log recording statement into the unique log identification.
6. The log storage method according to claim 5, wherein the log parameters include the unique log identifier, level information, a line number of a source code recorded in a log record statement corresponding to the log parameters, and service data generated by the source code.
7. The log storage method of claim 6, wherein the embedded product comprises at least two storage spaces; the storing the log parameters in a first storage device corresponding to the embedded product includes:
storing the log parameters generated by the embedded product in a first time period in a first storage space;
when the storage capacity of the first storage space is smaller than the preset storage capacity, storing the log parameters generated by the embedded product in a second time period in a second storage space; the second time period is a continuous time period with the first time period; the first storage space and the second storage space are any two storage spaces in the at least two storage spaces;
and when the storage capacity of the first storage space is smaller than the preset storage capacity, or the duration of the first time period is longer than the preset duration, storing the log parameters stored in the first storage space into the first storage device.
8. The log storage method according to claim 7, further comprising:
receiving a second request message for acquiring target log parameters; the second request message comprises a unique log identifier corresponding to the target log parameter;
responding to the second request message, and determining a target storage space for storing the target log parameter from the at least two storage spaces according to the unique log identifier corresponding to the target log parameter;
and reading the target log parameters from the target storage space and outputting the target log parameters.
9. A log storage device, comprising: a receiving unit and a processing unit;
the receiving unit is used for receiving the log information sent by the embedded product;
the processing unit is used for extracting log parameters used for identifying the log information from the log information received by the receiving unit; the storage occupation space of the log parameters is smaller than that of the log information;
the processing unit is further configured to store the log parameters in a first storage device corresponding to the embedded product.
10. The log storage device of claim 9,
the processing unit is further used for analyzing the source code file based on the configuration file to obtain log resource information; the configuration file is used for describing configuration information of the source code file; the source code file is used for generating the embedded product;
the processing unit is further configured to store the log resource information in a second storage device.
11. The log storage device of claim 10,
the receiving unit is further configured to receive a first request message for acquiring a target log;
the processing unit is further configured to read, in response to the first request message received by the receiving unit, a target log parameter corresponding to the target log from the first storage device;
the processing unit is further configured to read target log resource information corresponding to the target log from the second storage device;
the processing unit is further configured to generate the target log according to the target log parameter and the target log resource information.
12. The log storage device of claim 10,
the processing unit is further configured to determine, according to the configuration file, a name of the source code file, and a log macro definition and a log label corresponding to the source code file;
the processing unit is further configured to analyze the source code file and determine a sequence number and a fixed field of a log record statement in the source code file; the log recording statement is used for generating log information corresponding to the log recording statement;
the processing unit is further configured to determine a unique log identifier of the log recording statement according to the sequence number of the log recording statement, the log macro definition, and the log tag;
the processing unit is further configured to generate the log resource information according to the fixed field of the log record statement, the unique log identifier, and the name of the source code file.
13. The log storage device of claim 12,
the processing unit is further configured to update the source code identifier of the log recording statement to the unique log identifier.
14. The log storage device of claim 13, wherein the log parameters comprise the unique log identifier, level information, a line number of a source code recorded by a log record statement corresponding to the log parameters, and service data generated by the source code.
15. The log storage device of claim 14 wherein the embedded product comprises at least two storage spaces;
the processing unit is further used for storing the log parameters generated by the embedded product in a first time period in a first storage space;
the processing unit is further used for storing the log parameters generated by the embedded product in a second time period in a second storage space when the storage capacity of the first storage space is smaller than a preset storage capacity; the second time period is a continuous time period with the first time period; the first storage space and the second storage space are any two storage spaces in the at least two storage spaces;
the processing unit is further configured to store the log parameters stored in the first storage space into the first storage device when the storage amount of the first storage space is smaller than the preset storage amount, or the duration of the first time period is longer than the preset duration.
16. The log storage device of claim 15,
the receiving unit is further configured to receive a second request message for acquiring a target log parameter; the second request message comprises a unique log identifier corresponding to the target log parameter;
the processing unit is further configured to determine, in response to the second request message received by the receiving unit, a target storage space in which the target log parameter is stored from the at least two storage spaces according to the unique log identifier corresponding to the target log parameter;
the processing unit is further configured to read the target log parameter from the target storage space and output the target log parameter.
17. A log storage device comprising a memory and a processor; the memory is used for storing computer execution instructions, and the processor is connected with the memory through a bus; the processor executes the computer-executable instructions stored by the memory to cause the log storage device to perform the log storage method of any of claims 1-8 when the log storage device is running.
18. A computer-readable storage medium comprising computer-executable instructions that, when executed on a computer, cause the computer to perform the log storage method of any of claims 1-8.
CN202111314887.8A 2021-11-08 2021-11-08 Log storage method and device and storage medium Pending CN114090375A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111314887.8A CN114090375A (en) 2021-11-08 2021-11-08 Log storage method and device and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111314887.8A CN114090375A (en) 2021-11-08 2021-11-08 Log storage method and device and storage medium

Publications (1)

Publication Number Publication Date
CN114090375A true CN114090375A (en) 2022-02-25

Family

ID=80299324

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111314887.8A Pending CN114090375A (en) 2021-11-08 2021-11-08 Log storage method and device and storage medium

Country Status (1)

Country Link
CN (1) CN114090375A (en)

Similar Documents

Publication Publication Date Title
US20150347305A1 (en) Method and apparatus for outputting log information
CN100517281C (en) Method and system for collocating computer system
CN111124277B (en) Deep learning data set caching method, system, terminal and storage medium
CN101963912A (en) Implementation method for storing and checking hardware configuration information of system
CN103399840A (en) Out-of-band altering method of configuration file of computer and computer
CN112000463B (en) GPU resource allocation method, system, terminal and storage medium based on CUDA
CN105573711B (en) A kind of data cache method and device
CN108345462B (en) Method and device for upgrading components
CN113890712A (en) Data transmission method and device, electronic equipment and readable storage medium
CN111259014B (en) Method and system for storing data of one-way linked list of FPGA (field programmable Gate array)
CN114090375A (en) Log storage method and device and storage medium
CN114995770B (en) Data processing method, device, equipment, system and readable storage medium
CN109710187A (en) Read command accelerated method, device, computer equipment and the storage medium of NVMe SSD main control chip
CN111061355B (en) Power supply data acquisition method and equipment
CN112632266B (en) Data writing method and device, computer equipment and readable storage medium
CN108521646B (en) Near field communication method, device and computer readable storage medium
CN108509478B (en) Splitting and calling method of rule engine file, electronic device and storage medium
CN107547208B (en) Energy saving method and device
CN114296906B (en) Business dynamic scaling method, device, equipment and storage medium
CN111813679B (en) Method and device for executing test case based on python, electronic equipment and storage medium
CN115243286B (en) Data processing method, device and storage medium
CN110750597A (en) Data processing method and device, storage medium and processor
CN112988250B (en) Multi-mainboard USB service configuration method, system, terminal and storage medium
CN115604667B (en) Message sending method, device, computer equipment and storage medium
CN111597179B (en) Method and device for automatically cleaning data, electronic equipment and storage medium

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