CN109739735B - Log generation method and device - Google Patents

Log generation method and device Download PDF

Info

Publication number
CN109739735B
CN109739735B CN201811474321.XA CN201811474321A CN109739735B CN 109739735 B CN109739735 B CN 109739735B CN 201811474321 A CN201811474321 A CN 201811474321A CN 109739735 B CN109739735 B CN 109739735B
Authority
CN
China
Prior art keywords
program
log
preset
code statement
parameter data
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.)
Active
Application number
CN201811474321.XA
Other languages
Chinese (zh)
Other versions
CN109739735A (en
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.)
Neusoft Corp
Original Assignee
Neusoft Corp
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 Neusoft Corp filed Critical Neusoft Corp
Priority to CN201811474321.XA priority Critical patent/CN109739735B/en
Publication of CN109739735A publication Critical patent/CN109739735A/en
Application granted granted Critical
Publication of CN109739735B publication Critical patent/CN109739735B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Debugging And Monitoring (AREA)

Abstract

The disclosure relates to a log generation method and device. The method comprises the following steps: acquiring parameter data required by a program unique identifier corresponding to a preset variable of a code statement from parameter data of the program intercepted by a log interceptor in response to the program being executed according to a log template, wherein the log template comprises the code statement corresponding to the program unique identifier, and the code statement expresses log content in a preset form of the program according to the preset variable under a preset condition; inputting the acquired parameter data into a preset variable of a code statement corresponding to the unique program identifier in the log template according to the requirement; and generating the log content in a preset form displayed according to the code statement by uniquely identifying the corresponding code statement by operating the program. Therefore, as long as some contents in the parameter data are defined as variables in the log template, the log template is flexibly utilized to display log contents in different preset forms under different preset conditions in the deployment period, and the purpose of flexibly customizing the log is achieved.

Description

Log generation method and device
Technical Field
The present disclosure relates to the field of data processing, and in particular, to a log generation method and apparatus.
Background
The log is used for recording technical data of the program running condition. Generally, the content includes user operations performed by the program in response to user requests, whether there is an abnormality in the operating environment, data changes, and the like. Through the log, program maintenance personnel can perform troubleshooting and put forward a solution.
Currently, the logs are all written into the program by a programmer directly in the program coding stage for logging codes. In addition to business logic, program code is flooded with various code for logging. Therefore, the code for logging is strongly coupled with the code of the program itself, and the content of the log presentation can only be adjusted during the development period of the program. Once the item comes online, it will be difficult to adjust what needs to be presented by the log.
Disclosure of Invention
In view of this, an object of the present disclosure is to provide a log generating method and apparatus, so as to achieve the purpose of flexibly customizing a log.
In order to achieve the above object, a first aspect of the present disclosure provides a log generating method, where a log template is preset, and the log template includes a code statement corresponding to a unique program identifier, where the code statement expresses a log content in a preset form of a program according to a preset variable under a preset condition. The method comprises the following steps: according to the log template, acquiring parameter data required by a preset variable of a code statement uniquely identified by the program from the parameter data of the program intercepted by a log interceptor in response to the program being executed; inputting the acquired parameter data into a preset variable of a code statement corresponding to the program unique identifier in the log template according to requirements; and generating the log content in a preset form displayed according to the code statement by operating the code statement corresponding to the program unique identifier.
Optionally, the log template is a template engine that supports multiple script syntax rules and can run to generate a view. And the code statements in the log template are script statements written according to script grammar rules supported by the log template. The generating of the preset log content according to the code statement by operating the code statement corresponding to the program unique identifier includes: and generating a view showing the preset form log content according to the script statement by operating the log template.
Optionally, the obtaining, according to the log template, parameter data required by the program to uniquely identify a preset variable of a corresponding code statement from parameter data of the program intercepted by a log interceptor in response to the program being executed includes: and acquiring parameter data required by the program to uniquely identify the preset variable of the corresponding code statement from a log information storage according to the log template, wherein the log information storage stores the parameter data of the program intercepted by the log interceptor in response to the program being executed.
Optionally, the uniquely identifying, by the program, the corresponding code statement includes: the code statement which is uniquely identified by the class name, the program name and the success mark of the service code of the program and corresponds to the user under the condition of successful operation; and the code statement which is uniquely identified by the class name, the program name and the failure mark of the service code of the program and corresponds to the user operation failure condition is used. The inputting the acquired parameter data into the preset variable of the code statement corresponding to the program unique identifier in the log template according to the requirement comprises: acquiring a success mark for indicating success of user operation or a failure mark for indicating failure of user operation from parameter data of the program intercepted by a log interceptor in response to the program being executed; under the condition that the success mark is obtained, inputting the obtained parameter data into a preset variable of a code statement which is uniquely identified by a class name of a service code where the program is located, a program name and the success mark together according to needs so as to generate log content which is displayed according to the code statement and describes the success of the user operation; and under the condition of acquiring the failure mark, inputting the acquired parameter data into a preset variable of a code statement which is uniquely identified by the class name of the service code of the program, the program name and the failure mark together according to needs so as to generate log content which is displayed according to the code statement and used for describing the operation failure of the user.
A second aspect of the present disclosure provides a log generating apparatus, where a log template is preset, where the log template includes a code statement corresponding to a unique program identifier, and the code statement expresses a log content in a preset form of the program according to a preset variable under a preset condition. The device includes: and the data acquisition module is configured to acquire parameter data required by the program to uniquely identify the preset variable of the corresponding code statement from the parameter data of the program intercepted by the log interceptor in response to the program being executed according to the log template. And the data input module is configured to input the acquired parameter data into a preset variable of the code statement corresponding to the program unique identifier in the log template according to requirements. And the statement operating module is configured to operate the code statement corresponding to the program unique identifier to generate the preset-form log content displayed according to the code statement.
Optionally, the log template is a template engine that supports multiple script syntax rules and can run to generate a view. And the script statement in the log template is a script statement written according to script grammar rules supported by the log template. The statement execution module is configured to generate a view showing preset forms of log contents according to the script statements by executing the log template.
Optionally, the data obtaining module is configured to obtain, according to the log template, parameter data required by the program to uniquely identify a preset variable of a corresponding code statement from a log information storage, where the log information storage stores the parameter data of the program intercepted by the log interceptor in response to the program being executed.
Optionally, the uniquely identifying, by the program, the corresponding code statement includes: the code statement which is uniquely identified by the class name, the program name and the success mark of the service code of the program and corresponds to the user under the condition of successful operation; and the code statement which is uniquely identified by the class name, the program name and the failure mark of the service code of the program and corresponds to the user operation failure condition is used. The data input module includes: the mark acquisition sub-module is configured to acquire a success mark for indicating success of the user operation or a failure mark for indicating failure of the user operation from parameter data of the program intercepted by the log interceptor in response to the program being executed. And the success data input sub-module is configured to input the acquired parameter data into the preset variables of the code statement which are uniquely identified by the class name, the program name and the success mark of the service code of the program in the log template according to needs under the condition that the success mark is acquired, so as to generate log content which is displayed according to the code statement and describes the success of the user operation. And the failure data input sub-module is configured to input the acquired parameter data into a preset variable of a code statement which is uniquely identified by the class name, the program name and the failure mark of the service code of the program in the log template according to needs under the condition that the failure mark is acquired, so as to generate log content which is displayed according to the code statement and describes user operation failure.
A third aspect of the present disclosure provides a computer-readable storage medium having stored thereon a computer program which, when executed by a processor, performs the steps of the log generation method of any one of the first aspects of the present disclosure.
A fourth aspect of the present disclosure provides an electronic device, comprising: a memory having a computer program stored thereon; a processor for executing the computer program in the memory to implement the steps of the log generation method of any one of the first aspect of the present disclosure.
According to the method provided by the technical scheme of the disclosure, the parameter data of the program intercepted by the log interceptor in response to the program being executed is acquired, so that the log interceptor is used for realizing the decoupling of the data required by the log on the acquisition mode and the code of the program. And the preset log template comprises a code statement corresponding to the program unique identifier, wherein the code statement expresses the log content in the preset form of the program according to the preset variable under the preset condition, so that the acquired parameter data is correspondingly input into the corresponding preset variable of the log template, and the log content in the preset form shown according to the code statement can be generated by operating the code statement. Therefore, according to the log template of the technical scheme disclosed by the invention, as long as the parameter data contains contents, the contents can be defined as variables in the log template, the code statements of the log template are utilized to display the log contents in different preset forms under different preset conditions, the log contents can be flexibly adjusted in the deployment period, and the purpose of flexibly customizing the log is realized.
Additional features and advantages of the disclosure will be set forth in the detailed description which follows.
Drawings
The accompanying drawings, which are included to provide a further understanding of the disclosure and are incorporated in and constitute a part of this specification, illustrate embodiments of the disclosure and together with the description serve to explain the disclosure without limiting the disclosure. In the drawings:
FIG. 1 is a schematic diagram of an implementation environment shown in accordance with an exemplary embodiment.
Fig. 2 is a flowchart illustrating a method of log generation according to an exemplary embodiment in accordance with an aspect of the present disclosure.
Fig. 3a is a schematic diagram illustrating a log information storage according to an exemplary embodiment in accordance with an aspect of the present disclosure.
Fig. 3b is a diagram illustrating a log template content according to an exemplary embodiment in accordance with an aspect of the present disclosure.
Fig. 3c is a schematic diagram of log contents shown in an exemplary embodiment in accordance with an aspect of the present disclosure.
Fig. 3d is a schematic diagram illustrating another log template content in an exemplary embodiment in accordance with an aspect of the present disclosure.
Fig. 4 is a flowchart illustrating a method of log generation according to another exemplary embodiment of an aspect of the present disclosure.
Fig. 5 is a block diagram illustrating a log generation apparatus according to another aspect of the present disclosure.
Fig. 6 is a block diagram illustrating a log generation apparatus according to another exemplary embodiment of another aspect of the present disclosure.
FIG. 7 is a block diagram of an electronic device shown in accordance with an example embodiment.
Detailed Description
The following detailed description of specific embodiments of the present disclosure is provided in connection with the accompanying drawings. It should be understood that the detailed description and specific examples, while indicating the present disclosure, are given by way of illustration and explanation only, not limitation.
FIG. 1 is a schematic diagram of an implementation environment shown in accordance with an exemplary embodiment. The implementation environment includes: a computer 101. The computer 101 applies the log generation method provided by the embodiment of the present disclosure. A program that needs to be logged runs on the computer 101. The program may be a separate piece of code defined in the service code, and may behave differently in different language contexts, e.g. may be a certain method, a certain function.
Fig. 2 is a flowchart illustrating a method of log generation according to an exemplary embodiment in accordance with an aspect of the present disclosure. For example, the method may be applied to the computer 101 shown in fig. 1, and a log template is preset, where the log template includes a code statement corresponding to a program unique identifier, and the code statement expresses that log content in a preset form of the program is displayed according to a preset variable under a preset condition. As shown in fig. 2, the method may include:
in step 210, according to the log template, parameter data required by the program to uniquely identify a preset variable of a corresponding code statement is acquired from parameter data of the program intercepted by a log interceptor in response to the program being executed.
For example, the programs may include programs for implementing any business class, method. The parameter data may comprise input parameter data and/or output parameter data of the program.
The present disclosure is not limited to the implementation of the log interceptor. For example, in a possible manner, the log interceptor may intercept a method that needs to be logged by means of a spring associated program (AOP), and record the intercepted parameter data in a json manner in a log information store. And when the log content needs to be generated, acquiring parameter data required by the log template from the log information storage.
In the disclosure, the log interceptor may intercept the parameter data, that is, generate the log content in a preset form in combination with the log template, or write the parameter data of the program to be intercepted by the log interceptor as a record into the log information storage in response to the service system executing the program.
For the embodiment that the log information storage stores the parameter data intercepted by the log interceptor in response to the program being executed, when the log content needs to be generated, the parameter data required by the program to uniquely identify the preset variable of the corresponding code statement may be acquired from the log information storage according to the log template. In this embodiment, the log information storage can store sufficient and comprehensive log information, and even if the same log information is stored, different log templates can be customized as required, and the required content can be dynamically acquired from the log information storage as required to generate different log contents, thereby achieving the purpose of customizing the log more flexibly.
The log information storage may include, for example: a database or other storage means. For example, taking the log information storage as a database table as an example, the format of the log information storage may be as shown in fig. 3a, and the parameter data included in each record in the table may be divided into the following items, including: "ID", "operation time", "log information", "program name", "class name", "status (success or failure)", and the like. In the table, the parameter data of "ID" may be a unique identifier of a user who makes a request to the program; the parameter data of "operation time" may be the time of the operation performed by the program in response to the user request; the parameter data of "operator" can be the user name of the request; the parameter data of "log information" may be the content of an operation requested by the user; the parameter data of 'program name' can be the name of the program intercepted by the log interceptor, such as a method; the parameter data of "class name" can be the class name of the service code where the program is located; the parameter data "status (success or failure)" may be success or failure of the operation performed by the program in response to the user request. As shown in the table of fig. 3a, the parameter data of the log information is recorded in json. Through the division of various data of the database table, the parameter data required by the log template can be quickly read.
The procedures that need to be logged are known to the business system. Therefore, variables corresponding to contents in the parameter data of the program can be preset in the code statements of the log template. For example, the operation time, the operator, the content related to the user operation in the log information, etc. may be written as preset variables into the code statements of the log template, so that when the log content needs to be generated, executing the code statements may reveal the log content with the parameter data of the operation time, the operator, the content related to the user operation, etc. in a preset form.
In step 220, the acquired parameter data is input into a preset variable of a code statement corresponding to the program unique identifier in the log template as required.
It should be noted that, the technical solution of the present disclosure is not limited to the implementation manner of the log template. The manner in which the parameter data is entered into the preset variables may be determined according to the log template implementation.
For example, the log template may be a simple text, and when the log content needs to be generated, the parameter data may be input into the preset variable by way of variable assignment or the like. The log content is generated by reading out a code statement from the log template and executing the code statement in the corresponding execution environment.
For another example, the log template may be a template engine that supports a plurality of script syntax rules and is operable to generate a view, for example, a template engine velocity template (Java-based template engine) that is operable to generate a view, and preset variables in the log template may be directly replaced with corresponding parameter data as needed. Accordingly, the code statements in the log template may be script statements written according to script syntax rules supported by the log template.
Wherein, the plurality of grammar rules supported by the log template are not limited. For example, the plurality of grammar rules supported by the log template may include: and grammar rules such as variable expression mode, condition judgment grammar and cycle grammar. For example, an exemplary log template is shown in FIG. 3 b. In the log template, "$ {" and "}" are variable expression modes, the content between "$ {" and "}" is a preset variable, and the preset variable is dynamically replaced by corresponding parameter data through step 220 in a running period.
In yet another possible implementation, as shown in fig. 3d as an exemplary log template content, the uniquely identifying the corresponding code statement by the program may include: the code statement which is uniquely identified by the class name, the program name and the success mark of the service code of the program and corresponds to the user under the condition of successful operation; and the code statement which is uniquely identified by the class name, the program name and the failure mark of the service code of the program and corresponds to the user operation failure condition is used. In this embodiment, a success flag indicating success of a user operation or a failure flag indicating failure of a user operation may be acquired from parameter data of the program intercepted by a log interceptor in response to the program being executed; under the condition that the success mark is obtained, inputting the obtained parameter data into a preset variable of a code statement which is uniquely identified by a class name of a service code where the program is located, a program name and the success mark together according to needs so as to generate log content which is displayed according to the code statement and describes the success of the user operation; and under the condition of acquiring the failure mark, inputting the acquired parameter data into a preset variable of a code statement which is uniquely identified by the class name of the service code of the program, the program name and the failure mark together according to needs so as to generate log content which is displayed according to the code statement and used for describing the operation failure of the user. By the implementation mode, two descriptions of success and failure of user operation are distinguished in the log template, so that the code statements of the log template conform to two different running states of a program, namely for one program, two log template data are provided, one corresponds to success of operation and the other corresponds to failure of operation, and the class name, the program name and the success or failure mark are used for unique identification, thereby ensuring that log contents in different preset forms can be presented according to two different states of success or failure of the program, and the log can be customized more flexibly according to requirements.
In step 230, by running the code statement corresponding to the program unique identifier, the log content in the preset form displayed according to the code statement is generated.
For example, in an embodiment where the log template is a template engine that supports a plurality of script syntax rules and is operable to generate a view, a view that presents preset-form log contents according to the script statements may be generated by operating the log template. In the embodiment, after the preset variables in the log template are correspondingly replaced by the required contents, the customized log contents can be generated by directly operating the log template, and the purpose of simply and efficiently generating the log contents in the preset form is achieved.
It should be noted that the preset form is specified by a code statement in the log template, and the code statement may specify the preset form including the presentation format, the presented text, and the like.
For example, in the log template content shown in fig. 3b, the script statement "# foreach ($ a in $ content [0]. arg0) $ { a.account }" is a loop, which indicates that two persons are associated with one organization in the log information, and the accounts are "testUser 1" and "testUser 2", respectively, and this loop is executed twice, and then the "account" attribute value in the data is displayed. The script statement "# if ($ velocityCount | $ ═ content [0]. arg0.size ())," is a condition judgment, and if the number of loop executions is not equal to the actual number of people, one is displayed, ". If the preset variable in the content of the log template shown in fig. 3b is replaced by the required content in the parameter data shown in fig. 3a, and the log template is run, the log content in the form shown in fig. 3c can be generated by the script statement in the content of the log template shown in fig. 3 b. Therefore, the script statements written by the grammar rules can show different preset forms of log contents under different preset conditions.
Therefore, the technical scheme of the disclosure obtains the parameter data of the program intercepted by the log interceptor in response to the program being executed, so that the log interceptor is used for realizing the decoupling of the data required by the log from the code of the program in an obtaining mode. And the preset log template comprises a code statement corresponding to the program unique identifier, wherein the code statement expresses the log content in the preset form of the program according to the preset variable under the preset condition, so that the acquired parameter data is correspondingly input into the corresponding preset variable of the log template, and the log content in the preset form shown according to the code statement can be generated by operating the code statement. Therefore, according to the log template of the technical scheme disclosed by the invention, as long as some contents in the parameter data can be defined as variables in the log template, the log contents in different preset forms are displayed under different preset conditions by using the code statements of the log template, the log contents can be flexibly adjusted in the deployment period, and the purpose of flexibly customizing the log is realized.
In order to make the log generation method provided by the technical solution of the present disclosure easier to understand, a possible implementation manner of the present disclosure is described in detail below with reference to the above embodiments.
Fig. 4 is a flowchart illustrating a method of log generation according to another exemplary embodiment of an aspect of the present disclosure. For example, the method may be applied to the computer 101 shown in fig. 1, and a log template is preset, where the log template is a template engine that supports a plurality of script syntax rules and can generate a view, and includes a script statement corresponding to a program unique identifier, and the script statement is a script statement written according to the script syntax rules supported by the log template and expresses that log content in a program preset form is displayed according to preset variables under a preset condition. As shown in fig. 4, the method may include:
in step 410, according to a log template, parameter data required by the program to uniquely identify a preset variable of a corresponding script statement is obtained from a log information storage, wherein the log information storage stores the parameter data of the program intercepted by the log interceptor in response to the program being executed.
In step 420, the preset variables in the log template are replaced with the corresponding parameter data as needed.
In step 430, a view showing the preset form of log content according to the script statement is generated by running the log template.
In the embodiment, the log information storage can store sufficient and comprehensive log information, even if the same log information is stored, different log templates can be customized according to needs, the needed partial content can be dynamically acquired from the log information storage according to needs, the preset variables in the log templates are correspondingly replaced by the needed content, and then the log template is directly operated, so that the log content in the preset form can be dynamically generated, and the purposes of flexibly customizing the log and simply, efficiently and dynamically generating the log content in the preset form are achieved.
Fig. 5 is a block diagram 500 illustrating a log generation apparatus according to another aspect of the present disclosure. For example, the apparatus may be configured in the computer 101 shown in fig. 1, and a log template is preset, where the log template includes a code statement corresponding to the program unique identifier, and the code statement expresses that log content in a preset form of the program is displayed according to a preset variable under a preset condition. As shown in fig. 5, the apparatus may include: a data acquisition module 510, a data input module 520, and a statement execution module 530.
The data obtaining module 510 may be configured to obtain, according to the log template, parameter data required by the program to uniquely identify a preset variable of a corresponding code statement from parameter data of the program intercepted by a log interceptor in response to the program being executed;
the data input module 520 may be configured to input the acquired parameter data into a preset variable of a code statement corresponding to the unique program identifier in the log template as needed;
the statement execution module 530 may be configured to generate a preset form of log content exhibited according to the code statement by executing the code statement corresponding to the program unique identifier.
Therefore, the technical scheme of the disclosure obtains the parameter data of the program intercepted by the log interceptor in response to the program being executed, so that the log interceptor is used for realizing the decoupling of the data required by the log from the code of the program in an obtaining mode. And the preset log template comprises a code statement corresponding to the program unique identifier, wherein the code statement expresses the log content in the preset form of the program according to the preset variable under the preset condition, so that the acquired parameter data is correspondingly input into the corresponding preset variable of the log template, and the log content in the preset form shown according to the code statement can be generated by operating the code statement. Therefore, according to the log template of the technical scheme disclosed by the invention, as long as some contents in the parameter data can be defined as variables in the log template, the log contents in different preset forms are displayed under different preset conditions by using the code statements of the log template, the log contents can be flexibly adjusted in the deployment period, and the purpose of flexibly customizing the log is realized.
Alternatively, the log template may be a template engine that supports multiple script grammar rules and may run a generated view. And the code statements in the log template are script statements written according to script grammar rules supported by the log template. The statement execution module 530 may be configured to generate a view showing preset forms of log contents according to the script statements by executing the log template. In the embodiment, after the preset variables in the log template are correspondingly replaced by the required contents, the customized log contents can be generated by directly operating the log template, and the purpose of simply and efficiently generating the log contents in the preset form is achieved.
Optionally, the data obtaining module 510 may be configured to obtain, according to the log template, parameter data required by the program to uniquely identify a preset variable of a corresponding code statement from a log information storage in which the parameter data of the program intercepted by the log interceptor in response to the program being executed is stored. In this embodiment, the log information storage can store sufficient and comprehensive log information, and even if the same log information is stored, different log templates can be customized as required, and the required content can be dynamically acquired from the log information storage as required to generate different log contents, thereby achieving the purpose of customizing the log more flexibly.
Optionally, the uniquely identifying, by the program, the corresponding code statement may include: the code statement which is uniquely identified by the class name, the program name and the success mark of the service code of the program and corresponds to the user under the condition of successful operation; and the code statement which is uniquely identified by the class name, the program name and the failure mark of the service code of the program and corresponds to the code statement under the condition of user operation failure is jointly identified. As shown in fig. 6, another exemplary embodiment of the present disclosure shows a block diagram 600 of a log generating apparatus, the data input module 520 may include: the flag obtaining sub-module 521 may be configured to obtain a success flag indicating success of the user operation or a failure flag indicating failure of the user operation from parameter data of the program intercepted by the log interceptor in response to the program being executed. The success data input sub-module 522 may be configured to, in a case that the success flag is obtained, input the obtained parameter data into the preset variables of the code statement, which are uniquely identified by the class name of the service code where the program is located, the program name, and the success flag together, in the log template as needed, so as to generate log content, which is displayed according to the code statement and describes that the user operation is successful. The failure data input sub-module 523 may be configured to, in a case that the failure flag is obtained, input the obtained parameter data into the preset variables of the code statement, which are uniquely identified by the class name of the service code where the program is located, the program name, and the failure flag, as needed, so as to generate log content, which is displayed according to the code statement and describes a user operation failure. By the implementation mode, two descriptions of success and failure of user operation are distinguished in the log template, so that the code statements of the log template conform to two different running states of a program, namely for one program, two log template data are provided, one corresponds to success of operation and the other corresponds to failure of operation, and the class name, the program name and the success or failure mark are used for unique identification, thereby ensuring that log contents in different preset forms can be presented according to two different states of success or failure of the program, and the log can be customized more flexibly according to requirements.
With regard to the apparatus in the above-described embodiment, the specific manner in which each module performs the operation has been described in detail in the embodiment related to the method, and will not be elaborated here.
Fig. 7 is a block diagram illustrating an electronic device 700 in accordance with an example embodiment. As shown in fig. 7, the electronic device 700 may include: a processor 701 and a memory 702. The electronic device 700 may also include one or more of a multimedia component 703, an input/output (I/O) interface 704, and a communication component 705.
The processor 701 is configured to control the overall operation of the electronic device 700, so as to complete all or part of the steps in the log generation method. The memory 702 is used to store various types of data to support operation at the electronic device 700, such as instructions for any application or method operating on the electronic device 700 and application-related data, such as contact data, transmitted and received messages, pictures, audio, video, and the like. The Memory 702 may be implemented by any type or combination of volatile and non-volatile Memory devices, such as Static Random Access Memory (SRAM), Electrically Erasable Programmable Read-Only Memory (EEPROM), Erasable Programmable Read-Only Memory (EPROM), Programmable Read-Only Memory (PROM), Read-Only Memory (ROM), magnetic Memory, flash Memory, magnetic or optical disk. The multimedia components 703 may include screen and audio components. Wherein the screen may be, for example, a touch screen and the audio component is used for outputting and/or inputting audio signals. For example, the audio component may include a microphone for receiving external audio signals. The received audio signal may further be stored in the memory 702 or transmitted through the communication component 705. The audio assembly also includes at least one speaker for outputting audio signals. The I/O interface 704 provides an interface between the processor 701 and other interface modules, such as a keyboard, mouse, buttons, and the like. These buttons may be virtual buttons or physical buttons. The communication component 705 is used for wired or wireless communication between the electronic device 700 and other devices. Wireless Communication, such as Wi-Fi, bluetooth, Near Field Communication (NFC), 2G, 3G, or 4G, or a combination of one or more of them, so that the corresponding Communication component 705 may include: Wi-Fi module, bluetooth module, NFC module.
In an exemplary embodiment, the electronic Device 700 may be implemented by one or more Application Specific Integrated Circuits (ASICs), Digital Signal Processors (DSPs), Digital Signal Processing Devices (DSPDs), Programmable Logic Devices (PLDs), Field Programmable Gate Arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components for performing the log generation method described above.
In another exemplary embodiment, there is also provided a computer readable storage medium comprising program instructions which, when executed by a processor, implement the steps of the log generation method described above. For example, the computer readable storage medium may be the memory 702 described above including program instructions that are executable by the processor 701 of the electronic device 700 to perform the log generation method described above.
The preferred embodiments of the present disclosure are described in detail with reference to the accompanying drawings, however, the present disclosure is not limited to the specific details of the above embodiments, and various simple modifications may be made to the technical solution of the present disclosure within the technical idea of the present disclosure, and these simple modifications all belong to the protection scope of the present disclosure.
It should be noted that the various features described in the above embodiments may be combined in any suitable manner without departing from the scope of the invention. In order to avoid unnecessary repetition, various possible combinations will not be separately described in this disclosure.
In addition, any combination of various embodiments of the present disclosure may be made, and the same should be considered as the disclosure of the present disclosure as long as it does not depart from the gist of the present disclosure.

Claims (8)

1. A log generation method is characterized in that a log template is preset, the log template comprises a code statement corresponding to a program unique identifier, the code statement expresses log content in a preset form of the program according to preset variables under a preset condition, and the method comprises the following steps:
according to the log template, acquiring parameter data required by a preset variable of a code statement uniquely identified by the program from the parameter data of the program intercepted by a log interceptor in response to the program being executed;
inputting the acquired parameter data into a preset variable of a code statement corresponding to the program unique identifier in the log template according to requirements;
generating preset log content displayed according to the code statement by operating the code statement corresponding to the unique program identifier;
wherein, the unique program identifier of the corresponding code statement includes:
the code statement which is uniquely identified by the class name, the program name and the success mark of the service code of the program and corresponds to the user under the condition of successful operation;
the code statement which is uniquely identified by the class name, the program name and the failure mark of the service code of the program and corresponds to the user operation failure condition is identified;
the inputting the acquired parameter data into the preset variable of the code statement corresponding to the program unique identifier in the log template according to the requirement comprises:
acquiring a success mark for representing success of a user operation or a failure mark for representing failure of the user operation from parameter data of the program intercepted by a log interceptor in response to the program being executed;
under the condition that the success mark is obtained, inputting the obtained parameter data into a preset variable of a code statement which is uniquely identified by a class name of a service code where the program is located, a program name and the success mark together according to needs so as to generate log content which is displayed according to the code statement and describes the success of the user operation;
and under the condition of acquiring the failure mark, inputting the acquired parameter data into a preset variable of a code statement which is uniquely identified by the class name of the service code of the program, the program name and the failure mark together according to needs so as to generate log content which is displayed according to the code statement and used for describing the operation failure of the user.
2. The method of claim 1, wherein the log template is a template engine that supports a plurality of script grammar rules and is executable to generate a view;
the code statement in the log template is a script statement written according to a script grammar rule supported by the log template;
the generating of the preset log content according to the code statement by operating the code statement corresponding to the program unique identifier includes:
and generating a view showing the preset form log content according to the script statement by operating the log template.
3. The method of claim 1, wherein the obtaining, according to the log template, parameter data required for the program to uniquely identify a preset variable of a corresponding code statement from parameter data of the program intercepted by a log interceptor in response to the program being executed comprises:
and acquiring parameter data required by the program to uniquely identify the preset variable of the corresponding code statement from a log information storage according to the log template, wherein the log information storage stores the parameter data of the program intercepted by the log interceptor in response to the program being executed.
4. A log generation device is characterized in that a log template is preset, the log template comprises a code statement corresponding to a program unique identifier, and the code statement expresses log contents in a preset form of the program according to preset variables under a preset condition, and the device comprises:
a data acquisition module configured to acquire, from parameter data of the program intercepted by a log interceptor in response to the program being executed, parameter data required for the program to uniquely identify a preset variable of a corresponding code statement, according to the log template;
the data input module is configured to input the acquired parameter data into a preset variable of a code statement corresponding to the program unique identifier in the log template as required;
the statement operation module is configured to operate the code statement corresponding to the program unique identifier to generate the log content in a preset form displayed according to the code statement;
wherein, the unique program identifier of the corresponding code statement includes:
the code statement which is uniquely identified by the class name, the program name and the success mark of the service code of the program and corresponds to the user under the condition of successful operation;
the code statement which is uniquely identified by the class name, the program name and the failure mark of the service code of the program and corresponds to the user operation failure condition is identified;
the data input module includes:
the mark acquisition sub-module is configured to acquire a success mark for indicating success of user operation or a failure mark for indicating failure of user operation from parameter data of the program intercepted by the log interceptor in response to the program being executed;
the success data input sub-module is configured to input the acquired parameter data into the log template as required and preset variables of a code statement which are uniquely identified by the class name, the program name and the success mark of the service code of the program under the condition of acquiring the success mark so as to generate log content which is displayed according to the code statement and describes the success of the user operation;
and the failure data input sub-module is configured to input the acquired parameter data into a preset variable of a code statement which is uniquely identified by the class name, the program name and the failure mark of the service code of the program in the log template according to needs under the condition that the failure mark is acquired, so as to generate log content which is displayed according to the code statement and describes user operation failure.
5. The apparatus of claim 4, wherein the log template is a template engine that supports a plurality of script grammar rules and is executable to generate a view;
the script statement in the log template is a script statement written according to script grammar rules supported by the log template;
the statement running module is configured to generate a view showing preset form log contents according to the script statements by running the log template.
6. The apparatus of claim 4, wherein the data obtaining module is configured to obtain parameter data required by the program to uniquely identify the preset variable of the corresponding code statement from a log information store according to the log template, wherein the log information store stores the parameter data of the program intercepted by the log interceptor in response to the program being executed.
7. A computer-readable storage medium, on which a computer program is stored which, when being executed by a processor, carries out the steps of the method according to any one of claims 1 to 3.
8. An electronic device, comprising:
a memory having a computer program stored thereon;
a processor for executing the computer program in the memory to carry out the steps of the method of any one of claims 1 to 3.
CN201811474321.XA 2018-12-04 2018-12-04 Log generation method and device Active CN109739735B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811474321.XA CN109739735B (en) 2018-12-04 2018-12-04 Log generation method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811474321.XA CN109739735B (en) 2018-12-04 2018-12-04 Log generation method and device

Publications (2)

Publication Number Publication Date
CN109739735A CN109739735A (en) 2019-05-10
CN109739735B true CN109739735B (en) 2022-05-31

Family

ID=66359158

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811474321.XA Active CN109739735B (en) 2018-12-04 2018-12-04 Log generation method and device

Country Status (1)

Country Link
CN (1) CN109739735B (en)

Families Citing this family (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110618912A (en) * 2019-08-29 2019-12-27 凡普数字技术有限公司 Method and device for monitoring equipment and storage medium
CN110825465B (en) * 2019-11-06 2024-05-07 北京达佳互联信息技术有限公司 Log data processing method and device, electronic equipment and storage medium
CN111400128B (en) * 2020-03-04 2022-09-02 平安科技(深圳)有限公司 Log management method and device, computer equipment and storage medium
CN112527747A (en) * 2020-12-23 2021-03-19 安徽航天信息有限公司 Log template configuration and display method and device
CN114500503A (en) * 2022-01-14 2022-05-13 广东好太太智能家居有限公司 Intelligent device offline log uploading method, intelligent device and readable medium

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102043704A (en) * 2009-10-14 2011-05-04 中兴通讯股份有限公司 Method and system for generating log information
CN103577443A (en) * 2012-07-30 2014-02-12 中国银联股份有限公司 Log processing system
CN105426453A (en) * 2015-11-10 2016-03-23 国云科技股份有限公司 Method for controlling log output grade through configuration item
CN107818024A (en) * 2017-11-22 2018-03-20 北京汇通金财信息科技有限公司 A kind of request ID transmission methods and system based on spring blockers
CN108804644A (en) * 2018-06-05 2018-11-13 中国平安人寿保险股份有限公司 Interface log storing method, device, computer equipment and storage medium

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US10049171B2 (en) * 2014-09-10 2018-08-14 Ca, Inc. Batch processed data structures in a log repository referencing a template repository and an attribute repository

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102043704A (en) * 2009-10-14 2011-05-04 中兴通讯股份有限公司 Method and system for generating log information
CN103577443A (en) * 2012-07-30 2014-02-12 中国银联股份有限公司 Log processing system
CN105426453A (en) * 2015-11-10 2016-03-23 国云科技股份有限公司 Method for controlling log output grade through configuration item
CN107818024A (en) * 2017-11-22 2018-03-20 北京汇通金财信息科技有限公司 A kind of request ID transmission methods and system based on spring blockers
CN108804644A (en) * 2018-06-05 2018-11-13 中国平安人寿保险股份有限公司 Interface log storing method, device, computer equipment and storage medium

Also Published As

Publication number Publication date
CN109739735A (en) 2019-05-10

Similar Documents

Publication Publication Date Title
CN109739735B (en) Log generation method and device
US10705942B1 (en) Simulated testing of API
US10565293B2 (en) Synchronizing DOM element references
CN108959631B (en) Method and device for querying information
US11157270B2 (en) Multi-platform pattern-based user interfaces
US10033835B2 (en) System, method, and device for remotely operating a server
CN108733375A (en) Web front-end configuration melts forwarding method, device, storage medium and computer equipment
US11609804B2 (en) Flexible event ingestion framework in an event processing system
CN114981775B (en) Cloud-based API metadata management method and system for integrated API management
CN111831542B (en) API application debugging method and device and storage medium
CN110765746B (en) Form automatic generation method and system based on event agent
JP6440895B2 (en) Software analysis apparatus and software analysis method
CN112558967A (en) Page automatic generation method and device, electronic equipment and storage medium
US11709759B2 (en) Contextual drill back to source code and other resources from log data
CN111104123A (en) Automatic deployment of applications
CN115904989A (en) Interface testing method, device, equipment and readable storage medium
US11379209B2 (en) Upgrade of a software product
US20160092414A1 (en) Standardized approach to contextual code identification in editors and ides
CN113778897A (en) Automatic test method, device, equipment and storage medium of interface
CN111736825B (en) Information display method, device, equipment and storage medium
CN112685678B (en) Page configuration method, page configuration device, computer equipment and storage medium
US20150317404A1 (en) Accessing Content in a Rich Internet Application
CN111858302B (en) Method and device for testing small program, electronic equipment and storage medium
JP6551082B2 (en) Test support apparatus, test support method, and test support program
US10530835B2 (en) Application recording

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
GR01 Patent grant
GR01 Patent grant