CN114356638A - Log saving method and device, storage medium and computer equipment - Google Patents

Log saving method and device, storage medium and computer equipment Download PDF

Info

Publication number
CN114356638A
CN114356638A CN202210007920.0A CN202210007920A CN114356638A CN 114356638 A CN114356638 A CN 114356638A CN 202210007920 A CN202210007920 A CN 202210007920A CN 114356638 A CN114356638 A CN 114356638A
Authority
CN
China
Prior art keywords
buffer area
log
system log
buffer
judged
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
CN202210007920.0A
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.)
Guangdong Haohang Technology Co ltd
Original Assignee
Guangdong Haohang 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 Guangdong Haohang Technology Co ltd filed Critical Guangdong Haohang Technology Co ltd
Priority to CN202210007920.0A priority Critical patent/CN114356638A/en
Publication of CN114356638A publication Critical patent/CN114356638A/en
Pending legal-status Critical Current

Links

Images

Landscapes

  • Debugging And Monitoring (AREA)

Abstract

The embodiment of the invention provides a log saving method, a log saving device, a storage medium and computer equipment. The method comprises the following steps: establishing a circular buffer area in the set reserved memory, wherein the circular buffer area comprises a first buffer area and a second buffer area; outputting a system log to the first buffer; judging whether the system log of the first buffer area or the second buffer area is full; if the system log of the first buffer area is judged to be full, an application layer is informed to read, and the system log of the first buffer area is emptied; outputting a system log to the second buffer; and if the system log of the second buffer area is judged to be full, the application layer is informed to read, the system log of the second buffer area is emptied, and the step of outputting the system log to the first buffer area is continuously executed, so that the efficiency of saving the log is improved.

Description

Log saving method and device, storage medium and computer equipment
[ technical field ] A method for producing a semiconductor device
The present invention relates to the field of computer technologies, and in particular, to a log saving method and apparatus, a storage medium, and a computer device.
[ background of the invention ]
When the system is abnormal, error information printed by the system at the last moment often helps greatly to locate and analyze the error reason of the system, but the problem is difficult to reproduce due to the fact that products after leaving a factory cannot be externally connected with a debugging tool, and the system error information at that time cannot be stored when the system is abnormally collapsed, so that developers are difficult to locate the abnormal reason of the system.
In the related art, a kernel crash capture mechanism, which is a Kdump mechanism commonly used in Linux systems, is usually used to store partial system error information when an exception occurs in the system. However, when abnormal conditions such as system crash occur, the related information of system error needs to be manually operated everywhere, the operation process is complex and tedious, and the system error information can only be stored in the volatile memory, and the data is lost when the computer equipment is powered on again, thereby reducing the efficiency of log storage.
[ summary of the invention ]
In view of this, embodiments of the present invention provide a log saving method, an apparatus, a storage medium, and a computer device, so as to improve efficiency of saving logs.
In one aspect, an embodiment of the present invention provides a log saving method, including:
establishing a circular buffer area in the set reserved memory, wherein the circular buffer area comprises a first buffer area and a second buffer area;
outputting a system log to the first buffer;
judging whether the system log of the first buffer area or the second buffer area is full;
if the system log of the first buffer area is judged to be full, an application layer is informed to read, and the system log of the first buffer area is emptied;
outputting a system log to the second buffer;
and if the system log of the second buffer area is judged to be full, informing an application layer to read, emptying the system log of the second buffer area, and continuously executing the step of outputting the system log to the first buffer area.
Optionally, the method further comprises:
if the system logs of the first buffer area or the second buffer area are judged to be not fully written, judging whether the system normally operates;
and if the system is judged to be normally operated, continuously executing the step of outputting the system log to the first buffer area.
Optionally, the method further comprises:
and if the system is judged not to normally operate, triggering the system to restart through a watchdog.
Optionally, the circular buffer is provided with magic numbers, and after the watchdog triggers the system to restart, the method includes:
judging whether the system is abnormally restarted;
if the system is judged to be abnormally restarted, judging whether the magic number is damaged or not;
if the magic number is not damaged, judging whether the system log of the first buffer area or the second buffer area is full;
if the system log of the first buffer area or the second buffer area is judged to be full, the system log of the first buffer area or the second buffer area which is full is obtained according to the corresponding relation between the set physical memory address and the user virtual address, and the first buffer area or the second buffer area which is full is emptied;
storing the remaining system logs in a non-volatile storage medium;
and marking the remaining system logs as abnormal logs.
Optionally, the method further comprises:
if the system is judged not to be abnormally restarted, judging whether system log information sent by a kernel is received or not;
if the fact that the system log information sent by the kernel is received is judged, whether the magic number is damaged or not is judged;
if the magic number is judged not to be damaged, acquiring a system log of the first buffer area or the second buffer area which is fully written;
storing the system log of the first buffer area or the second buffer area which is fully written to a nonvolatile storage medium;
and emptying the first buffer area or the second buffer area which is fully written, and continuously executing the step of judging whether the system is abnormally restarted.
Optionally, the method further comprises:
and if the system logs in the first buffer area or the second buffer area are judged to be not fully written, continuously executing the step of storing the rest system logs in the nonvolatile storage medium.
Optionally, the method further comprises:
and if the magic number is judged to be damaged, displaying and storing abnormal alarm information.
In another aspect, an embodiment of the present invention provides a log saving apparatus, including:
the device comprises an establishing module, a storage module and a processing module, wherein the establishing module is used for establishing a circular buffer area in a set reserved memory, and the circular buffer area comprises a first buffer area and a second buffer area;
the first output module is used for outputting the system log to the first buffer area;
the first judgment module is used for judging whether the system logs of the first buffer area or the second buffer area are full;
the first emptying module is used for notifying the application layer to read and emptying the system log of the first buffer area if the first judging module judges that the system log of the first buffer area is fully written;
the second output module is used for outputting the system log to a second buffer area;
and the second emptying module is used for informing the application layer to read if the first judging module judges that the system log of the second buffer area is fully written, emptying the system log of the second buffer area and triggering the first output module to continuously execute the step of outputting the system log to the first buffer area.
In another aspect, an embodiment of the present invention provides a storage medium, including: the storage medium comprises a stored program, wherein when the program runs, the device where the storage medium is located is controlled to execute the log saving method.
In another aspect, an embodiment of the present invention provides a computer device, including a memory and a processor, where the memory is used to store information including program instructions, and the processor is used to control execution of the program instructions, where the program instructions are loaded by the processor and executed to implement the steps of the log saving method.
In the technical scheme of the log saving method provided by the embodiment of the invention, a circular buffer area is established in a set reserved memory, and the circular buffer area comprises a first buffer area and a second buffer area; outputting the system log to a first buffer; judging whether the system log of the first buffer area or the second buffer area is full; if the system log of the first buffer area is judged to be full, an application layer is informed to read, and the system log of the first buffer area is emptied; outputting a system log to the second buffer; if the system log of the second buffer area is judged to be written fully, the application layer is informed to read, the system log of the second buffer area is emptied, and the step of outputting the system log to the first buffer area is continuously executed, so that the efficiency of saving the log is improved.
[ description of the drawings ]
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings needed to be used in the embodiments will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without inventive labor.
Fig. 1 is a flowchart of a log saving method according to an embodiment of the present invention;
FIG. 2 is a flowchart of another log saving method according to an embodiment of the present invention;
FIG. 3 is a diagram illustrating a structure of a circular buffer;
fig. 4 is a schematic structural diagram of a log saving device according to an embodiment of the present invention;
fig. 5 is a schematic diagram of a computer device according to an embodiment of the present invention.
[ detailed description ] embodiments
For better understanding of the technical solutions of the present invention, the following detailed descriptions of the embodiments of the present invention are provided with reference to the accompanying drawings.
It should be understood that the described embodiments are only some embodiments of the invention, and not all 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 invention.
The terminology used in the embodiments of the invention is for the purpose of describing particular embodiments only and is not intended to be limiting of the invention. As used in the examples of the present invention and the appended claims, the singular forms "a," "an," and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise.
It should be understood that the term "and/or" as used herein is merely one type of associative relationship that describes an associated object, meaning that three types of relationships may exist, e.g., A and/or B, may mean: a exists alone, A and B exist simultaneously, and B exists alone. In addition, the character "/" herein generally indicates that the former and latter related objects are in an "or" relationship.
An embodiment of the present invention provides a log saving method, and fig. 1 is a flowchart of the log saving method provided in the embodiment of the present invention, and as shown in fig. 1, the method includes:
step 102, establishing a circular buffer area in the set reserved memory, wherein the circular buffer area comprises a first buffer area and a second buffer area.
In the embodiment of the invention, each step is executed by computer equipment.
In the embodiment of the invention, a section of memory space is reserved in a system kernel in a mode of starting parameters or a device tree, and the section of memory is reserved memory, so that the reserved memory can be specially used for storing system information. The reserved memory is not used for other functions during the running of the kernel.
And 104, outputting the system log to the first buffer area.
And step 106, judging whether the system log of the first buffer area or the second buffer area is full.
In the embodiment of the present invention, the AorB _ FULL is used to indicate that data in the current first buffer or the second buffer is FULL, and determine whether the system log in the first buffer or the second buffer satisfies the AorB _ FULL; if the system log of the first buffer area or the second buffer area is judged to meet AorB _ FULL, the system log of the first buffer area or the second buffer area is indicated to be FULL; if the system log of the first buffer area or the second buffer area is judged not to satisfy AorB _ FULL, the system log of the first buffer area or the second buffer area is indicated to be not FULL.
And step 108, if the system log of the first buffer area is judged to be full, informing the application layer to read, and emptying the system log of the first buffer area.
And step 110, outputting the system log to a second buffer area.
Step 112, if it is determined that the system log in the second buffer area is fully written, the application layer is notified to read, the system log in the second buffer area is cleared, and step 104 is continuously executed.
In the embodiment of the invention, when the first buffer area is full, the system log is output to the second buffer area, and when the second buffer area is full, the system log is rewritten to the first buffer area, and the operation is repeatedly executed. When any data area in the first buffer area or the second buffer area is full, the marking processing is carried out, and the application layer is informed to read the data of the full first buffer area or the full second buffer area. Therefore, when reading is restarted in the subsequent crash, the final data reading area is determined based on the offset position of the pointer, so that the required data is read, the data volume of the data which needs to be read at present is reduced, and the processing efficiency is improved. If the currently read data volume is not enough to completely display the required log information, corresponding data can be found from the data read by the application layer according to the time sequence according to the time stamp, so that the required system log is completely displayed.
In the technical scheme provided by the embodiment of the invention, a circular buffer area is established in a set reserved memory, and the circular buffer area comprises a first buffer area and a second buffer area; outputting the system log to a first buffer; judging whether the system log of the first buffer area or the second buffer area is full; if the system log of the first buffer area is judged to be full, an application layer is informed to read, and the system log of the first buffer area is emptied; outputting a system log to the second buffer; if the system log of the second buffer area is judged to be written fully, the application layer is informed to read, the system log of the second buffer area is emptied, and the step of outputting the system log to the first buffer area is continuously executed, so that the efficiency of saving the log is improved.
An embodiment of the present invention provides another log saving method, and fig. 2 is a flowchart of another log saving method provided in the embodiment of the present invention, and as shown in fig. 2, the method includes:
step 202, establishing a circular buffer area in the set reserved memory, wherein the circular buffer area comprises a first buffer area and a second buffer area.
In the embodiment of the invention, each step is executed by computer equipment.
In the embodiment of the invention, a section of memory space is reserved in a system kernel in a mode of starting parameters or a device tree, and the section of memory is reserved memory, so that the reserved memory can be specially used for storing system information. The reserved memory is not used for other functions during the running of the kernel.
In an embodiment of the present invention, a circular buffer (circular buffer) is a data structure for representing a buffer with a fixed size and connected end to end, and is suitable for buffering a data stream.
In the embodiment of the present invention, fig. 3 is a schematic structural diagram of a circular buffer, and as shown in fig. 3, magic numbers magic _ num are disposed at the head and the tail of the circular buffer, so that system information can be continuously recorded in a limited memory space. The circular Buffer area comprises a first Buffer area A Buffer and a second Buffer area B Buffer, and is mainly used for storing system logs. In fig. 3, Cur _ point is used to identify the current position of the write pointer, AorB _ FULL is used to indicate that the data of the first buffer or the second buffer is currently FULL, a _ buffer _ begin/end is used to identify the first and last end addresses of the first buffer, and B _ buffer _ begin/end is used to identify the first and last end addresses of the second buffer.
And step 204, outputting the system log to a first buffer area.
Step 206, determining whether the system log of the first buffer or the second buffer is full, if yes, executing step 208; if the system log of the second buffer is judged to be full, go to step 212; if it is determined that the system log in the first buffer or the second buffer is not full, step 214 is executed.
In the embodiment of the present invention, AorB _ FULL indicates that the data in the first buffer or the second buffer is currently FULL, and when the system log in the first buffer is FULL, step 208 is executed; when the system log of the second buffer is full, step 212 is performed.
And step 208, notifying the application layer to read, and emptying the system log of the first buffer area.
And step 210, outputting the system log to a second buffer area.
Step 212, notifying the application layer to read, emptying the system log of the second buffer area, and continuing to execute step 204.
In this embodiment of the present invention, the circular buffer further includes an information management area, where the information management area is used to indicate whether the current data is stored in the first buffer or the second buffer, and information such as the size of the data area, the system runtime, the offset of the write data pointer, and a flag indicating whether the partition information of the first buffer or the second buffer is full.
In the embodiment of the invention, in the running process of the system, all system log output is recorded into the first buffer area or the second buffer area and the pointer of the information management area is updated.
In this embodiment of the present invention, after step 212, the method further includes: register the system log output console register _ Console, and output the system print information into the circular buffer.
Step 214, judging whether the system normally operates, if so, executing step 204; if not, go to step 216.
As an alternative, whether the system normally operates can be judged through the system log, and if the system log returns to the normal operation of the system, step 204 is executed; if the system log returns that the system is not operating normally, go to step 216.
And step 216, triggering the system to restart through a watchdog.
In the embodiment of the invention, the watchdog is a circuit which periodically checks the internal condition of the chip and sends a restart signal to the chip once an error occurs. The command of the watchdog has the highest priority in the interruption of the program, so that the program can be prevented from running away, and dead loop can be prevented when the program runs online.
Step 218, judging whether the system is abnormally restarted, if so, executing step 220; if not, go to step 230.
In the embodiment of the invention, the restart type comprises power failure restart, reboot restart and abnormal restart, wherein when a user _ rebot is 0 and a kernel _ rebot is 0, the restart type is power failure restart; the restart type is reboot restart when the user _ rebot is 1 and the kernel _ rebot is 1, and the restart type is abnormal restart when the user _ rebot is 0 and the kernel _ rebot is 1.
In the embodiment of the present invention, steps 218 to 238 are specific steps for executing the application layer monitoring program.
In the embodiment of the invention, a mark can be set in the kernel restart function kernel _ restart, and the restart is added and marked as the abnormal restart in the abnormal restart process.
In the embodiment of the invention, the application layer monitoring program judges whether the current restart is abnormal restart or not through the restart marks of the kernel and the busy box.
Step 220, judging whether the magic number is damaged, if so, executing step 240; if not, go to step 222.
In this step, it is determined whether Magic _ num in the circular buffer is damaged, and if it is determined that Magic _ num is damaged, it indicates that the memory data in the circular buffer is damaged, step 240 is executed; if the Magic _ num is determined not to be damaged, it indicates that the memory data in the circular buffer is not damaged, and step 222 is executed.
Step 222, determining whether the system log of the first buffer area or the second buffer area is full, if yes, executing step 224; if not, go to step 226.
In the embodiment of the present invention, AorB _ FULL indicates that the data in the first buffer or the second buffer is currently FULL, and when the system log in the first buffer or the second buffer is FULL, step 224 is executed; when the system logs of the first buffer and the second buffer are not full, step 226 is performed.
Step 224, obtaining the system log of the first buffer area or the second buffer area which is fully written according to the corresponding relation between the set physical memory address and the user virtual address, and emptying the first buffer area or the second buffer area which is fully written.
In this step, the corresponding relationship between the physical memory address and the user virtual address is set through the memory mapping function, so that the application layer can read the reserved memory.
In the embodiment of the present invention, the memory mapping function includes a remap _ pfn _ range function.
Step 226, store the remaining system logs to non-volatile storage media.
In the embodiment of the invention, the nonvolatile storage medium can store data in a power-on state or a power-off state. For example, the nonvolatile storage medium includes an Embedded multimedia Card (eMMC), a flash Memory (flash), or a Secure Digital Card (SD Card).
And step 228, marking the rest system logs as abnormal logs, and ending the process.
Step 230, judging whether system log information which is sent by a kernel and is obtained is received, if so, executing step 232; if not, go to step 218.
In this step, if it is determined that the system log information sent by the kernel is received and acquired, it indicates that the system is abnormal, and the log information needs to be acquired, and step 232 is executed; if it is determined that the acquired system log information sent by the kernel is received, it indicates that the system is not abnormal, and step 218 is executed.
Step 232, judging whether the magic number is damaged, if so, executing step 240; if not, go to step 234.
In this step, it is determined whether Magic _ num in the circular buffer is damaged, and if it is determined that Magic _ num is damaged, it indicates that the memory data in the circular buffer is damaged, step 240 is executed; if the Magic _ num is determined not to be damaged, it indicates that the memory data in the circular buffer is not damaged, and step 234 is executed.
Step 234, obtain the system log of the first buffer or the second buffer that is full.
And step 236, storing the system log of the first buffer area or the second buffer area which is fully written to the nonvolatile storage medium.
In the embodiment of the invention, the nonvolatile storage medium can store data in a power-on state or a power-off state. For example, the nonvolatile storage medium includes eMMC, flash, or SD card.
Step 238 is to empty the first buffer or the second buffer that is full, and continue to step 218.
And step 240, displaying and storing abnormal alarm information.
In the technical scheme provided by the embodiment of the invention, a circular buffer area is established in a set reserved memory, and the circular buffer area comprises a first buffer area and a second buffer area; outputting the system log to a first buffer; judging whether the system log of the first buffer area or the second buffer area is full; if the system log of the first buffer area is judged to be full, an application layer is informed to read, and the system log of the first buffer area is emptied; outputting a system log to the second buffer; if the system log of the second buffer area is judged to be written fully, the application layer is informed to read, the system log of the second buffer area is emptied, and the step of outputting the system log to the first buffer area is continuously executed, so that the efficiency of saving the log is improved.
According to the technical scheme provided by the embodiment of the invention, the occurrence of system abnormal crash can be identified. Therefore, related error information is automatically stored in the nonvolatile memory when the system crashes, and developers can conveniently remotely analyze the error reasons of the positioning system.
In the technical scheme provided by the embodiment of the invention, the whole operation process is automatically completed by software without participation of developers.
In the technical scheme provided by the embodiment of the invention, the system error information is stored in the volatile storage medium and can be flexibly consulted. When the network can be connected, the information can be uploaded to a server, so that a developer can remotely check and count the problems of the computer equipment.
The embodiment of the invention provides a log saving device. Fig. 4 is a schematic structural diagram of a log saving apparatus according to an embodiment of the present invention, and as shown in fig. 4, the apparatus includes: the device comprises a building module 11, a first output module 12, a first judging module 13, a first emptying module 14, a second output module 15 and a second emptying module 16.
The establishing module 11 is configured to establish a circular buffer area in the set reserved memory, where the circular buffer area includes a first buffer area and a second buffer area.
The first output module 12 is configured to output the system log to the first buffer.
The first determining module 13 is configured to determine whether the system log of the first buffer or the second buffer is full.
The first emptying module 14 is configured to notify the application layer to read the system log of the first buffer if the first determining module 13 determines that the system log of the first buffer is full, and empty the system log of the first buffer.
The second output module 15 is configured to output the system log to the second buffer.
The second emptying module 16 is configured to notify the application layer to read the system log of the second buffer if the first determining module 13 determines that the system log of the second buffer is fully written, empty the system log of the second buffer, and trigger the first output module 12 to continue to execute the step of outputting the system log to the first buffer.
In the embodiment of the present invention, the apparatus further includes: a second decision module 17.
The second judging module 17 is configured to judge whether the system normally operates if the first judging module 13 judges that the system log of the first buffer area or the second buffer area is not full; if the system is judged to be normally operated, the first output module 12 is triggered to continue to output the system log to the first buffer area.
In the embodiment of the present invention, the apparatus further includes: the module 18 is restarted.
The restart module 18 is configured to trigger the system restart through a watchdog if the second determination module 17 determines that the system is not operating normally.
In the embodiment of the present invention, the apparatus further includes: a third judging module 19, a fourth judging module 20, a fifth judging module 21, a third emptying module 22, a first storage module 23 and a marking module 24.
The third judging module 19 is used for judging whether the system is abnormally restarted; if the system is judged to be abnormally restarted, the fourth judging module 20 is triggered to judge whether the magic number is damaged or not; if the magic number is not damaged, triggering a fifth judging module 21 to judge whether the system log of the first buffer area or the second buffer area is full; if the system log of the first buffer area or the second buffer area is judged to be full, the third emptying module 22 is triggered to acquire the system log of the full first buffer area or the full second buffer area according to the corresponding relation between the set physical memory address and the user virtual address, and empty the full first buffer area or the full second buffer area.
The first storage module 23 is used to store the remaining system logs into a nonvolatile storage medium.
The marking module 24 is configured to mark the remaining system logs as exception logs.
In the embodiment of the present invention, the apparatus further includes: a sixth judging module 25, a seventh judging module 26, an obtaining module 27, a second storing module 28 and a fourth emptying module 29.
The sixth judging module 25 is configured to judge whether the system log information sent by the kernel is received or not if the third judging module 19 judges that the system is not abnormally restarted; if the system log information sent by the kernel is judged to be received, the seventh judging module 26 is triggered to judge whether the magic number is damaged; if the magic number is not damaged, the acquiring module 27 is triggered to acquire the system log of the first buffer area or the second buffer area which is fully written.
The second storage module 28 is configured to store the system log of the first buffer or the second buffer that is full to the nonvolatile storage medium.
The fourth emptying module 29 is configured to empty the first buffer area or the second buffer area that is completely written, and trigger the third determining module 19 to continue executing the step of determining whether the system is abnormally restarted.
In this embodiment of the present invention, if the fifth determining module 21 determines that the system log in the first buffer or the second buffer is not fully written, the first storing module 23 is triggered to continue to execute the step of storing the remaining system log in the nonvolatile storage medium.
In the embodiment of the present invention, the apparatus further includes: a display module 30.
The display module 30 is used for displaying and storing the abnormal alarm information if the fourth judging module 20 or the seventh judging module 26 judges that the magic number is damaged.
In the technical scheme provided by the embodiment of the invention, a circular buffer area is established in a set reserved memory, and the circular buffer area comprises a first buffer area and a second buffer area; outputting the system log to a first buffer; judging whether the system log of the first buffer area or the second buffer area is full; if the system log of the first buffer area is judged to be full, an application layer is informed to read, and the system log of the first buffer area is emptied; outputting a system log to the second buffer; if the system log of the second buffer area is judged to be written fully, the application layer is informed to read, the system log of the second buffer area is emptied, and the step of outputting the system log to the first buffer area is continuously executed, so that the efficiency of saving the log is improved.
The log saving device provided in this embodiment may be used to implement the log saving method in fig. 1 and fig. 2, and for specific description, reference may be made to an embodiment of the log saving method, and a description is not repeated here.
An embodiment of the present invention provides a storage medium, where the storage medium includes a stored program, where each step of the embodiment of the log saving method is executed by a device in which the storage medium is located when the program runs, and for specific description, reference may be made to the embodiment of the log saving method.
Embodiments of the present invention provide a computer device, including a memory and a processor, where the memory is configured to store information including program instructions, and the processor is configured to control execution of the program instructions, and the program instructions are loaded by the processor and executed to implement steps of the embodiment of the log saving method, and specific descriptions may refer to the embodiment of the log saving method.
Fig. 5 is a schematic diagram of a computer device according to an embodiment of the present invention. As shown in fig. 5, the computer apparatus 50 of this embodiment includes: the processor 51, the memory 52, and the computer program 53 stored in the memory 52 and capable of running on the processor 51, where the computer program 53 is executed by the processor 51 to implement the log saving method applied in the embodiment, and in order to avoid repetition, the details are not repeated herein. Alternatively, the computer program is executed by the processor 51 to implement the functions of the models/units applied to the log saving device in the embodiments, which are not repeated herein to avoid redundancy.
The computer device 50 includes, but is not limited to, a processor 51, a memory 52. Those skilled in the art will appreciate that fig. 5 is merely an example of a computer device 50 and is not intended to limit the computer device 50 and that it may include more or fewer components than shown, or some components may be combined, or different components, e.g., the computer device may also include input output devices, network access devices, buses, etc.
The Processor 51 may be a Central Processing Unit (CPU), other general purpose Processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA) or other Programmable logic device, discrete Gate or transistor logic device, discrete hardware component, or the like. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
The memory 52 may be an internal storage unit of the computer device 50, such as a hard disk or a memory of the computer device 50. The memory 52 may also be an external storage device of the computer device 50, such as a plug-in hard disk provided on the computer device 50, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), and the like. Further, the memory 52 may also include both internal and external storage devices for the computer device 50. The memory 52 is used to store computer programs and other programs and data required by the computer device. The memory 52 may also be used to temporarily store data that has been output or is to be output.
It is clear to those skilled in the art that, for convenience and brevity of description, the specific working processes of the above-described systems, apparatuses and units may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
In the embodiments provided in the present invention, it should be understood that the disclosed system, 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 units is only one logical division, and there may be other divisions in actual implementation, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. 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.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, or in a form of hardware plus a software functional unit.
The integrated unit implemented in the form of a software functional unit may be stored in a computer readable storage medium. The software functional unit is stored in a storage medium and includes several instructions for causing a computer device (which may be a personal computer, a server, or a network device) or a Processor (Processor) to execute some steps of the methods according to the embodiments of the present invention. And the aforementioned storage medium includes: various media capable of storing program codes, such as a usb disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk, or an optical disk.
The above description is only for the purpose of illustrating the preferred embodiments of the present invention and is not to be construed as limiting the invention, and any modifications, equivalents, improvements and the like made within the spirit and principle of the present invention should be included in the scope of the present invention.

Claims (10)

1. A method for log saving, comprising:
establishing a circular buffer area in the set reserved memory, wherein the circular buffer area comprises a first buffer area and a second buffer area;
outputting a system log to the first buffer;
judging whether the system log of the first buffer area or the second buffer area is full;
if the system log of the first buffer area is judged to be full, an application layer is informed to read, and the system log of the first buffer area is emptied;
outputting a system log to the second buffer;
and if the system log of the second buffer area is judged to be full, informing an application layer to read, emptying the system log of the second buffer area, and continuously executing the step of outputting the system log to the first buffer area.
2. The method of claim 1, further comprising:
if the system logs of the first buffer area or the second buffer area are judged to be not fully written, judging whether the system normally operates;
and if the system is judged to be normally operated, continuously executing the step of outputting the system log to the first buffer area.
3. The method of claim 2, further comprising:
and if the system is judged not to normally operate, triggering the system to restart through a watchdog.
4. The method of claim 3, wherein the loop buffer is provided with magic numbers, and after the system restart is triggered by the watchdog, the method comprises the following steps:
judging whether the system is abnormally restarted;
if the system is judged to be abnormally restarted, judging whether the magic number is damaged or not;
if the magic number is not damaged, judging whether the system log of the first buffer area or the second buffer area is full;
if the system log of the first buffer area or the second buffer area is judged to be full, the system log of the first buffer area or the second buffer area which is full is obtained according to the corresponding relation between the set physical memory address and the user virtual address, and the first buffer area or the second buffer area which is full is emptied;
storing the remaining system logs in a non-volatile storage medium;
and marking the remaining system logs as abnormal logs.
5. The method of claim 4, further comprising:
if the system is judged not to be abnormally restarted, judging whether system log information sent by a kernel is received or not;
if the fact that the system log information sent by the kernel is received is judged, whether the magic number is damaged or not is judged;
if the magic number is judged not to be damaged, acquiring a system log of the first buffer area or the second buffer area which is fully written;
storing the system log of the first buffer area or the second buffer area which is fully written to a nonvolatile storage medium;
and emptying the first buffer area or the second buffer area which is fully written, and continuously executing the step of judging whether the system is abnormally restarted.
6. The method of claim 4, further comprising:
and if the system logs in the first buffer area or the second buffer area are judged to be not fully written, continuously executing the step of storing the rest system logs in the nonvolatile storage medium.
7. The method of claim 4 or 5, further comprising:
and if the magic number is judged to be damaged, displaying and storing abnormal alarm information.
8. A log saving apparatus, comprising:
the device comprises an establishing module, a storage module and a processing module, wherein the establishing module is used for establishing a circular buffer area in a set reserved memory, and the circular buffer area comprises a first buffer area and a second buffer area;
the first output module is used for outputting the system log to the first buffer area;
the first judgment module is used for judging whether the system logs of the first buffer area or the second buffer area are full;
the first emptying module is used for notifying the application layer to read and emptying the system log of the first buffer area if the first judging module judges that the system log of the first buffer area is fully written;
the second output module is used for outputting the system log to a second buffer area;
and the second emptying module is used for informing the application layer to read if the first judging module judges that the system log of the second buffer area is fully written, emptying the system log of the second buffer area and triggering the first output module to continuously execute the step of outputting the system log to the first buffer area.
9. A storage medium, comprising: the storage medium includes a stored program, wherein when the program runs, the device in which the storage medium is located is controlled to execute a log saving method according to any one of claims 1 to 7.
10. A computer device comprising a memory for storing information including program instructions and a processor for controlling the execution of the program instructions, wherein the program instructions are loaded and executed by the processor to implement the steps of a log saving method as claimed in any one of claims 1 to 7.
CN202210007920.0A 2022-01-06 2022-01-06 Log saving method and device, storage medium and computer equipment Pending CN114356638A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210007920.0A CN114356638A (en) 2022-01-06 2022-01-06 Log saving method and device, storage medium and computer equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210007920.0A CN114356638A (en) 2022-01-06 2022-01-06 Log saving method and device, storage medium and computer equipment

Publications (1)

Publication Number Publication Date
CN114356638A true CN114356638A (en) 2022-04-15

Family

ID=81107306

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210007920.0A Pending CN114356638A (en) 2022-01-06 2022-01-06 Log saving method and device, storage medium and computer equipment

Country Status (1)

Country Link
CN (1) CN114356638A (en)

Similar Documents

Publication Publication Date Title
US8468389B2 (en) Firmware recovery system and method of baseboard management controller of computing device
EP1638000B1 (en) Method, apparatus and program for performing panic memory dump
CN108874624B (en) Server, method for monitoring Java process and storage medium
CN102662785B (en) Method and device for acquiring kernel error information of Android system
CN103827834B (en) A kind of moving method of internal storage data, computing machine and device
CN103842968B (en) A kind of moving method of internal storage data, computing machine and device
EP3770765B1 (en) Error recovery method and apparatus
CN106682162B (en) Log management method and device
US20120124420A1 (en) Reset method and monitoring apparatus
CN109271206B (en) Memory compression and storage method for abnormal site
CN102141939A (en) Device capable of recording restart reason of whole machine
CN110221932B (en) Computer and control method thereof
US20100332914A1 (en) Dump output control apparatus and dump output control method
CN114385418A (en) Protection method, device, equipment and storage medium for communication equipment
CN113536320A (en) Error information processing method, device and storage medium
CN113641537A (en) Starting system, method and medium for server
CN113190256A (en) Upgrading method, device and equipment
CN107957923B (en) Memory diagnosis method and device
JP2017078998A (en) Information processor, log management method, and computer program
CN114356638A (en) Log saving method and device, storage medium and computer equipment
CN113849230A (en) Server starting method and device, electronic equipment and readable storage medium
JP2014182676A (en) Log collection device, arithmetic unit, and log collection method
CN105353980A (en) Memory data migration method, computer and apparatus
CN113868023B (en) Snapshot method and device of storage system, electronic equipment and readable storage medium
CN116701042B (en) Memory data retention method, retention device and related equipment

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