Method for dynamically updating log printing quantity
By dynamically adjusting the log level, the problem of excessive log service occupation is solved in the on-board infotainment system according to the system resource load, and the need to reduce the burden at high load and provide detailed logging when the load is normal, ensuring the system Stable and efficient operation.
Patent Information
- Application Number
- CN202411190334.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-28
- Publication Date
- 2024-12-06
AI Technical Summary
In vehicle infotainment systems, low-level logging services will cause excessive resource usage, which may cause system lag and data loss problems, and high-level logging cannot provide detailed log evidence when the system load is normal.
By dynamically adjusting the log print volume, increasing or restoring the log level according to the load conditions of the CPU and RAM, ensuring that the log print volume is reduced at high load and increasing detail when the load is normal. The specific steps include setting log levels, setting level switching conditions, starting log services and cycling programs, regularly checking system resource load, and adjusting log levels according to thresholds.
Reduce resource burden when the system load is high, avoid lag and data loss, and provide more log evidence when the load is normal, meet the needs of detailed records in normal states and efficient operation in busy states, and avoid excessive occupation of system resources.
Smart Images

Figure CN119088557A_ABST
Abstract
Description
Technical Field
[0001] The invention relates to a method for dynamically updating a log printing amount in the technical field of an in-vehicle information entertainment system. Background Art
[0002] The in-vehicle infotainment system (referred to as the system) is a physical product with a display screen and a touch screen. In the system, there is a service called the log service that records the internal information of the system. The log service is used to record and review the details of the system during operation, such as: operation information, access records, calculation process, signal input and output, etc. The log service outputs logs in a variety of ways, and the more typical way is to output to standard output or to file records.
[0003] The log service has multiple levels, and the common log levels in the Android system are: Verbose (the most detailed level), Debug (debugging level), Info (critical information level), Warning (warning level), and Error (error level), with the levels increasing from Verbose to Fatal.
[0004] If the system runs at a low level, logs at this level and all higher levels will be printed out, with a large amount of information. For example, if the system level is Verbose, then higher levels such as Verbose, Debug, Info, Warning, and Error will be included in the log output category. The log service load is large, occupying more system resources, and there may be risks such as resource exhaustion, system freeze, and data loss. Summary of the invention
[0005] The purpose of the present invention is to provide a method for dynamically updating the log printing volume, which can increase the log service level when the system load is high (such as high CPU and RAM) to reduce the system burden and avoid the risks of resource exhaustion, system freeze, data loss, etc., and adjust the log level back to a more detailed log level when the system load is normal to provide more log evidence.
[0006] To achieve the above object, the present invention provides a method for dynamically updating the log printing amount, comprising the following steps: Step 1, set the log level; Step 2: Set the switching conditions of the log level; Step 3: Start the log service and perform normal log recording. Step 4, start the cycle program.
[0007] As a further improvement of the present invention, the specific content of step 1 is as follows: Step 1.1, the log level is divided into five levels, from low to high: Verbose, Debug, Info, Warning, and Error.
[0008] Step 1.2, set the default log level, which can be any one of Verbose, Debug, Info, and Warning; Step 1.3, set the higher level of the log, which can be any one of Debug, Info, Warning and Error, and the higher level must be higher than the default level; As a further improvement of the present invention, the specific content of step 2 is as follows: Set the conditions for switching the log level between "default level" and "higher level", specifically "level increase conditions" and "default level restoration conditions". These two conditions correspond to the system resource conditions for increasing the system log level and restoring the system log level, including but not limited to the two dimensions of CPU and RAM. For each dimension, you need to set the percentage threshold for increasing the level and the percentage threshold for restoring the default level.
[0009] As a further improvement of the present invention, the specific content of step 4 is as follows: Step 4.1, set the waiting time; Step 4.2, check and analyze system resources after the waiting time; Step 4.3: Dynamically switch the log level.
[0010] As a further improvement of the present invention, the specific content of step 4.2 is as follows: Execute the command for viewing system resources once and analyze the execution result information to obtain the load of system resources.
[0011] As a further improvement of the present invention, the specific content of step 4.3 is as follows: If the current log level is higher than the default log level, check whether the system meets the conditions for restoring the default log level; if the system meets the recovery conditions, set the log level to the default level to reduce the amount of log printing, and record the action of switching levels at a higher level, and then go to step 4.2; if the system does not meet the recovery conditions, go directly to step 4.2.
[0012] As a further improvement of the present invention, step 4.3 also includes the following content: If the current log level is equal to or lower than the default log level, check whether the system is in a high load state, that is, whether the system has reached the conditions for upgrading to a higher log level; if the system is in a high load, set the log level to a higher level, and record the action of switching levels at a higher level, and then go to step 4.2; if the system has not reached a high load, go directly to step 4.2.
[0013] Compared with the prior art, the beneficial effect of the present invention is that it can record more logs in "normal state", and can meet the needs of recording logs for the more efficient process of system operation in "busy state", and can also record key system logs. It can prevent excessive use of system resource viewing commands from occupying too many system resources. BRIEF DESCRIPTION OF THE DRAWINGS
[0014] Figure 1 It is a flow chart of the present invention.
[0015] Figure 2 This is a flow chart of Embodiment 1 of the present invention.
[0016] Figure 3 This is a flow chart of Embodiment 2 of the present invention.
[0017] Figure 4 It is the log level in the present invention. DETAILED DESCRIPTION
[0018] The present invention is further described below in conjunction with the accompanying drawings: like Figure 1 and 4 A method for dynamically updating the log printing volume shown in the figure comprises the following steps: Step 1, set the log level; Step 1.1, the log level is divided into five levels, from low to high: Verbose, Debug, Info, Warning, and Error.
[0019] Step 1.2, set the default log level, which can be any one of Verbose, Debug, Info, and Warning; Step 1.3, set the higher level of the log, which can be any one of Debug, Info, Warning and Error, and the higher level must be higher than the default level; Step 2: Set the switching conditions of the log level; Set the conditions for switching the log level between "default level" and "higher level", specifically "level increase conditions" and "default level restoration conditions". These two conditions correspond to the system resource conditions for increasing the system log level and restoring the system log level, including but not limited to the two dimensions of CPU and RAM. For each dimension, you need to set the percentage threshold for increasing the level and the percentage threshold for restoring the default level.
[0020] Step 3: Start the log service and perform normal log recording. Step 4, start the cycle program.
[0021] Step 4.1, set the waiting time; Step 4.2, check and analyze system resources after the waiting time; Execute the command for viewing system resources once and analyze the execution result information to obtain the load of system resources.
[0022] Step 4.3: Dynamically switch the log level.
[0023] If the current log level is higher than the default log level, check whether the system meets the conditions for restoring the default log level; if the system meets the recovery conditions, set the log level to the default level to reduce the amount of log printing, and record the action of switching levels at a higher level, and then go to step 4.2; if the system does not meet the recovery conditions, go directly to step 4.2.
[0024] If the current log level is equal to or lower than the default log level, check whether the system is in a high load state, that is, whether the system has reached the conditions for upgrading to a higher log level; if the system is in a high load, set the log level to a higher level, and record the action of switching levels at a higher level, and then go to step 4.2; if the system has not reached a high load, go directly to step 4.2. Example
[0025] like Figure 2 As shown, percentage is used as a method to increase the log level and restore the default log level.
[0026] The log space is limited. The lower the log level, the more information is printed per unit time, which results in a shorter time for the log to reflect the operation details. When searching for logs, only logs from a very short period of time are found, making it impossible to locate the problem, causing losses to customers. Therefore, the logs need to print only key information at the Info level and above, and when the system is busy, only Warning level and above are printed.
[0027] (1) Set the default log level to I, which is the Info level.
[0028] (2) Set the higher log level to W, which is the Warning level.
[0029] (3) Set the conditions for switching the log level between "default level" and "higher level": "Level increase condition" is set to remaining available RAM less than 10% or CPU availability less than 8%; and "Restore default level condition" is set to remaining available RAM greater than 12% and CPU availability greater than 11%.
[0030] (4) The log service is started when the computer is turned on. After startup, the log service performs normal log recording work.
[0031] (5) Without affecting the log service log recording work, start the following loop program.
[0032] (6) Wait for 10 seconds.
[0033] (7) Execute the top command to view system resources and analyze its execution result information to obtain the load of system resources.
[0034] (8) Check the log level. If the current log level is higher than the default log level, check whether the system has reached the conditions for restoring the default log level. If the system has reached the recovery conditions, set the log level to the default Info level, and record the action of switching levels at a higher Warning level, and then proceed to step (6); if the system has not reached the recovery conditions, proceed directly to step (6).
[0035] (9) If the current log level is equal to or lower than the default log level, check whether the system is in a high load state (i.e., whether the system has reached the conditions for upgrading to a higher log level). If the system is in a high load state, set the log level to a higher level, Warning, and record the action of switching the level at a higher level, Warning, and then go to step (6); if the system has not reached a high load, go directly to step (6). Example
[0036] like Figure 3 As shown in the figure, percentage is used as a way to increase the log level and restore the default log level, but the memory uses megabytes (abbreviated as "M") in absolute byte size as the judgment unit. Since the log space is relatively ample, when the log level is higher, the log level of Debug and above is selected, and when the system is busy, only Info and above levels are printed.
[0037] (1) Set the default log level to D, which is the Debug level.
[0038] (2) Set the higher log level to I, which is the Info level.
[0039] (3) Set the conditions for switching the log level between "default level" and "higher level": "Level increase condition" is set to remaining available RAM less than 550M and CPU availability less than 10%; and "Default level restoration condition" is set to remaining available RAM greater than 750M and CPU availability greater than 18%.
[0040] (4) The log service is started when the computer is turned on. After startup, the log service performs normal log recording work.
[0041] (5) Without affecting the log service log recording work, start the following loop program.
[0042] (6) Wait for 5 seconds.
[0043] (7) Check the system resources once and analyze the execution result information to obtain the load of the system resources.
[0044] (8) Check the log level. If the current log level is higher than the default log level, check whether the system has reached the conditions for restoring the default log level. If the system has reached the recovery conditions, set the log level to the default level and record the action of switching the level at a higher level, then proceed to step (6); if the system has not reached the recovery conditions, proceed directly to step (6).
[0045] (9) If the current log level is equal to or lower than the default log level, check whether the system is in a high load state (i.e., whether the system has reached the conditions for upgrading to a higher log level). If the system is in a high load state, set the log level to a higher level, and record the action of switching the level at a higher level, and then go to step (6); if the system has not reached a high load, go directly to step (6).
[0046] The present invention can not only improve the log service level to reduce the system burden when the system load is high (for example, high CPU and RAM), thereby avoiding the possible risks of resource exhaustion, system freeze, data loss, etc., but also adjust the log level back to a more detailed log level (providing more log evidence) when the system load is normal.
[0047] Therefore, the present invention can meet the needs of recording more logs at a low level in the "normal state", and can also meet the needs of recording logs at a high level in the "busy state" to make way for the system operation process. At the same time, it can also record the key logs of the system, and can prevent excessive use of commands to view system resources and occupy too many system resources.
[0048] The present invention is not limited to the above-mentioned embodiments. On the basis of the technical solution disclosed herein, technicians in this field can make some substitutions and deformations to some technical features therein according to the disclosed technical content without creative labor, and these substitutions and deformations are all within the protection scope of the present invention.
Claims
1. A method for dynamically updating log printing volume, characterized in that: The following steps are included: Step 1, set the log level; Step 2: Set the switching conditions of the log level; Step 3: Start the log service and perform normal log recording. Step 4, start the cycle program.
2. A method for dynamically updating log printing volume according to claim 1, characterized in that: The specific contents of step 1 are as follows: Step 1.1, the log level is divided into five levels, from low to high, namely Verbose, Debug, Info, Warning and Error; Step 1.2, set the default log level, which can be any one of Verbose, Debug, Info, and Warning; Step 1.3, set a higher level of the log, which can be any one of Debug, Info, Warning, and Error, and the higher level must be higher than the default level.
3. A method for dynamically updating log printing volume according to claim 2, characterized in that: The specific contents of step 2 are as follows: Set the conditions for switching the log level between "Default Level" and "Higher Level", specifically "Level Increase Condition" and "Default Level Restoration Condition". These two conditions correspond to the system resource conditions for increasing the system log level and restoring the system log level, including but not limited to the two dimensions of CPU and RAM. For each dimension, you need to set the percentage threshold for increasing the level and the percentage threshold for restoring the default level.
4. A method for dynamically updating log printing volume according to claim 3, characterized in that: The specific contents of step 4 are as follows: Step 4.1, set the waiting time; Step 4.2, check and analyze system resources after the waiting time; Step 4.3: Dynamically switch the log level.
5. A method for dynamically updating log printing volume according to claim 4, characterized in that: The specific contents of step 4.2 are as follows: Execute the command for viewing system resources once and analyze the execution result information to obtain the load of system resources.
6. A method for dynamically updating log printing volume according to claim 5, characterized in that: The specific contents of step 4.3 are as follows: If the current log level is higher than the default log level, check whether the system meets the conditions for restoring the default log level; if the system meets the recovery conditions, set the log level to the default level to reduce the amount of log printing, and record the action of switching levels at a higher level, and then go to step 4.2; if the system does not meet the recovery conditions, go directly to step 4.
2.
7. A method for dynamically updating log printing volume according to claim 6, characterized in that: Step 4.3 also includes the following: If the current log level is equal to or lower than the default log level, check whether the system is in a high load state, that is, whether the system has reached the conditions for upgrading to a higher log level; if the system is in a high load, set the log level to a higher level, and record the action of switching levels at a higher level, and then go to step 4.2; if the system has not reached a high load, go directly to step 4.2.
