CN111752737A - Log storage method, electronic device and storage medium - Google Patents

Log storage method, electronic device and storage medium Download PDF

Info

Publication number
CN111752737A
CN111752737A CN202010518981.4A CN202010518981A CN111752737A CN 111752737 A CN111752737 A CN 111752737A CN 202010518981 A CN202010518981 A CN 202010518981A CN 111752737 A CN111752737 A CN 111752737A
Authority
CN
China
Prior art keywords
system event
event information
log
identifier
current system
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
CN202010518981.4A
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.)
Shenzhen Queclink Communication Technology Co ltd
Original Assignee
Shenzhen Queclink Communication Technology 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 Shenzhen Queclink Communication Technology Co ltd filed Critical Shenzhen Queclink Communication Technology Co ltd
Priority to CN202010518981.4A priority Critical patent/CN111752737A/en
Publication of CN111752737A publication Critical patent/CN111752737A/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/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/0703Error or fault processing not based on redundancy, i.e. by taking additional measures to deal with the error or fault not making use of redundancy in operation, in hardware, or in data representation
    • G06F11/0766Error or fault reporting or storing
    • G06F11/0787Storage of error reports, e.g. persistent data storage, storage using memory protection
    • 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/14Details of searching files based on file metadata
    • G06F16/148File search processing
    • 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/18File system types
    • G06F16/1805Append-only file systems, e.g. using logs or journals to store data
    • G06F16/1815Journaling file systems

Landscapes

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

Abstract

The embodiment of the invention relates to the field of data processing, and discloses a log storage method, electronic equipment and a storage medium. The method comprises the steps of generating current system event information according to a system event occurring in the electronic equipment, determining an identifier corresponding to the current system event information according to a corresponding relation between the system event information and the identifier, further generating a log corresponding to the current system event according to the identifier corresponding to the current system event information, and storing the log corresponding to the current system event into a memory.

Description

Log storage method, electronic device and storage medium
Technical Field
The embodiment of the invention relates to the field of computers, in particular to a log storage method, electronic equipment and a storage medium.
Background
In the operating process of the electronic device, the operating state of the electronic device is usually stored in a system log, where the system log includes specific description information of events that occur in the electronic device, for example, the system log includes a restart time of the electronic device, a description of a restart event, and a log level corresponding to the restart event. When the electronic equipment fails, a user can presume the failure type of the electronic equipment by reading the system log. And when the memory space occupied by the stored system log exceeds the memory space which can be provided by the electronic equipment, deleting the previously stored system log.
The inventor finds that at least the following problems exist in the prior art: because the memory space of the embedded device is small, the space available for storing the system logs is limited, and the storage space which can be provided by the embedded device can be occupied by the system logs with small storage quantity.
Disclosure of Invention
The embodiment of the invention aims to provide a log storage method, electronic equipment and a storage medium, so that the space occupied by a log is smaller.
In order to solve the above technical problem, an embodiment of the present invention provides a log storage method, including the following steps:
generating current system event information according to a system event which occurs currently in the electronic equipment;
determining an identifier corresponding to the current system event information according to the corresponding relation between the system event information and the identifier; identifying that the number of occupied bytes is less than the number of bytes occupied by system event information;
and generating a log corresponding to the currently occurring system event according to the identifier corresponding to the current system event information, and storing the log corresponding to the currently occurring system event into a memory.
An embodiment of the present invention also provides an electronic device, including:
at least one processor; and the number of the first and second groups,
a memory communicatively coupled to the at least one processor; wherein the content of the first and second substances,
the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the log storage method described above.
Embodiments of the present invention also provide a computer-readable storage medium storing a computer program, which when executed by a processor implements the log storage method described above.
Compared with the prior art, the embodiment of the invention generates the current system event information according to the system event currently occurring in the electronic equipment, and determining the identifier corresponding to the current system event information according to the corresponding relationship between the system event information and the identifier, further generating a log corresponding to the currently occurring system event according to the identifier corresponding to the current system event information, and stores the log corresponding to the currently occurring system event into the memory, because the number of bytes occupied by the identifier is less than the number of bytes occupied by the system event information, the number of bytes occupied by generating the log corresponding to the currently occurring system event according to the identification is smaller than the number of bytes occupied by generating the log according to the system event information, the occupied memory space of the logs corresponding to the currently occurring system events is reduced, and the number of the logs stored in the memory with limited space is increased.
In addition, before determining the target identifier corresponding to the current system event information according to the corresponding relationship between the system event information and the identifier, the method further comprises: acquiring an event grade of a currently occurring system event, wherein the event grade is used for indicating the importance grade of the currently occurring system event: and when the event grade of the currently generated system event is not lower than the grade threshold, determining the identifier corresponding to the current system event information according to the corresponding relation between the system event information and the identifier. And determining the identifier corresponding to the current system event information according to the corresponding relationship between the system event information and the identifier only when the event grade of the current system event is not lower than the grade threshold, so that only the log of the system event of which the event grade is not lower than the grade threshold is generated when the log corresponding to the current system event is generated, and further only the log of the system event of which the event grade is not lower than the grade threshold is stored when the log is stored, thereby more effectively utilizing the limited memory space.
In addition, when the event level of the currently occurring system event is not lower than the level threshold, before determining the identifier corresponding to the current system event information according to the corresponding relationship between the system event information and the identifier, the method further comprises: the level threshold is determined based on a level instruction entered by a user. And determining a grade threshold according to a grade instruction input by a user, so that whether the current identification corresponding to the system event information is determined according to the corresponding relation between the system event information and the identification according to the event grade of the current system event, further generating a log corresponding to the system event according to the identification corresponding to the current system event information, and flexibly determining whether the log is stored according to the requirement of the user when the log corresponding to the system event is stored.
In addition, when the event level of the currently occurring system event is not lower than the level threshold, before determining the identifier corresponding to the current system event information according to the corresponding relationship between the system event information and the identifier, the method further comprises: and determining a grade threshold value according to the memory value of the residual space of the memory. The grade threshold is determined according to the memory value of the residual space of the memory, so that the grade threshold is automatically determined according to the memory value of the residual space of the memory, and the intelligence of determining whether to store the log corresponding to the current system event according to the event grade of the current system event is improved.
In addition, before determining the identifier corresponding to the current system event information according to the corresponding relationship between the system event information and the identifier, the method further comprises: acquiring an event type of a system event which currently occurs in the electronic equipment; when the event type of the current system event belongs to an event type set, determining an identifier corresponding to the current system event information according to the corresponding relation between the system event information and the identifier, wherein the event type set comprises at least one event type. The method comprises the steps that only when the event type of the current system event belongs to an event type set, the identification corresponding to the current system event information is determined according to the corresponding relation between the system event information and the identification, so that only the log of the system event of which the event type belongs to the event type set is generated when the log corresponding to the system event is generated, and further, only the log of the system event of which the event type belongs to the event type set is stored when the log is stored, and limited memory space is utilized more effectively.
In addition, when the event type of the currently occurring system event belongs to the event type set, before determining the identifier corresponding to the current system event information according to the corresponding relationship between the system event information and the identifier, the method further includes: and acquiring a selection instruction input by a user, and determining an event type set. The event type set is determined according to a selection instruction input by a user, so that whether the log corresponding to the currently occurring system event is stored or not can be flexibly determined according to the requirement of the user when the log corresponding to the currently occurring system event is determined or not according to the event type of the currently occurring system event.
In addition, the method further comprises: receiving a query instruction input by a user, and identifying a log to be queried indicated by the query instruction; acquiring a log to be queried from a memory; and displaying system event information corresponding to the log to be inquired.
In addition, the displaying of the system event information corresponding to the log to be queried includes: and displaying the system event information corresponding to the log to be inquired according to the identification in the log to be inquired and the corresponding relation between the system event information and the identification. The method and the device have the advantages that the system event information corresponding to the log to be inquired is displayed according to the identification in the log to be inquired and the corresponding relation between the system event information and the identification, so that a user can visually read the system event information expressed by the log to be inquired, the intuitiveness of the displayed system event information is improved, and the accuracy of the user for estimating the fault type of the electronic equipment according to the system log is improved.
Drawings
One or more embodiments are illustrated by way of example in the accompanying drawings, which correspond to the figures in which like reference numerals refer to similar elements and which are not to scale unless otherwise specified.
FIG. 1 is a flow diagram that illustrates a method for log storage in one embodiment;
FIG. 2 is a flow chart illustrating a method for storing logs in another embodiment;
FIG. 3 is a flowchart illustrating a log storage method according to another embodiment;
FIG. 4 is a flowchart illustrating a log storage method according to another embodiment;
fig. 5 is a schematic structural diagram of an electronic device in one embodiment.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention more apparent, embodiments of the present invention will be described in detail below with reference to the accompanying drawings. However, it will be appreciated by those of ordinary skill in the art that numerous technical details are set forth in order to provide a better understanding of the present application in various embodiments of the present invention. However, the technical solution claimed in the present application can be implemented without these technical details and various changes and modifications based on the following embodiments. The following embodiments are divided for convenience of description, and should not be construed as limiting the specific implementation manner of the present invention, and the embodiments are not contradictory.
As a common electronic device, various failures often occur in the using or developing process of the embedded device, and in order to enable a technician to locate the cause of the failure as soon as possible, system events occurring in the embedded device are usually recorded in a system log in real time and stored in a memory of the embedded device, wherein the system log includes system event information for describing the system events. For example:
and (3) error code: 0xA5
And (3) expression of characters: "Error A occurred with the Error code 0xA 5"
The time of occurrence: 20200328-193018
The log type: SYS
The generated system log is as follows: [20200328- & 193018] [ SYS ] Error A occurred with the Error code 0xA5. each character occupies 1 byte, and the system log occupies 65 bytes in total. When the user needs to view the system log, the system log displayed to the user is: [20200328- & 193018] [ SYS ] Error A occurred with the Error code 0xA5.
However, due to cost limitation, the embedded device usually uses a memory with a small storage capacity, a small space is used for storing the system logs, and the number of the stored system logs is small.
Fig. 1 is a flowchart illustrating a log storage method in an embodiment, and this embodiment relates to a specific process of how to reduce the number of bytes occupied by stored logs. The following describes implementation details of the log storage method according to the present embodiment in detail, and the following is only provided for facilitating understanding of the implementation details and is not necessary for implementing the present embodiment. As shown in fig. 1, the method includes:
step 101, generating current system event information according to a system event currently occurring in the electronic device.
The memory space for storing the system log in the electronic device is smaller than a preset threshold, for example, the electronic device may be an embedded device. The System event may be various types of events occurring on the electronic device, such as device restart, System clock exception, Global Navigation Satellite System (GNSS) location update data … …, and the System event information typically describes the System event by fixed characters, such as: the system event information of the system clock abnormity comprises the following information: SysTick enable! And nd it's interrupt interval is% d ms. When the system event currently occurring in the electronic device is determined, the system event can be described by the corresponding fixed character, that is, the current system event information is generated.
102, determining an identifier corresponding to the current system event information according to the corresponding relation between the system event information and the identifier; the number of bytes occupied by the identification is less than the number of bytes occupied by the system event information.
As can be seen from the above description, the system event information generally describes the system event using fixed characters, and a user can generally directly read the information described by the system event information. The identifier may be a number or a letter, which is not limited in this embodiment as long as the number of bytes occupied by the identifier is less than the number of bytes occupied by the system event information. That is, the system event information typically occupies a larger number of bytes than the identification. The correspondence between the system event information and the identifier may be preset, for example, as shown in table 1, one system event information is corresponded by one number. When the system event information is generated, the identifier corresponding to the current system event information can be determined according to the corresponding relationship between the system event information and the identifier.
TABLE 1
Identification System event information
0 CPU reset!And the reason is 0x%X.
1 SysTick enable!And it's interrupt interval is%d ms
2 RTC enable!And it's interrupt interval is%d ms
…… ……
100 GNSS has closed
…… ……
And 103, generating a log corresponding to the currently occurring system event according to the identifier corresponding to the current system event information, and storing the log corresponding to the currently occurring system event into a memory.
When the identifier corresponding to the current system event information is determined, a log corresponding to the system event can be generated according to the identifier corresponding to the current system event information. When the log corresponding to the system event is generated according to the identifier corresponding to the current system event information, the system event information in the traditional system log can be replaced by the corresponding identifier to generate the log corresponding to the system event, and other contents in the log are kept unchanged. The log may include the contents as shown in table 2, where the number of bytes occupied by the identifier is 2, which is much smaller than the number of bytes occupied by the system event information.
TABLE 2
Figure BDA0002531204730000051
Figure BDA0002531204730000061
For example, the conventional system log is "[ 20200328- & 193018] [ GNSS ]: GNSS has closed. Wherein, the identifier corresponding to the system event information "GNSS has closed" is 100, and the log corresponding to the system event is generated according to the identifier corresponding to the current system event information as "[ 20200328 and 193018] [ GNSS ]:100 ]. That is, the number of bytes occupied by generating the log corresponding to the system event according to the identifier corresponding to the current system event information is smaller than the number of bytes occupied by generating the log according to the system event information.
The log storage method generates current system event information according to the current system event of the electronic equipment, and determining the identifier corresponding to the current system event information according to the corresponding relationship between the system event information and the identifier, further generating a log corresponding to the currently occurring system event according to the identifier corresponding to the current system event information, and stores the log corresponding to the currently occurring system event into the memory, because the number of bytes occupied by the identifier is less than the number of bytes occupied by the system event information, the number of bytes occupied by generating the log corresponding to the system event according to the identifier corresponding to the current system event information is less than the number of bytes occupied by generating the log according to the system event information, the memory space occupied by the logs corresponding to the currently-occurring system events is reduced, and the number of the system logs stored in the memory with limited space is increased.
In an embodiment, before determining the identifier corresponding to the current system event information according to the corresponding relationship between the system event information and the identifier, the event level of the current system event may be obtained first, and then whether the identifier corresponding to the current system event information needs to be determined according to the corresponding relationship between the system event information and the identifier according to the event level of the current system event is determined. This is described in detail below by means of the embodiment shown in fig. 2. As shown in fig. 2, the method further comprises:
step 201, obtaining an event grade of a currently occurring system event, where the event grade is used to indicate an importance grade of the currently occurring system event.
For example, the event level of a system event may include one or more of DEBUG, INFO, WARN, ERROR, and EMERC; the event levels are DEBUG, INFO, WARN, ERROR and EMERC in sequence from low to high according to importance. Wherein, DEBUG: the log of the lowest level is represented, the importance degree of the information is general, and the output frequency is high; and (3) INFO: indicating that the importance level is higher than the DEBUG, the output frequency is generally lower than the DEBUG, and the INFO level is usually used to record some more important things that occur during normal use of the device; WARN: the representation importance degree is higher than the INFO grade but lower than the ERROR grade, and the grade is generally used for recording some common abnormal phenomena (abnormal phenomena which are not enough to cause software exception) which occur in the working process of the equipment; ERROR: representing a very important event grade, generally recording some serious abnormal phenomena occurring in the working process of the equipment by using the grade, wherein the serious abnormal phenomena are likely to cause the equipment to fail to work normally; EMERC: the log representing the highest level typically records significant system-level anomalies. Different system events correspond to different event classes.
Step 202, when the event grade of the currently occurring system event is not lower than the grade threshold, determining the identifier corresponding to the current system event information according to the corresponding relationship between the system event information and the identifier.
When the event level of the currently occurring system event is not lower than the level threshold, determining the identifier corresponding to the current system event information according to the corresponding relationship between the system event information and the identifier, further generating a log corresponding to the currently occurring system event according to the identifier corresponding to the current system event information, and storing the log corresponding to the currently occurring system event into the memory. When the event level of the currently occurring system event is lower than the level threshold, the identifier corresponding to the current system event information does not need to be determined according to the corresponding relationship between the system event information and the identifier, that is, a log corresponding to the system event does not need to be generated according to the identifier corresponding to the current system event information, and the log corresponding to the currently occurring system event is stored in the memory. That is, when the event level of the currently occurring system event is lower than the level threshold, the log corresponding to the currently occurring system event is not stored.
According to the log storage method, the identification corresponding to the current system event information is determined according to the corresponding relation between the system event information and the identification only when the event grade of the current system event is not lower than the grade threshold, so that only the log of the system event of which the event grade is not lower than the grade threshold is generated when the log corresponding to the current system event is generated, and further only the log of the system event of which the event grade is not lower than the grade threshold is stored when the log is stored, and the limited memory space is more effectively utilized.
In an embodiment, when the event level of the currently occurring system event is not lower than the level threshold, before determining the identifier corresponding to the current system event information according to the correspondence between the system event information and the identifier, optionally, the level threshold is determined according to a level instruction input by a user.
The level instruction input by the user may be a voice instruction, a text instruction, or a touch instruction, which is not limited in the embodiments of the present application. The electronic device may determine the rating threshold based on the event rating indicated in the rating directive entered by the user.
According to the log storage method, the grade threshold value is determined according to the grade instruction input by the user, so that whether the log corresponding to the current system event is stored or not is determined according to the corresponding relation between the system event information and the identification according to the event grade of the current system event, the identification corresponding to the current system event information is determined, the log corresponding to the current system event is generated according to the identification corresponding to the current system event information, and when the log corresponding to the current system event is stored, whether the log is stored or not can be flexibly determined according to the requirements of the user.
In an embodiment, when the event level of the currently occurring system event is not lower than the level threshold, before determining the identifier corresponding to the current system event information according to the correspondence between the system event information and the identifier, optionally, the level threshold is determined according to the memory value of the remaining space of the memory.
For example, when the memory value of the remaining space of the memory is greater than the first preset threshold, the level threshold may be set to INFO, and when the event level of the currently occurring system event is not lower than INFO, for example, when the event level of the currently occurring system event is INFO, WARN, ERROR, or ERROR, the identifier corresponding to the current system event information is determined according to the correspondence between the system event information and the identifier, and then a log corresponding to the currently occurring system event is generated according to the identifier corresponding to the current system event information, and the log corresponding to the currently occurring system event is stored in the memory, that is, when the event level of the currently occurring system event is DEBUG, the log corresponding to the currently occurring system event is not stored. When the memory value of the remaining space of the memory is smaller than a second preset threshold, which is smaller than the first preset threshold, the level threshold may be set as the WARN, and only when the event level of the currently occurring system event is not lower than the WARN and is the WARN, ERROR or EMERC, the identifier corresponding to the current system event information is determined according to the corresponding relationship between the system event information and the identifier, and then the log corresponding to the currently occurring system event is generated according to the identifier corresponding to the current system event information, and the log corresponding to the currently occurring system event is stored in the memory. That is, when the event level of the currently occurring system event is DEBUG or INFO, the log corresponding to the currently occurring system event is not stored.
According to the log storage method, the grade threshold is determined according to the memory value of the residual space of the memory, so that the grade threshold is automatically determined according to the memory value of the residual space of the memory, and the intelligence of determining whether to store the log corresponding to the currently occurring system event according to the event grade of the currently occurring system event is improved. Meanwhile, by adopting the log storage method provided by the application, when the residual space of the memory is insufficient, the grade of the stored log can be intelligently adjusted so as to ensure that the important log can be stored.
In an embodiment, before determining the identifier corresponding to the current system event information according to the corresponding relationship between the system event information and the identifier, an event type of a system event currently occurring in the electronic device may be obtained first, and then it is determined whether to determine the identifier corresponding to the current system event information according to the corresponding relationship between the system event information and the identifier according to the event type, which is described in detail below with reference to fig. 3, as shown in fig. 3, the method further includes:
step 301, acquiring an event type of a system event currently occurring in the electronic device.
The system events may be divided into a limited number of event types according to specific events, for example, system events related to the system are divided into system classes; classifying system events related to GNSS positioning into GNSS classes; system events related to bluetooth low energy are classified as bluetooth low energy class. When a system event occurs, the event type of the system event may be determined based on the particular system event.
Step 302, when the event type of the current system event belongs to the event type set, determining the identifier corresponding to the current system event information according to the corresponding relationship between the system event information and the identifier; the event type set comprises at least one event type.
Wherein, the event type set comprises at least one event type. When the event type of the current system event belongs to the event type set, determining the identifier corresponding to the current system event information according to the corresponding relationship between the system event information and the identifier, further generating the log corresponding to the current system event according to the identifier corresponding to the current system event information, and storing the log corresponding to the current system event into the memory. That is, only if the event type of the currently occurring system event belongs to the set of system event types, the log of the system event is stored. When the event type of the currently occurring system event does not belong to the event type set, the identifier corresponding to the current system event information does not need to be determined according to the corresponding relationship between the system event information and the identifier, that is, the log corresponding to the currently occurring system event does not need to be generated according to the identifier corresponding to the current system event information, and the log corresponding to the currently occurring system event is stored in the memory. That is, when the event type of the currently occurring system event does not belong to the event type set, the log corresponding to the currently occurring system event is not stored.
In one possible case, when the corresponding identifier of the system event information is a number, the corresponding identifier of the system event information of the same event type may be an adjacent number, for example, as shown in table 3. When the event type is a system type, the corresponding mark of each system event information is a number between 0 and 99; when the event type is GNSS, the corresponding identifier of each system event information is 100-1000 digits; when the event type is the low power consumption bluetooth class, the corresponding identifier of each system event information is a number of 1001 and 2000.
TABLE 3
Identification Event type
0-99 System for controlling a power supply
100-1000 GNSS
1001-2000 Low power consumption Bluetooth
…… ……
According to the log storage method, only when the event type of the currently-occurring system event belongs to the event type set, the identifier corresponding to the current system event information is determined according to the corresponding relation between the system event information and the identifier, so that only the log of the system event of which the event type belongs to the event type set is generated when the log corresponding to the currently-occurring system event is generated, further, only the log of the system event of which the event type belongs to the event type set is stored when the log is stored, and the limited memory space is more effectively utilized.
In an embodiment, when the event type of the currently occurring system event belongs to the event type set, before determining the identifier corresponding to the current system event information according to the correspondence between the system event information and the identifier, optionally, a selection instruction input by a user is obtained, and the event type set is determined.
Wherein, the event type set comprises at least one event type. The selection instruction input by the user may be a voice instruction, a text instruction, or a touch instruction, which is not limited in the embodiments of the present application. The electronic equipment can select at least one event type from a plurality of event types according to a selection instruction input by a user, and the selected event type is used as an event type in the event type set; or according to a selection instruction input by a user, selecting a target event type from a plurality of event types, and using other event types as the event types in the event type set. It should be noted that, in one possible case, the target event type is null.
According to the log storage method, the event type set is determined according to the selection instruction input by the user, so that whether the log corresponding to the currently occurring system event is stored or not can be flexibly determined according to the requirement of the user when the log corresponding to the currently occurring system event is determined or not according to the event type of the currently occurring system event.
On the basis of the embodiment, the electronic device can also display the system event information corresponding to the log to be queried to the user according to the query instruction input by the user. As will be described in detail below with reference to fig. 4, as shown in fig. 4, the method further includes:
step 401, receiving a query instruction input by a user, and identifying a log to be queried indicated by the query instruction.
The query instruction received by the user may be a voice instruction received by the user, a text instruction received by the user, or a touch instruction received by the user, which is not limited in the embodiment of the present application. The query instruction is used for indicating a log to be queried. The log to be stored can be indicated by indicating the time of log generation, and the log to be stored can also be indicated by indicating the number of the log, which is not limited in the embodiment of the present application. The log to be stored indicated by the query instruction may be one log or a plurality of logs, which is not limited in this embodiment of the present application. For example, the log to be queried indicated by the query instruction is all the time between the time a and the time B when the log is generated.
Step 402, obtaining a log to be queried from a memory.
And step 403, displaying system event information corresponding to the log to be queried.
When the log to be stored is obtained from the memory, the system event information corresponding to the log to be inquired is displayed to a user, so that the user can read the system event information and presume the fault type of the electronic equipment according to the system event information. Optionally, the system event information corresponding to the log to be queried is displayed according to the identifier in the log to be queried and the corresponding relationship between the system event information and the identifier. For example, when the identifier in the log to be queried is 100, the system event information corresponding to the log may be output as "GNSS has closed" according to the correspondence shown in table 1.
According to the log storage method, the system event information corresponding to the log to be queried is displayed through the identification in the log to be queried and the corresponding relation between the system event information and the identification, so that a user can visually read the system event information expressed by the log to be queried, the intuitiveness of the displayed system event information is improved, and the accuracy of the user for estimating the fault type of the electronic equipment according to the system log is improved.
In one embodiment, similar to the traditional approach, there are system events:
and (3) error code: 0xA5
And (3) expression of characters: "Error A occurred with the Error code 0xA 5"
The time of occurrence: 20200328-193018
The log type: SYS
Log corresponding ID: 100
Log level: WARN
Carrying data: error code
When the system log is stored, the stored system log is as follows:
a time stamp [1585395018], wherein the time stamp is converted to seconds since 1/00 of 1970, and takes 6 bytes of 4 bytes plus the character '[', ']';
log ID (2 bytes) 100;
carrying data: 0xA5, occupying 1 byte;
the check code takes 1 byte.
That is, the system log occupies 11 bytes in total, which is much smaller than the byte number occupied by the system log in the conventional method. When the user needs to read the system log, the system log displayed to the user is [ 20200328-. This is consistent with the traditional method of displaying the system log to the user without losing any information.
The above examples are merely illustrative for easy understanding, and do not limit the technical aspects of the present invention.
The steps of the above methods are divided for clarity, and the implementation may be combined into one step or split some steps, and the steps are divided into multiple steps, so long as the same logical relationship is included, which are all within the protection scope of the present patent; it is within the scope of the patent to add insignificant modifications to the algorithms or processes or to introduce insignificant design changes to the core design without changing the algorithms or processes.
Another embodiment of the invention relates to an electronic device, as shown in fig. 5, comprising at least one processor 401; a memory 402 communicatively coupled to the at least one processor 401; the memory 402 stores instructions executable by the at least one processor 401 to cause the at least one processor 401 to perform the method steps illustrated in the above-described method class embodiments.
Where the memory 402 and the processor 401 are coupled by a bus, which may include any number of interconnected buses and bridges that couple one or more of the various circuits of the processor 401 and the memory 402 together. The bus may also connect various other circuits such as peripherals, voltage regulators, power management circuits, and the like, which are well known in the art, and therefore, will not be described any further herein. A bus interface provides an interface between the bus and the transceiver. The transceiver may be one element or a plurality of elements, such as a plurality of receivers and transmitters, providing a means for communicating with various other apparatus over a transmission medium. The data processed by the processor 401 may be transmitted over a wireless medium via an antenna, which may receive the data and transmit the data to the processor 401.
The processor 401 is responsible for managing the bus and the processor's conventional processing functions, and may also provide various functions including timing, peripheral interfaces, voltage regulation, power management, and other control functions. And memory 402 may be used to store data used by processor 401 in performing operations.
Another embodiment of the present invention relates to a computer-readable storage medium storing a computer program. The computer program realizes the above-described method embodiments when executed by a processor.
That is, as can be understood by those skilled in the art, all or part of the steps in the method for implementing the embodiments described above may be implemented by a program instructing related hardware, where the program is stored in a storage medium and includes several instructions to enable a device (which may be a single chip, a chip, or the like) or a processor (processor) to execute all or part of the steps of the method described in the embodiments of the present application. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes.
It will be understood by those of ordinary skill in the art that the foregoing embodiments are specific examples for carrying out the invention, and that various changes in form and details may be made therein without departing from the spirit and scope of the invention in practice.

Claims (10)

1. A method of log storage, comprising:
generating current system event information according to a system event which occurs currently in the electronic equipment;
determining an identifier corresponding to the current system event information according to the corresponding relationship between the system event information and the identifier; the number of bytes occupied by the identifier is less than the number of bytes occupied by the system event information;
and generating a log corresponding to the currently occurring system event according to the identifier corresponding to the current system event information, and storing the log corresponding to the currently occurring system event into a memory.
2. The method according to claim 1, wherein before determining the identifier corresponding to the current system event information according to the correspondence between the system event information and the identifier, the method further comprises:
acquiring an event grade of the currently occurring system event, wherein the event grade is used for indicating the importance grade of the currently occurring system event;
the determining the identifier corresponding to the current system event information according to the corresponding relationship between the system event information and the identifier includes:
and when the event grade of the currently occurring system event is not lower than the grade threshold, determining the identifier corresponding to the current system event information according to the corresponding relation between the system event information and the identifier.
3. The method according to claim 2, wherein when the event level of the currently occurring system event is not lower than the level threshold, before determining the identifier corresponding to the current system event information according to the correspondence between the system event information and the identifier, the method further comprises:
and determining the grade threshold according to the grade instruction input by the user.
4. The method according to claim 2, wherein when the event level of the currently occurring system event is not lower than the level threshold, before determining the identifier corresponding to the current system event information according to the correspondence between the system event information and the identifier, the method further comprises:
and determining the grade threshold according to the memory value of the residual space of the memory.
5. The method according to any one of claims 1 to 4, wherein before determining the identifier corresponding to the current system event information according to the correspondence between the system event information and the identifier, the method further comprises:
acquiring the event type of a system event currently occurring in the electronic equipment;
the determining the identifier corresponding to the current system event information according to the corresponding relationship between the system event information and the identifier includes:
when the event type of the current system event belongs to the event type set, determining an identifier corresponding to the current system event information according to the corresponding relation between the system event information and the identifier; the event type set comprises at least one event type.
6. The method according to claim 5, wherein before determining the identifier corresponding to the current system event information according to the correspondence between system event information and identifiers when the event type of the currently occurring system event belongs to the set of event types, the method further comprises:
and determining the event type set according to a selection instruction input by a user.
7. The method according to any one of claims 1-3, further comprising:
receiving a query instruction input by a user, and identifying a log to be queried indicated by the query instruction;
acquiring a log to be queried from a memory;
and displaying the system event information corresponding to the log to be inquired.
8. The method according to claim 7, wherein the displaying the system event information corresponding to the log to be queried comprises:
and displaying the system event information corresponding to the log to be inquired according to the identification in the log to be inquired and the corresponding relation between the system event information and the identification.
9. An electronic device, comprising: at least one processor; and the number of the first and second groups,
a memory communicatively coupled to the at least one processor; wherein the content of the first and second substances,
the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the log storage method of any of claims 1 to 8.
10. A computer-readable storage medium storing a computer program, wherein the computer program, when executed by a processor, implements the log storage method of any one of claims 1 to 8.
CN202010518981.4A 2020-06-09 2020-06-09 Log storage method, electronic device and storage medium Pending CN111752737A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010518981.4A CN111752737A (en) 2020-06-09 2020-06-09 Log storage method, electronic device and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010518981.4A CN111752737A (en) 2020-06-09 2020-06-09 Log storage method, electronic device and storage medium

Publications (1)

Publication Number Publication Date
CN111752737A true CN111752737A (en) 2020-10-09

Family

ID=72675864

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010518981.4A Pending CN111752737A (en) 2020-06-09 2020-06-09 Log storage method, electronic device and storage medium

Country Status (1)

Country Link
CN (1) CN111752737A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113190399A (en) * 2021-03-30 2021-07-30 深圳市广和通无线股份有限公司 Log storage method and device, computer equipment and storage medium

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108629865A (en) * 2018-04-28 2018-10-09 百度在线网络技术(北京)有限公司 Generation method, device, equipment and the storage medium of fault log
CN109375871A (en) * 2018-09-26 2019-02-22 郑州云海信息技术有限公司 A kind of log processing method, system and electronic equipment and storage medium
CN111092946A (en) * 2019-12-18 2020-05-01 博依特(广州)工业互联网有限公司 Data processing method and system applied to edge computing gateway
CN111221790A (en) * 2019-10-25 2020-06-02 苏州浪潮智能科技有限公司 Log file processing method and device and computer readable storage medium

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108629865A (en) * 2018-04-28 2018-10-09 百度在线网络技术(北京)有限公司 Generation method, device, equipment and the storage medium of fault log
CN109375871A (en) * 2018-09-26 2019-02-22 郑州云海信息技术有限公司 A kind of log processing method, system and electronic equipment and storage medium
CN111221790A (en) * 2019-10-25 2020-06-02 苏州浪潮智能科技有限公司 Log file processing method and device and computer readable storage medium
CN111092946A (en) * 2019-12-18 2020-05-01 博依特(广州)工业互联网有限公司 Data processing method and system applied to edge computing gateway

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113190399A (en) * 2021-03-30 2021-07-30 深圳市广和通无线股份有限公司 Log storage method and device, computer equipment and storage medium

Similar Documents

Publication Publication Date Title
CN109086199B (en) Method, terminal and storage medium for automatically generating test script
CN102866961A (en) Memory transfer with extended data and user privacy protection
US20120136613A1 (en) Extensible testing system
CN111813680B (en) Method and device for generating test script, computer equipment and storage medium
CN111125220B (en) Information custom export method and device
CN110765750A (en) Report data entry method and terminal equipment
CN115562587A (en) Data storage method, device and equipment applied to storage medium and storage medium
CN111752737A (en) Log storage method, electronic device and storage medium
CN113590405A (en) Hard disk error detection method and device, storage medium and electronic device
CN113050020B (en) Out-of-tolerance event recording method and device for double-core intelligent ammeter and computer equipment
CN116302079B (en) Service data processing method and device, electronic equipment and storage medium
CN105009006A (en) Programmable controller, programmable controller system, and execute error information creation method
CN113704177B (en) Storage method, system and related components of server firmware upgrade file
CN113590581B (en) Data transmission method, device, equipment and storage medium
US10922023B2 (en) Method for accessing code SRAM and electronic device
CN113407989A (en) Data desensitization method and device, electronic equipment and storage medium
CN111914128A (en) Method and device for determining associated user, electronic equipment and readable storage medium
CN112632266A (en) Data writing method and device, computer equipment and readable storage medium
CN112905396B (en) Information display method, device and equipment and storage medium
CN111078718B (en) Frequency control method, device, equipment and computer storage medium
CN111309623B (en) Coordinate class data classification test method and device
CN110795297B (en) Electronic equipment testing method and device
CN113434359B (en) Data traceability system construction method and device, electronic device and readable storage medium
CN101685411A (en) Method for automatically backing up and restoring data and article capable of being read by computer
CN116010138A (en) GPU control method, device, electronic equipment and computer readable 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