Log linkage storage method and device based on shared memory and computer equipment
By allocating the second storage area in the volatile memory to cache the key information level and debug information level logs, and dropping it into the non-volatile memory when the user program generates an error level log, the problem of inability to take into account both the storage media life and the traceability of the problem in the prior art is solved, and the balance between the storage media life and problem investigation is achieved.
Patent Information
- Application Number
- CN202411995185.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-31
- Publication Date
- 2025-05-23
AI Technical Summary
The prior art cannot take into account the life of the storage medium and ensure traceability after the problem occurs, resulting in limited storage space and a lack of effective storage solutions.
The log management process allocates a second storage area for the key information level and debug information level logs of the user program in the volatile memory, and when the user program generates an error level log, the relevant logs are put into the first storage area of the nonvolatile memory.
It ensures traceability after problems arise without affecting the life of the storage medium. By rationally utilizing the characteristics of volatile memory and nonvolatile memory, the service life of the storage medium and the traceability of problem investigation are balanced.
Smart Images

Figure CN120029866A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a log linkage storage method, device and computer equipment based on shared memory. Background Art
[0002] In embedded devices, the storage space is limited. If the amount of log storage is too large, the life of the storage medium will be affected; if the amount of log storage is too small, there will not be enough log information to locate the root cause of the problem when the software has a problem. Reproduction and other operations are needed to locate the root cause of the problem, resulting in a large waste of manpower and material resources. Currently, there is a lack of storage solutions that take into account the life of the storage medium and ensure traceability after the problem occurs.
[0003] There is no effective solution to the storage solution in the related technology that cannot take into account both the life of the storage medium and the traceability after the problem occurs. Summary of the invention
[0004] In this embodiment, a log linkage storage method, apparatus and computer device based on shared memory are provided to solve the problem of storage solutions in related technologies that cannot take into account both the life of the storage medium and the traceability after a problem occurs.
[0005] In a first aspect, a log linkage storage method based on shared memory is provided in this embodiment, which is applicable to a log linkage storage system; the log linkage storage system includes a target device, a log management process and a volatile memory; the target device includes a non-volatile memory; a user program of the target device is respectively connected to the non-volatile memory and the volatile memory through the log management process; the log level includes a critical information level, a debugging information level, a warning level and an error level, and the method includes:
[0006] Through the log management process, a second storage area is allocated in the volatile memory for the key information level log and the debug information level log of the user program; the volatile memory is used to cache the key information level log and the debug information level log;
[0007] When the user program generates an error level log, the log associated with the error level log is written to the first storage area of the non-volatile memory through the log management process according to a preset processing strategy and the logs cached in the volatile memory.
[0008] In some embodiments, the method further comprises:
[0009] During the operation of the user program without generating an error-level log, the warning-level log is written to the first storage area of the non-volatile memory through the log management process, and the critical information-level log and the debug information-level log are cached in the second storage area of the volatile memory.
[0010] In some of the embodiments, the non-volatile memory is an EMMC storage space in the first operating system; and the volatile memory is a DDR storage space in the second operating system.
[0011] In some of the embodiments, allocating a second storage area in the volatile memory for the key information level log and the debug information level log of the user program through the log management process includes:
[0012] After the user program of the target device is started, initiating a request for the key information level log and the debug information level log to the log management process;
[0013] After receiving the request, the log management process dynamically applies for a second storage area of the volatile memory; and feeds back a second storage address corresponding to the applied second storage area to the user program.
[0014] In some embodiments, the method further comprises:
[0015] According to the log level and the second storage address, the second storage area is actively selected for caching; the key information level log is cached separately to one second storage area; the debug information level log is cached to multiple second storage areas by module.
[0016] In some of the embodiments, when the user program generates an error level log, according to a preset processing strategy and the logs cached in the volatile memory, the log management process writes the log associated with the error level log to the first storage area of the non-volatile memory, including:
[0017] Determine whether the generated log is the error-level log;
[0018] If it is the error-level log, then set the printing disk-falling time of the second storage area in the volatile memory, and lock all storage areas at the same time; the error-level log, all the key information-level logs in the second storage area, and the debugging information-level log associated with the error-level log are flushed to the first storage area of the non-volatile memory through the log management process;
[0019] If it is not the error-level log, determine whether it is a warning-level log;
[0020] If it is the warning level log, the warning level log is written to the first storage area of the non-volatile memory through the log management process;
[0021] If it is not the warning level log, the generated log is cached in the second storage area of the volatile memory through the log management process.
[0022] In some embodiments, the method further comprises:
[0023] When the log management process receives the error-level log, detecting whether the corresponding first storage area is locked;
[0024] If the corresponding first storage area is locked, the error level log is stored separately in a new first storage area, and the new first storage area is unlocked after resetting the read-write pointer;
[0025] If the corresponding first storage area is not locked, the error-level log is written to the corresponding first storage area.
[0026] In a second aspect, a log linkage storage device based on shared memory is provided in the present embodiment, which is applicable to a log linkage storage system; the log linkage storage system includes a target device, a log management process and a volatile memory; the target device includes a non-volatile memory; the user program of the target device is respectively connected to the non-volatile memory and the volatile memory through the log management process; the log level includes a critical information level, a debugging information level, a warning level and an error level, and the device includes: an allocation module and a linkage storage module;
[0027] The allocation module is used to allocate a second storage area for the key information level and debug information level logs of the user program in the volatile memory through the log management process; the volatile memory is used to cache the logs corresponding to the key information level and the debug information level;
[0028] The linkage storage module is used to, when the user program generates an error level log, write the log associated with the error level log to the first storage area of the non-volatile memory through the log management process according to a preset processing strategy and the log cached in the volatile memory.
[0029] In a third aspect, a computer device is provided in this embodiment, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the shared memory-based log linkage storage method described in the first aspect is implemented.
[0030] In a fourth aspect, a storage medium is provided in this embodiment, on which a computer program is stored, and when the program is executed by a processor, the log linkage storage method based on shared memory described in the first aspect is implemented.
[0031] Compared with the related art, the shared memory-based log linkage storage method, device and computer equipment provided in this embodiment allocate a second storage area for the key information level log and debug information level log of the user program in the volatile memory through the log management process; the volatile memory is used to cache the key information level log and debug information level log; when the user program generates an error level log, according to the preset processing strategy and the log cached in the volatile memory, the log associated with the error level log is written to the first storage area of the non-volatile memory through the log management process, thereby solving the problem of the storage solution in the related art that cannot take into account both the life of the storage medium and the traceability after the problem occurs. The second storage area in the volatile memory is used to cache the key information level log and the debug information level log. Only when the user program generates an error level log, the relevant log is written to the first storage area of the non-volatile memory, thereby achieving a balance between the life of the storage medium and the traceability after the problem occurs.
[0032] Details of one or more embodiments of the present application are set forth in the following drawings and description to make other features, objects, and advantages of the present application more readily apparent. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0034] Figure 1 It is a hardware structure block diagram of a terminal device of a log linkage storage method based on shared memory provided by an embodiment of the present application;
[0035] Figure 2 It is a flow chart of a log linkage storage method based on shared memory provided by an embodiment of the present application;
[0036] Figure 3 It is a structural diagram of a log linkage storage system provided by an embodiment of the present application;
[0037] Figure 4 It is an interactive schematic diagram of a partition application provided in an embodiment of the present application;
[0038] Figure 5 It is a flow chart of the log processing logic provided by an embodiment of the present application;
[0039] Figure 6 It is a flow chart of the log management process processing logic provided by an embodiment of the present application;
[0040] Figure 7 It is a structural block diagram of a log linkage storage device based on shared memory provided in one embodiment of the present application.
[0041] In the figure: 102, processor; 104, memory; 106, transmission device; 108, input and output device; 210, allocation module; 220, linkage storage module. DETAILED DESCRIPTION
[0042] In order to more clearly understand the purpose, technical solutions and advantages of the present application, the present application is described and illustrated below in conjunction with the accompanying drawings and embodiments.
[0043] Unless otherwise defined, the technical terms or scientific terms involved in this application shall have the general meaning understood by people with ordinary skills in the technical field to which this application belongs. The words "one", "a", "a", "the", "these" and the like in this application do not represent quantitative restrictions, and they can be singular or plural. The terms "include", "comprise", "have" and any variants thereof involved in this application are intended to cover non-exclusive inclusions; for example, a process, method and system, product or device comprising a series of steps or modules (units) is not limited to the listed steps or modules (units), but may include unlisted steps or modules (units), or may include other steps or modules (units) inherent to these processes, methods, products or devices. The words "connect", "connected", "coupled" and the like involved in this application are not limited to physical or mechanical connections, but may include electrical connections, whether directly or indirectly. The "multiple" involved in this application refers to two or more. "And / or" describes the association relationship of associated objects, indicating that there can be three relationships. For example, "A and / or B" can mean: A exists alone, A and B exist at the same time, and B exists alone. Usually, the character " / " indicates that the objects associated with each other are in an "or" relationship. The terms "first", "second", "third", etc. involved in this application are only used to distinguish similar objects and do not represent a specific ordering of the objects.
[0044] The method embodiment provided in this embodiment can be executed in a terminal, a computer or a similar computing device. For example, running on a terminal, Figure 1 : is a hardware structure block diagram of a terminal of the log linkage storage method based on shared memory in this embodiment. Figure 1 As shown, the terminal may include one or more ( Figure 1Only one is shown in the figure) processor 102 and memory 104 for storing data, wherein processor 102 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA. The above terminal may also include a transmission device 106 and an input and output device 108 for communication functions. It can be understood by those skilled in the art that Figure 1 The structure shown is only for illustration and does not limit the structure of the above terminal. Figure 1 More or fewer components as shown, or with Figure 1 Different configurations shown.
[0045] The memory 104 can be used to store computer programs, for example, software programs and modules of application software, such as the computer program corresponding to the log linkage storage method based on shared memory in this embodiment. The processor 102 executes various functional applications and data processing by running the computer program stored in the memory 104, that is, to implement the above method. The memory 104 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 104 may further include a memory remotely arranged relative to the processor 102, and these remote memories may be connected to the terminal via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0046] The transmission device 106 is used to receive or send data via a network. The above network includes a wireless network provided by the communication provider of the terminal. In one example, the transmission device 106 includes a network adapter (Network Interface Controller, referred to as NIC), which can be connected to other network devices through a base station so as to communicate with the Internet. In one example, the transmission device 106 can be a radio frequency (Radio Frequency, referred to as RF) module, which is used to communicate with the Internet wirelessly.
[0047] In this embodiment, a log linkage storage method based on shared memory is provided. Figure 2 is a flow chart of the log linkage storage method based on shared memory of this embodiment, such as Figure 2 As shown, the process includes the following steps:
[0048] Step S210, through the log management process, a second storage area is allocated in the volatile memory for the key information level log and the debug information level log of the user program; the volatile memory is used to cache the key information level log and the debug information level log;
[0049] Step S220, when the user program generates an error level log, according to the preset processing strategy and the logs cached in the volatile memory, the log management process writes the log associated with the error level log to the first storage area of the non-volatile memory.
[0050] It should be noted that if Figure 3 As shown, this embodiment is applicable to a log linkage storage system; the log linkage storage system includes a target device, a log management process and a volatile memory; the target device includes a non-volatile memory; the user program of the target device is connected to the non-volatile memory and the volatile memory respectively through the log management process. The log management process can be run in the target device or in the device where the volatile memory is located, and there is no restriction on this. Each user program corresponds to an application process, and the connection between the application process and the log management process can be understood as the connection between the user program and the log management process.
[0051] Among them, the non-volatile memory can be a disk of the target device, as a storage medium, and is used in its first storage area to store logs for a long time (including error-level logs and warning-level logs, and all key information-level logs when error-level logs are generated, and debug information-level logs associated with error-level logs). The volatile memory is DDR memory, which is a type of dynamic random access memory (DRAM) and a directly accessible storage medium. Key information-level logs and debug information-level logs are temporarily stored in its second storage area. Since the volatile memory can be read and written repeatedly, and the temporarily stored data recovery storage space will be deleted after restarting, the storage space can be greatly increased. Among them, the first storage area and the second storage area are only used to distinguish the storage areas in the non-volatile memory and the volatile memory, and do not represent a specific ordering of objects.
[0052] In other embodiments, the non-volatile memory and the volatile memory may belong to the storage space of an operating system; then the operating system can access the non-volatile memory and the volatile memory at the same time. In other embodiments, the non-volatile memory and the volatile memory may belong to different operating systems, for example: the non-volatile memory is the EMMC storage space in the first operating system; the volatile memory is the DDR storage space in the second operating system. Among them, the non-volatile memory can also be EPROM storage space, EEPROM storage space, etc.; the volatile memory can also be SRAM storage space, Cache storage space, etc., without limitation. Among them, the first operating system includes but is not limited to Linux, QNX system, etc., and the second operating system includes but is not limited to RTOS, Sysbios system, etc., without limitation. Based on this, the log linkage storage system of this embodiment can be considered as a SOC heterogeneous system, which can improve the adaptability of the method embodiment.
[0053] Among them, the log levels are divided into error level (ERROR), warning level (WARNING), key information level (INFO), and debug information level (DEBUG); each level has corresponding logs. The error level represents a deterministic exception, indicating that serious problems have occurred during the program execution, resulting in the program being unable to execute certain functions properly. These problems usually need to be resolved immediately, otherwise the program may crash or produce incorrect results. The warning level is one level lower than the error level, indicating that the program has encountered some situations that may cause problems, but the program can still continue to run at present. Warnings usually prompt developers or administrators of potential errors that need to be handled at an appropriate time. The key information level is one level lower than the warning level and is used to record important information during the program execution. This information helps to understand the running status and process of the program. The key information level usually contains some valuable content output by a normally running program, such as the start and stop times of the program, important configuration parameters, etc.; it is key and normal information with a small amount of data. The debug information level is one level lower than the key information level and is the most detailed log level, containing various details during the program execution, such as variable values, function call sequences, loop execution times, etc., with a large amount of logs; it is very important for locating exceptions inside specific functional modules. In actual use, if all the logs at this level are stored in non-volatile memory, it will cause a significant increase in the loading of the target device and affect the normal operation of the target device; and usually only the debug information level logs of the module associated with the problem BUG need to be opened during problem troubleshooting.
[0054] Among them, the log management process is pre-built and has two-way communication capabilities for realizing the communication between the user program and non-volatile memory and volatile memory respectively. The storage of logs is achieved through the log management process; for example: sending the generated logs to the log management process, and the log management process stores the logs in the corresponding storage area; or: the log management process actively obtains the generated logs and then stores the obtained logs in the corresponding storage area.
[0055] In this embodiment, first, a second storage area is allocated in the volatile memory for the key information level log and the debug information level log of the user program through the log management process; the volatile memory is used to cache the key information level log and the debug information level log; when the user program generates an error level log, according to the preset processing strategy and the log cached in the volatile memory, the log corresponding to the error level log is written to the first storage area of the non-volatile memory through the log management process; that is, the key information level log and the debug information level log are cached in the second storage area of the volatile memory through the log management process, and are not directly written to the first storage area of the non-volatile memory; and the volatile memory will be cleared after restarting to expand the storage space; only when the user program generates an error level log, the log related to the error level log will be written to the first storage area of the non-volatile memory, thereby increasing the service life; and the log related to the error level will not be affected by the restart in the first storage area, and can be used for problem troubleshooting, thereby achieving a balance between the life of the compatible storage medium and the traceability after the problem occurs; the problem of the storage solution in the related art that cannot simultaneously take into account the life of the storage medium and ensure the traceability after the problem occurs is solved. Among them, writing to disk refers to the action of writing logs to non-volatile memory. Non-volatile memory can save data even after power failure, while non-volatile memory cannot save data after power failure, and the data will be overwritten cyclically.
[0056] In some of the embodiments, the log linkage storage method based on shared memory further includes the following steps:
[0057] During the operation of the user program without generating an error level, the warning level log is written to the first storage area of the non-volatile memory through the log management process, and the critical information level log and the debug information level log are cached in the second storage area of the volatile memory.
[0058] Specifically, the data volume of the warning-level log is relatively small, and the anomaly at this log level is relatively important; therefore, during operation, the warning-level log is written to the first storage area of the non-volatile memory through the log management process. Among them, the data volume of the key information-level log and the debug information-level log is relatively large, and is mainly used to assist in locating problems when the error-level log is generated; in this way, if the error-level log is not generated, it will never be written to the first storage area of the non-volatile memory, but will only be cached in the second storage area of the volatile memory.
[0059] Through this embodiment, the storage capacity in the non-volatile memory can be reduced to a great extent and the service life can be increased.
[0060] In some embodiments, the step S210 of allocating a second storage area in a volatile memory for the critical information level and debug information level logs of the user program through the log management process includes the following steps:
[0061] Step S211, after the user program of the target device is started, a request for a critical information level log and a debug information level log is initiated to the log management process;
[0062] Step S212: After receiving the request, the log management process dynamically applies for a second storage area of the volatile memory; and feeds back a second storage address corresponding to the applied second storage area to the user program.
[0063] Specifically, Figure 4 As shown, the second storage area can be dynamically allocated, and a handshake will be initiated to the log management process after the user program is started for the first time or each time; after the handshake is passed, the number and size of the data storage areas required for the critical information level log and the debug information level log request are initiated, that is, the second storage area is dynamically applied to the volatile memory, and the second storage address corresponding to the applied second storage area is fed back to the user program. Among them, since the amount of critical information level log data is relatively small; therefore, only one second storage area needs to be applied for. Since the amount of debug information level log data is very large, multiple second storage areas will be applied for at this time to store the debug information level logs corresponding to different modules. The following is an example:
[0064] For example, for the second storage area of the volatile memory with a memory of 1M, the debug information level log of module A can be cached for 1000s, or the debug information level log of module B can be cached for 10s. If the debug information level logs of module A and module B are cached together in a second storage area, that is, the debug information level log of module A for 1000s and the debug information level log of module B for 1000s need to be stored, then a second storage area with a memory of 101M is required to meet the requirement, and the above-mentioned second storage area with a memory of 1M is not applicable. If the debug information level logs of module A and module B are cached separately in two second storage areas (one second storage area caches the debug information level log of module A for 1000s; the other second storage area caches the debug information level log of module B for 10s), only two second storage areas with a memory of 1M are needed, so that the second storage areas can be used flexibly.
[0065] After the dynamic application is completed, the log management process will not actively access the second storage area of the volatile memory; the log management process will only access it after being triggered by the generation of an error level log. In other embodiments, after the user program applies for the corresponding second storage address, the corresponding same user program does not need to apply again; if the second storage address is valid, it can be re-applied.
[0066] Through this embodiment, different storage areas are designed in the volatile memory for different logs, which can greatly optimize the use efficiency of the memory.
[0067] In some of the embodiments, the log linkage storage method based on shared memory further includes the following steps:
[0068] According to the log level and the second storage address of the log, the second storage area is actively selected for caching; the key information level log is cached separately to a second storage area; the debugging information level log is cached to multiple second storage areas according to the module.
[0069] Specifically, the critical information level log is cached in a second storage area separately; the debug information level log can have multiple second storage areas, which are cached in the corresponding second storage area according to the module. When the critical information level log and the debug information level log are allocated, the corresponding second storage address is allocated to each user program.
[0070] In this embodiment, the user program in the target device has complete autonomy over log writing to each storage area, and will actively select a suitable second storage area for caching based on the log level (critical information level and debugging information level) and the second storage address of the log, thereby reducing the performance loss of program running.
[0071] In some embodiments, when the user program generates an error level log in step S220, according to a preset processing strategy and the logs cached in the volatile memory, the log associated with the error level log is written to the first storage area of the non-volatile memory through the log management process, including the following steps:
[0072] Step S221, determining whether the generated log is an error level log;
[0073] Step S222: If it is an error-level log, set the print-to-disk time of the second storage area in the volatile memory, and lock all storage areas at the same time; write the error-level log, all key information-level logs in the second storage area, and the debug information-level log associated with the error-level log to the first storage area of the non-volatile memory through the log management process;
[0074] Step S223, if it is not an error level log, determine whether it is a warning level log;
[0075] Step S224: If it is a warning level log, the warning level log is written to the first storage area of the non-volatile memory through the log management process;
[0076] Step S225: If it is not a warning level log, the generated log is cached in the second storage area of the volatile memory through the log management process.
[0077] Specifically, the schematic diagram of log processing logic is as follows Figure 5 As shown, logs of different log levels have different processing strategies, and error-level logs will trigger the logs of other log levels to be dropped to disk. After the log is generated, determine whether the generated log is an error-level log; if it is an error-level log, set the print drop time Tinfo (default is 30s) of all key information-level logs, set the print drop time Tdebug (default is 5s) of the associated debug information-level logs, and lock all storage areas at the same time (the management program needs to be unlocked, otherwise new logs cannot be recorded). At this time, the error-level log, all key information-level logs in the second storage area, and the debug information-level logs associated with the error-level logs in the second storage area are dropped to the first storage area of the non-volatile memory through the log management process. If the error-level log is triggered again during the drop time, the print drop time of the key information-level log and the debug information-level log will be restored to Tinfo and Tdebug.
[0078] If it is not an error-level log, determine whether it is a warning-level log; if it is a warning-level log, cache the warning-level log in the first storage area of the volatile memory through the log management process; if it is not a warning-level log, determine whether the printing of this module is open; if it is open, determine whether the time for printing of this module has arrived; if it has not arrived, transmit the corresponding log to the log management process and cache it in the second storage area of the volatile memory. If it has arrived, close the printing of this module, or, if this module is not open, determine whether it is an associated log that needs to be recorded locally (default record for debug information-level logs); determine whether the corresponding storage area is locked; if locked, discard the corresponding log; if not locked, store it in the corresponding storage area in a loop.
[0079] Through this embodiment, the life of the storage medium and the traceability after the problem occurs can be further balanced; and through the locking mechanism, the competition problem introduced when the user program and the log management process operate on the storage area of the same memory can be effectively solved.
[0080] In some of the embodiments, the log linkage storage method based on shared memory further includes the following steps:
[0081] When the log management process receives the error-level log, detecting whether the corresponding first storage area is locked;
[0082] If the corresponding first storage area is locked, the error level log is stored separately in a new first storage area, and the new first storage area is unlocked after resetting the read-write pointer;
[0083] If the corresponding first storage area is not locked, the error-level log is written to the corresponding first storage area.
[0084] Specifically, the log management process is not only responsible for dynamically allocating the second storage area, but also responsible for writing logs associated with error-level logs to disk, which can solve the problem that heterogeneous cores do not have a file system and cannot write logs to non-volatile memory (disk). Figure 6 As shown, after receiving the error-level log, the log management program needs to detect whether the first storage area related to the error-level log source program is locked. If it is locked, the error-level log is read and stored separately in a new first storage area, and then the read-write pointer is reset and then unlocked; if it is not locked, the error-level log is written to the corresponding first storage area.
[0085] Through this embodiment, the log management process is used to ensure that the error-level logs are written to the disk, providing basic data for problem tracing.
[0086] It should be noted that the steps shown in the above process or the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0087] In this embodiment, a log linkage storage device based on shared memory is also provided, which is used to implement the above-mentioned embodiments and preferred implementation modes, and will not be repeated hereafter. The terms "module", "unit", "subunit", etc. used below can implement a combination of software and / or hardware of predetermined functions. Although the devices described in the following embodiments are preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceivable.
[0088] Figure 7 is a structural block diagram of a log linkage storage device based on shared memory in this embodiment, such as Figure 7 As shown, the device includes: an allocation module 210 and a linkage storage module 220;
[0089] The allocation module 210 is used to allocate a second storage area for the key information level and debug information level logs of the user program in the volatile memory through the log management process; the volatile memory is used to cache the key information level logs and debug information level logs;
[0090] The linkage storage module 220 is used to write the log associated with the error level to the first storage area of the non-volatile memory through the log management process according to the preset processing strategy and the log cached in the volatile memory when the user program generates an error level.
[0091] Through the above-mentioned device, the problem of the storage scheme in the related art that it is impossible to take into account both the life of the storage medium and the traceability after the problem occurs is solved. The second storage area in the volatile memory is used to cache the key information level log and the debug information level log, and only when the user program generates an error level log is the associated log written to the first storage area of the non-volatile memory, thereby achieving a balance between the life of the storage medium and the traceability after the problem occurs.
[0092] In some of the embodiments, the log linkage storage device based on shared memory further includes: a separate storage module;
[0093] A separate storage module is used to store warning-level logs in a first storage area of a non-volatile memory and cache critical information-level logs and debug information-level logs in a second storage area of a volatile memory through a log management process during the operation of a user program that does not generate error-level logs.
[0094] In some of the embodiments, the non-volatile memory is an EMMC storage space in the first operating system; and the volatile memory is a DDR storage space in the second operating system.
[0095] In some of the embodiments, the allocation module 210 is further used to initiate a critical information level and a debugging information level request to the log management process after the user program of the target device is started;
[0096] After receiving the request, the log management process dynamically applies for the second storage area of the volatile memory; and feeds back the second storage address corresponding to the applied second storage area to the user program.
[0097] In some of the embodiments, the allocation module 210 is also used to actively select a second storage area for caching based on the log level and the second storage address of the log; critical information level logs are cached separately to a second storage area; and debug information level logs are cached to multiple second storage areas by module.
[0098] In some of the embodiments, the linkage storage module 220 is also used to
[0099] Determine whether the generated log is an error-level log;
[0100] If it is an error-level log, set the printing time of the second storage area in the volatile memory, and lock all storage areas at the same time; write the error-level log, all key information-level logs in the second storage area, and the debugging information-level log associated with the error-level log to the first storage area of the non-volatile memory through the log management process;
[0101] If it is not an error-level log, determine whether it is a warning-level log;
[0102] If it is a warning-level log, the warning-level log is written to the first storage area of the non-volatile memory through the log management process;
[0103] If it is not a warning-level log, the generated log is cached to the second storage area of the volatile memory through the log management process.
[0104] In some of the embodiments, the log linkage storage device based on shared memory further includes a detection module;
[0105] The detection module is configured to detect whether the corresponding first storage area is locked when the log management process receives an error-level log;
[0106] If the corresponding first storage area is locked, the error-level log is separately stored in a new first storage area, and the new first storage area is unlocked after resetting the read-write pointer;
[0107] If the corresponding first storage area is not locked, the error-level log is written to the corresponding first storage area.
[0108] It should be noted that the above-mentioned various modules can be functional modules or program modules, and can be implemented either by software or by hardware. For the modules implemented by hardware, the above-mentioned various modules can be located in the same processor; or the above-mentioned various modules can also be located in different processors in any combined form.
[0109] In this embodiment, a computer device is further provided, including a memory and a processor. A computer program is stored in the memory, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.
[0110] Optionally, the above computer device may further include a transmission device and an input / output device, wherein the transmission device is connected to the above processor, and the input / output device is connected to the above processor.
[0111] Optionally, in this embodiment, the above processor may be configured to execute the following steps through a computer program:
[0112] S1, through the log management process, allocate a second storage area in the volatile memory for the critical information level and debug information level logs of the user program; the volatile memory is used to cache the critical information level logs and debug information level logs;
[0113] S2, when the user program generates an error level, according to the preset processing strategy and the logs cached in the volatile memory, the log management process writes the log associated with the error level log to the first storage area of the non-volatile memory.
[0114] It should be noted that the specific examples in this embodiment can refer to the examples described in the above embodiments and optional implementation modes, and will not be repeated in this embodiment.
[0115] In addition, in combination with the log linkage storage method based on shared memory provided in the above embodiment, a storage medium can also be provided in this embodiment to implement the method. The storage medium stores a computer program; when the computer program is executed by the processor, any one of the log linkage storage methods based on shared memory in the above embodiment is implemented.
[0116] It should be noted that the information and data involved in this application are all authorized by the user or fully authorized by all parties and will be used legally.
[0117] It should be understood that the specific embodiments described herein are only used to explain the application, rather than to limit it. Based on the embodiments provided in this application, all other embodiments obtained by ordinary technicians in this field without creative work are within the protection scope of this application.
[0118] Obviously, the drawings are only some examples or embodiments of the present application. For ordinary technicians in the field, the present application can also be applied to other similar situations based on these drawings without creative work. In addition, it is understandable that although the work done in this development process may be complicated and lengthy, for ordinary technicians in the field, certain changes in design, manufacturing or production based on the technical content disclosed in this application are only conventional technical means and should not be regarded as insufficient content disclosed in this application.
[0119] The term "embodiment" in this application refers to a specific feature, structure or characteristic described in conjunction with the embodiment that can be included in at least one embodiment of the present application. The appearance of this phrase in various locations in the specification does not necessarily mean the same embodiment, nor does it mean that it is mutually exclusive with other embodiments and is independent or optional. It is clearly or implicitly understood by those of ordinary skill in the art that the embodiments described in this application can be combined with other embodiments without conflict.
[0120] The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of patent protection. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the scope of protection of the present application. Therefore, the scope of protection of the present application shall be subject to the attached claims.
Claims
1. A log linkage storage method based on shared memory, characterized in that: Applicable to a log linkage storage system; the log linkage storage system comprises a target device, a log management process and a volatile memory; the target device comprises a non-volatile memory; a user program of the target device is connected to the non-volatile memory and the volatile memory respectively through the log management process; The log levels include critical information level, debugging information level, warning level and error level. The method includes: Through the log management process, a second storage area is allocated in the volatile memory for the key information level log and the debug information level log of the user program; the volatile memory is used to cache the key information level log and the debug information level log; When the user program generates an error level log, the log associated with the error level log is written to the first storage area of the non-volatile memory through the log management process according to a preset processing strategy and the logs cached in the volatile memory.
2. The log linkage storage method based on shared memory according to claim 1, characterized in that: The method further comprises: During the operation of the user program without generating an error-level log, the warning-level log is written to the first storage area of the non-volatile memory through the log management process, and the critical information-level log and the debug information-level log are cached in the second storage area of the volatile memory.
3. The log linkage storage method based on shared memory according to claim 1, characterized in that: The non-volatile memory is the EMMC storage space in the first operating system; the volatile memory is the DDR storage space in the second operating system.
4. The log linkage storage method based on shared memory according to claim 1, characterized in that: By means of the log management process, a second storage area is allocated in the volatile memory for the key information level log and the debug information level log of the user program, including: After the user program of the target device is started, initiating a request for the key information level log and the debug information level log to the log management process; After receiving the request, the log management process dynamically applies for a second storage area of the volatile memory; and feeds back a second storage address corresponding to the applied second storage area to the user program.
5. The log linkage storage method based on shared memory according to claim 4 is characterized in that: The method further comprises: According to the log level and the second storage address, the second storage area is actively selected for caching; the key information level log is cached separately to one second storage area; the debug information level log is cached to multiple second storage areas by module.
6. The log linkage storage method based on shared memory according to claim 1, characterized in that: When the user program generates an error level log, according to a preset processing strategy and the logs cached in the volatile memory, the log management process stores the log associated with the error level log in the first storage area of the non-volatile memory, including: Determine whether the generated log is the error-level log; If it is the error-level log, set the printing disk-falling time of the second storage area in the volatile memory, and lock all storage areas at the same time; write the error-level log, all the key information-level logs in the second storage area, and the debugging information-level log associated with the error-level log to the first storage area of the non-volatile memory through the log management process; If it is not the error-level log, determine whether it is a warning-level log; If it is the warning level log, the warning level log is written to the first storage area of the non-volatile memory through the log management process; If it is not the warning level log, the generated log is cached in the second storage area of the volatile memory through the log management process.
7. The log linkage storage method based on shared memory according to claim 1 is characterized in that: The method further comprises: When the log management process receives the error-level log, detecting whether the corresponding first storage area is locked; If the corresponding first storage area is locked, the error level log is stored separately in a new first storage area, and the new first storage area is unlocked after resetting the read-write pointer; If the corresponding first storage area is not locked, the error-level log is written to the corresponding first storage area.
8. A log linkage storage device based on shared memory, characterized in that: Applicable to a log linkage storage system; the log linkage storage system comprises a target device, a log management process and a volatile memory; the target device comprises a non-volatile memory; a user program of the target device is connected to the non-volatile memory and the volatile memory respectively through the log management process; The log levels include critical information level, debugging information level, warning level and error level. The device includes: an allocation module and a linkage storage module; The allocation module is used to allocate a second storage area for the key information level and debug information level logs of the user program in the volatile memory through the log management process; the volatile memory is used to cache the logs corresponding to the key information level and the debug information level; The linkage storage module is used to, when the user program generates an error level log, write the log associated with the error level log to the first storage area of the non-volatile memory through the log management process according to a preset processing strategy and the log cached in the volatile memory.
9. A computer device comprising a memory and a processor, characterized in that: A computer program is stored in the memory, and the processor is configured to run the computer program to execute the steps of the log linkage storage method based on shared memory according to any one of claims 1 to 7.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the log linkage storage method based on shared memory described in any one of claims 1 to 7 are implemented.