Log printing method, device, computer equipment, storage medium and program product

By classifying and dyeing log information, the problem of low redundant log viewing efficiency is solved, efficient distinction and positioning of log information is achieved, and the work efficiency of developers is improved.

CN114356257BActive Publication Date: 2024-12-06PING AN COMMERCIAL FACTORING CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202210213211.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-03-04
Publication Date
2024-12-06
Estimated Expiration
2042-03-04

AI Technical Summary

Technical Problem

In the prior art, logging generates a large number of redundant logs, making it difficult for users to grasp the key points when viewing the logs and are inefficient.

Method used

Provide a log printing method. By obtaining the log information to be printed and pre-set dyeing rules, classifying and dyeing the log information according to the classification rules, and outputting log information of different colors. Users only need to view the corresponding log based on the dyeing.

Benefits of technology

Improve the efficiency of log viewing. Users do not need to view all log information. They only need to distinguish key information based on dyeing, which significantly improves the work efficiency of developers and bug positioning speed.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114356257B_ABST
    Figure CN114356257B_ABST
Patent Text Reader

Abstract

The present application relates to the field of artificial intelligence, and in particular to a log printing method, device, computer equipment, storage medium and program product. The method comprises: obtaining log information to be printed; obtaining a preset coloring rule, wherein the coloring rule comprises a classification rule; classifying the log information to be printed according to the classification rule; coloring the classified log information to be printed according to the coloring rule; and printing the coloring log information to be printed. The method can be used to classify and print logs, thereby improving efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of artificial intelligence technology, and in particular to a log printing method, device, computer equipment, storage medium and program product. Background Art

[0002] With the development of computer technology, operation logs of systems and applications have emerged. Specifically, since programs run very fast, people cannot know the running status of programs. Therefore, logs are generated to record the running status of programs. This log recording process generally records all the processes of the program, so that problems can be promptly checked when they occur.

[0003] Due to the nature of logs, a large number of redundant logs will be generated. However, due to different requirements, logs also have different printing needs. To print logs, users need to view every line, which results in users viewing a large number of logs and not being able to grasp the key points. Summary of the invention

[0004] Based on this, it is necessary to provide a log printing method, device, computer equipment, storage medium and program product that can classify and print logs to improve efficiency in response to the above technical problems.

[0005] In a first aspect, the present application provides a log printing method, the method comprising:

[0006] Get the log information to be printed;

[0007] Acquire a preset coloring rule, wherein the coloring rule includes a classification rule;

[0008] Classifying the log information to be printed according to the classification rule;

[0009] Coloring the classified log information to be printed according to the coloring rule;

[0010] The dyed log information to be printed is printed.

[0011] In one embodiment, the classification rule includes at least one of a component classification rule, a page classification rule, and a fault level classification rule.

[0012] In one embodiment, classifying the log information to be printed according to the classification rule includes:

[0013] Classifying the log information to be printed according to a component classification rule or a page classification rule to obtain an initial classification;

[0014] The log information to be printed under each initial classification is classified according to the fault level classification rule to obtain a target classification.

[0015] In one embodiment, the method further comprises:

[0016] Counting the number of occurrences of the log information to be printed that meets the requirements of the fault level;

[0017] When the number of occurrences is greater than or equal to a preset number, an alarm message is output.

[0018] In one embodiment, before coloring the classified log information to be printed according to the coloring rule, the method further includes:

[0019] When the category of the log information to be printed is a preset category, receiving a selection instruction for the log information to be printed;

[0020] Acquire target log information according to the selection instruction, and acquire the type of the target log information;

[0021] The target log information is formatted according to the type of the target log information.

[0022] In one embodiment, the method further comprises:

[0023] Receiving a coloring rule configuration instruction, and configuring a coloring rule according to the coloring rule configuration instruction;

[0024] storing the coloring rule;

[0025] The obtaining of the preset coloring rules includes:

[0026] A pre-stored coloring rule is obtained, and the coloring rule is loaded into a memory.

[0027] In a second aspect, the present application further provides a log printing device, the device comprising:

[0028] A log information acquisition module is used to obtain log information to be printed;

[0029] A rule acquisition module, used to acquire preset coloring rules, wherein the coloring rules include classification rules;

[0030] A classification module, used for classifying the log information to be printed according to the classification rules;

[0031] A coloring module, used for coloring the classified log information to be printed according to the coloring rule;

[0032] The printing module is used to print the dyed log information to be printed.

[0033] In a third aspect, the present application further provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the method in any one of the above embodiments when executing the computer program.

[0034] In a fourth aspect, the present application further provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the steps of the method in any one of the above embodiments are implemented.

[0035] In a fifth aspect, the present application also provides a computer program product, including a computer program, which implements the steps of the method in any one of the above embodiments when executed by a processor.

[0036] The above-mentioned log printing method, device, computer equipment, storage medium and program product classify the log information to be printed according to the classification rules, and then color the classified log information to be printed according to the coloring rules, so as to output the log information to be printed with different colors, thereby realizing the classification coloring of the log information to be printed. In this way, the user only needs to view the corresponding log information to be printed according to the coloring, and the user does not need to view all the log information to be printed, thereby improving efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0037] Figure 1 An application environment diagram of a log printing method in an embodiment;

[0038] Figure 2 A flow chart of a log printing method in one embodiment;

[0039] Figure 3 A flow chart of a log printing method in another embodiment;

[0040] Figure 4 is a structural block diagram of a log printing device in an embodiment;

[0041] Figure 5 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION

[0042] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0043] The log printing method provided in the embodiment of the present application can be applied to Figure 1In the application environment shown. Among them, the terminal 102 communicates with the server 104 through the network. The data storage system can store the data that the server 104 needs to process. The data storage system can be integrated on the server 104, or it can be placed on the cloud or other network servers. When the terminal 102 runs the program, a large number of logs may be generated and stored. Preferably, when performing research and development debugging, a large number of debugging logs may be generated, and the research and development can determine the problems of the program based on these debugging logs, so as to modify the program to obtain a program that meets the requirements. When debugging, the debugging log is stored so that the server 104 can obtain the log information to be printed, obtain the pre-set coloring rules, and the coloring rules include classification rules; classify the log information to be printed according to the classification rules; color the classified log information to be printed according to the coloring rules; print the colored log information to be printed. In this way, the log information to be printed is classified according to the classification rules, and then the classified log information to be printed is colored according to the coloring rules. In this way, the log information to be printed with different colors is output, so that the classified coloring of the log information to be printed can be realized. In this way, the user only needs to view the corresponding log information to be printed according to the coloring, and the user does not need to view all the log information to be printed, thereby improving efficiency.

[0044] The terminal 102 may be, but is not limited to, various personal computers, laptops, smart phones, tablet computers, IoT devices, and portable wearable devices. The IoT devices may be smart speakers, smart TVs, smart air conditioners, smart car-mounted devices, etc. The portable wearable devices may be smart watches, smart bracelets, head-mounted devices, etc. The server 104 may be implemented as an independent server or a server cluster consisting of multiple servers.

[0045] In one embodiment, Figure 2 As shown, a log printing method is provided, which is applied to Figure 1 The server in the example is used to illustrate the following steps:

[0046] S202: Obtain log information to be printed.

[0047] Specifically, the log information to be printed can be collected by means of tracking points. Specifically, after the front-end project that has been deployed and running has added the log output and collection plug-in device, the tracking point function can be used, that is, the captured important information is uploaded to the remote server through the interface. By adding tracking points, when the user touches the mouse or page events such as clicks and slides, the captured information is sent to the server to collect user behavior and interface information as much as possible. When it is captured that the user has problems in the interface call and the frequency is high, the problem interface is automatically reported to the developer, and the reported interface is analyzed and the problem is solved in time, which can optimize the project operation process and improve user satisfaction. Based on the collected user behavior operations, guidance can be provided for the direction of the next demand analysis.

[0048] S204: Acquire preset coloring rules, where the coloring rules include classification rules.

[0049] Specifically, the coloring rule is a rule for coloring the log information to be printed, which can provide the coloring information required for each type of log information to be printed. The classification rule is a rule for classifying the log information to be printed, which divides the log information to be printed into multiple categories to classify and output the log information to be printed.

[0050] Specifically, the log printing method further includes: receiving a coloring rule configuration instruction, configuring the coloring rule according to the coloring rule configuration instruction; storing the coloring rule; obtaining a preset coloring rule, including: obtaining a pre-stored coloring rule, and loading the coloring rule into the memory.

[0051] The coloring rules are pre-configured, and the server can pre-receive the coloring rules configured by the user and store them in a configuration file. In this way, each time the log information needs to be printed, the configuration file is loaded into the memory to read the coloring rules, wherein the coloring rules include classification rules. In this way, the server first classifies the log information to be printed according to the classification rules, and then colors the log information to be printed based on the classification.

[0052] S206: Classify the log information to be printed according to the classification rule.

[0053] Specifically, the server classifies the log information to be printed according to the classification rules. Specifically, the server can obtain the classification fields in each log information to be printed, and classify the log information to be printed according to the classification fields. Among them, the classification of the log information to be printed can be to obtain the classification field, and then determine whether the classification field exists in the log information to be printed, and whether the value of the classification field is compared with the category in the classification rules. If the comparison is successful, the log information to be printed is divided into the corresponding category. The printing information is secondary classified, and the importance of the printing information, the front-end page where it is located, or the component can be used as the classification dimension. Under each category, different color printing fonts can be randomly generated in the same color system, so that the printed log has a higher degree of recognition.

[0054] In one embodiment, the classification rule includes at least one of a component classification rule, a page classification rule, and a fault level classification rule.

[0055] Therefore, the server can obtain the component to which the log information to be printed belongs, and classify the log information to be printed according to the component. In other embodiments, the server can obtain the page to which the log information to be printed belongs, and then classify the log information to be printed according to the page. In other embodiments, the server can obtain the fault information of the log information to be printed, and then match the fault information with the pre-configured fault level to determine the fault level to which the fault information belongs, and finally classify the log information to be printed according to the fault level.

[0056] S208: Coloring the classified log information to be printed according to the coloring rule.

[0057] S210: Printing the dyed log information to be printed.

[0058] Specifically, the server obtains the classified log information to be printed, and then obtains the color system corresponding to the classification of the printed log information, and colors the log information to be printed under the classification according to the color in the color system. Different color printing fonts can be randomly generated under the same color system for each classification, so that the printed logs have high recognition. When there are a lot of log information, it can effectively help developers distinguish the log content, improve development speed and locate the location of bugs in the code.

[0059] The above-mentioned log printing method classifies the log information to be printed according to the classification rules, and then colors the classified log information to be printed according to the coloring rules, so as to output the log information to be printed with different colors, thereby realizing the classification coloring of the log information to be printed. In this way, the user only needs to view the corresponding log information to be printed according to the coloring, and the user does not need to view all the log information to be printed, thereby improving efficiency.

[0060] In one of the embodiments, classifying the log information to be printed according to the classification rules includes: classifying the log information to be printed according to the component classification rules or the page classification rules to obtain an initial classification; and classifying the log information to be printed under each initial classification according to the fault level classification rules to obtain a target classification.

[0061] Specifically, in this embodiment, the print log information is classified in layers, that is, the server first classifies the log information to be printed according to the components and / or pages to obtain a first-level classification, and then continues to classify the log information to be printed under the first-level classification according to the fault level, etc. to obtain a second-level classification, that is, the target classification. Optionally, in order to improve the classification efficiency, during the second-level classification, the server can perform multi-threaded classification as needed, that is, on the basis of each first-level classification, a thread is configured for each first-level classified log information to be printed, so that the second-level classification is performed in the respective threads. In other embodiments, classification can be performed by other classification methods to improve the classification efficiency.

[0062] In this embodiment, when the classification dimension is set to page or component, special tags can be added to further classify the fault level, quickly capture the interface where the problem code is located, and speed up the location of the problem point. For complex and cumbersome logic codes where problems are not easy to find, the importance can be used as a division dimension. After coloring, the dominant effect of the rule mark is promoted to quickly find the problem code fragment. According to the division dimension, the font color of the log information is divided into different colors, which is convenient for viewing the debugging information concisely and clearly, quickly locating the bug location, and speeding up the development speed of developers.

[0063] In one of the embodiments, the log printing method further includes: counting the number of occurrences of the to-be-printed log information whose fault level meets the requirements; and outputting an alarm message when the number of occurrences is greater than or equal to a preset number.

[0064] Specifically, when the dimension to which the bug belongs is at a serious level and occurs a large number of times, an alarm message is output, such as automatically sending an email report to remind developers to pay more attention to the code at that location.

[0065] Specifically, the alarm information can include the fault level and the log information to be printed, which is convenient for developers to view directly. The encapsulated tracking function is used to collect production line bugs, and problems in the back-end interface can be reported in a timely manner. Serious and high-frequency bugs will trigger email notifications, which will encourage developers to fix code vulnerabilities in a timely manner. The production line environment will also have the function of collecting window.onerror, achieving a simple log monitoring effect.

[0066] In one of the embodiments, before coloring the classified log information to be printed according to the coloring rules, it also includes: when the classification of the log information to be printed is a preset classification, receiving a selection instruction for the log information to be printed; obtaining the target log information according to the selection instruction, and obtaining the type of the target log information; formatting the target log information according to the type of the target log information.

[0067] Among them, in this embodiment, when printing log information, the log plug-in collection device will determine the type of information, such as Function, Object, Array, String, etc. When the amount of information data is large, for example, it is an object without empty key-value pairs, the object can be formatted through JSON.stringify(object,null,4), and then the object type information is formatted and output. When the array length is too large, it can also be formatted and output through the JSON.stringify() method.

[0068] Specifically, when the classification of the log information to be printed is the target classification, such as error, the problem is more serious, and the log information to be printed is directly printed. For other classifications, such as warning, etc., the server can receive the selection instructions of the R&D personnel, and obtain the target log information in a targeted manner according to the selection instructions input by the R&D personnel, and print it. For example, the R&D personnel can select a component or the log information of a page, and then obtain the type of log information, such as Function, Object, Array, String and other types, and format the target log information according to the processing logic corresponding to these types. Since the log information is output in one line, there are mainly two types when formatting. One is that if the amount of information data is large, the code can be formatted in lines according to the grammatical semantics of the code. When the array length is large, it can be formatted in lines according to the grammatical semantics of the array.

[0069] In the above embodiment, when the log information is large, it can be formatted according to the data type of the print log to print out a standardized formatted log. The plug-in device can not only reduce the development time cost and improve the development speed, but also has a very reliable reference in the management and tracking maintenance of large projects.

[0070] Specifically, combined Figure 3 As shown, Figure 3 It is a schematic diagram of a log printing system in an embodiment, wherein the log printing system includes a classification dimension module, a buried point collection module and a complex log formatting module, wherein the classification dimension module is mainly used to store coloring rules, the buried point collection module is mainly used for automatic reporting of serious bugs, and the complex log formatting module is mainly used for formatting logs.

[0071] Specifically, the server re-encapsulates the original console.log("%c","color:blue") method and re-classifies the printed information. The importance of the printed information, the front-end page, or the component can be used as the classification dimension. Different colors of printing fonts can be randomly generated under the same color system under each category. In this way, the printed logs have high recognition. When there are a lot of log information, it can effectively help developers distinguish the log content, improve development speed and locate the location of bugs in the code. When setting the classification dimension to page or component, special tags can be added to quickly capture the interface where the problem code is located and speed up the location of the problem. For complex and cumbersome logic codes where problems are not easy to find, the importance can be used as a division dimension. After coloring, the dominant role of rule tags is promoted to quickly find the problem code fragment. When the dimension to which the bug belongs is at a serious level and the number of occurrences is large, an email report is automatically sent to remind developers to pay more attention to the code at that location.

[0072] After the front-end project has been deployed and running, you can use the tracking function after adding the log printing system, that is, upload the captured important information to the remote server through the interface. By adding tracking points, when the user touches the mouse or page events such as clicks and slides, the captured information is sent to the server, and user behavior and interface information are collected as much as possible. When the user encounters problems in the interface call and the frequency is high, the problem interface is automatically reported to the developer. The reported interface is analyzed and the problem is solved in time, which can optimize the project operation process and improve user satisfaction. According to the collected user behavior operations, guidance can be provided for the direction of the next demand analysis.

[0073] When printing log information, the log plug-in collection device will determine the type of information, such as Function, Object, Array, String, etc. When the amount of information data is large, for example, an object without empty key-value pairs, you can use JSON.stringify(object,null,4) to format the object, and then format the object type information for output. When the array length is too large, you can also use the JSON.stringify() method to format it for output.

[0074] It should be understood that, although the steps in the flowcharts involved in the above embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps is not strictly limited in order, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above embodiments may include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.

[0075] Based on the same inventive concept, the embodiment of the present application also provides a log printing device for implementing the log printing method involved above. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above method, so the specific limitations in one or more log printing device embodiments provided below can refer to the limitations on the log printing method above, and will not be repeated here.

[0076] In one embodiment, Figure 4 As shown, a log printing device is provided, including: a log information acquisition module 401, a rule acquisition module 402, a classification module 403, a coloring module 404 and a printing module 405, wherein:

[0077] The log information acquisition module 401 is used to acquire the log information to be printed;

[0078] A rule acquisition module 402 is used to acquire preset coloring rules, where the coloring rules include classification rules;

[0079] A classification module 403, used for classifying the log information to be printed according to the classification rules;

[0080] The coloring module 404 is used to color the classified log information to be printed according to the coloring rules;

[0081] The printing module 405 is used to print the dyed log information to be printed.

[0082] In one embodiment, the classification rule includes at least one of a component classification rule, a page classification rule, and a fault level classification rule.

[0083] In one embodiment, the classification module 403 may include:

[0084] A first classification unit is used to classify the log information to be printed according to a component classification rule or a page classification rule to obtain an initial classification;

[0085] The second classification unit is used to classify the log information to be printed under each initial classification according to the fault level classification rule to obtain a target classification.

[0086] In one embodiment, the log printing device further includes:

[0087] A statistics module is used to count the number of occurrences of log information to be printed that meets the requirements of the fault level;

[0088] The output module is used to output alarm information when the number of occurrences is greater than or equal to the preset number of times.

[0089] In one embodiment, the log printing device further includes:

[0090] A first receiving module, configured to receive a selection instruction for the log information to be printed when the category of the log information to be printed is a preset category;

[0091] A type acquisition module is used to acquire target log information according to a selection instruction and acquire the type of the target log information;

[0092] The formatting module is used to format the target log information according to the type of the target log information.

[0093] In one embodiment, the log printing device further includes:

[0094] A second receiving module is used to receive a coloring rule configuration instruction, and configure the coloring rule according to the coloring rule configuration instruction;

[0095] A storage module, used for storing coloring rules;

[0096] The coloring module 404 is also used to obtain pre-stored coloring rules and load the coloring rules into the memory.

[0097] Each module in the log printing device can be implemented in whole or in part by software, hardware or a combination thereof. Each module can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute operations corresponding to each module.

[0098] In one embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as follows: Figure 5As shown. The computer device includes a processor, a memory and a network interface connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store log information. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a log printing method is implemented.

[0099] Those skilled in the art will understand that Figure 5 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0100] In one embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the following steps when executing the computer program: obtaining log information to be printed; obtaining preset coloring rules, wherein the coloring rules include classification rules; classifying the log information to be printed according to the classification rules; coloring the classified log information to be printed according to the coloring rules; and printing the colored log information to be printed.

[0101] In one embodiment, the classification rules involved when the processor executes the computer program include at least one of a component classification rule, a page classification rule, and a fault level classification rule.

[0102] In one embodiment, the classification of the log information to be printed according to the classification rules implemented when the processor executes the computer program includes: classifying the log information to be printed according to the component classification rules or the page classification rules to obtain an initial classification; classifying the log information to be printed under each initial classification according to the fault level classification rules to obtain a target classification.

[0103] In one embodiment, when the processor executes the computer program, the following steps are also implemented: counting the number of occurrences of the to-be-printed log information that meets the failure level requirement; when the number of occurrences is greater than or equal to a preset number, outputting an alarm message.

[0104] In one embodiment, before the processor executes a computer program to color the classified log information to be printed according to the coloring rules, it also includes: when the classification of the log information to be printed is a preset classification, receiving a selection instruction for the log information to be printed; obtaining target log information according to the selection instruction, and obtaining the type of the target log information; formatting the target log information according to the type of the target log information.

[0105] In one embodiment, when the processor executes the computer program, the following steps are also implemented: receiving coloring rule configuration instructions, configuring coloring rules according to the coloring rule configuration instructions; storing coloring rules; obtaining pre-set coloring rules implemented by the processor when executing the computer program includes: obtaining pre-stored coloring rules, and loading the coloring rules into the memory.

[0106] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the following steps are implemented: obtaining log information to be printed; obtaining preset coloring rules, the coloring rules including classification rules; classifying the log information to be printed according to the classification rules; coloring the classified log information to be printed according to the coloring rules; and printing the colored log information to be printed.

[0107] In one embodiment, the classification rules involved when the computer program is executed by the processor include at least one of a component classification rule, a page classification rule, and a fault level classification rule.

[0108] In one embodiment, the computer program implemented when executed by the processor classifies the log information to be printed according to the classification rules, including: classifying the log information to be printed according to the component classification rules or the page classification rules to obtain an initial classification; classifying the log information to be printed under each initial classification according to the fault level classification rules to obtain a target classification.

[0109] In one embodiment, when the computer program is executed by the processor, the following steps are also implemented: counting the number of occurrences of to-be-printed log information that meets the failure level requirement; when the number of occurrences is greater than or equal to a preset number, outputting an alarm message.

[0110] In one embodiment, before the computer program is executed by the processor and the classified log information to be printed is colored according to the coloring rules, it also includes: when the classification of the log information to be printed is a preset classification, receiving a selection instruction for the log information to be printed; obtaining the target log information according to the selection instruction, and obtaining the type of the target log information; formatting the target log information according to the type of the target log information.

[0111] In one embodiment, when the computer program is executed by the processor, the following steps are also implemented: receiving coloring rule configuration instructions, configuring coloring rules according to the coloring rule configuration instructions; storing coloring rules; when the computer program is executed by the processor, obtaining pre-set coloring rules includes: obtaining pre-stored coloring rules, and loading the coloring rules into the memory.

[0112] In one embodiment, a computer program product is provided, including a computer program, which, when executed by a processor, implements the following steps: obtaining log information to be printed; obtaining preset coloring rules, the coloring rules including classification rules; classifying the log information to be printed according to the classification rules; coloring the classified log information to be printed according to the coloring rules; and printing the colored log information to be printed.

[0113] In one embodiment, the classification rules involved when the computer program is executed by the processor include at least one of a component classification rule, a page classification rule, and a fault level classification rule.

[0114] In one embodiment, the computer program implemented when executed by the processor classifies the log information to be printed according to the classification rules, including: classifying the log information to be printed according to the component classification rules or the page classification rules to obtain an initial classification; classifying the log information to be printed under each initial classification according to the fault level classification rules to obtain a target classification.

[0115] In one embodiment, when the computer program is executed by the processor, the following steps are also implemented: counting the number of occurrences of to-be-printed log information that meets the failure level requirement; when the number of occurrences is greater than or equal to a preset number, outputting an alarm message.

[0116] In one embodiment, before the computer program is executed by the processor and the classified log information to be printed is colored according to the coloring rules, it also includes: when the classification of the log information to be printed is a preset classification, receiving a selection instruction for the log information to be printed; obtaining the target log information according to the selection instruction, and obtaining the type of the target log information; formatting the target log information according to the type of the target log information.

[0117] In one embodiment, when the computer program is executed by the processor, the following steps are also implemented: receiving coloring rule configuration instructions, configuring coloring rules according to the coloring rule configuration instructions; storing coloring rules; when the computer program is executed by the processor, obtaining pre-set coloring rules includes: obtaining pre-stored coloring rules, and loading the coloring rules into the memory.

[0118] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., but are not limited to this.

[0119] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0120] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be construed as limiting the scope of the present application. It should be noted that, for a person of ordinary skill in the art, several modifications and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.

Claims

1. A log printing method, characterized in that: The method comprises: Get the log information to be printed; Acquire a preset coloring rule, wherein the coloring rule includes a classification rule; Classifying the log information to be printed according to the classification rule; Coloring the classified log information to be printed according to the coloring rule; Printing the dyed log information to be printed; Before coloring the classified log information to be printed according to the coloring rule, the method further includes: When the category of the log information to be printed is a preset category, receiving a selection instruction for the log information to be printed; Acquire target log information according to the selection instruction, and acquire the type of the target log information; The target log information is formatted according to the type of the target log information, wherein the formatting process includes formatting the code in lines according to the grammatical semantics of the code when the amount of information data is greater than a first threshold, and formatting the code in lines according to the grammatical semantics of the code when the length of the array is greater than a second threshold.

2. The method according to claim 1, characterized in that The classification rules include at least one of component classification rules, page classification rules, and fault level classification rules.

3. The method according to claim 2, characterized in that The classifying the log information to be printed according to the classification rule includes: Classifying the log information to be printed according to a component classification rule or a page classification rule to obtain an initial classification; The log information to be printed under each initial classification is classified according to the fault level classification rule to obtain a target classification.

4. The method according to claim 3, characterized in that The method further comprises: Counting the number of occurrences of the log information to be printed that meets the requirements of the fault level; When the number of occurrences is greater than or equal to a preset number, an alarm message is output.

5. The method according to claim 1, characterized in that The method further comprises: Receiving a coloring rule configuration instruction, and configuring a coloring rule according to the coloring rule configuration instruction; storing the coloring rule; The obtaining of the preset coloring rules includes: A pre-stored coloring rule is obtained, and the coloring rule is loaded into a memory.

6. A log printing device, characterized in that: The device comprises: A log information acquisition module is used to obtain log information to be printed; A rule acquisition module, used to acquire preset coloring rules, wherein the coloring rules include classification rules; A classification module, used for classifying the log information to be printed according to the classification rules; A coloring module, used for coloring the classified log information to be printed according to the coloring rule; A printing module, used for printing the log information to be printed after dyeing; A first receiving module, configured to receive a selection instruction for the log information to be printed when the category of the log information to be printed is a preset category; A type acquisition module, used to acquire target log information according to the selection instruction, and acquire the type of the target log information; A formatting module is used to format the target log information according to the type of the target log information, wherein the formatting processing includes formatting the code in lines according to the grammatical semantics of the code when the amount of information data is greater than a first threshold, and formatting the code in lines according to the grammatical semantics of the array when the length of the array is greater than a second threshold.

7. The device according to claim 6, characterized in that The classification rules include at least one of component classification rules, page classification rules, and fault level classification rules.

8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 5 are implemented.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 5 are implemented.

10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 5 are implemented.