Device monitoring method and apparatus
By adding key log comments to the device source code and generating log template files, the problem of low device monitoring accuracy in existing technologies is solved, and more efficient device monitoring and report generation are achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-09-06
- Publication Date
- 2026-03-31
AI Technical Summary
Existing device monitoring methods rely on log templates, which lack flexibility and maintainability, resulting in low monitoring accuracy.
By adding key log comments to the source code of the monitored device, a log template file is generated. Based on the key log output code and comments, the device operation report is obtained, enabling the maintenance and updating of the log template.
It improves the accuracy and flexibility of equipment monitoring, and can adapt to changes in source code and log comments in real time to generate more accurate equipment operation reports.
Smart Images

Figure CN115470073B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer information processing technology, and in particular to a device for monitoring equipment. Background Technology
[0002] With the development of the Internet, network devices have become increasingly popular. However, these devices are becoming more and more complex and their functions are increasing. As a result, many problems are difficult to detect and locate in a timely manner. Therefore, it is necessary to monitor the devices to ensure that we can understand their operating status and information in real time.
[0003] Existing device monitoring methods typically rely on log templates for log matching. This approach is overly dependent on log templates and lacks flexibility. Furthermore, current log template solutions are independent of the device source code, hindering template maintenance and updates. These issues all contribute to low accuracy in device monitoring. Summary of the Invention
[0004] This invention provides a method and apparatus for equipment monitoring, which addresses the shortcomings of low accuracy in equipment monitoring in the prior art.
[0005] This invention provides a device monitoring method, comprising:
[0006] Obtain the source code files based on the source code of the device to be monitored;
[0007] Add critical log comments to the source code in the source code file to identify the critical log output code in the source code file;
[0008] Based on the key log output code and key log comments in the source code file, obtain the log template file;
[0009] Based on the log template file and the log file of the device to be monitored, obtain the device operation report of the device to be monitored.
[0010] Optionally, obtaining the log template file based on the key log output code and key log comments in the source code file includes:
[0011] The key log output code in the source code file is scanned to determine the function to which the key log output code belongs and the calling relationship of the function to which the key log output code belongs;
[0012] Based on the critical log output code, the function to which the critical log output code belongs, and the call relationship of the function to which the critical log output code belongs, the critical log, the function to which the critical log belongs, and the call relationship of the function to which the critical log belongs are determined;
[0013] Based on the key logs, the functions to which the key logs belong, the call relationships of the functions to which the key logs belong, and the comments on the key logs, obtain the description of the key logs;
[0014] Based on the aforementioned key log descriptions, obtain the log template file.
[0015] Optionally, obtaining the device operation report of the device under monitoring based on the log template file and the log file of the device under monitoring includes:
[0016] The log template file and the log file are compared to determine the key logs that appear in the log file and the key logs that do not appear in the log file.
[0017] The device operation report is generated based on the key logs that appeared and the key logs that did not appear.
[0018] Optionally, after obtaining the log template file, the method further includes:
[0019] If the source code and / or the key log comments are changed, the log template file is regenerated based on the changed source code and / or the changed key log comments.
[0020] Optionally, after generating the device operation report, the method further includes:
[0021] Configure the display attributes of the text in the device operation report;
[0022] The text in the device operation report is displayed based on the aforementioned display attributes.
[0023] Optionally, the key log annotations include one or more of the following:
[0024] Key operation log comments;
[0025] Key error log comments;
[0026] Key status log comments.
[0027] The present invention also provides a device monitoring apparatus, comprising:
[0028] The first acquisition module is used to acquire source code files based on the source code of the device to be monitored;
[0029] The determination module is used to add key log comments to the source code in the source code file and determine the key log output code in the source code file.
[0030] The second acquisition module is used to acquire a log template file based on the key log output code and the key log comments in the source code file;
[0031] The third acquisition module is used to acquire the device operation report of the device to be monitored based on the log template file and the log file of the device to be monitored.
[0032] The present invention also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the device monitoring method as described in any of the above.
[0033] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the device monitoring method as described in any of the above claims.
[0034] The present invention also provides a computer program product, including a computer program that, when executed by a processor, implements the device monitoring method as described in any of the above.
[0035] The device monitoring method and apparatus provided by this invention, by adding key log comments to the source code and generating log template files based on the source code and key log comments, realizes the maintenance and updating of log template files based on the source code and key log comments, thereby improving the accuracy of device monitoring. Attached Figure Description
[0036] To more clearly illustrate the technical solutions in this invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0037] Figure 1 This is one of the flowcharts illustrating the device monitoring method provided in this embodiment of the invention;
[0038] Figure 2 This is a second schematic flowchart of the device monitoring method provided in this embodiment of the invention;
[0039] Figure 3 This is a schematic diagram of the structure of the equipment monitoring device provided in an embodiment of the present invention;
[0040] Figure 4 This is a schematic diagram of the structure of the electronic device provided in an embodiment of the present invention. Detailed Implementation
[0041] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this invention. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without creative effort are within the scope of protection of this invention.
[0042] Figure 1 This is one of the flowcharts illustrating the device monitoring method provided in this embodiment of the invention, such as... Figure 1 As shown, this invention provides a device monitoring method. The device monitoring method can be executed by any device with communication, storage, and display functions, such as a mobile phone, tablet, or computer. This device and the device to be monitored can be the same device. The device monitoring method includes:
[0043] Step 101: Obtain the source code file based on the source code of the device to be monitored.
[0044] Specifically, the device to be monitored can be any device with communication and storage functions, such as mobile phones, tablets, computers, and wearable devices.
[0045] The source code of the device to be monitored can be obtained through version control tools such as Git.
[0046] Figure 2 This is a second flowchart illustrating the device monitoring method provided in this embodiment of the invention, as shown below. Figure 2 As shown, the source code of the device to be monitored is saved as a source code file.
[0047] Alternatively, the source files may contain only a portion of the source code.
[0048] Step 102: Add key log comments to the source code in the source code file to determine the key log output code in the source code file.
[0049] Specifically, critical log comments are added to part or all of the source code in the source code file. These critical log comments can be added during the development of the device's program or during runtime. They can be added after the source code or elsewhere within it. One line of code in the source code can correspond to multiple critical log comments.
[0050] The source code with critical log comments added is the critical log output code. The critical log output code is the code that outputs critical logs.
[0051] Step 103: Obtain the log template file based on the key log output code and key log comments in the source code file.
[0052] Specifically, after determining the key log output code, key log descriptions are generated based on the key logs output by the key log output code and the key log comments. The key log descriptions are then summarized to form a log template file.
[0053] Step 104: Based on the log template file and the log file of the device to be monitored, obtain the device operation report of the device to be monitored.
[0054] Specifically, logs from the monitored devices are acquired in real time and saved as log files.
[0055] By comparing the log files and log template files, we can analyze which key logs from the log template files appear in the log files, thus determining which critical code has been executed and which has not been executed on the monitored device.
[0056] The device monitoring method analyzes the operational status of the monitored device based on executed and unexecuted critical code, generating a device operation report. This invention provides a device monitoring method that adds critical log comments to the source code and generates a log template file based on the source code and critical log comments. This enables the maintenance and updating of the log template file based on the source code and critical log comments, improving the accuracy of device monitoring.
[0057] Optionally, the key log annotations include one or more of the following:
[0058] Key operation log comments;
[0059] Key error log comments;
[0060] Key status log comments.
[0061] Specifically, critical log comments may include one or more of the following: critical status log comments, critical error log comments, and critical operation log comments.
[0062] Critical operation log comments and critical error log comments must include operation scenario identifiers. Critical operation log comments can include the operation execution order, as well as start and end markers and step numbers. Critical status log attributes can include status description identifiers.
[0063] For example, the critical error log comment text is: " / / config*@*", where " / / " is a C language comment symbol, indicating that this is a comment message; the text "*@*" is a critical error identifier, and the text "config" indicates that the operation scenario of the log is configuration.
[0064] For example, the critical operation log comment text is: " / / config*#*1", where " / / " is a C language comment symbol, indicating that this is a comment message; the text "*#*" is a critical operation identifier, indicating that the type of this log is a critical operation log; the text "config" indicates that the operation scenario of the log is config; and "1" indicates that the execution order of the log is 1.
[0065] For example, the C language log output code is: "LOG_INFO("state%s",str_state)", where the value of state can be "idle", "busy", or "error". The output of this code can be "state idle", "state busy", or "state error".
[0066] The critical status log comment text is: " / / ERROR*=*error", where " / / " is a C language comment symbol, indicating that this is a comment message; the text "*=*" is a critical status identifier, and the text "ERROR*=*error" indicates that when the log output contains the text "error", its device status is "ERROR", that is, the device status is abnormal.
[0067] The critical status log comment text is: " / / NORMAL*=*busy", where " / / " is a C language comment symbol, indicating that this is a comment message; the text "*=*" is a critical status identifier, and the text "NORMAL*=*busy" indicates that when the log output contains the text "busy", its device status is "NORMAL", that is, the device status is normal.
[0068] Optionally, obtaining the log template file based on the key log output code and key log comments in the source code file includes:
[0069] The key log output code in the source code file is scanned to determine the function to which the key log output code belongs and the calling relationship of the function to which the key log output code belongs;
[0070] Based on the critical log output code, the function to which the critical log output code belongs, and the call relationship of the function to which the critical log output code belongs, the critical log, the function to which the critical log belongs, and the call relationship of the function to which the critical log belongs are determined;
[0071] Based on the key logs, the functions to which the key logs belong, the call relationships of the functions to which the key logs belong, and the comments on the key logs, obtain the description of the key logs;
[0072] Based on the aforementioned key log descriptions, obtain the log template file.
[0073] Specifically, the key log output code in the source code file is scanned to determine the function to which the key log output code belongs and the calling relationship of the function to which the key log output code belongs.
[0074] The critical log is determined based on the critical log output code, the function to which the critical log belongs is determined based on the function to which the critical log output code belongs, and the call relationship of the function to which the critical log belongs is determined based on the call relationship of the function to which the critical log output code belongs.
[0075] Based on the operation execution step sequence number in the critical log comments, the output code of the critical operation log is sorted, the critical logs are sorted based on the sorting of the critical operation log output code, and a critical log list is generated based on the sorted critical logs.
[0076] The function call relationships of the critical logs are sorted, and call relationship descriptions are added. A list of critical functions is generated based on the sorted critical log functions.
[0077] Based on the critical log, the function to which the critical log belongs, the functions called by the function to which the critical log belongs, and the critical log comments, generate a critical log description.
[0078] The critical log descriptions include descriptions of critical operation logs and descriptions of critical error logs.
[0079] The descriptions of critical operation logs and critical error logs may include operation scenario identifiers.
[0080] The critical operation log description may also include critical operation log information and code information that outputs the critical operation log. The code information may include information about the function to which the log output code belongs.
[0081] The critical operation log description can also output code logic relationships based on the critical logs, including descriptions of critical operations that were not executed. These code logic relationships include, but are not limited to, code call order and function call relationships.
[0082] The log of unexecuted critical operations belongs to the same operation scenario as the current critical operation log. When the software is running normally, the log of unexecuted critical operations is output after the current critical operation log and before other critical operation logs in the same operation scenario.
[0083] The description of the "Critical Operation Not Performed" log includes information about the critical operation that was not performed and the code that output the critical operation log.
[0084] The order of operations not performed can be adjusted according to the comments in the critical operation log.
[0085] Summarize the key log descriptions to form a log template file.
[0086] For example, the log template text information is "config*#*config parm**func_config_parm**func_config_dev", where "config" is the operation scenario identifier, "#" is the separator, "config parm" is the log text finally output by the critical operation log output code, "func_config_parm" is the function name to which the critical log output code belongs, and "func_config_dev" is the function called by the function "func_config_parm". The "func_config_dev" function is also part of the critical function list, and it also contains a critical operation log or a critical error log.
[0087] The device monitoring method provided in this embodiment of the invention determines the key log, the function to which the key log belongs, and the calling relationship of the function to which the key log belongs based on the key log output code. Then, based on the key log, the function to which the key log belongs, the calling relationship of the function to which the key log belongs, and the key log comments, the log template file is obtained, which further facilitates the maintenance and updating of the log template file and further improves the accuracy of device monitoring.
[0088] Optionally, after obtaining the log template file, the method further includes:
[0089] If the source code and / or the key log comments are changed, the log template file is regenerated based on the changed source code and / or the changed key log comments.
[0090] Specifically, the source code files are monitored in real time, or the source code files are polled periodically to determine whether the source code and / or key log comments have changed.
[0091] In the event of source code changes, the key log output code is redefined in the changed source code based on key log comments, and the log template file is regenerated based on the redefined key log output code and key log comments.
[0092] When critical log comments are changed, the critical log output code is redefined in the source code based on the changed critical log comments, and the log template file is regenerated based on the redefined critical log output code and the changed critical log comments.
[0093] When both the source code and critical log comments have changed, the critical log output code is redefined in the changed source code based on the changed critical log comments, and the log template file is regenerated based on the redefined critical log output code and the changed critical log comments.
[0094] The device monitoring method provided in this invention regenerates the log template file based on the changed source code and / or changed key log comments, thereby enabling real-time generation and updating of the log template file and improving the adaptability and flexibility of the log template file.
[0095] Optionally, obtaining the device operation report of the device under monitoring based on the log template file and the log file of the device under monitoring includes:
[0096] The log template file and the log file are compared to determine the key logs that appear in the log file and the key logs that do not appear in the log file.
[0097] The device operation report is generated based on the key logs that appeared and the key logs that did not appear.
[0098] Specifically, the log files and log template files of the monitored devices can be compared periodically to analyze whether the key logs in the log template files appear in the log files, and to determine the key logs that appear in the log files and the key logs that do not appear.
[0099] Based on the key logs that appeared and those that did not, determine the key code that was executed and the key code that was not executed on the device to be monitored.
[0100] Analyze the execution and non-execution critical code of the monitored equipment to generate an equipment operation report.
[0101] When a critical operation log appears in the log file, the next operation log entry to be output under the same operation scenario should also be written into the device operation report.
[0102] The log files of the monitored device will be updated in real time as the logs of the monitored device are updated.
[0103] Optionally, a preset time can be set to generate a device operation report every preset time. The preset time can be set according to the usage scenario.
[0104] For example, a device operation report is generated every 5 seconds.
[0105] The device monitoring method provided in this embodiment of the invention improves the accuracy of device monitoring by comparing log template files and log files and generating device operation reports based on the comparison results.
[0106] Optionally, after generating the device operation report, the method further includes:
[0107] Configure the display attributes of the text in the device operation report;
[0108] The text in the device operation report is displayed based on the aforementioned display attributes.
[0109] Specifically, the log files of the monitored devices are scanned, and different display attributes are set for the text in the device operation reports based on the specific content of the logs.
[0110] For example, if the scanned key status log text is "NORMAL*=*state idle", then the text generated in the device operation report will be "status_normal:Status:state idle". The text "status_normal" indicates that the display attribute of this text is status_normal, the text "Status" indicates that this is a status message, ":" is the separator, and the text "state idle" is the device status information that needs to be displayed.
[0111] For example, if the key error log text detected by scanning is "config*@*parm error", then the text generated in the device operation report will be "method_err:config:parm error". The text "method_err" indicates that the display attribute of this text is method_err, the text "config" indicates that the current operation scenario is "config", ":" is the separator, and the text "parm error" is the specific error information.
[0112] For example, if the key operation log text detected is "config*@*config parm", then two lines of text will be generated in the device operation report. The first line of text is "method_done:func_config_parm:config parm", where "method_done" indicates that the display attribute of this text is method_done, "config" indicates that the current operation scenario is config, ":" is the separator, "func_config_parm" is the function information to which the log belongs, and "config_parm" is the specific log information. The second line of text is "method_todo:func_config_dev:configdev", where "method_done" indicates that the display attribute of this text is method_done, ":" is the separator, "func_config_dev" is the function information to be executed, and "config dev" is the log information that will be printed when the "func_config_dev" function is executed.
[0113] Different fonts, colors, and shapes can be used to display the content of the device operation report based on different display attributes.
[0114] For example, when the text display attribute in the device operation report is method_done, it can be displayed in green font; when the text display attribute in the device operation report is method_err, it can be displayed in red bold.
[0115] The device monitoring method provided in this embodiment of the invention improves the readability of the device operation report by setting the display attributes of the text in the device operation report and displaying the text in the device operation report based on the display attributes.
[0116] The equipment monitoring device provided by the present invention is described below. The equipment monitoring device described below and the equipment monitoring method described above can be referred to in correspondence.
[0117] Figure 3 This is a schematic diagram of the structure of the equipment monitoring device provided in an embodiment of the present invention, as shown below. Figure 3 As shown, the present invention also provides a device monitoring apparatus, comprising: a first acquisition module 301, a determination module 302, a second acquisition module 303, and a third acquisition module 304, wherein:
[0118] The first acquisition module 301 is used to acquire source code files based on the source code of the device to be monitored;
[0119] The determination module 302 is used to add key log comments to the source code in the source code file and determine the key log output code in the source code file;
[0120] The second acquisition module 303 is used to acquire a log template file based on the key log output code and the key log comments in the source code file;
[0121] The third acquisition module 304 is used to acquire the device operation report of the device to be monitored based on the log template file and the log file of the device to be monitored.
[0122] Optionally, the second acquisition module 303 is specifically used to: scan the key log output code in the source code file to determine the function to which the key log output code belongs and the calling relationship of the function to which the key log output code belongs;
[0123] Based on the critical log output code, the function to which the critical log output code belongs, and the call relationship of the function to which the critical log output code belongs, the critical log, the function to which the critical log belongs, and the call relationship of the function to which the critical log belongs are determined;
[0124] Based on the key logs, the functions to which the key logs belong, the call relationships of the functions to which the key logs belong, and the comments on the key logs, obtain the description of the key logs;
[0125] Based on the aforementioned key log descriptions, obtain the log template file.
[0126] Optionally, the third acquisition module 304 is specifically used to: compare the log template file and the log file to determine the key logs that appear in the log file and the key logs that do not appear;
[0127] The device operation report is generated based on the key logs that appeared and the key logs that did not appear.
[0128] Optionally, the apparatus further includes a regeneration module, configured to regenerate a log template file based on the changed source code and / or the changed key log comments when the source code and / or the key log comments are changed.
[0129] Optionally, the device further includes a display module, which is specifically used to set the display attributes of the text in the device operation report;
[0130] The text in the device operation report is displayed based on the aforementioned display attributes.
[0131] Optionally, the key log annotations include one or more of the following:
[0132] Key operation log comments;
[0133] Key error log comments;
[0134] Key status log comments.
[0135] Specifically, the device monitoring device provided in this application embodiment can implement all the method steps implemented in the above method embodiment and can achieve the same technical effect. Here, the parts that are the same as those in the method embodiment and the beneficial effects will not be described in detail.
[0136] Figure 4 This is a schematic diagram of the structure of the electronic device provided in the embodiment of the present invention, such as... Figure 4 As shown, the electronic device may include a processor 410, a communications interface 420, a memory 430, and a communication bus 440, wherein the processor 410, communications interface 420, and memory 430 communicate with each other via the communication bus 440. The processor 410 can call logical instructions in the memory 430 to execute a device monitoring method, which includes: obtaining a source code file based on the source code of the device to be monitored; adding key log comments to the source code in the source code file to determine the key log output code in the source code file; obtaining a log template file based on the key log output code and the key log comments in the source code file; and obtaining a device operation report of the device to be monitored based on the log template file and the log file of the device to be monitored.
[0137] Furthermore, the logical instructions in the aforementioned memory 430 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, essentially, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0138] On the other hand, the present invention also provides a computer program product, which includes a computer program that can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the device monitoring method provided by the above methods. The method includes: obtaining a source code file based on the source code of the device to be monitored; adding key log comments to the source code in the source code file to determine the key log output code in the source code file; obtaining a log template file based on the key log output code and the key log comments in the source code file; and obtaining a device operation report of the device to be monitored based on the log template file and the log file of the device to be monitored.
[0139] In another aspect, the present invention also provides a non-transitory computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements the device monitoring method provided by the above methods. The method includes: obtaining a source code file based on the source code of the device to be monitored; adding key log comments to the source code in the source code file to determine the key log output code in the source code file; obtaining a log template file based on the key log output code and the key log comments in the source code file; and obtaining a device operation report of the device to be monitored based on the log template file and the log file of the device to be monitored.
[0140] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.
[0141] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.
[0142] In the embodiments of this application, the terms "first," "second," etc., are used to distinguish similar objects, and not to describe a specific order or sequence. It should be understood that such terms can be used interchangeably where appropriate so that embodiments of this application can be implemented in orders other than those illustrated or described herein, and the objects distinguished by "first" and "second" are generally of the same class, and the number of objects is not limited; for example, the first object can be one or more.
[0143] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A device monitoring method characterized by, The method comprises the following steps: Based on the source code of the device to be monitored, a source code file is obtained; Key log annotations are added to the source code in the source code file to determine key log output codes in the source code file; Based on the key log output codes in the source code file and the key log annotations, a log template file is obtained; Based on the log template file and the log file of the device to be monitored, a device running report of the device to be monitored is obtained; The method comprises the following steps: The key log output codes in the source code file are scanned to determine the functions to which the key log output codes belong and the calling relationship of the functions to which the key log output codes belong; Based on the key log output codes, the functions to which the key log output codes belong, and the calling relationship of the functions to which the key log output codes belong, key logs, functions to which the key logs belong, and the calling relationship of the functions to which the key logs belong are determined; Based on the key logs, the functions to which the key logs belong, the calling relationship of the functions to which the key logs belong, and the key log annotations, key log explanations are obtained; Based on the key log explanations, the log template file is obtained.
2. The device monitoring method according to claim 1, wherein, The method comprises the following steps: The log template file and the log file are compared to determine key logs that appear in the log file and key logs that do not appear in the log file; Based on the appearing key logs and the non-appearing key logs, the device running report is generated.
3. The method of claim 1, wherein, After the log template file is obtained, the method further comprises the following steps: In the case that the source code and / or the key log annotations change, the log template file is regenerated based on the changed source code and / or the changed key log annotations.
4. The method of claim 2, wherein, After the device running report is generated, the method further comprises the following steps: The display properties of the text in the device running report are set; Based on the display properties, the text in the device running report is displayed.
5. The method of claim 1, wherein, The key log annotations comprise one or more of the following: Key operation log annotations; Key error log annotations; Key state log annotations.
6. An apparatus monitoring device, characterized by The method comprises the following steps: A first obtaining module is configured to obtain a source code file based on the source code of the device to be monitored; A determining module is configured to add key log annotations to the source code in the source code file to determine key log output codes in the source code file; A second obtaining module is configured to obtain a log template file based on the key log output codes in the source code file and the key log annotations; A third obtaining module is configured to obtain a device running report of the device to be monitored based on the log template file and the log file of the device to be monitored; The second obtaining module is specifically configured to: The key log output codes in the source code file are scanned to determine the functions to which the key log output codes belong and the calling relationship of the functions to which the key log output codes belong; determine a key log, a function to which the key log belongs, and a calling relationship of the function to which the key log belongs based on the key log output code, the function to which the key log output code belongs, and the calling relationship of the function to which the key log output code belongs; obtain a key log explanation based on the key log, the function to which the key log belongs, the calling relationship of the function to which the key log belongs, and the key log annotation; obtain the log template file based on the key log explanation.
7. An electronic device comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, characterized in that, The processor implements the device monitoring method as claimed in any one of claims 1 to 5 when executing the computer program.
8. A non-transitory computer-readable storage medium having stored thereon a computer program, characterized in that, The computer program implements the device monitoring method as claimed in any one of claims 1 to 5 when executed by the processor.
9. A computer program product comprising a computer program, characterized in that, The computer program implements the device monitoring method as claimed in any one of claims 1 to 5 when executed by the processor.
Citation Information
Patent Citations
Log recording method and device, equipment and medium
CN114328152A