Log storage method, electronic equipment and storage medium

By dynamically adjusting the storage space according to the log level, the problem of log being blocked under the log storage mode is solved, ensuring that the logs of serious problem are not lost, and the efficiency of problem analysis and user experience are improved.

CN119066041APending Publication Date: 2024-12-03SHANGHAI PATEO ELECTRONIC EQUIPMENT MANUFACTURING CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202310601772.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-05-25
Publication Date
2024-12-03

AI Technical Summary

Technical Problem

The existing log storage method will cause the newly generated log data to drop the earliest log data under capacity or time limit, resulting in the inability to determine the cause of the problem in serious system problems.

Method used

By obtaining the log to be stored, determining its target log level based on the log information, and storing it in the corresponding storage space, dynamically adjusting the storage space to ensure that high-level logs are not pushed off, and part of the storage space of low-level logs is retained.

Benefits of technology

Ensure that when serious problems arise, even if the log is not obtained for a long time, the logs in this part will not be knocked out, which improves the efficiency of problem analysis and product quality, and improves user experience and driving safety.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119066041A_ABST
    Figure CN119066041A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a log storage method, electronic equipment and a storage medium. The method comprises the steps of obtaining a to-be-stored log; determining a target log level of the to-be-stored log according to the log information of the to-be-stored log; and storing the to-be-stored log in a target storage space corresponding to the target log level. According to the embodiment of the invention, the logs are stored in the sub-storage spaces according to the log levels, so that when a serious problem occurs, even if the logs are not obtained for a long time, the logs in the part cannot be jacked off.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of log processing, and in particular to a log storage method, electronic device and storage medium. Background Art

[0002] At present, in-vehicle hosts or other in-vehicle devices, a log storage mechanism is usually added to save user / vehicle action data of a certain capacity or a period of time. The vehicle / user log data can be copied through USB or cloud for problem analysis.

[0003] Log storage has a certain capacity or time limit. If the limit is exceeded, the newly generated log data will replace the earliest log data. In the log storage, it often happens that the problem occurs and it takes a long time to obtain the log. At this time, if it is a serious system problem and difficult to reproduce, the log when the problem occurred has been replaced, and it is impossible to determine the cause of the problem. Summary of the invention

[0004] The embodiments of the present application provide a log storage method, an electronic device, and a storage medium to solve the problem that the existing log storage method may cause the logs of system problems to be discarded, and the cause of the problem cannot be determined.

[0005] In order to solve the above technical problems, the embodiment of the present application is implemented as follows:

[0006] In a first aspect, an embodiment of the present application provides a log storage method, the method comprising the following steps:

[0007] Get the logs to be stored;

[0008] Determining a target log level of the log to be stored according to the log information of the log to be stored;

[0009] The log to be stored is stored in the target storage space corresponding to the target log level.

[0010] Optionally, determining a target log level of the log to be stored according to the log information of the log to be stored comprises the following steps:

[0011] Obtaining log triggering action information corresponding to the log to be stored;

[0012] Based on the log triggering action information, a target log level of the log to be stored is determined.

[0013] Optionally, determining a target log level of the log to be stored according to the log information of the log to be stored comprises the following steps:

[0014] Extracting log keywords from the log to be stored;

[0015] Based on the log keyword, a target log level of the log to be stored is determined.

[0016] Optionally, storing the log to be stored in a target storage space corresponding to the target log level comprises the following steps:

[0017] When the target log level is a first log level, storing the log to be stored in a first storage space corresponding to the first log level; or

[0018] When the target log level is the second log level, storing the log to be stored in a second storage space corresponding to the second log level;

[0019] The first log level is higher than the second log level.

[0020] Optionally, storing the log to be stored in a first storage space corresponding to the first log level comprises the following steps:

[0021] Determine whether the remaining memory of the first storage space is greater than or equal to the memory occupied by the log to be stored;

[0022] In response to the remaining memory of the first storage space being less than the memory occupied by the log to be stored, increasing the memory of the first storage space and decreasing the memory of the second storage space;

[0023] Storing the log to be stored in the first storage space;

[0024] The total memory of the first storage space and the second storage space is a fixed memory value.

[0025] Optionally, the increasing the memory of the first storage space and decreasing the memory of the second storage space comprises the following steps:

[0026] Acquire a first total memory of the first storage space and a second total memory of the second storage space;

[0027] Determine whether the first total memory is greater than or equal to a memory upper limit threshold corresponding to the first storage space, and whether the second total memory is equal to a memory lower limit threshold corresponding to the second storage space, and the memory upper limit threshold is greater than the memory lower limit threshold;

[0028] In response to the first total memory being less than the memory upper threshold and the second total memory being equal to the memory lower threshold, the memory of the first storage space is increased, and the memory of the second storage space is decreased.

[0029] Optionally, storing the log to be stored in a second storage space corresponding to the second log level comprises the following steps:

[0030] Determine whether the remaining memory of the second storage space is greater than or equal to the memory occupied by the log to be stored;

[0031] In response to the remaining memory of the second storage space being less than the occupied memory of the log to be stored, acquiring a fourth total memory of the second storage space;

[0032] Determine whether the fourth total memory reaches the low-level memory upper limit threshold corresponding to the second log level;

[0033] In response to the fourth total memory reaching the low-level memory upper limit threshold, deleting the log with the earliest storage time in the second storage space, and storing the log to be stored in the second storage space;

[0034] In response to the fourth total memory not reaching the low-level memory upper limit threshold, the memory of the first storage space is reduced, the memory of the second storage space is increased, and the log to be stored is stored in the second storage space.

[0035] Optionally, after obtaining the log to be stored, the following steps are further included:

[0036] Obtaining the application corresponding to the log to be stored;

[0037] Determine whether the application belongs to a target type of application, where the target type of application refers to an application whose error frequency is greater than a set threshold within a preset time from the current time;

[0038] In response to the application being an application of a target type, the log to be stored is stored in a designated storage space, and a storage time length of the log in the designated storage space is greater than a preset time length threshold.

[0039] In a second aspect, an embodiment of the present application provides an electronic device, including:

[0040] A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program implements any of the above-mentioned log storage methods when executed by the processor.

[0041] In a third aspect, an embodiment of the present application provides a readable storage medium. When instructions in the storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute any of the log storage methods described above.

[0042] In the embodiment of the present application, by obtaining the log to be stored, according to the log information of the log to be stored, the target log level of the log to be stored is determined, and the log to be stored is stored in the target storage space corresponding to the target log level. By storing the logs in different storage spaces according to the log level, the embodiment of the present application can ensure that when a serious problem occurs, even if the logs are not obtained for a long time, this part of the logs will not be pushed out.

[0043] The above description is only an overview of the technical solution of the present application. In order to more clearly understand the technical means of the present application, it can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the present application more obvious and easy to understand, the specific implementation methods of the present application are listed below. BRIEF DESCRIPTION OF THE DRAWINGS

[0044] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the description of the embodiments of the present application will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0045] Figure 1 A flow chart of the steps of a log storage method provided in an embodiment of the present application;

[0046] Figure 2 A flowchart of a method for determining a target log level provided in an embodiment of the present application;

[0047] Figure 3 A flowchart of another method for determining a target log level provided in an embodiment of the present application;

[0048] Figure 4 A flowchart of another log storage method provided in an embodiment of the present application;

[0049] Figure 5 A flowchart of another log storage method provided in an embodiment of the present application;

[0050] Figure 6 A flowchart of a storage space adjustment method provided in an embodiment of the present application;

[0051] Figure 7 A flowchart of another log storage method provided in an embodiment of the present application;

[0052] Figure 8 A flowchart of a method for storing logs to be stored provided in an embodiment of the present application;

[0053] Fig. 9A schematic diagram of a log storage process provided in an embodiment of the present application;

[0054] Fig.10 A schematic diagram of another log storage process provided in an embodiment of the present application;

[0055] Fig.11 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0056] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0057] Reference Figure 1 , shows a flow chart of the steps of a log storage method provided by an embodiment of the present application, such as Figure 1 As shown, the log storage method may include: step 101, step 102 and step 103.

[0058] Step 101: Obtain logs to be stored.

[0059] The embodiments of the present application can be applied to a scenario where logs are stored in different storage spaces according to log levels.

[0060] The embodiments of the present application can be applied to vehicle-mounted terminals, but are not limited thereto. Specifically, the application subject of the embodiments of the present application can be determined according to business requirements, and the embodiments do not impose any restrictions on this.

[0061] The log to be stored refers to the newly generated log information for storage. In this example, the log to be stored can be an operating system log, a network daemon log, an application log, a network infrastructure log, and other types of logs. Specifically, the specific type of the log to be stored can be determined according to the actual situation, and this embodiment does not limit this.

[0062] During the system operation, the generated logs to be stored can be obtained in real time.

[0063] After the log to be stored is obtained, step 102 is executed.

[0064] Step 102: Determine a target log level of the log to be stored according to the log information of the log to be stored.

[0065] Log information refers to information used to indicate the level of the log to be stored. In this example, the log information may be information such as log keywords and log trigger actions.

[0066] The target log level refers to the log level of the log to be stored. In this example, the log level can be divided into two levels, namely, a high level and a low level.

[0067] After the log to be stored is obtained, the log information of the log to be stored may be obtained, and the target log level of the log to be stored may be determined according to the log information of the log to be stored.

[0068] In this example, the action can be triggered according to the log to be stored to determine the target log level of the log to be stored. Figure 2 This is described in detail as follows.

[0069] Reference Figure 2 , shows a flowchart of the steps of a method for determining a target log level provided by an embodiment of the present application. Figure 2 As shown, the target log level determination method may include: step 201 and step 202.

[0070] Step 201: Obtain log triggering action information corresponding to the log to be stored.

[0071] In this embodiment, after obtaining the log to be stored, the log trigger action information corresponding to the log to be stored can be obtained. In this example, the log trigger action information can be but is not limited to action information such as automatic machine restart, machine blue screen, turning on WiFi hotspot, and automatic application exiting foreground operation.

[0072] After obtaining the log triggering action information corresponding to the log to be stored, step 202 is executed.

[0073] Step 202: Determine the target log level of the log to be stored based on the log triggering action information.

[0074] After obtaining the log trigger action information corresponding to the log to be stored, the target log level of the log to be stored can be determined based on the log trigger action information. For example, when the log trigger action information is the machine automatic restart information, it can indicate that there may be a problem with the system. At this time, the target log level of the log to be stored can be determined as a high level. When the log trigger action information is the machine blue screen information, it can indicate that there may be a problem with the system. At this time, the target log level of the log to be stored can be determined as a high level. When the log trigger action information is the action information of the application automatically exiting the foreground running, it indicates that there may be a problem with the application. At this time, the target log level of the log to be stored can be determined as a high level. When the log trigger action information is the action information of the user manually closing the application, it can indicate that the application exits normally. At this time, the target log level of the log to be stored can be determined as a low level, and so on.

[0075] It can be understood that the above examples are merely examples listed for a better understanding of the technical solutions of the embodiments of the present application, and are not intended to be the sole limitation to the embodiments.

[0076] The embodiment of the present application determines the log level by combining the triggering action of the log, and can accurately distinguish between logs with serious problems and normal logs to facilitate subsequent partition storage.

[0077] In the embodiment of the present application, the target log level of the log to be stored can also be determined according to the log keyword. Figure 3 This is described in detail as follows.

[0078] Reference Figure 3 , shows a flowchart of another method for determining a target log level provided by an embodiment of the present application. Figure 3 As shown, the target log level determination method may include: step 301 and step 302.

[0079] Step 301: extracting log keywords from the log to be stored.

[0080] In this embodiment, after the log to be stored is obtained, the log keywords in the log to be stored can be extracted. In this example, the log keywords in the log to be stored can be obtained by specifying commands, such as Linux commands and the like.

[0081] After extracting the log keywords in the log to be stored, step 302 is executed.

[0082] Step 302: Based on the log keyword, determine the target log level of the log to be stored.

[0083] After extracting the log keywords in the log to be stored, the target log level of the log to be stored can be determined based on the log keywords. Specifically, the log keywords can be analyzed to determine whether the log keywords are keywords that cause serious problems. If so, the target log level of the log to be stored can be determined to be a high level. If not, the target log level of the log to be stored can be determined to be a low level, etc.

[0084] The embodiment of the present application extracts log keywords of the log to be stored to analyze the log level of the log to be stored, so as to accurately identify the log level of the log to be stored and improve the recognition accuracy of the log level.

[0085] After the target log level of the log to be stored is determined according to the log information of the log to be stored, step 103 is executed.

[0086] Step 103: Store the log to be stored in the target storage space corresponding to the target log level.

[0087] After determining the target log level of the log to be stored according to the log information of the log to be stored, the log to be stored can be stored in the target storage space corresponding to the target log level. In this embodiment, the log level can be divided into two levels, namely, high level and low level, and the corresponding log storage space is also divided into two levels, namely, high level storage space and low level storage space. Figure 4 This is described in detail as follows.

[0088] Reference Figure 4 , shows a flow chart of another log storage method provided by an embodiment of the present application. Figure 4 As shown, the log storage method may include: step 401 and step 402.

[0089] Step 401: When the target log level is a first log level, the log to be stored is stored in a first storage space corresponding to the first log level.

[0090] Step 402: When the target log level is the second log level, the log to be stored is stored in a second storage space corresponding to the second log level;

[0091] In this embodiment, the first log level is higher than the second log level, that is, the first log level is a high level and the second log level is a low level.

[0092] When the target log level is the first log level, the log to be stored may be stored in a first storage space corresponding to the first log level.

[0093] When the target log level is the second log level, the log to be stored may be stored in the second storage space corresponding to the second log level.

[0094] In the embodiment of the present application, the total memory of the first storage space and the second storage space is a fixed memory value, and the memory size of the first storage space and the second storage space can be dynamically adjusted. When the target log level is the first log level, if the remaining memory of the first storage space is less than the memory occupied by the log to be stored, the memory of the first storage space can be increased, and then the log to be stored can be stored. Figure 5 This is described in detail as follows.

[0095] Reference Figure 5 , shows a flow chart of steps of another log storage method provided by an embodiment of the present application. Figure 5As shown, the log storage method may include: step 501, step 502 and step 503.

[0096] Step 501: Determine whether the remaining memory of the first storage space is greater than or equal to the memory occupied by the log to be stored.

[0097] In this embodiment, the remaining memory refers to the remaining available memory in the first storage space.

[0098] The occupied memory refers to the memory required to store the logs to be stored.

[0099] When it is determined that the target log level of the log to be stored is the first log level, it can be determined whether the remaining memory of the first storage space is greater than or equal to the occupied memory of the log to be stored. Specifically, the remaining available memory of the first storage space, i.e., the remaining memory, can be calculated based on the total memory of the first storage space and the occupied memory of the first storage space. Then, the size relationship between the remaining memory and the occupied memory of the log to be stored is compared.

[0100] When the remaining memory of the first storage space is greater than or equal to the occupied memory of the log to be stored, the log to be stored may be stored in the first storage space.

[0101] When the remaining memory of the first storage space is smaller than the memory occupied by the log to be stored, step 502 is executed.

[0102] Step 502: In response to the remaining memory of the first storage space being less than the memory occupied by the logs to be stored, the memory of the first storage space is increased and the memory of the second storage space is decreased.

[0103] When it is determined that the remaining memory of the first storage space is less than the occupied memory of the logs to be stored, the memory of the first storage space can be increased and the memory of the second storage space can be decreased in response to the remaining memory of the first storage space being less than the occupied memory of the logs to be stored.

[0104] In a specific implementation, the upper memory threshold of the first storage space can be pre-set, and the lower memory threshold of the second storage space can be pre-set. When the memory of the first storage space needs to be adjusted, it is necessary to determine whether the total memory of the first storage space is greater than or equal to its corresponding upper memory threshold, and determine whether the total memory of the second storage space is equal to its corresponding lower memory threshold. That is, determine whether the memory adjustment conditions of the first storage space and the second storage space are met. If so, adjust the memory of the first storage space and the second storage space, and store the logs to be stored in the first storage space. This implementation process can be combined with Figure 6 This is described in detail as follows.

[0105] Reference Figure 6, shows a flowchart of the steps of the storage space adjustment method provided by the embodiment of the present application. Figure 6 As shown, the storage space adjustment method may include: step 601, step 602 and step 603.

[0106] Step 601: Obtain a first total memory of the first storage space and a second total memory of the second storage space.

[0107] In this embodiment, when the memory of the first storage space needs to be adjusted, a first total memory of the first storage space and a second total memory of the second storage space may be obtained.

[0108] After the first total memory of the first storage space and the second total memory of the second storage space are acquired, step 602 is executed.

[0109] Step 602: Determine whether the first total memory is greater than or equal to the memory upper limit threshold corresponding to the first storage space, and whether the second total memory is equal to the memory lower limit threshold corresponding to the second storage space, and the memory upper limit threshold is greater than the memory lower limit threshold.

[0110] After obtaining the first total memory of the first storage space and the second total memory of the second storage space, it can be determined whether the first total memory is greater than or equal to the memory upper limit threshold corresponding to the first storage space, and whether the second total memory is equal to the memory lower limit threshold corresponding to the second storage space, where the memory upper limit threshold is greater than the memory lower limit threshold.

[0111] Step 603: In response to the first total memory being less than the memory upper threshold and the second total memory being equal to the memory lower threshold, the memory of the first storage space is increased and the memory of the second storage space is decreased.

[0112] When the first total memory is less than the upper memory threshold and the second total memory is greater than the lower memory threshold, the memory of the first storage space can be adjusted, the memory of the second storage space can be lowered, and the subsequent operation of storing the logs to be stored in the first storage space can be performed.

[0113] It can be understood that when the first total memory is greater than or equal to the memory upper limit threshold, and / or the second total memory is equal to the memory lower limit threshold, the memory of the first storage space cannot be adjusted. At this time, the log with the longest storage time in the first storage space can be deleted, and the log to be stored can be stored in the first storage space.

[0114] The embodiment of the present application pre-sets the memory upper limit of the first storage space and the memory lower limit of the second storage space, so that a small amount of storage space can be reserved for low-level logs while ensuring the storage of more high-level logs, thereby avoiding the phenomenon that the storage space is completely occupied by high-level logs.

[0115] After the memory of the first storage space is increased and the memory of the second storage space is decreased, step 503 is executed.

[0116] Step 503: Store the log to be stored in the first storage space.

[0117] After the memory of the first storage space is increased and the memory of the second storage space is decreased, the logs to be stored can be stored in the first storage space.

[0118] The embodiment of the present application dynamically allocates log storage space for high-level logs and low-level logs, thereby achieving the purpose of storing as many high-level logs as possible while reserving a small amount of memory for low-level logs, thereby avoiding the phenomenon that the storage space is completely occupied by high-level logs. At the same time, the storage capacity of high-level logs can be increased.

[0119] In this embodiment, when the target log level of the log to be stored is the second log level and the log to be stored is stored in the second storage space, it can be determined whether the remaining memory of the second storage space meets the storage conditions of the log to be stored. If not, the memory of the second storage space is increased to store the log to be stored. Figure 7 This is described in detail as follows.

[0120] Reference Figure 7 , shows a flow chart of steps of another log storage method provided by an embodiment of the present application. Figure 7 As shown, the log storage method may include: step 701, step 702, step 703, step 704 and step 705.

[0121] Step 701: Determine whether the remaining memory of the second storage space is greater than or equal to the memory occupied by the log to be stored.

[0122] In the embodiment of the present application, when it is determined that the target log level of the log to be stored is the second log level, it can be determined whether the remaining memory of the second storage space is greater than or equal to the occupied memory of the log to be stored.

[0123] If the remaining memory of the second storage space is greater than or equal to the occupied memory of the log to be stored, the log to be stored may be stored in the second storage space.

[0124] If the remaining memory of the second storage space is smaller than the memory occupied by the log to be stored, step 702 is executed.

[0125] Step 702: In response to the remaining memory of the second storage space being smaller than the memory occupied by the log to be stored, a fourth total memory of the second storage space is obtained.

[0126] When it is determined that the remaining memory of the second storage space is less than the memory occupied by the logs to be stored, a fourth total memory of the second storage space may be acquired in response to the remaining memory of the second storage space being less than the memory occupied by the logs to be stored.

[0127] After the fourth total memory of the second storage space is acquired, step 703 is executed.

[0128] Step 703: Determine whether the fourth total memory reaches the low-level memory upper limit threshold corresponding to the second log level.

[0129] After obtaining the fourth total memory of the second storage space, it can be determined whether the fourth total memory reaches the lower level memory upper limit threshold corresponding to the second log level, that is, the memory upper limit of the second storage space.

[0130] Step 704: In response to the fourth total memory reaching the low-level memory upper limit threshold, deleting the log with the earliest storage time in the second storage space, and storing the log to be stored in the second storage space.

[0131] When it is determined that the fourth total memory reaches the low-level memory upper limit threshold, the log with the earliest storage time in the second storage space may be deleted, and the log to be stored may be stored in the second storage space.

[0132] Step 705: In response to the fourth total memory not reaching the low-level memory upper limit threshold, reduce the memory of the first storage space, increase the memory of the second storage space, and store the log to be stored in the second storage space.

[0133] When it is determined that the fourth total memory does not reach the low-level memory upper limit threshold, the memory of the first storage space can be reduced, the memory of the second storage space can be increased, and the log to be stored is stored in the second storage space.

[0134] In this embodiment, the high-level log storage space and the low-level log storage space are partially dynamically allocated: the lower limit of the storage space for the low-level log storage is set to A, the upper limit of the space for the high-level log storage is set to B, the upper limit of the total storage space of the high and low levels is C, the actual storage capacity of the high-level log is D, and the upper limit of the low-level log storage space is E, where: A+B=C.

[0135] When D is less than B, E = CD. If the value of D gradually increases, the value of E gradually decreases. At this time, the earliest low-level logs are gradually flushed to ensure that high-level logs can continue to be saved. The minimum value of E is A, which can ensure that some low-level logs can also be saved. It is used to confirm recent minor problems.

[0136] In this embodiment, it can also be determined whether the application program for which the log is to be stored is an application program with an error frequency greater than a set threshold within a preset time period from the current time. If so, the log to be stored can be stored in the specified storage space. Figure 8 This is described in detail as follows.

[0137] Reference Figure 8 , shows a flow chart of the steps of a method for storing logs to be stored provided by an embodiment of the present application. Figure 8 As shown, the method for storing the logs to be stored may include: step 801, step 802 and step 803.

[0138] Step 801: Obtain the application corresponding to the log to be stored.

[0139] In this embodiment, after obtaining the log to be stored, the application corresponding to the log to be stored can be obtained. For example, when the log to be stored is a log generated by the automatic shutdown of application A, the application corresponding to the log to be stored is application A. Alternatively, when the log to be stored is a log generated by logging into application B, the application corresponding to the log to be stored is application B, etc.

[0140] It can be understood that the above examples are merely examples listed for a better understanding of the technical solutions of the embodiments of the present application, and are not intended to be the sole limitation to the embodiments.

[0141] After the application corresponding to the log to be stored is obtained, step 802 is executed.

[0142] Step 802: Determine whether the application belongs to a target type of application, where the target type of application refers to an application whose error frequency is greater than a set threshold within a preset time period from the current time.

[0143] The target type of application refers to an application whose error frequency is greater than a set threshold within a preset time from the current time.

[0144] In this example, the set threshold is a preset threshold of the application error frequency. The specific value of the set threshold can be determined according to business requirements, and this embodiment does not limit this.

[0145] The preset duration may be a pre-set duration for counting application error frequencies. In this example, the preset duration may be one week, one month, etc. Specifically, the specific value of the preset duration may be determined based on business requirements, and this embodiment does not impose any restrictions on this.

[0146] After obtaining the application corresponding to the log to be stored, it can be determined whether the application belongs to the target type of application.

[0147] In this example, an application list of target type applications can be pre-set. After obtaining the application corresponding to the log to be stored, it can be determined whether the application is in the application list. If the application is in the application list, it can be determined that the application belongs to the target type application, etc.

[0148] In a specific implementation, other methods may be used to determine whether the application corresponding to the log to be stored belongs to the target type of application. Specifically, the determination method may be determined according to business requirements, and this embodiment does not limit this.

[0149] After determining that the application belongs to the target type of application, step 803 is executed.

[0150] Step 803: In response to the application being an application of the target type, the log to be stored is stored in a designated storage space, and the storage time of the log in the designated storage space is greater than a preset time threshold.

[0151] After determining that the application belongs to the target type of application, the logs to be stored can be stored in a designated storage space in response to the application belonging to the target type of application, and the storage time of the logs in the designated storage space is greater than the preset time threshold. For example, taking a vehicle as an example, key logs can be exported for actual problems of different users. If a user often encounters problems when using a certain application, the logs corresponding to the application can be set to a higher priority in the cloud. And on the vehicle, the logs corresponding to the application will be saved for a longer time.

[0152] The embodiment of the present application provides a longer storage period by saving the logs generated by applications that often fail to save the logs to a specified storage space, thereby avoiding the situation where the logs of the application are pushed out due to a long time and the problem cannot be located.

[0153] The above implementation process can be combined with Fig. 9 and Fig.10 Each is described in detail as follows.

[0154] Reference Fig. 9 , showing a schematic diagram of a log storage process provided in an embodiment of the present application.

[0155] like Fig. 9 As shown, the log storage process may include the following steps:

[0156] Step 901: Get the newly generated log.

[0157] Step 902: When executing the log saving operation, the log level can be determined. If the log level of the newly generated log is high, step 903 is executed. If the log level of the newly generated log is low, step 907 is executed.

[0158] Step 903: Determine whether the high-level storage space has reached the upper limit. If so, execute step 906; otherwise, execute step 904.

[0159] Step 904: When the high-level storage space does not reach the upper limit, the newly generated log (ie, the high-level log) is directly saved.

[0160] Step 905: When saving high-level logs, it is necessary to determine whether the low-level log space needs to be adjusted, that is, whether the remaining memory of the high-level storage space meets the memory occupancy condition for storing the newly generated high-level logs. If yes, execute step 911; otherwise, execute step 910.

[0161] Step 906: If the high-level storage space reaches the upper limit, the newly generated high-level log can be saved after the earliest high-level log in the high-level storage space.

[0162] Step 907: When the log level of the newly generated log is a low log level, it is determined whether the low level storage space has reached the upper limit. If so, step 909 is executed. Otherwise, step 908 is executed.

[0163] Step 908: When the low-level storage space does not reach the upper limit, the low-level logs are directly saved.

[0164] Step 909: If the low-level storage space reaches the upper limit, the earliest low-level log in the low-level storage space may be replaced and the newly generated low-level log may be saved.

[0165] Step 910: When the low-level log space does not need to be adjusted, the memory of the log storage space is not adjusted, and the newly generated high-level log is stored in the high-level log storage space.

[0166] Step 911: When the low-level log space needs to be adjusted, the low-level log space can be adjusted.

[0167] Step 912: When adjusting the low-level log space, if the remaining memory of the low-level log space is insufficient, the earliest low-level log in the low-level log space may be replaced, and then the log space may be adjusted.

[0168] Reference Fig.10 , showing a schematic diagram of another log storage process provided in an embodiment of the present application.

[0169] like Fig.10 As shown, the log storage process may include the following steps:

[0170] Step 1001: Get the newly generated log.

[0171] Step 1002: Determine whether there is a high-level log keyword in the newly generated log. If yes, execute step 1003; otherwise, execute step 1008.

[0172] Step 1003: When there is a high-level log keyword in the newly generated log, the newly generated log can be copied to the high-level log area for storage.

[0173] Step 1004: Determine whether the high-level storage area has reached the upper limit. If so, execute step 1006; otherwise, execute step 1005.

[0174] Step 1005: If the high-level storage area has not reached the upper limit, the high-level log is directly saved.

[0175] Step 1006: If the high-level storage area reaches the upper limit, the earliest high-level log in the high-level storage area is replaced and the newly generated high-level log is saved.

[0176] Step 1007: While saving the high-level logs in the high-level storage area, the logs can also be saved in the normal log space at the same time to achieve the log backup function.

[0177] Step 1008: If the newly generated log does not contain the high-level log keyword, it can be determined that the newly generated log is a low-level log. At this time, the newly generated log can be directly saved in other log storage spaces outside the non-high-level space.

[0178] Step 1009: Determine whether the log storage area has reached the upper limit. If yes, execute step 1011; otherwise, execute step 1010.

[0179] Step 1010: If the log storage area has not reached the upper limit, the newly generated low-level logs are directly saved.

[0180] Step 1011: If the log storage area reaches the upper limit, the oldest log in the log storage area may be replaced and the newly generated log may be saved.

[0181] The above log storage method provided in the embodiment of the present application has two innovative features: 1. Management of sunlight by region; 2. Dynamic allocation of log regions. Logs can be stored in different storage spaces according to log levels, which can ensure that when serious problems occur, even if logs are not obtained for a long time, this part of the log will not be replaced. For vehicle-mounted terminals, it can improve the efficiency of analyzing the causes when solving vehicle-mounted problems, improve product quality, and enhance user experience and driving safety.

[0182] The log storage method provided in the embodiment of the present application obtains the log to be stored, determines the target log level of the log to be stored according to the log information of the log to be stored, and stores the log to be stored in the target storage space corresponding to the target log level. The embodiment of the present application stores the logs in different storage spaces according to the log level, so as to ensure that when a serious problem occurs, even if the logs are not obtained for a long time, the logs in this part will not be replaced.

[0183] In addition, an embodiment of the present application further provides an electronic device, comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program implements the above-mentioned log storage method when executed by the processor.

[0184] Fig.11 FIG. 1 is a schematic diagram showing the structure of an electronic device 1100 according to an embodiment of the present invention. Fig.11 As shown, the electronic device 1100 includes a central processing unit (CPU) 1101, which can perform various appropriate actions and processes according to computer program instructions stored in a read-only memory (ROM) 1102 or computer program instructions loaded from a storage unit 1108 to a random access memory (RAM) 1103. In the RAM 1103, various programs and data required for the operation of the electronic device 1100 can also be stored. The CPU 1101, the ROM 1102, and the RAM 1103 are connected to each other via a bus 1104. An input / output (I / O) interface 1105 is also connected to the bus 1104.

[0185] Multiple components in the electronic device 1100 are connected to the I / O interface 1105, including: an input unit 1106, such as a keyboard, a mouse, a microphone, etc.; an output unit 1107, such as various types of displays, speakers, etc.; a storage unit 1108, such as a disk, an optical disk, etc.; and a communication unit 1109, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 1109 allows the electronic device 1100 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.

[0186] The various processes and processing described above may be performed by the processing unit 1101. For example, the method of any of the above embodiments may be implemented as a computer software program, which is tangibly contained in a computer-readable medium, such as the storage unit 1108. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 1100 via the ROM 1102 and / or the communication unit 1109. When the computer program is loaded into the RAM 1103 and executed by the CPU 1101, one or more actions in the method described above may be performed.

[0187] The embodiment of the present application also provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, each process of the above-mentioned log storage method embodiment is implemented, and the same technical effect can be achieved. To avoid repetition, it is not repeated here. The computer-readable storage medium is, for example, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.

[0188] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or device including the element.

[0189] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, a magnetic disk, or an optical disk), and includes a number of instructions for a terminal (which can be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) to execute the methods described in each embodiment of the present application.

[0190] The embodiments of the present application are described above in conjunction with the accompanying drawings, but the present application is not limited to the above-mentioned specific implementation methods. The above-mentioned specific implementation methods are merely illustrative and not restrictive. Under the guidance of the present application, ordinary technicians in this field can also make many forms without departing from the purpose of the present application and the scope of protection of the claims, all of which are within the protection of the present application.

[0191] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed in the present application can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.

[0192] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.

[0193] In the embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0194] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0195] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.

[0196] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, server, or network device, etc.) to perform all or part of the steps of the methods described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as USB flash drives, mobile hard drives, ROM, RAM, magnetic disks, or optical disks.

[0197] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.

Claims

1. A log storage method, It is characterized in that The method comprises the following steps: Get the logs to be stored; Determining a target log level of the log to be stored according to the log information of the log to be stored; The log to be stored is stored in the target storage space corresponding to the target log level.

2. The method according to claim 1, wherein the target log level of the log to be stored is determined according to the log information of the log to be stored, The following steps are involved: Obtaining log triggering action information corresponding to the log to be stored; Based on the log triggering action information, a target log level of the log to be stored is determined.

3. The method according to claim 1, wherein the target log level of the log to be stored is determined according to the log information of the log to be stored, The following steps are involved: Extracting log keywords from the log to be stored; Based on the log keyword, a target log level of the log to be stored is determined.

4. The method according to claim 1, wherein the log to be stored is stored in a target storage space corresponding to the target log level. The following steps are involved: When the target log level is a first log level, storing the log to be stored in a first storage space corresponding to the first log level; or When the target log level is the second log level, storing the log to be stored in a second storage space corresponding to the second log level; The first log level is higher than the second log level.

5. The method according to claim 4, wherein the log to be stored is stored in a first storage space corresponding to the first log level, The following steps are involved: Determine whether the remaining memory of the first storage space is greater than or equal to the memory occupied by the log to be stored; In response to the remaining memory of the first storage space being less than the memory occupied by the log to be stored, increasing the memory of the first storage space and decreasing the memory of the second storage space; Storing the log to be stored in the first storage space; The total memory of the first storage space and the second storage space is a fixed memory value.

6. The method according to claim 5, wherein the memory of the first storage space is increased and the memory of the second storage space is decreased. The following steps are involved: Acquire a first total memory of the first storage space and a second total memory of the second storage space; Determine whether the first total memory is greater than or equal to a memory upper limit threshold corresponding to the first storage space, and whether the second total memory is equal to a memory lower limit threshold corresponding to the second storage space, and the memory upper limit threshold is greater than the memory lower limit threshold; In response to the first total memory being less than the memory upper threshold and the second total memory being equal to the memory lower threshold, the memory of the first storage space is increased, and the memory of the second storage space is decreased.

7. The method according to claim 4, wherein the log to be stored is stored in a second storage space corresponding to the second log level. The following steps are involved: Determine whether the remaining memory of the second storage space is greater than or equal to the memory occupied by the log to be stored; In response to the remaining memory of the second storage space being less than the occupied memory of the log to be stored, acquiring a fourth total memory of the second storage space; Determine whether the fourth total memory reaches the low-level memory upper limit threshold corresponding to the second log level; In response to the fourth total memory reaching the low-level memory upper limit threshold, deleting the log with the earliest storage time in the second storage space, and storing the log to be stored in the second storage space; In response to the fourth total memory not reaching the low-level memory upper limit threshold, the memory of the first storage space is reduced, the memory of the second storage space is increased, and the log to be stored is stored in the second storage space.

8. The method according to claim 1, after obtaining the log to be stored, further The following steps are involved: Obtaining the application corresponding to the log to be stored; Determine whether the application belongs to a target type of application, where the target type of application refers to an application whose error frequency is greater than a set threshold within a preset time from the current time; In response to the application being an application of a target type, the log to be stored is stored in a designated storage space, and a storage time length of the log in the designated storage space is greater than a preset time length threshold.

9. An electronic device, It is characterized in that include: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program implements the log storage method according to any one of claims 1 to 8 when executed by the processor.

10. A readable storage medium, It is characterized in that When the instructions in the storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute the log storage method according to any one of claims 1 to 8.

Citation Information

Patent Citations

  • Method for saving logs and log system

    CN101571827A

  • Memory-based anti-overflow method of log information

    CN102521148A

  • Log storage method and device, computer equipment and storage medium

    CN114116614A

  • Log storage method and system, electronic equipment and storage medium

    CN115114250A