CN115543234A - Log printing method and related device - Google Patents

Log printing method and related device Download PDF

Info

Publication number
CN115543234A
CN115543234A CN202211243195.3A CN202211243195A CN115543234A CN 115543234 A CN115543234 A CN 115543234A CN 202211243195 A CN202211243195 A CN 202211243195A CN 115543234 A CN115543234 A CN 115543234A
Authority
CN
China
Prior art keywords
dynamic debugging
dynamic
service scene
log
service
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202211243195.3A
Other languages
Chinese (zh)
Inventor
徐栋
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Ping An Bank Co Ltd
Original Assignee
Ping An Bank Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Ping An Bank Co Ltd filed Critical Ping An Bank Co Ltd
Priority to CN202211243195.3A priority Critical patent/CN115543234A/en
Publication of CN115543234A publication Critical patent/CN115543234A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/12Digital output to print unit, e.g. line printer, chain printer
    • G06F3/1201Dedicated interfaces to print systems
    • G06F3/1202Dedicated interfaces to print systems specifically adapted to achieve a particular effect
    • G06F3/1218Reducing or saving of used resources, e.g. avoiding waste of consumables or improving usage of hardware resources
    • G06F3/122Reducing or saving of used resources, e.g. avoiding waste of consumables or improving usage of hardware resources with regard to computing resources, e.g. memory, CPU
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/12Digital output to print unit, e.g. line printer, chain printer
    • G06F3/1201Dedicated interfaces to print systems
    • G06F3/1202Dedicated interfaces to print systems specifically adapted to achieve a particular effect
    • G06F3/121Facilitating exception or error detection and recovery, e.g. fault, media or consumables depleted

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Human Computer Interaction (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Mathematical Physics (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The application relates to a log printing method and related equipment thereof, wherein the method comprises the following steps: receiving a log printing request; identifying each service scene corresponding to the input data at an entrance of the application program to obtain a plurality of service scene identifications corresponding to each service scene; inputting a plurality of service scene identifications into a unified processing channel, and respectively judging whether each service scene identification is correspondingly configured with a dynamic debugging component, wherein: if the service scene identification is correspondingly configured with the dynamic debugging component, setting a first dynamic debugging mark corresponding to the service scene identification; if no dynamic debugging component is configured correspondingly to the service scene identifier, detecting whether the input data is correspondingly provided with dynamic debugging information; the log print request is responded to based on the first dynamic debug flag and/or the dynamic debug information. According to the log printing dynamic debugging method and device, the risk of log printing blocking can be reduced through log printing dynamic debugging processing, and the utilization rate and the operation efficiency of system resources are improved.

Description

Log printing method and related device
Technical Field
The present application relates to the field of computer technologies, and in particular, to a log printing method and related devices.
Background
The log printing of the application system is an important recording mode for the information of the system operation process, is used for observing the system operation process and troubleshooting and positioning faults, and is an important means for system operation and maintenance. The common log recording mode adopts simple file output or mature open source log library components to record logs. The open source journal library component can provide rich journal logging functionality, typically by calling a journaler when used.
However, the open source log library component, while supporting naming of the loggers and adjustment and filtering at the log level, has coarse granularity for these functions. For example, during the calling process of the application system, part of the common code may repeatedly appear in a plurality of business scenarios. When the application system has a problem, the application system may be abnormal in a certain service scenario and normal in other service scenarios. At this time, the conventional coarse-grained logging method needs to open all logging functions of the common code, and cannot open the logger in a specific service scenario. Under the condition of very high traffic, the log recording function is started to generate a large amount of log records in the system instantly, so that the waste of system resources is caused, and even the operating efficiency of the system is greatly reduced under the severe condition.
Disclosure of Invention
In view of this, the present application provides a log printing method and related devices thereof, which can achieve the capability of accurately outputting logs required by a specific scene for the specific scene, and further achieve the purpose of printing logs of the specific scene with a low system resource consumption cost, and reduce the risk of log printing blocking and improve the utilization rate and operating efficiency of system resources by dynamically debugging and processing the log printing.
According to an aspect of the present application, there is provided a log printing method, the method including: receiving a log printing request; identifying each service scene corresponding to the input data at an entrance of the application program to obtain a plurality of service scene identifications corresponding to each service scene; inputting the service scene identifications into a unified processing channel, and respectively judging whether each service scene identification is correspondingly configured with a dynamic debugging component, wherein: if the service scene identification is correspondingly configured with a dynamic debugging component, setting a first dynamic debugging mark corresponding to the service scene identification; if no dynamic debugging component is configured correspondingly to the service scene identifier, detecting whether the input data is correspondingly provided with dynamic debugging information; responding to the log print request based on the first dynamic debug flag and/or the dynamic debug information.
Further, identifying each service scene corresponding to the input data at the application program entrance to obtain a plurality of service scene identifiers corresponding to each service scene, including: acquiring a plurality of service parameters corresponding to all service scenes, and storing the plurality of service parameters in a database in advance; identifying current each service scene according to at least one service parameter in the input data; and acquiring a plurality of service scene identifications corresponding to the current service scenes at an entrance of an application program.
Further, the dynamic debugging component is disposed in the processing channel, inputs the plurality of service scene identifiers into a unified processing channel, and respectively determines whether each of the service scene identifiers is configured with the dynamic debugging component, including: acquiring a plurality of functional components corresponding to the service scene identifiers; judging whether each functional component accesses the relevant attribute of the processing channel, wherein: if the functional component accesses the relevant attribute of the processing channel, when the processing channel calls the functional component, the functional component is correspondingly configured with a dynamic debugging component; if the functional component can not access the relevant attributes of the processing channel, when the processing channel calls the functional component, the functional component is correspondingly configured with no dynamic debugging component.
Further, the processing channel entry is provided with a dynamic debugging switch, and if the service scene identifier is configured without a dynamic debugging component, it is detected whether the input data is provided with dynamic debugging information correspondingly, including: judging whether to turn on the dynamic debugging switch according to the input data, wherein: when the dynamic debugging switch is turned on, the input data is correspondingly provided with dynamic debugging information; and under the condition of closing the dynamic debugging switch, no dynamic debugging information is correspondingly set in the input data.
Further, responding to the log print request based on the first dynamic debug flag and/or the dynamic debug information includes: judging whether the first dynamic debugging mark is equal to a preset first dynamic debugging mark threshold value, wherein: if the first dynamic debugging mark is equal to a preset first dynamic debugging mark threshold value, printing a service scene log corresponding to the first dynamic debugging mark; and if the first dynamic debugging mark is not equal to the preset first dynamic debugging mark threshold value, executing the next step code of the application program.
Further, responding to the log printing request based on the first dynamic debugging flag and/or the dynamic debugging information further includes: judging whether the input data is correspondingly provided with dynamic debugging information, wherein: if no dynamic debugging information is set correspondingly to the input data, setting a second dynamic debugging mark corresponding to the input data; if the input data is correspondingly provided with dynamic debugging information, setting the first dynamic debugging mark; under the condition that a second dynamic debugging mark corresponding to the input data is set, judging whether the second dynamic debugging mark is equal to a preset second dynamic debugging mark threshold value or not, wherein: if the second dynamic debugging mark is equal to a preset second dynamic debugging mark threshold value, printing a service scene log corresponding to the second dynamic debugging mark; and if the second dynamic debugging mark is not equal to the preset second dynamic debugging mark threshold value, executing the next step code of the application program.
Further, the log printing method further includes: acquiring a log frame corresponding to the application program; and calling the log frame based on the first dynamic debugging mark and/or the dynamic debugging information to print a target service scene log.
According to still another aspect of the present application, there is provided a log printing apparatus including: the receiving module is used for receiving a log printing request; the identification acquisition module is used for identifying each service scene corresponding to the input data at the entrance of the application program to obtain a plurality of service scene identifications corresponding to each service scene; a judging module, configured to input the service scene identifiers into a unified processing channel, and respectively judge whether each service scene identifier is configured with a dynamic debugging component, where: if the service scene identification is correspondingly configured with a dynamic debugging component, setting a first dynamic debugging mark corresponding to the service scene identification; if no dynamic debugging component is configured correspondingly to the service scene identifier, detecting whether the input data is correspondingly provided with dynamic debugging information; and the printing module is used for responding the log printing request based on the first dynamic debugging mark and/or the dynamic debugging information.
According to yet another aspect of the present application, there is provided a computer readable medium having stored thereon a computer program which, when executed by a processor, implements the log printing method.
According to still another aspect of the present application, there is provided an electronic device including: one or more processors; a storage device to store one or more programs that, when executed by the one or more processors, cause the one or more processors to implement the log printing method.
The method comprises the steps of identifying each service scene corresponding to input data at an application program entrance to obtain a plurality of service scene identifications corresponding to each service scene, inputting the plurality of service scene identifications to a unified processing channel, respectively judging whether each service scene identification is correspondingly configured with a dynamic debugging component, setting a first dynamic debugging mark corresponding to the service scene identification under the condition that the service scene identification is correspondingly configured with the dynamic debugging component, detecting whether the input data is correspondingly provided with dynamic debugging information under the condition that the service scene identification is correspondingly configured with no dynamic debugging component, and finally responding to a log printing request based on the first dynamic debugging mark and/or the dynamic debugging information.
Drawings
The technical solution and other advantages of the present application will become apparent from the detailed description of the embodiments of the present application with reference to the accompanying drawings.
Fig. 1 shows a flowchart of a log printing method according to an embodiment of the present application.
Fig. 2 is a schematic diagram illustrating a log printing method according to an embodiment of the present application.
Fig. 3 shows a block diagram of a log printing apparatus of an embodiment of the present application.
Fig. 4 shows a schematic structural diagram of an electronic device according to an embodiment of the present application.
Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application. It should be apparent that the described embodiments are only some of the embodiments of the present application, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
In the description of the present application, it is to be understood that the terms "center," "longitudinal," "lateral," "length," "width," "thickness," "upper," "lower," "front," "rear," "left," "right," "vertical," "horizontal," "top," "bottom," "inner," "outer," "clockwise," "counterclockwise," and the like are used in an orientation or positional relationship indicated in the drawings for convenience in describing the present application and to simplify the description, and are not intended to indicate or imply that the device or element so referred to must have a particular orientation, be constructed in a particular orientation, and be operated in a particular orientation, and thus are not to be construed as limiting the present application. Furthermore, the terms "first", "second" and "first" are used for descriptive purposes only and are not to be construed as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, features defined as "first" and "second" may explicitly or implicitly include one or more of the described features. In the description of the present application, "a plurality" means two or more unless specifically limited otherwise.
In the description of the present application, it is to be noted that, unless otherwise explicitly specified or limited, the terms "mounted," "connected," and "connected" are to be construed broadly, e.g., as meaning either a fixed connection, a removable connection, or an integral connection; may be mechanically connected, may be electrically connected or may be in communication with each other; either directly or indirectly through intervening media, either internally or in any other suitable relationship. The specific meaning of the above terms in the present application can be understood by those of ordinary skill in the art as the case may be.
The following disclosure provides many different embodiments or examples for implementing different features of the application. In order to simplify the disclosure of the present application, specific example components and arrangements are described below. Of course, they are merely examples and are not intended to limit the present application. Moreover, the present application may repeat reference numerals and/or letters in the various examples, such repetition is for the purpose of simplicity and clarity and does not in itself dictate a relationship between the various embodiments and/or configurations discussed. In addition, examples of various specific processes and materials are provided herein, but one of ordinary skill in the art may recognize the application of other processes and/or the use of other materials. In some instances, methods, means, elements and circuits that are well known to those skilled in the art have not been described in detail so as not to obscure the present application.
Fig. 1 shows a flowchart of a log printing method according to an embodiment of the present application. As shown in fig. 1, the log printing method may include:
step S1: receiving a log printing request;
the log printing request can be sent by a developer writing the application program, and can also be sent by a tester testing the application program. For example, an application written by a developer is first sent to a tester for testing. If the test result does not match the expected result, the tester may print a partial log of the application program in advance, and check whether the test exception is caused by test-related factors such as misoperation of the test itself through the partial log. If the tester confirms that the test exception is caused by a non-test factor, a developer may be introduced for further inspection. Developers can adjust the level of log output and position the position of program exception through more comprehensive log analysis, thereby providing support for solving the problem of test exception.
In the present application, the journal printing may occur in a variety of business scenarios. For example, a part of parameters in the application program cannot be empty, and when the part of parameters is empty, it indicates that an exception occurs in the program, and at this time, a log related to the part of parameters needs to be printed to locate the exception problem. For another example, in the process of debugging the application program, it may be difficult to view console information, and at this time, stack information needs to be recorded in a log, so as to quickly locate the code with the exception when the application program runs abnormally.
Step S2: identifying each service scene corresponding to the input data at an entrance of the application program to obtain a plurality of service scene identifications corresponding to each service scene;
wherein the application portal may be an initial part of an application. Since the data transmitted and input at the entrance of the application program is not processed, the business scenes corresponding to the input data can be identified at the entrance of the application program, and whether the original data input by the application program is in accordance with the expectation can be easily judged.
The input data may include parameters associated with each service scenario that may be used to characterize a particular service characteristic of the service scenario. For example, when stack information needs to be recorded in a log, if input data contains a thread name or a stack top related to a stack, it may be determined that one of the business scenarios corresponding to the input data is a location of a code exception. It should be noted that the input data may be a data set including one or more service scenarios. For each service scene, a service scene identifier corresponding to the service scene may be set to distinguish different service scenes.
For example, the service scenario identifier may be a character sequence for identifying a service scenario corresponding to the service scenario identifier. For example, the service scenario identifier 01 may correspond to a service scenario determined by a code exception location, and the service scenario identifier 02 may correspond to a service scenario passing a parameter value error.
Further, identifying each service scene corresponding to the input data at the application program entrance to obtain a plurality of service scene identifiers corresponding to each service scene, including:
step S21: acquiring a plurality of service parameters corresponding to all service scenes, and storing the plurality of service parameters in a database in advance;
in the application, a plurality of service parameters corresponding to all possible service scenes can be collected firstly, then the plurality of service parameters are preprocessed in a data cleaning, duplication removing, vacancy supplementing and other modes, and the preprocessed plurality of service parameters are stored in the database in advance according to the types of the service scenes, so that the plurality of service parameters can be cached in advance, and the data reading and writing speed is accelerated.
Step S22: identifying current each service scene according to at least one service parameter in the input data;
one service scenario may correspond to one service parameter or may correspond to a plurality of service parameters, that is, the service scenario in the embodiment of the present application may be characterized by using one or more service parameters. It can be understood that, the application is not limited to the mapping relationship between the service parameter and the service scenario.
Step S23: and acquiring a plurality of service scene identifications corresponding to the current service scenes at an entrance of an application program.
When the current service scenes are identified according to at least one service parameter in the input data, a plurality of service scene identifiers corresponding to the current service scenes can be acquired according to the mapping relationship between the preset service scenes and the corresponding service scene identifiers. In the present application, a description is given by taking an example in which one service scenario corresponds to one service scenario identifier.
And step S3: inputting the service scene identifications into a unified processing channel, and respectively judging whether each service scene identification is correspondingly configured with a dynamic debugging component, wherein: if the service scene identification is correspondingly configured with a dynamic debugging component, setting a first dynamic debugging mark corresponding to the service scene identification; if no dynamic debugging component is configured correspondingly to the service scene identifier, detecting whether the input data is correspondingly provided with dynamic debugging information;
wherein the dynamic debug component is disposable within the processing channel. The processing channels are uniform channels and can be used for processing the plurality of service scenes in a centralized manner. For the purposes of this application, the dynamic debug component may be preconfigured within the processing channel for each business scenario. Of course, for business scenarios that do not require printing, the dynamic debug component may not be configured within the processing channel. It should be noted that, in the present application, the configuration of the dynamic debugging component is dynamic, and whether to configure the dynamic debugging component may be determined according to actual needs. In one example, the dynamic debugging component can be a custom function.
After the plurality of service scene identifiers are input into the unified processing channel, whether each service scene identifier is configured with a dynamic debugging component correspondingly or not can be judged respectively. If the service scene identifier is configured with a dynamic debugging component, it is indicated that the service scene corresponding to the service scene identifier needs to be printed, and at this time, a first dynamic debugging flag corresponding to the service scene identifier may be set. The first dynamic debug flag may be a fixed value. Further, if no dynamic debugging component is configured correspondingly to the service scene identifier, it is indicated that the service scene corresponding to the service scene identifier does not need to be printed, and at this time, it may be further detected whether the input data is correspondingly provided with dynamic debugging information.
Therefore, in the present application, when the dynamic log needs to be opened, the dynamic log can be enabled in two ways. The first way is based on the first dynamic debug flag. For example, for the first way, a first dynamic debug flag may be set in the operation management segment of a specific service scenario, and all calls of the specific service scenario will print the required log. The operation management segment may be any one of the processing stages in processing the specific service scenario. The second way is based on the dynamic debug information. The dynamic debug information is associated with the input data, so that other flag bits can be set in the external input data to enable the dynamic log.
Both of the above two approaches can be used to turn on the capability of the dynamic debug identity. Compared with the prior art that the original log library cannot dynamically start the log, the log printing method and the log printing system have the advantages that the dynamic log is started by setting two different modes, the log printing quantity and the system consumption can be greatly reduced, and the fine-grained log printing control is realized.
Further, inputting the service scene identifiers into a unified processing channel, and respectively determining whether each service scene identifier is configured with a dynamic debugging component, including:
step S31: acquiring a plurality of functional components corresponding to the service scene identifiers;
step S32: judging whether each functional component accesses the relevant attribute of the processing channel, wherein: if the functional component accesses the relevant attribute of the processing channel, when the processing channel calls the functional component, the functional component is correspondingly configured with a dynamic debugging component; if the functional component cannot access the relevant attributes of the processing channel, when the processing channel calls the functional component, the functional component is correspondingly configured with no dynamic debugging component.
Wherein the functional components are also referred to as functional constituents. A plurality of functional components may be included within the processing channel. When respectively judging whether each service scene identifier is configured with a dynamic debugging component, a plurality of functional components corresponding to each service scene identifier may be obtained first, and then whether each functional component accesses the relevant attribute of the processing channel is judged. The relevant attributes of the processing channel may be characteristics associated with the processing channel, such as parameter values, content, and the like.
Specifically, if the functional component accesses the relevant attribute of the processing channel, it is indicated that the functional component can normally access the relevant attribute of the processing channel, and at this time, when the processing channel calls the functional component, it may be determined that the functional component is configured with the dynamic debugging component correspondingly. In other words, when the processing channel calls the functional component, the dynamic debugging component can be automatically set on the functional component, so that the functional component can smoothly and automatically acquire the dynamic debugging component. If the functional component cannot access the relevant attribute of the processing channel, which means that the functional component cannot access the relevant attribute of the processing channel, when the processing channel calls the functional component, it is determined that no dynamic debugging component is correspondingly configured for the functional component. In addition, the dynamic debug identification of the present application is not passed through the thread context, but through the processing channel and the specific attributes of the functional component itself.
Further, the processing channel entry is provided with a dynamic debugging switch, and if no dynamic debugging component is configured correspondingly to the service scene identifier, it is detected whether the input data is correspondingly provided with dynamic debugging information, including:
step S321: judging whether to turn on the dynamic debugging switch according to the input data, wherein: under the condition that the dynamic debugging switch is turned on, the input data is correspondingly provided with dynamic debugging information; and under the condition of closing the dynamic debugging switch, no dynamic debugging information is correspondingly set in the input data.
Specifically, at a configuration entrance of the processing channel, the embodiment of the present application may set the logic of the dynamic debug switch according to a specific service scenario. This facilitates a further determination of whether to set dynamic commissioning in the input data when required. When the dynamic debugging switch is turned on, it is indicated that the input data corresponding to the current service scene is correspondingly provided with dynamic debugging information; and under the condition that the dynamic debugging switch is closed, the input data corresponding to the current service scene is indicated to be correspondingly provided with no dynamic debugging information.
And step S4: responding to the log print request based on the first dynamic debug flag and/or the dynamic debug information.
In this application, the log printing request responded based on the first dynamic debug flag and the log printing request responded based on the dynamic debug information are two different log printing modes, which can be replaced with each other or performed simultaneously. It is noted that a further determination may be made as to the dynamic journal for responding to the journal print request based on the dynamic debug information.
Further, responding to the log print request based on the first dynamic debug flag and/or the dynamic debug information includes:
step S41: judging whether the first dynamic debugging mark is equal to a preset first dynamic debugging mark threshold value, wherein: if the first dynamic debugging mark is equal to a preset first dynamic debugging mark threshold value, printing a service scene log corresponding to the first dynamic debugging mark; and if the first dynamic debugging mark is not equal to a preset first dynamic debugging mark threshold value, executing the next step code of the application program.
The threshold of the first dynamic debugging flag may be preset, and is used to check whether the first dynamic debugging flag is a first dynamic debugging flag corresponding to a target scene that needs to be printed. Specifically, if the first dynamic debugging flag is equal to a preset first dynamic debugging flag threshold, it indicates that the service scene corresponding to the first dynamic debugging flag needs to be printed, and at this time, a service scene log corresponding to the first dynamic debugging flag is printed; if the first dynamic debugging mark is not equal to the preset first dynamic debugging mark threshold value, the service scene corresponding to the first dynamic debugging mark does not need to be printed, and then the next step of the application program can be executed in a skipping mode.
Further, responding to the log printing request based on the first dynamic debugging flag and/or the dynamic debugging information further includes:
step S42: judging whether the input data is correspondingly provided with dynamic debugging information, wherein: if no dynamic debugging information is set correspondingly to the input data, setting a second dynamic debugging mark corresponding to the input data; if the input data is correspondingly provided with dynamic debugging information, setting the first dynamic debugging mark;
the second dynamic debugging flag can be set in the input data and identified by a code part of an application program. In this application, determining whether the input data is correspondingly provided with the dynamic debug information may be a prerequisite condition for setting a corresponding second dynamic debug flag. And setting a second dynamic debugging mark corresponding to the input data only if no dynamic debugging information is set corresponding to the input data, otherwise, setting the first dynamic debugging mark.
Step S43: under the condition that a second dynamic debugging mark corresponding to the input data is set, judging whether the second dynamic debugging mark is equal to a preset second dynamic debugging mark threshold value or not, wherein: if the second dynamic debugging mark is equal to a preset second dynamic debugging mark threshold value, printing a service scene log corresponding to the second dynamic debugging mark; and if the second dynamic debugging mark is not equal to the preset second dynamic debugging mark threshold value, executing the next step code of the application program.
Here, the processing procedure of step S43 is similar to step S41, except that the processing object of step S43 is the second dynamic debug flag. In practical applications, the log print request may be responded to based on the first dynamic debug flag and/or the second dynamic debug flag. The second dynamic debug threshold may be equal to the first dynamic debug threshold, or may be set according to actual needs.
Step S52: and calling the log frame based on the first dynamic debugging mark and/or the dynamic debugging information to print a target service scene log.
Fig. 2 is a schematic diagram illustrating a log printing method according to an embodiment of the present application.
As shown in fig. 2, in an example, external input data may be received first, then a service scenario identifier is obtained according to the external input data, and then whether a service scenario corresponding to the service scenario identifier configures dynamic debugging is detected. Specifically, whether the dynamic debugging is configured in the service scenario may be determined by determining whether the service scenario identifier is configured with a dynamic debugging component. Under the condition that the service scene corresponding to the service scene identifier is configured with dynamic debugging, a first dynamic debugging flag can be set, and then whether the first dynamic debugging flag is equal to a preset threshold value or not is judged. If the first dynamic debugging mark is equal to a preset threshold value, recording a log; and if the first dynamic debugging mark is equal to a preset threshold value, executing other functional codes.
And under the condition that the service scene corresponding to the service scene identification is not configured with dynamic debugging, jumping to another branch and judging whether the input information comprises a dynamic debugging mark. Specifically, whether the input information includes a dynamic debugging flag may be determined by determining whether the input data corresponds to dynamic debugging information. If the input information comprises a dynamic debugging mark, comparing the dynamic debugging mark with a preset threshold value; and if the input information does not comprise the dynamic debugging mark, setting a second dynamic debugging mark, and comparing the second debugging mark with a preset threshold value. The preset threshold may be a first dynamic debug flag threshold, or a second dynamic debug flag threshold.
Further, the log printing method further includes:
step S51: acquiring a log frame corresponding to the application program;
illustratively, the Log framework may be a Log4j Log framework. The Log4j Log framework can be used to control the destination of Log information output, such as console or file, and can also be used to control the output format of each Log. The parameters such as the output destination and the output format of the log information can be flexibly configured through the log configuration file without modifying the application software code. The Log4j Log framework may include components such as a logger, exporter, formatter, and the like.
Loggers (Loggers) are used to control the output level of the log. In one example, the output level of the log from high to low may be in order: OFF, FATAL, ERROR, WARN, INFO, DEBUG, TRACE, ALL. The OFF grade is highest, which means that all log recording switches are closed; FATAL grade indicates outputting FATAL error; the ERROR level indicates output ERROR information; the WARN level represents output warning information; the INFO level represents output prompt information; the DEBUG level represents output debugging information; TRACE level indicates output TRACE information; the ALL level is lowest, indicating that ALL logging switches are open. In practical applications, in order to simplify the print content of the log, the output level of the log may be set to five or four levels. It is to be understood that the present application is not limited to the output level of the log.
An outputter (applicator) is used to write the log information to the target destination. For example, a console exporter is used to export log information to a console, a file exporter is used to write the log information to a specified file, a split file exporter is used to write the log information to a plurality of files, and a database exporter is used to write the log information to a database table.
The formatter (Layout) is configured to receive the log information output by the outputter and format the log information into a target pattern. For example, a simple formatter may output log information in a simple format, such as an INFO-level message; the custom formatter can return a formatted log information result according to a custom conversion mode.
Furthermore, by the fine-grained log printing control mode, after the application system is operated on line, logs in a specific service scene can be flexibly started. In consideration of the basic capability provided by the log library, the embodiment of the application can also realize log content and range control of multiple layers. Specifically, the embodiment of the application can adjust the log level of a specific log recorder, so as to record all logs within the influence range of the log recorder; or in the configuration of a service scenario, a dynamic debug switch of a specific service scenario is turned on, and then all subsequent calls related to the service scenario record relevant logs. In an application system, a general configuration switch can be dynamically enabled, which means that after the switch is enabled, if there are a plurality of transactions in the service scenario, the processing of each service will record the relevant process log.
For example, when a specific service is called, the initiator modifies an identifiable flag bit preset in the input information, and sets the flag bit to a state of enabling the dynamic log, so that the application system records the relevant log when processing the service processing. In this case, only one transaction log is recorded, and is not associated with the subsequent business process. If the input information of the next service processing does not include a specific flag bit, the logging behavior does not occur. Therefore, by the aid of the dynamic log debugging processing scheme, the log level adjusting capacity of the log device after the log library is opened is combined, the dynamic log adjusting capacity is realized on multiple levels, the log recording capacity is accurately started in a single service processing process, fine-granularity log printing is more accurately performed, and flexibility is improved.
In summary, compared with the deficiency that the efficiency of the common log recording mode in the prior art is low, the log printing method provided by the application can support fine-grained log printing control while supporting coarse-grained schemes such as log level adjustment of the conventional log recorder. Specifically, the log printing method provided by the application can realize the capability of accurately outputting the logs required by the specific scene aiming at the specific scene, and further achieves the purpose of printing the logs of the specific scene with less system resource consumption cost without opening a large-range log recording function. By dynamically debugging and processing the log printing, the risk of log printing blockage is reduced, and the utilization rate and the operating efficiency of system resources are improved.
Fig. 3 shows a block diagram of a log printing apparatus according to an embodiment of the present application.
As shown in fig. 3, the log printing apparatus 30 according to the embodiment of the present application may include:
a receiving module 31, configured to receive a log print request;
the identifier obtaining module 32 is configured to identify each service scene corresponding to the input data at the application program entrance, and obtain a plurality of service scene identifiers corresponding to each service scene;
a determining module 33, configured to input the multiple service scene identifiers into a unified processing channel, and respectively determine whether each service scene identifier is configured with a dynamic debugging component, where: if the service scene identification is correspondingly configured with a dynamic debugging component, setting a first dynamic debugging mark corresponding to the service scene identification; if no dynamic debugging component is configured correspondingly to the service scene identifier, detecting whether the input data is correspondingly provided with dynamic debugging information;
a printing module 34, configured to respond to the log printing request based on the first dynamic debug flag and/or the dynamic debug information.
Further, the present application provides a computer-readable medium having stored thereon a computer program which, when executed by a processor, implements the log printing method.
Further, the present application also provides an electronic device, including: one or more processors; a storage device to store one or more programs that, when executed by the one or more processors, cause the one or more processors to implement the log printing method.
Fig. 4 shows a schematic structural diagram of an electronic device according to an embodiment of the present application.
As shown in fig. 4, the electronic device may be used to implement the service code-based testing method. In particular, the electronic device may comprise a computer system. It should be noted that the electronic device shown in fig. 3 is only an example, and should not bring any limitation to the functions and the application scope of the embodiments of the present application.
As shown in fig. 4, the computer system includes a Central Processing Unit (CPU) 1801, which can perform various appropriate actions and processes, such as executing the method described in the above embodiments, according to a program stored in a Read-Only Memory (ROM) 1802 or a program loaded from a storage portion 1808 into a Random Access Memory (RAM) 1803. In the RAM 1803, various programs and data necessary for system operation are also stored. The CPU 1801, ROM 1802, and RAM 1803 are connected to each other via a bus 1804. An Input/Output (I/O) interface 1805 is also connected to bus 1804.
The following components are connected to the I/O interface 1805: an input portion 1806 including a keyboard, a mouse, and the like; an output section 1807 including a Display such as a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and a speaker; a storage portion 1808 including a hard disk and the like; and a communication section 1809 including a Network interface card such as a LAN (Local Area Network) card, a modem, or the like. The communication section 1809 performs communication processing via a network such as the internet. A driver 1810 is also connected to the I/O interface 1805 as needed. A removable medium 1811 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on the drive 1810 as necessary, so that a computer program read out therefrom is mounted in the storage portion 1808 as necessary.
In particular, according to embodiments of the application, the processes described above with reference to the flow diagrams may be implemented as computer software programs. For example, embodiments of the present application include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising a computer program for performing the method illustrated by the flow chart. In such embodiments, the computer program may be downloaded and installed from a network via the communication portion 1809, and/or installed from the removable media 1811. The computer program executes various functions defined in the system of the present application when executed by a Central Processing Unit (CPU) 1801.
It should be noted that the computer readable medium shown in the embodiments of the present application may be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a Read-Only Memory (ROM), an Erasable Programmable Read-Only Memory (EPROM), a flash Memory, an optical fiber, a portable Compact Disc Read-Only Memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the present application, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In this application, however, a computer readable signal medium may include a propagated data signal with a computer program embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. The computer program embodied on the computer readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wired, etc., or any suitable combination of the foregoing.
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present application. Each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams or flowchart illustration, and combinations of blocks in the block diagrams or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The units described in the embodiments of the present application may be implemented by software, or may be implemented by hardware, and the described units may also be disposed in a processor. Wherein the names of the elements do not in some way constitute a limitation on the elements themselves.
As another aspect, the present application also provides a computer-readable medium, which may be contained in the electronic device described in the above embodiments; or may be separate and not incorporated into the electronic device. The computer readable medium carries one or more programs which, when executed by an electronic device, cause the electronic device to implement the method described in the above embodiments.
It should be noted that although in the above detailed description several modules or units of the device for action execution are mentioned, such a division is not mandatory. Indeed, the features and functionality of two or more modules or units described above may be embodied in one module or unit, according to embodiments of the application. Conversely, the features and functions of one module or unit described above may be further divided into embodiments by a plurality of modules or units.
Through the above description of the embodiments, those skilled in the art will readily understand that the exemplary embodiments described herein may be implemented by software, or by software in combination with necessary hardware. Therefore, the technical solution according to the embodiments of the present application can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a usb disk, a removable hard disk, etc.) or on a network, and includes several instructions to enable a computing device (which can be a personal computer, a server, a touch terminal, or a network device, etc.) to execute the method according to the embodiments of the present application.
In the foregoing embodiments, the descriptions of the respective embodiments have respective emphasis, and for parts that are not described in detail in a certain embodiment, reference may be made to related descriptions of other embodiments.
The service code-based test method and the related devices provided by the embodiment of the present application are introduced in detail, and a specific example is applied in the description to explain the principle and the implementation of the present application, and the description of the embodiment is only used to help understand the technical scheme and the core idea of the present application; those of ordinary skill in the art will understand that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; such modifications or substitutions do not depart from the spirit and scope of the present disclosure as defined by the appended claims.

Claims (10)

1. A method of printing a journal, the method comprising:
receiving a log printing request;
identifying each service scene corresponding to the input data at an application program entrance to obtain a plurality of service scene identifications corresponding to each service scene;
inputting the service scene identifications into a unified processing channel, and respectively judging whether each service scene identification is correspondingly configured with a dynamic debugging component, wherein: if the service scene identification is correspondingly configured with a dynamic debugging component, setting a first dynamic debugging mark corresponding to the service scene identification; if no dynamic debugging component is configured correspondingly to the service scene identifier, detecting whether the input data is correspondingly provided with dynamic debugging information;
responding to the log print request based on the first dynamic debug flag and/or the dynamic debug information.
2. The method for printing the log according to claim 1, wherein identifying each service scenario corresponding to the input data at the entrance of the application program to obtain a plurality of service scenario identifiers corresponding to each service scenario comprises:
acquiring a plurality of service parameters corresponding to all service scenes, and storing the plurality of service parameters in a database in advance;
identifying each current service scene according to at least one service parameter in the input data;
and acquiring a plurality of service scene identifications corresponding to the current service scenes at an entrance of an application program.
3. The log printing method according to claim 1, wherein the dynamic debugging component is disposed in the processing channel, the plurality of service scene identifiers are input into a unified processing channel, and whether each of the service scene identifiers is configured with the dynamic debugging component correspondingly is respectively determined, including:
acquiring a plurality of functional components corresponding to the service scene identifiers;
judging whether each functional component accesses the relevant attribute of the processing channel, wherein: if the functional component accesses the relevant attribute of the processing channel, when the processing channel calls the functional component, the functional component is correspondingly configured with a dynamic debugging component; if the functional component cannot access the relevant attributes of the processing channel, when the processing channel calls the functional component, the functional component is correspondingly configured with no dynamic debugging component.
4. The log printing method according to claim 3, wherein a dynamic debug switch is disposed at the processing channel entry, and if no dynamic debug component is configured correspondingly to the service scene identifier, detecting whether the input data is correspondingly provided with dynamic debug information includes:
judging whether to turn on the dynamic debugging switch according to the input data, wherein: when the dynamic debugging switch is turned on, the input data is correspondingly provided with dynamic debugging information; and under the condition that the dynamic debugging switch is closed, no dynamic debugging information is correspondingly set in the input data.
5. The log printing method according to claim 1, wherein responding to the log printing request based on the first dynamic debug flag and/or the dynamic debug information comprises:
judging whether the first dynamic debugging mark is equal to a preset first dynamic debugging mark threshold value, wherein: if the first dynamic debugging mark is equal to a preset first dynamic debugging mark threshold value, printing a service scene log corresponding to the first dynamic debugging mark; and if the first dynamic debugging mark is not equal to the preset first dynamic debugging mark threshold value, executing the next step code of the application program.
6. The log printing method according to claim 5, wherein responding to the log printing request based on the first dynamic debug flag and/or the dynamic debug information further comprises:
judging whether the input data is correspondingly provided with dynamic debugging information, wherein: if no dynamic debugging information is set correspondingly to the input data, setting a second dynamic debugging mark corresponding to the input data; if the input data is correspondingly provided with dynamic debugging information, setting the first dynamic debugging mark;
under the condition that a second dynamic debugging flag corresponding to the input data is set, judging whether the second dynamic debugging flag is equal to a preset second dynamic debugging flag threshold value or not, wherein: if the second dynamic debugging mark is equal to a preset second dynamic debugging mark threshold value, printing a service scene log corresponding to the second dynamic debugging mark; and if the second dynamic debugging mark is not equal to the preset second dynamic debugging mark threshold value, executing the next step code of the application program.
7. The journal printing method according to claim 1, further comprising:
acquiring a log frame corresponding to the application program;
and calling the log frame based on the first dynamic debugging mark and/or the dynamic debugging information to print a target service scene log.
8. A log printing apparatus, characterized by comprising:
the receiving module is used for receiving a log printing request;
the identification acquisition module is used for identifying each service scene corresponding to the input data at the entrance of the application program to obtain a plurality of service scene identifications corresponding to each service scene;
a judging module, configured to input the service scene identifiers into a unified processing channel, and respectively judge whether each service scene identifier is configured with a dynamic debugging component, where: if the service scene identification is correspondingly configured with a dynamic debugging component, setting a first dynamic debugging mark corresponding to the service scene identification; if no dynamic debugging component is configured correspondingly to the service scene identifier, detecting whether the input data is correspondingly provided with dynamic debugging information;
and the printing module is used for responding the log printing request based on the first dynamic debugging mark and/or the dynamic debugging information.
9. A computer-readable medium, on which a computer program is stored, which, when being executed by a processor, implements the log printing method according to any one of claims 1 to 7.
10. An electronic device, comprising:
one or more processors;
a storage device for storing one or more programs which, when executed by the one or more processors, cause the one or more processors to implement the log printing method according to any one of claims 1 to 7.
CN202211243195.3A 2022-10-11 2022-10-11 Log printing method and related device Pending CN115543234A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211243195.3A CN115543234A (en) 2022-10-11 2022-10-11 Log printing method and related device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211243195.3A CN115543234A (en) 2022-10-11 2022-10-11 Log printing method and related device

Publications (1)

Publication Number Publication Date
CN115543234A true CN115543234A (en) 2022-12-30

Family

ID=84733620

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211243195.3A Pending CN115543234A (en) 2022-10-11 2022-10-11 Log printing method and related device

Country Status (1)

Country Link
CN (1) CN115543234A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116107524A (en) * 2023-04-13 2023-05-12 杭州朗和科技有限公司 Low-code application log processing method, medium, device and computing equipment

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116107524A (en) * 2023-04-13 2023-05-12 杭州朗和科技有限公司 Low-code application log processing method, medium, device and computing equipment

Similar Documents

Publication Publication Date Title
US9396094B2 (en) Software test automation systems and methods
CN110088744B (en) Database maintenance method and system
WO2019227641A1 (en) Application testing method, apparatus, terminal device and medium
US10467590B2 (en) Business process optimization and problem resolution
CN112115005B (en) Test data acquisition method and device, computer equipment and storage medium
CN111209206A (en) Automatic test method and system for software product
CN115543234A (en) Log printing method and related device
CN111274130A (en) Automatic testing method, device, equipment and storage medium
CN112416803A (en) Automatic testing method and device
CN112131573A (en) Method and device for detecting security vulnerability and storage medium
CN114546881A (en) Application software testing method, electronic device and computer readable storage medium
CN111400171B (en) Interface testing method, system and device and readable storage medium
CN115080426A (en) Program file detection method and device, storage medium and electronic equipment
CN115454856A (en) Multi-application security detection method, device, medium and electronic equipment
CN114064510A (en) Function testing method and device, electronic equipment and storage medium
CN108845932B (en) Unit testing method and device of network library, storage medium and terminal
CN116820946B (en) Method and device for automatically testing compatibility of target software
CN114756217B (en) Plug-in based script generation system
CN112559372B (en) Method, system and storage medium for generating interface test case
CN114401032B (en) Testing method and system for satellite communication comprehensive tester
CN115357458B (en) Method and device for testing TISDM display information
CN111008138B (en) Method and device for processing code coverage rate and computer equipment
CN116954975A (en) Fault processing method, system and device for software product and storage medium
CN116820946A (en) Method and device for automatically testing compatibility of target software
JP2008262473A (en) Equipment maintenance management system

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination