CN117331789A - Log generation method, device, computer equipment and storage medium - Google Patents

Log generation method, device, computer equipment and storage medium Download PDF

Info

Publication number
CN117331789A
CN117331789A CN202311394602.5A CN202311394602A CN117331789A CN 117331789 A CN117331789 A CN 117331789A CN 202311394602 A CN202311394602 A CN 202311394602A CN 117331789 A CN117331789 A CN 117331789A
Authority
CN
China
Prior art keywords
parameter
log
component
program component
preset
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
CN202311394602.5A
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.)
Industrial Bank Co Ltd
Original Assignee
Industrial 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 Industrial Bank Co Ltd filed Critical Industrial Bank Co Ltd
Priority to CN202311394602.5A priority Critical patent/CN117331789A/en
Publication of CN117331789A publication Critical patent/CN117331789A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/3003Monitoring arrangements specially adapted to the computing system or computing system component being monitored
    • G06F11/302Monitoring arrangements specially adapted to the computing system or computing system component being monitored where the computing system component is a software system
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/3065Monitoring arrangements determined by the means or processing involved in reporting the monitored data
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/3065Monitoring arrangements determined by the means or processing involved in reporting the monitored data
    • G06F11/3068Monitoring arrangements determined by the means or processing involved in reporting the monitored data where the reporting involves data format conversion
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2201/00Indexing scheme relating to error detection, to error correction, and to monitoring
    • G06F2201/865Monitoring of software

Abstract

The application relates to a log generation method, a log generation device, computer equipment and a storage medium. The method comprises the following steps: responding to the running operation of a current program component in a software application to be tested, and acquiring a first log parameter corresponding to the current program component; according to a preset parameter verification rule, verifying the first log parameter; under the condition that the first log parameters meet the parameter verification rule, inputting the first log parameters into a formatting component, and calling the formatting component to obtain a log in a preset format corresponding to the current program component; the formatting component and the current program component are written in the same programming language; and responding to the running operation of the next program component of the current program component, obtaining a log in a preset format corresponding to the next program component until the generation of the logs in the preset format corresponding to all the program components to be tested in the software application is finished, and obtaining a test log file of the software application. By adopting the method, the consistency of the log format can be ensured.

Description

Log generation method, device, computer equipment and storage medium
Technical Field
The present application relates to the field of computer technology, and in particular, to a log generating method, apparatus, computer device, storage medium, and computer program product.
Background
With the continued development of computer technology, software systems, which are collections of data and instructions, have emerged. The software system can implement various functions, for example, the software system may be a business system, a database system, or the like. Accordingly, software systems are increasingly being used in a variety of fields.
The log of the software system is a record of various events in the running process of the system, so that related personnel can know the running condition of the system by analyzing the log. However, in the prior art, the complexity of the log is high, so that the analysis of the log is difficult, and furthermore, when a software system has a problem, the related personnel are difficult to check the problem or optimize the system based on the log.
Disclosure of Invention
In view of the foregoing, it is desirable to provide a log generating method, apparatus, computer device, computer-readable storage medium, and computer program product capable of ensuring consistency of log formats.
In a first aspect, the present application provides a log generating method, including:
responding to the running operation of a current program component in a software application to be tested, and acquiring a first log parameter corresponding to the current program component;
checking the first log parameters according to a preset parameter checking rule;
under the condition that the first log parameter meets the parameter verification rule, inputting the first log parameter into a formatting component, and calling the formatting component to obtain a log in a preset format corresponding to the current program component; the formatting component and the current program component are written in the same programming language;
and responding to the running operation of the next program component of the current program component, acquiring a second log parameter corresponding to the next program component, checking the second log parameter, and inputting the second log parameter to the formatting component under the condition that the second log parameter meets the parameter checking rule to obtain a log in a preset format corresponding to the next program component until the generation of the logs in the preset format corresponding to all the program components to be tested in the software application is finished, so as to obtain a test log file of the software application.
In one embodiment, in a case where the first log parameter satisfies the parameter verification rule, inputting the first log parameter to the formatting component includes:
acquiring the parameter quantity of the first log parameter and the corresponding parameter value;
and under the condition that the parameter number meets the preset number specified in the parameter verification rule and the parameter value meets the parameter value range in the parameter verification rule, inputting the first log parameter into the formatting component.
In one embodiment, after the verifying the first log parameter according to the preset parameter verification rule, the method further includes:
and under the condition that the first log parameter does not meet the parameter checking rule, displaying the parameter checking rule.
In one embodiment, the first log parameter includes: the system comprises a type parameter, an identification parameter, a state and an operation result parameter, wherein the type parameter is used for identifying the type of an event generated by the operation of the current program component, the parameter value of the identification parameter is the program name of the current program component, and the parameter value of the state and operation result parameter is a text for expressing the event;
the calling the formatting component to obtain a log in a preset format corresponding to the current program component comprises the following steps:
acquiring the calling time of the formatting component;
determining enumeration values corresponding to the parameter values of the type parameters according to the parameter values of the type parameters;
and outputting the enumeration value, the calling time, the identification parameter, the state and the operation result parameter according to a preset sequence.
In one embodiment, the first log parameter further includes: an alert parameter, the method further comprising:
sending alarm information when the parameter value of the type parameter is a preset parameter value and the alarm parameter is not null; the alarm information comprises a log in a preset format corresponding to the current program component and a log in a preset format corresponding to an associated program component, wherein the associated program component is a program component with a calling relationship with the current program component.
In one embodiment, the obtaining the test log file of the software application includes:
determining the address of a test log file according to preset environmental parameters;
according to the generation sequence of the logs in the preset format corresponding to each program component, sequentially writing the logs in the preset format into the test log files corresponding to the addresses;
and under the condition that the test log file comprises preset keywords, determining the log in the preset format corresponding to the preset keywords.
In a second aspect, the present application further provides a log generating apparatus, including:
the system comprises an acquisition module, a judgment module and a control module, wherein the acquisition module is used for responding to the running operation of a current program component in a software application to be tested and acquiring a first log parameter corresponding to the current program component;
the verification module is used for verifying the first log parameters according to a preset parameter verification rule;
the first formatting module is used for inputting the first log parameters into a formatting component and calling the formatting component to obtain a log in a preset format corresponding to the current program component under the condition that the first log parameters meet the parameter checking rule; the formatting component and the current program component are written in the same programming language;
the second formatting module is configured to respond to an operation of a next program component of the current program component, obtain a second log parameter corresponding to the next program component, verify the second log parameter, and input the second log parameter to the formatting component when the second log parameter meets the parameter verification rule, so as to obtain a log in a preset format corresponding to the next program component, until all logs in preset formats corresponding to all program components to be tested in the software application are generated, and obtain a test log file of the software application.
In a third aspect, the present application also provides a computer device comprising a memory storing a computer program and a processor implementing the steps of any one of the methods described above when the computer program is executed by the processor.
In a fourth aspect, the present application also provides a computer-readable storage medium, on which a computer program is stored, which when executed by a processor, implements the steps of the method of any of the preceding claims.
In a fifth aspect, the present application also provides a computer program product comprising a computer program which, when executed by a processor, implements the steps of the method of any of the preceding claims.
According to the log generation method, the log generation device, the computer equipment, the storage medium and the computer program product, the log parameters are standardized through the preset parameter verification rule, and further, the formatted components are obtained through the pre-defined programming language which is the same as that of the current program components, so that logs in the preset format can be generated for the running operation of each step of program components, and the consistency of the log format is ensured. Therefore, the log file formed by the logs with the consistent format has strong readability, is convenient for processing massive logs, and can realize the integral problem investigation of the software application based on the log file.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the related art, the drawings that are required to be used in the embodiments or the related technical descriptions will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present application, and other drawings may be obtained according to the drawings without inventive effort for a person having ordinary skill in the art.
FIG. 1 is an application environment diagram of a log generation method in one embodiment;
FIG. 2 is a flow chart of a log generation method according to an embodiment;
FIG. 3 is a flowchart of a log generation method according to another embodiment;
FIG. 4 is a block diagram showing a structure of a log generating apparatus in one embodiment;
fig. 5 is an internal structural diagram of a computer device in one embodiment.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the present application will be further described in detail with reference to the accompanying drawings and examples. It should be understood that the specific embodiments described herein are for purposes of illustration only and are not intended to limit the present application.
The log generation method provided by the embodiment of the application can be applied to an application environment shown in fig. 1. Wherein the terminal 102 communicates with the server 104 via a network. The data storage system may store data that the server 104 needs to process. The data storage system may be integrated on the server 104 or may be located on a cloud or other network server. The software system may run on the server 104. The software system may include a plurality of modules that may be written in different programming languages, e.g., shell, SQL (Structured Query Language), perl (Practical Extraction and Report Language), etc. Multiple modules may be used to implement different functions. By selecting and configuring modules in a software system, software applications can be obtained that meet specific functional requirements. The software application may run on the server 104 and the terminal 102 may obtain services provided by the software application over a network. A software application may also be running on the terminal 102. The terminal 102 may be, but not limited to, various personal computers, notebook computers, smart phones, tablet computers, internet of things devices, and portable wearable devices, where the internet of things devices may be smart speakers, smart televisions, smart air conditioners, smart vehicle devices, and the like. The portable wearable device may be a smart watch, smart bracelet, headset, or the like. The server 104 may be implemented as a stand-alone server or as a server cluster of multiple servers.
In an exemplary embodiment, as shown in fig. 2, a log generating method is provided, and an example of application of the method to the server 104 in fig. 1 is described, including the following steps 201 to 204.
Wherein:
step 201, in response to an operation of a current program component in a software application to be tested, acquiring a first log parameter corresponding to the current program component.
Wherein the program component may consist of functions. An operating program component may implement a particular function. The software application may include a plurality of program components. Here, testing of the software application may occur during a development phase of the software application, or during a maintenance phase of operation.
Specifically, the server 104 may acquire the first log parameter of the current program component input by the related person through the terminal 102 once every time the operation on the program component is executed.
Step 202, verifying the first log parameter according to a preset parameter verification rule.
Here, the first log parameters of the plurality of program components included in the software application to be tested may be verified according to a unified parameter verification rule. Specifically, the preset parameter calibration rule may be converted into a parameter calibration function, and then the server 104 may input the obtained first log parameter to the parameter calibration function to obtain a calibration result.
Step 203, under the condition that the first log parameter meets the parameter verification rule, inputting the first log parameter to a formatting component, and calling the formatting component to obtain a log in a preset format corresponding to the current program component; wherein the formatting component and the current program component are written in the same programming language.
The formatting component may be encapsulated by a formatting function, where the formatting function is configured to receive the first log parameter and output a log in a preset format. The formatting component may be used to adjust the order between the first log parameters. The formatting component may also be configured to adjust the parameter value of the first log parameter to be within a corresponding parameter value range.
Program components may be written in different programming languages. Thus, the formatting components may be written in different programming languages. The server 104 may call a formatting component written in the same writing language as the program component after performing a running operation on the program component. For example, the formatting component may be written in a programming language such as Shell, SQL, perl. In one possible implementation, formatting components written in different programming languages may be stored in specific locations on server 104. In another possible implementation, the formatting component, and the program component written in the same writing language as the formatting component, may also be stored in the same location. For example, the software application to be tested includes a module a, where the module a is written in Shell language, and the module a includes a program component A1, and then a formatting component A2 written in Shell language may be encapsulated in the module a. Similarly, the software application to be tested may further include a module B written in the SQL language, where the module B includes the program component B1, and the formatting component B2 written in the SQL language may be encapsulated in the module B.
Step 204, in response to the operation of the next program component of the current program component, obtaining a second log parameter corresponding to the next program component, checking the second log parameter, and inputting the second log parameter to the formatting component to obtain a log of a preset format corresponding to the next program component if the second log parameter meets the parameter checking rule, until the generation of the logs of the preset format corresponding to all the program components to be tested in the software application is completed, so as to obtain a test log file of the software application.
Here, the running process of the current program component may include requesting the running of the next program component, and returning the running result of the next program component to the current program component. Alternatively, the end of the current program component run may trigger the next program component to run.
Specifically, the server 104 may perform the formatting process on the first log parameter of the current program component every time the running operation on the program component is executed, so as to generate a log in a corresponding preset format. For example, when the running process of the program component C includes a call to the program component D and a running result of the program component D is returned to the program component C, in response to the running operation of the program component C, the current program component is the program component C, and the next program component is the program component D; in response to the operation of the program component D, the current program component is the program component D, and the next program component is the program component C. For another example, the program component C, the program component D, and the program component E are sequentially executed program components, and then the program component D is the next program component of the program component C, and the program component E is the next program component of the program component D.
According to the log generation method, the log parameters are standardized through the preset parameter verification rule, and further, the formatting component is obtained through the pre-defined programming language which is the same as that of the current program component, so that the log with the preset format can be generated according to the running operation of each step of program component, and the consistency of the log format is ensured. Therefore, the log file formed by the logs with the consistent format has strong readability, is convenient for processing massive logs, and can realize the integral problem investigation of the software application based on the log file.
In an exemplary embodiment, as shown in fig. 3, another log generating method is provided, including:
step 301, obtaining a first log parameter corresponding to a current program component in response to an operation of the current program component in the software application to be tested.
For example, the server 104 may present a prompt to invoke the formatting component in response to a running operation of the current program component, prompting the user to input a first log parameter to the formatting component.
Step 302, verifying the first log parameter according to a preset parameter verification rule.
Step 303, obtaining the parameter number of the first log parameter and the corresponding parameter value.
For example, the server 104 may input the obtained first log parameter to a parameter number check function, and a parameter value check function. The parameter number checking function and the parameter value checking function are respectively used for checking whether the parameter number meets the preset number specified in the parameter checking rule and whether the parameter value meets the parameter value range in the parameter checking rule. Here, the parameter number check function and the parameter value check function may be converted from a preset parameter check rule.
Step 304, when the number of parameters satisfies the preset number specified in the parameter verification rule and the parameter value satisfies the parameter value range in the parameter verification rule, inputting the first log parameter to the formatting component.
For example, the parameter verification rule may be set to verify whether the parameter value of the first log parameter is one of a plurality of preset parameter values.
Optionally, the parameter verification rule may further include verifying the environmental parameter.
In this embodiment, the normalization of the parameters for generating the log can be further improved by checking the number of the parameters, the range of the parameter values, and other related parameters of the first log parameter.
The first log parameter may include: the system comprises a type parameter, an identification parameter, a state and an operation result parameter, wherein the type parameter is used for identifying the type of an event generated by the operation of the current program component, the parameter value of the identification parameter is the program name of the current program component, and the parameter value of the state and the operation result parameter is a text used for expressing the event.
For example, the type parameter may be "ERROR", "INFO", "WARNING", "DEBUG". Wherein, "ERROR" is used to identify that the type of event generated by the current program component is an ERROR event, "INFO" is used to identify that the type of event generated by the current program component is a message event, "WARNING" is used to identify that the type of event generated by the current program component is a WARNING event, and "DEBUG" is used to identify that the type of event generated by the current program component is a DEBUG event.
Alternatively, the parameter value of the identification parameter may be a module name of the current module, where the current module is a running module, and the current module includes a current program component and other program components to be tested.
The state and operation result parameters are used for expressing events generated by the operation of the current program component, for example, the state and operation result parameters can be texts such as "start data import", "no import authority of the current user", "data import failure", and the like.
In an exemplary embodiment, as shown in fig. 3, the above log generating method further includes:
step 305, get the call time of the formatting component.
Illustratively, after obtaining the call time of the formatting component, the server 104 may format the call time.
In step 305, according to the parameter value of the type parameter, an enumeration value corresponding to the parameter value of the type parameter is determined.
For example, the enumerated values for "ERROR", "INFO", "WARNING", "DEBUG" may be "E", "I", "W", "D", respectively.
Step 307, outputting enumeration values, calling time, identification parameters, states and running result parameters according to a preset sequence.
In this embodiment, an exemplary log format is provided, through which the basic operation condition of the current program component can be known.
In an exemplary embodiment, the first log parameter further includes: as shown in fig. 3, the method for generating the log further includes:
step 308, sending alarm information when the parameter value of the type parameter is a preset parameter value and the alarm parameter is not null; the alarm information comprises a log in a preset format corresponding to the current program component and a log in a preset format corresponding to the associated program component, wherein the associated program component is a program component with a calling relationship with the current program component.
For example, the alarm parameter may be checked in case the type parameter is "ERROR". The alert parameter may be "email" or null. In the case that the alert parameter is "email", the server 104 may send a log in a preset format corresponding to the current program component to the relevant person.
In a possible implementation manner, in the case that the alert parameter is not null, the server 104 may acquire an environment parameter corresponding to the current program component, and send the day in the preset format corresponding to the current program component to the relevant person according to the smtp server address, the mail authorization code and the default recipient configured in the environment parameter.
In order to enable the related personnel to know the context information of the event generated by the operation of the current program component, the server 104 may also send the log in the preset format corresponding to the associated program component with the calling relationship of the current program component to the related personnel when the alarm parameter is not null.
In one possible implementation manner, the stack trace information of the program component may be added to the log in the preset format, and then the server 104 can determine, according to the stack trace information in the log in the preset format, a call chain of the current program component, and further determine an associated program component having a call relationship with the current program component.
In this embodiment, by sending the log of the current program component and the log of the associated component, where the alarm parameter is not null, to the associated personnel when the log type is a specific type, the associated personnel can understand the program component running in error and the running condition of the program component having a calling relationship with the program component, so that the associated personnel can analyze the problem in time, and the running stability of the software application is ensured.
In an exemplary embodiment, as shown in fig. 3, the above log generating method further includes:
step 309, in case the first log parameter does not meet the parameter check rule, displaying the parameter check rule.
For example, the parameter verification rules may be written to a particular document, which may also include methods of use of the formatting components, as well as exemplary reference parameters, and the like.
In the embodiment, the verification rule is displayed to the related personnel under the condition that the log parameter does not meet the verification rule, so that the related personnel can be reminded to input the log parameter according to the format meeting the verification rule, and the normalization of the log parameter is ensured.
In an exemplary embodiment, the method for generating a log further includes:
step 310, determining the address of the test log file according to the preset environmental parameters.
Step 311, according to the generation sequence of the logs in the preset format corresponding to each program component, sequentially writing the logs in the preset format into the test log file corresponding to the address.
In step 312, in the case that the test log file includes a preset keyword, a log in a preset format corresponding to the preset keyword is determined.
The preset keyword may be a specific parameter value or a parameter range. Therefore, the log file can be further parsed by determining whether the log file includes a preset keyword. For example, the time it takes to run a program component or module, the number of logs whose log type is a particular type, and the like can be obtained by parsing the log file.
Further, since the formatted logs are sequentially written into the log file according to the generation sequence, and the formatted logs are sequentially generated in response to the running operation of the program component, the call chain of each program component can be determined by the sequence of the formatted logs in the log file.
In summary, according to the log generating method, the device, the computer equipment, the storage medium and the computer program product, the log parameters are standardized through the preset parameter checking rule, and further, the formatted component is obtained through writing in the same programming language as the current program component through the predefined definition, so that the log in the preset format can be generated for the running operation of each step of program component, and the consistency of the log format is ensured. Therefore, the log file formed by the logs with the consistent format has strong readability, is convenient for processing massive logs, and can realize the integral problem investigation of the software application based on the log file.
It should be understood that, although the steps in the flowcharts related to the embodiments described above are sequentially shown as indicated by arrows, these steps are not necessarily sequentially performed in the order indicated by the arrows. The steps are not strictly limited to the order of execution unless explicitly recited herein, and the steps may be executed in other orders. Moreover, at least some of the steps in the flowcharts described in the above embodiments may include a plurality of steps or a plurality of stages, which are not necessarily performed at the same time, but may be performed at different times, and the order of the steps or stages is not necessarily performed sequentially, but may be performed alternately or alternately with at least some of the other steps or stages.
Based on the same inventive concept, the embodiment of the application also provides a log generating device for realizing the log generating method. The implementation of the solution provided by the device is similar to the implementation described in the above method, so the specific limitation in the embodiments of the log generating device or log generating devices provided below may refer to the limitation of the log generating method hereinabove, and will not be repeated herein.
In an exemplary embodiment, as shown in fig. 4, there is provided a log generating apparatus 400, including: an acquisition module 401, a verification module 402, a first formatting module 403, and a second formatting module 404, wherein:
the obtaining module 401 is configured to obtain a first log parameter corresponding to a current program component in response to an operation of the current program component in the software application to be tested.
The verification module 402 is configured to verify the first log parameter according to a preset parameter verification rule.
The first formatting module 403 is configured to input the first log parameter to the formatting component, and call the formatting component to obtain a log in a preset format corresponding to the current program component when the first log parameter meets the parameter verification rule; wherein the formatting component and the current program component are written in the same programming language.
And the second formatting module 404 is configured to respond to an operation of a next program component of the current program component, obtain a second log parameter corresponding to the next program component, verify the second log parameter, and input the second log parameter to the formatting component to obtain a log in a preset format corresponding to the next program component if the second log parameter meets a parameter verification rule, until all logs in the preset format corresponding to the program components to be tested in the software application are generated, and obtain a test log file of the software application.
In one embodiment, the first formatting module 403 includes:
and the acquisition sub-module is used for acquiring the parameter quantity of the first log parameter and the corresponding parameter value.
And the formatting sub-module is used for inputting the first log parameter into the formatting component under the condition that the parameter quantity meets the preset quantity specified in the parameter checking rule and the parameter value meets the parameter value range in the parameter checking rule.
In one embodiment, the log generating apparatus 400 further includes:
and the display module is used for displaying the parameter verification rule under the condition that the first log parameter does not meet the parameter verification rule.
In one embodiment, the first log parameter comprises: the system comprises a type parameter, an identification parameter, a state and an operation result parameter, wherein the type parameter is used for identifying the type of an event generated by the operation of the current program component, the parameter value of the identification parameter is the program name of the current program component, and the parameter value of the state and operation result parameter is a text for expressing the event; the first formatting module 403 further includes:
and the time acquisition sub-module is used for acquiring the calling time of the formatting component.
The enumeration value determining submodule is used for determining enumeration values corresponding to parameter values of the type parameters according to the parameter values of the type parameters.
And the output sub-module is used for outputting the enumeration value, the calling time, the identification parameter, the state and the operation result parameter according to a preset sequence.
In one embodiment, the first log parameter further comprises: the log generation device 400 further includes alarm parameters:
the alarm module is used for sending alarm information when the parameter value of the type parameter is a preset parameter value and the alarm parameter is not null; the alarm information comprises a log in a preset format corresponding to the current program component and a log in a preset format corresponding to the associated program component, wherein the associated program component is a program component with a calling relationship with the current program component.
In one embodiment, the second formatting module 404 includes:
and the address determination submodule is used for determining the address of the test log file according to the preset environmental parameter.
The writing sub-module is used for sequentially writing the logs in the preset format into the test log files corresponding to the addresses according to the generation sequence of the logs in the preset format corresponding to each program component.
The log determining sub-module is used for determining a log in a preset format corresponding to a preset keyword under the condition that the test log file comprises the preset keyword.
Each of the modules in the log generation apparatus described above may be implemented in whole or in part by software, hardware, and combinations thereof. The above modules may be embedded in hardware or may be independent of a processor in the computer device, or may be stored in software in a memory in the computer device, so that the processor may call and execute operations corresponding to the above modules.
In one exemplary embodiment, a computer device is provided, which may be a server, the internal structure of which may be as shown in fig. 5. The computer device includes a processor, a memory, an Input/Output interface (I/O) and a communication interface. The processor, the memory and the input/output interface are connected through a system bus, and the communication interface is connected to the system bus through the input/output interface. Wherein the processor of the computer device is configured 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, computer programs, and a database. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage media. The database of the computer device is used for storing logs in a preset format. The input/output interface of the computer device is used to exchange information between the processor and the external device. The communication interface of the computer device is used for communicating with an external terminal through a network connection. The computer program, when executed by a processor, implements a log generation method.
It will be appreciated by those skilled in the art that the structure shown in fig. 5 is merely a block diagram of some of the structures associated with the present application and is not limiting of the computer device to which the present application may be applied, and that a particular computer device may include more or fewer components than shown, or may combine certain components, or have a different arrangement of components.
In an exemplary embodiment, a computer device is provided, comprising a memory and a processor, the memory having stored therein a computer program, the processor performing the steps of the method embodiments described above when the computer program is executed.
In an exemplary embodiment, a computer-readable storage medium is provided, on which a computer program is stored, which computer program, when being executed by a processor, carries out the steps of the method embodiments described above.
In an exemplary embodiment, a computer program product is provided, comprising a computer program which, when executed by a processor, implements the steps of the method embodiments described above.
Those skilled in the art will appreciate that implementing all or part of the above described methods may be accomplished by way of a computer program stored on a non-transitory computer readable storage medium, which when executed, may comprise the steps of the embodiments of the methods described above. Any reference to memory, database, or other medium used in the various embodiments provided herein may include at least one of non-volatile and volatile memory. The nonvolatile Memory may include Read-Only Memory (ROM), magnetic tape, floppy disk, flash Memory, optical Memory, high density embedded nonvolatile Memory, resistive random access Memory (ReRAM), magnetic random access Memory (Magnetoresistive Random Access Memory, MRAM), ferroelectric Memory (Ferroelectric Random Access Memory, FRAM), phase change Memory (Phase Change Memory, PCM), graphene Memory, and the like. Volatile memory can include random access memory (Random Access Memory, RAM) or external cache memory, and the like. By way of illustration, and not limitation, RAM can be in the form of a variety of forms, such as static random access memory (Static Random Access Memory, SRAM) or dynamic random access memory (Dynamic Random Access Memory, DRAM), and the like. The databases referred to in the various embodiments provided herein may include at least one of relational databases and non-relational databases. The non-relational database may include, but is not limited to, a blockchain-based distributed database, and the like. The processors referred to in the embodiments provided herein may be general purpose processors, central processing units, graphics processors, digital signal processors, programmable logic units, quantum computing-based data processing logic units, etc., without being limited thereto.
The technical features of the above embodiments may be arbitrarily combined, and all possible combinations of the technical features in the above embodiments are not described for brevity of description, however, as long as there is no contradiction between the combinations of the technical features, they should be considered as the scope of the description.
The above examples only represent a few embodiments of the present application, which are described in more detail and are not to be construed as limiting the scope of the present application. It should be noted that it would be apparent to those skilled in the art that various modifications and improvements could be made without departing from the spirit of the present application, which would be within the scope of the present application. Accordingly, the scope of protection of the present application shall be subject to the appended claims.

Claims (10)

1. A method of log generation, the method comprising:
responding to the running operation of a current program component in a software application to be tested, and acquiring a first log parameter corresponding to the current program component;
checking the first log parameters according to a preset parameter checking rule;
under the condition that the first log parameter meets the parameter verification rule, inputting the first log parameter into a formatting component, and calling the formatting component to obtain a log in a preset format corresponding to the current program component; the formatting component and the current program component are written in the same programming language;
and responding to the running operation of the next program component of the current program component, acquiring a second log parameter corresponding to the next program component, checking the second log parameter, and inputting the second log parameter to the formatting component under the condition that the second log parameter meets the parameter checking rule to obtain a log in a preset format corresponding to the next program component until the generation of the logs in the preset format corresponding to all the program components to be tested in the software application is finished, so as to obtain a test log file of the software application.
2. The method of claim 1, wherein, in the event that the first log parameter satisfies the parameter check rule, inputting the first log parameter to the formatting component comprises:
acquiring the parameter quantity of the first log parameter and the corresponding parameter value;
and under the condition that the parameter number meets the preset number specified in the parameter verification rule and the parameter value meets the parameter value range in the parameter verification rule, inputting the first log parameter into the formatting component.
3. The method of claim 1, wherein after verifying the first log parameter according to the preset parameter verification rule, further comprising:
and under the condition that the first log parameter does not meet the parameter checking rule, displaying the parameter checking rule.
4. The method of claim 1, wherein the first log parameter comprises: the system comprises a type parameter, an identification parameter, a state and an operation result parameter, wherein the type parameter is used for identifying the type of an event generated by the operation of the current program component, the parameter value of the identification parameter is the program name of the current program component, and the parameter value of the state and operation result parameter is a text for expressing the event;
the calling the formatting component to obtain a log in a preset format corresponding to the current program component comprises the following steps:
acquiring the calling time of the formatting component;
determining enumeration values corresponding to the parameter values of the type parameters according to the parameter values of the type parameters;
and outputting the enumeration value, the calling time, the identification parameter, the state and the operation result parameter according to a preset sequence.
5. The method of claim 4, wherein the first log parameter further comprises: an alert parameter, the method further comprising:
sending alarm information when the parameter value of the type parameter is a preset parameter value and the alarm parameter is not null; the alarm information comprises a log in a preset format corresponding to the current program component and a log in a preset format corresponding to an associated program component, wherein the associated program component is a program component with a calling relationship with the current program component.
6. The method of claim 1, wherein the obtaining the test log file for the software application comprises:
determining the address of a test log file according to preset environmental parameters;
according to the generation sequence of the logs in the preset format corresponding to each program component, sequentially writing the logs in the preset format into the test log files corresponding to the addresses;
and under the condition that the test log file comprises preset keywords, determining the log in the preset format corresponding to the preset keywords.
7. A log generating apparatus, the apparatus comprising:
the system comprises an acquisition module, a judgment module and a control module, wherein the acquisition module is used for responding to the running operation of a current program component in a software application to be tested and acquiring a first log parameter corresponding to the current program component;
the verification module is used for verifying the first log parameters according to a preset parameter verification rule;
the first formatting module is used for inputting the first log parameters into a formatting component and calling the formatting component to obtain a log in a preset format corresponding to the current program component under the condition that the first log parameters meet the parameter checking rule; the formatting component and the current program component are written in the same programming language;
the second formatting module is configured to respond to an operation of a next program component of the current program component, obtain a second log parameter corresponding to the next program component, verify the second log parameter, and input the second log parameter to the formatting component when the second log parameter meets the parameter verification rule, so as to obtain a log in a preset format corresponding to the next program component, until all logs in preset formats corresponding to all program components to be tested in the software application are generated, and obtain a test log file of the software application.
8. A computer device comprising a memory and a processor, the memory storing a computer program, characterized in that the processor implements the steps of the method of any of claims 1 to 6 when the computer program is executed.
9. A computer readable storage medium, on which a computer program is stored, characterized in that the computer program, when being executed by a processor, implements the steps of the method of any of claims 1 to 6.
10. A computer program product comprising a computer program, characterized in that the computer program, when being executed by a processor, implements the steps of the method of any of claims 1 to 6.
CN202311394602.5A 2023-10-25 2023-10-25 Log generation method, device, computer equipment and storage medium Pending CN117331789A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311394602.5A CN117331789A (en) 2023-10-25 2023-10-25 Log generation method, device, computer equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311394602.5A CN117331789A (en) 2023-10-25 2023-10-25 Log generation method, device, computer equipment and storage medium

Publications (1)

Publication Number Publication Date
CN117331789A true CN117331789A (en) 2024-01-02

Family

ID=89275350

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311394602.5A Pending CN117331789A (en) 2023-10-25 2023-10-25 Log generation method, device, computer equipment and storage medium

Country Status (1)

Country Link
CN (1) CN117331789A (en)

Similar Documents

Publication Publication Date Title
CN110019116B (en) Data tracing method, device, data processing equipment and computer storage medium
CN115357590A (en) Recording method and device for data change, electronic device and storage medium
CN117331789A (en) Log generation method, device, computer equipment and storage medium
CN113778996A (en) Large data stream data processing method and device, electronic equipment and storage medium
CN114238085A (en) Interface testing method and device, computer equipment and storage medium
CN116362230A (en) Parameter verification method, device and computer equipment storable medium
CN117785674A (en) Interface use case generation method, device, computer equipment and storage medium
CN107784047B (en) Method and device for realizing storage process
CN117591260A (en) Task execution method, device, equipment, storage medium and program product
CN115629958A (en) Universal field level automatic checking method and device for different service interfaces
CN117851484A (en) Data processing method and device based on rule engine and computer equipment
CN117971649A (en) Data processing method, device, computer equipment and storage medium
CN116361149A (en) Batch processing automatic test method, device, computer equipment and storage medium
CN115827478A (en) Code viewing method and device, computer equipment and storage medium
CN117094292A (en) Form file processing method, form file processing device, form file processing equipment, storage medium and program product
CN117349131A (en) System error information display method and device and computer equipment
CN117453561A (en) Test script calling method, device, computer equipment and storage medium
CN116881164A (en) Verification and correction method, device and equipment for test data in financial information system
CN116521546A (en) Interface performance adjusting method and device, computer equipment and storage medium
CN117331812A (en) Service code verification method, device, computer equipment, storage medium and product
CN116991662A (en) Time sequence alarm rule processing method and device and computer equipment
CN116860576A (en) Method, device, computer equipment and storage medium for recording operation log
CN116880927A (en) Rule management method, device, computer equipment and storage medium
CN117389605A (en) Service interface configuration method, device, equipment, storage medium and program product
CN117033172A (en) Test data processing method, apparatus, device, storage medium and program product

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