CN110888756A - Diagnostic log generation method and device - Google Patents

Diagnostic log generation method and device Download PDF

Info

Publication number
CN110888756A
CN110888756A CN201911132684.XA CN201911132684A CN110888756A CN 110888756 A CN110888756 A CN 110888756A CN 201911132684 A CN201911132684 A CN 201911132684A CN 110888756 A CN110888756 A CN 110888756A
Authority
CN
China
Prior art keywords
source code
code file
regular expression
target source
target
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
CN201911132684.XA
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.)
Alipay Hangzhou Information Technology Co Ltd
Original Assignee
Alipay Hangzhou Information Technology 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 Alipay Hangzhou Information Technology Co Ltd filed Critical Alipay Hangzhou Information Technology Co Ltd
Priority to CN201911132684.XA priority Critical patent/CN110888756A/en
Publication of CN110888756A publication Critical patent/CN110888756A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/0703Error or fault processing not based on redundancy, i.e. by taking additional measures to deal with the error or fault not making use of redundancy in operation, in hardware, or in data representation
    • G06F11/079Root cause analysis, i.e. error or fault diagnosis
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/32Monitoring with visual or acoustical indication of the functioning of the machine
    • G06F11/323Visualisation of programs or trace data
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/34Recording or statistical evaluation of computer activity, e.g. of down time, of input/output operation ; Recording or statistical evaluation of user activity, e.g. usability assessment
    • G06F11/3466Performance evaluation by tracing or monitoring
    • G06F11/3476Data logging

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Health & Medical Sciences (AREA)
  • Biomedical Technology (AREA)
  • Data Mining & Analysis (AREA)
  • Computer Hardware Design (AREA)
  • Debugging And Monitoring (AREA)

Abstract

One or more embodiments of the present specification provide a diagnostic log generation method and apparatus, where the method includes: firstly, a target source code file is obtained, wherein the target source code file comprises: a plurality of lines of source code; then, for each line of source code to be identified, identifying the source code by using a pre-configured regular expression set, and generating a diagnosis log for the source code; and finally, writing the diagnosis logs corresponding to the source codes in the target source code file into corresponding positions in the target source code file, so that subsequent related technicians can more intuitively perform abnormal reason investigation based on the target source code file embedded with the diagnosis logs.

Description

Diagnostic log generation method and device
Technical Field
The present invention relates to the field of internet technologies, and in particular, to a method and an apparatus for generating a diagnostic log.
Background
At present, with the rapid development of internet technology, various service application programs come into existence, and users can install required application programs on their clients according to their respective actual requirements; if the client detects that the user performs touch operation on an application program, the source code file corresponding to the application program is operated to provide corresponding business service for the user, but in the operation process of the source code file, the abnormal operation condition of the application program may occur, and a business service provider receives abnormal complaints from the client, so that related technicians are required to investigate the reason of the abnormal complaints.
Currently, the process of troubleshooting the abnormal reason of the application program mainly comprises: corresponding diagnosis logs need to be generated aiming at the source code files, so that the abnormal reasons are checked, and related technical personnel are effectively guided to maintain. However, at present, logic analysis is mainly performed on related source code files manually, a diagnosis log is generated manually, and then the diagnosis log is combined to determine the reason of the application abnormality. On one hand, the manual generation of the diagnostic log is inefficient and costly, and on the other hand, the accuracy of the generated diagnostic log is easily limited by the level of human experience.
Therefore, it is necessary to provide a diagnostic log generating method for a source code file with high accuracy and high efficiency.
Disclosure of Invention
One or more embodiments of the present disclosure provide a method and an apparatus for generating a diagnostic log, where a source code in a target source code file is filtered regularly, so as to achieve the purpose of accurately locating a source code type and a logical bifurcation point in the source code, and improve the efficiency and accuracy of generating the diagnostic log; meanwhile, the diagnosis logs are automatically generated in the running process of the target source code file, and the diagnosis logs generated aiming at each row of source codes are embedded into corresponding positions in the target source code file, so that subsequent related technicians can more intuitively perform abnormal reason troubleshooting based on the target source code file embedded with the diagnosis logs, and the abnormal reason troubleshooting efficiency is improved.
To solve the above technical problem, one or more embodiments of the present specification are implemented as follows:
one or more embodiments of the present specification provide a diagnostic log generating method including:
acquiring a target source code file, wherein the target source code file comprises: a plurality of lines of source code;
for each line of source codes to be identified, identifying the source codes by utilizing a pre-configured regular expression set, and generating a diagnosis log for the source codes;
and writing the diagnosis logs corresponding to the source codes in the target source code file into the target source code file.
One or more embodiments of the present specification provide a diagnostic log generating apparatus including:
a source code file obtaining module, configured to obtain a target source code file, where the target source code file includes: a plurality of lines of source code;
the regular expression identification module is used for identifying the source code to be identified in each row by utilizing a pre-configured regular expression set to generate a diagnosis log aiming at the source code;
and the diagnosis log writing module is used for writing the diagnosis logs corresponding to the source codes in the target source code file into the target source code file.
One or more embodiments of the present specification provide a diagnostic log generating apparatus including:
a processor; and a memory arranged to store computer executable instructions that, when executed, cause the processor to:
acquiring a target source code file, wherein the target source code file comprises: a plurality of lines of source code;
for each line of source codes to be identified, identifying the source codes by utilizing a pre-configured regular expression set, and generating a diagnosis log for the source codes;
and writing the diagnosis logs corresponding to the source codes in the target source code file into the target source code file.
One or more embodiments of the present specification provide a storage medium storing computer-executable instructions that, when executed by a processor, implement a method of:
acquiring a target source code file, wherein the target source code file comprises: a plurality of lines of source code;
for each line of source codes to be identified, identifying the source codes by utilizing a pre-configured regular expression set, and generating a diagnosis log for the source codes;
and writing the diagnosis logs corresponding to the source codes in the target source code file into the target source code file.
In one or more embodiments of the present description, a method and an apparatus for generating a diagnostic log first obtain a target source code file, where the target source code file includes: a plurality of lines of source code; then, for each line of source code to be identified, identifying the source code by using a pre-configured regular expression set, and generating a diagnosis log for the source code; and finally, respectively writing the diagnosis logs corresponding to the source codes in the target source code file into corresponding positions in the target source code file, so that subsequent related technicians can more intuitively perform abnormal reason investigation based on the target source code file embedded with the diagnosis logs. One or more embodiments of the present specification implement the purpose of accurately positioning the type of a source code and a logic branch point in the source code by performing regular filtering on the source code in a target source code file, and improve the generation efficiency and accuracy of a diagnostic log; meanwhile, the diagnosis logs are automatically generated in the running process of the target source code file, and the diagnosis logs generated aiming at each row of source codes are embedded into corresponding positions in the target source code file, so that subsequent related technicians can more intuitively perform abnormal reason troubleshooting based on the target source code file embedded with the diagnosis logs, and the abnormal reason troubleshooting efficiency is improved.
Drawings
In order to more clearly illustrate one or more embodiments or prior art solutions of the present specification, the drawings that are needed in the description of the embodiments or prior art will be briefly described below, it is obvious that the drawings in the following description are only some of the embodiments described in one or more of the specification, and that other drawings can be obtained by those skilled in the art without inventive exercise.
FIG. 1 is a first schematic flow diagram of a diagnostic log generation method provided in one or more embodiments of the present disclosure;
FIG. 2 is a second schematic flow diagram of a diagnostic log generation method according to one or more embodiments of the present disclosure;
FIG. 3 is a third schematic flow diagram of a diagnostic log generation method provided by one or more embodiments of the present disclosure;
FIG. 4 is a fourth flowchart of a diagnostic log generation method according to one or more embodiments of the present disclosure;
FIG. 5 is a fifth flowchart of a diagnostic log generation method according to one or more embodiments of the present disclosure;
fig. 6 is a schematic diagram illustrating a first module composition of a diagnostic log generation apparatus according to one or more embodiments of the present disclosure;
FIG. 7 is a schematic diagram illustrating a second module of a diagnostic log generation apparatus according to one or more embodiments of the present disclosure;
fig. 8 is a schematic structural diagram of a diagnostic log generation device according to one or more embodiments of the present disclosure.
Detailed Description
In order to make the technical solutions in one or more embodiments of the present disclosure better understood, the technical solutions in one or more embodiments of the present disclosure will be clearly and completely described below with reference to the accompanying drawings in one or more embodiments of the present disclosure, and it is obvious that the described embodiments are only a part of one or more embodiments of the present disclosure, but not all embodiments. All other embodiments that can be derived by a person skilled in the art from the embodiments described in one or more of the present specification without inventive step should be considered within the scope of protection of this document.
One or more embodiments of the present specification provide a diagnostic log generation method and apparatus, where a source code in a target source code file is regularly filtered, so as to achieve the purpose of accurately positioning a source code type and a logical bifurcation point in the source code, and improve diagnostic log generation efficiency and accuracy; meanwhile, the diagnosis logs are automatically generated in the running process of the target source code file, and the diagnosis logs generated aiming at each row of source codes are embedded into corresponding positions in the target source code file, so that subsequent related technicians can more intuitively perform abnormal reason troubleshooting based on the target source code file embedded with the diagnosis logs, and the abnormal reason troubleshooting efficiency is improved.
Fig. 1 is a first flowchart of a diagnostic log generation method provided in one or more embodiments of the present specification, where the method in fig. 1 can be executed by a user terminal, and the user terminal is configured to run a target source code file to provide a corresponding service for a user, as shown in fig. 1, the method at least includes the following steps:
s102, acquiring a target source code file, wherein the target source code file comprises: a plurality of lines of source code, each source code corresponding to a code line identification;
specifically, the target source code file may be a source code file that needs to be run to execute a certain application program, and when an execution request of a user for the certain application program is received, source code files under a source code file storage path of the target application program are automatically scanned, and one of the source code files is sequentially selected as a target source code file; then, scanning a plurality of lines of source codes in the currently selected target source code file line by line, and determining the currently scanned code line as the source code to be identified; after the current source code to be identified is subjected to regular identification, continuing to scan the next line of source codes to be used as the next source code to be identified;
s104, aiming at each line of source codes to be identified, identifying the source codes by utilizing a pre-configured regular expression set, and generating a diagnosis log aiming at the source codes;
the regular expression set comprises a plurality of regular expressions, if any regular expression is matched with the current source code to be identified, whether the current source code to be identified accords with the filtering logic of the regular expression can be determined, and further, the specific function contained in the current source code to be identified and the logic bifurcation passing through when the specific function is used can be determined; correspondingly, the diagnostic log may include: the running condition of the application programs such as the specific function passed by the current service data and the logic bifurcation passed by each function when the function is used;
s106, writing the diagnosis logs corresponding to the source codes in the target source code file into the target source code file;
specifically, in the specific implementation, after each line of source code in the target source code file generates a corresponding diagnosis log, the diagnosis log is inserted into a preset position of the corresponding source code in the target source code file, for example, a lower position of the source code, so that a subsequent relevant person can quickly identify one-to-one correspondence between the diagnosis log and the source code;
specifically, in the running process of a target application program, a preset regular expression set is utilized to perform regular identification filtering on source codes in a related source code file, and a corresponding diagnosis log is automatically generated by combining an identification filtering result, so that the use condition and the running condition of the application program are tracked, and the application program optimization and the running abnormal reason investigation are performed by combining a tracking result in the following process;
the diagnosis log generation process is suitable for source code files of various language types because the identification of the regular expression is not limited by the language type.
In one or more embodiments of the present description, the purpose of accurately positioning the type of a source code and a logic branch point in the source code is achieved by performing regular filtering on the source code in a target source code file, and the generation efficiency and accuracy of a diagnostic log are improved; meanwhile, the diagnosis logs are automatically generated in the running process of the target source code file, and the diagnosis logs generated aiming at each row of source codes are embedded into corresponding positions in the target source code file, so that subsequent related technicians can more intuitively perform abnormal reason troubleshooting based on the target source code file embedded with the diagnosis logs, and the abnormal reason troubleshooting efficiency is improved.
Considering that the diagnostic log is automatically generated in the process of running the user terminal, the generated source code file containing the diagnostic log is stored in the user terminal, and the server needs to perform function optimization and exception checking on the application program based on the source code file containing the diagnostic log, so that the user terminal needs to send the source code file containing the diagnostic log to the server, based on this, as shown in fig. 2, after writing the diagnostic logs corresponding to the source codes in the target source code file into the target source code file in the above S106, the method further includes:
s108, receiving a diagnosis log obtaining request sent by a server, wherein the diagnosis log obtaining request carries a source code file identifier;
specifically, after receiving complaint information of the user terminal for representing abnormal use of the application program, the background server determines identification information of the user terminal and identification information of a source code file required for running the application program based on the complaint information, and then sends a diagnosis log acquisition request to the corresponding user terminal; correspondingly, the user terminal receives the diagnosis log obtaining request;
s110, sending a source code file written with a diagnosis log corresponding to the source code file identifier to the server;
specifically, after receiving a diagnosis log acquisition request, a user terminal searches for a corresponding source code file based on a source code file identifier carried in the acquisition request, wherein when an application program runs, a corresponding diagnosis log is inserted into the source code file; the user terminal sends the searched source code file to the background server, so that the background server can acquire a diagnosis log of the source code file related to the application program of the abnormal complaint of the user terminal, and further carry out abnormal reason investigation by combining the diagnosis log;
in one or more embodiments of the present disclosure, considering that only when an application program is abnormal, the diagnosis log of a related source code file is needed to be used for troubleshooting of the abnormal reason, so to reduce traffic waste of a user terminal and reduce information processing amount of a server, a manner in which the server actively obtains the diagnosis log from the user terminal may be adopted instead of a manner in which the user terminal actively reports the diagnosis log.
As shown in fig. 3, in the step S104, for each line of source code to be identified, identifying the source code by using a pre-configured regular expression set, and generating a diagnostic log for the source code, specifically, the method includes:
s1041, sequentially selecting a regular expression from a pre-configured regular expression set to perform logic filtering on the source code aiming at each row of source codes to be identified to obtain a corresponding logic filtering result;
s1042, determining whether the source code is matched with the selected regular expression according to the determined logic filtering result;
specifically, the process of the logic filtering is a process of function type matching and statement block type matching, if the function type included in the current source code line to be identified is consistent with the function type filtered by the currently selected regular expression, and the statement block type related to the current source code line to be identified is consistent with the statement block type filtered by the currently selected regular expression, the obtained logic filtering result representation source code is matched with the regular expression, otherwise, the obtained logic filtering result representation source code is not matched with the regular expression, and whether the source code line is matched with other regular expressions needs to be continuously verified;
if yes, S1043 is executed, and a diagnosis log for the source code is generated according to the determined filtering logic corresponding to the regular expression matched with the source code;
specifically, if a regular expression matched with the current source code line is determined in the regular expression set, the function name and the code statement type included in the current source code line can be determined, that is, the specific function passed by the current source code line and the logic bifurcation passed by each function are identified, and then the diagnosis log corresponding to the current source code line is generated;
if not, executing S1044, selecting a next regular expression, and continuing to execute the step of S1041 until it is determined that the source code matches the currently selected regular expression or it is determined that the source code does not match each regular expression in the regular expression set, that is, until the regular expression matching the source code is determined for the first time or the regular expression matching the source code is not determined, and continuing to perform regular identification on the next line of source codes.
In S1043, generating a diagnostic log for the source code according to the determined filtering logic corresponding to the regular expression matched with the source code, specifically including:
step one, determining a function name and/or a code statement type contained in a source code according to a determined filtering logic corresponding to a regular expression matched with the source code;
the code statement type refers to a statement block type of a regular expression matched with a source code, and may also be referred to as a diagnostic type, for example, if, else, try, or catch;
secondly, generating a diagnosis log aiming at the source code according to the determined function name and/or code statement type;
specifically, the canonical format of the diagnostic log for each line of source code may be: function noun + number of lines the code is located + diagnostic type (e.g., if, else, try, or catch).
As shown in fig. 4, in step S106, writing the diagnostic logs corresponding to the source codes in the target source code file into the target source code file, specifically, the method includes:
s1061, aiming at each line of currently identified source code, determining a code line number identifier corresponding to the source code;
s1062, inserting the diagnosis log corresponding to the currently recognized source code into the preset position of the source code in the target source code file according to the determined code line number identification;
specifically, the diagnostics log may be inserted below the source code in the target source code file so that subsequent associated personnel can quickly identify the one-to-one correspondence between the diagnostics log and the source code.
Wherein, considering that when the regular identification is carried out for the source code to be identified, one regular expression needs to be selected in turn to be matched with the source code to be identified, if the matching is successful, then the regular identification of the source code is completed and a corresponding diagnostic log is generated, and if the matching is unsuccessful, then the next regular expression needs to be selected to match the source code to be identified, and therefore, the more advanced the regular expression matching the source code to be identified, the higher the regular identification efficiency, based on which, in order to improve the regular expression matching efficiency, thereby improving the generation efficiency of the diagnosis log, and specifically, in S1041, for each line of the source code to be identified, sequentially selecting a regular expression from a pre-configured regular expression set to perform logic filtering on the source code to obtain a corresponding logic filtering result, wherein the method specifically comprises the following steps:
the method comprises the steps that firstly, according to the type of a target source code file and/or a logic filtering result of a source code identified in advance, the selection priorities of a plurality of regular expressions in a pre-configured regular expression set are sorted;
specifically, based on the logic filtering result of the previously identified source code, the regular expression of the source code in the previous preset number of rows of the source code to be currently identified can be determined;
step two, sequentially selecting a regular expression from a pre-configured regular expression set according to the sequence of the selection priority from high to low;
and thirdly, performing logic filtering on the source code to be identified by using the currently selected regular expression to obtain a corresponding logic filtering result.
Specifically, before regular identification is carried out on a current source code line to be identified, a plurality of regular expressions in a regular expression set are subjected to selection priority ranking, and the regular expressions matched with the current source code line to be identified are taken as preferential selection objects as much as possible, so that the regular expressions matched with the current source code line to be identified can be quickly determined;
specifically, for the case that the number of regular expressions in the regular expression set is large, a machine learning model for regular expression ranking is obtained by training in advance by using a machine learning method and based on a model training sample set, wherein the model training sample set includes: a plurality of model training samples, each model training sample comprising: the sample source code correlation information comprises the correlation information of the sample source codes and the corresponding relation between regular expressions matched with the sample source codes, wherein the correlation information comprises the following steps: at least one of the type of a source code file to which the sample source code belongs and the regular expression matched with the source code lines of the sample source code in the preset number;
correspondingly, before regular recognition is carried out on a current source code line to be recognized, a plurality of regular expressions in a regular expression set are subjected to selection priority ranking by using a pre-trained machine learning model; specifically, at least one of the type of a target source code file and a regular expression matched with a previously identified source code is used as input of a pre-trained machine learning model, the machine learning model is used for determining the matching probability between each regular expression in a regular expression set and the current source code to be identified, and the regular expressions are subjected to selection priority ordering according to the sequence of the matching probabilities from high to low.
In the above S106, after writing the diagnosis logs corresponding to the source codes in the target source code file into the target source code file, the method further includes:
after inserting a diagnostic log corresponding to the currently identified source code into a target source code file, judging whether the currently identified source code is the last line of source codes in the target source code file;
if so, selecting a next target source code file in a preset constructed array until the currently selected target source code file is the last target source code file in the array;
and if not, determining the next line of source codes in the target source code file as the next source code to be identified.
Specifically, after regular identification is completed for a current source code line to be identified and a corresponding diagnosis log is generated, whether the current identified source code is the last line in a target source code file is judged, if yes, regular identification is completed for all code lines in the target source code file, and a next target source code file is continuously selected; if not, the regular identification of all code lines in the target source code file is not finished, and the next code line to be identified is continuously selected from the target source code file until the regular identification of all target source code files and all code lines is finished.
Further, in specific implementation, in order to ensure that each source code file can be automatically traversed in sequence as a target source code file in the process of performing regular identification on the source codes in the source code files, so as to perform regular identification on the source codes in each target source code file in sequence, a plurality of source code files may be sorted into an array in advance, and based on this, before the obtaining of the target source code file in the above S102, the method further includes:
acquiring a plurality of target source code files under a preset file storage path;
specifically, when an operation request of a target application program is detected, all applications under a source code file storage path of the target application program are automatically scanned, and a source code file with a correct file protocol is obtained;
secondly, constructing the obtained target source code files into an array according to the sequence of running the target source code files;
specifically, the acquired source code files are arranged into an array so as to automatically traverse each source code file, and the source codes in the source code files are subjected to regular identification filtering, so that corresponding diagnosis logs are generated according to identification filtering results.
In one particular embodiment, as shown in FIG. 5, if the regular expression set includes: regular expression 1(if regular judgment), regular expression 2(else regular judgment), regular expression 3(try regular judgment), and regular expression 4(catch regular judgment); correspondingly, when the source code in the source code file is subjected to regular identification, regular expressions in the regular expression set are sequentially selected to perform regular judgment on the source code to be identified currently, and a corresponding diagnosis log is generated, specifically:
s501, after an execution request of an application program is detected, scanning a target source code meeting the requirement of a preset protocol under a source code file storage path of the application program;
s502, arranging the obtained target source code files into an application program file array, and specifically, determining a source code file traversal sequence of the application program file array according to the sequence of the target source code files;
s503, traversing each source code file in the application program file array, and sequentially selecting a target source code file;
s504, scanning a plurality of source codes in the currently selected target source code file line by line;
s505, utilizing a pre-configured regular expression set to perform regular judgment on the currently scanned source code, generating a corresponding diagnosis log according to a regular judgment result, and inserting the diagnosis log below the currently scanned line; the method specifically comprises the following steps:
s5051, if regular judgment is carried out on the currently scanned source code line by using a regular expression 1 to judge whether the currently scanned source code line is matched with the regular expression 1, and specifically, whether the currently scanned source code line accords with the filtering logic of the regular expression 1 is judged;
if so, S5052 is executed to insert a diagnostic log: iapd diagnostic ("function name" + "code line" + "-if-"); specifically, a diagnostic log generated for a currently scanned source code line is inserted below the currently scanned source code line in a source code file;
if not, executing S5053, performing else regular judgment on the currently scanned source code line by using the regular expression 2 to judge whether the currently scanned source code line is matched, and specifically judging whether the currently scanned source code line meets the filtering logic of the regular expression 2;
if so, S5054 is executed to insert a diagnosis log: IAPD diagnostic ("function name" + "code line" + "-else-"); specifically, a diagnostic log generated for a currently scanned source code line is inserted below the currently scanned source code line in a source code file;
if not, executing S5055, performing try regular judgment on the currently scanned source code line by using the regular expression 3 to judge whether the currently scanned source code line is matched, and specifically judging whether the currently scanned source code line meets the filtering logic of the regular expression 3;
if so, execution proceeds to S5056, where a diagnostic log is inserted: IAPDiogicog ("function name" + "code line" + "-try-"); specifically, a diagnostic log generated for a currently scanned source code line is inserted below the currently scanned source code line in a source code file;
if not, S5057 is executed, catch regular judgment is carried out on the currently scanned source code line by using the regular expression 4 to judge whether the currently scanned source code line is matched, and specifically, whether the currently scanned source code line meets the filtering logic of the regular expression 4 is judged;
if so, S5058 is executed to insert a diagnostic log: IAPDiogicog ("function name" + "code line" + "-catch-"); specifically, a diagnostic log generated for a currently scanned source code line is inserted below the currently scanned source code line in a source code file;
if not, ending the regular judgment process aiming at the currently scanned source code line, and executing,
s506, judging whether the currently scanned source code line is the last line of source codes in the target source code file;
if not, namely the current scanning behavior is not the last line, continuing to execute the step S504, namely continuing to scan the next line of source codes in the currently selected target source code file;
if so, namely the last line of the current scanning behavior, executing S507, and judging whether the target source code file is the last source code file in the application program file array;
if not, that is, the current target source code file is not the last source code file, the step S503 is continuously executed, that is, the next target source code file is continuously selected from the array;
if so, namely the current target source code file is the last source code file, the diagnostic log generation process is ended.
In one or more embodiments of the present description, a diagnostic log generating method first obtains a target source code file, where the target source code file includes: a plurality of lines of source code; then, for each line of source code to be identified, identifying the source code by using a pre-configured regular expression set, and generating a diagnosis log for the source code; and finally, respectively writing the diagnosis logs corresponding to the source codes in the target source code file into corresponding positions in the target source code file, so that subsequent related technicians can more intuitively perform abnormal reason investigation based on the target source code file embedded with the diagnosis logs. One or more embodiments of the present specification implement the purpose of accurately positioning the type of a source code and a logic branch point in the source code by performing regular filtering on the source code in a target source code file, and improve the generation efficiency and accuracy of a diagnostic log; meanwhile, the diagnosis logs are automatically generated in the running process of the target source code file, and the diagnosis logs generated aiming at each row of source codes are embedded into corresponding positions in the target source code file, so that subsequent related technicians can more intuitively perform abnormal reason troubleshooting based on the target source code file embedded with the diagnosis logs, and the abnormal reason troubleshooting efficiency is improved.
On the basis of the same technical concept, corresponding to the diagnostic log generating method described in fig. 1 to 5, one or more embodiments of the present specification further provide a diagnostic log generating apparatus, and fig. 6 is a schematic diagram of a first module of the diagnostic log generating apparatus provided in one or more embodiments of the present specification, the apparatus is configured to execute the diagnostic log generating method described in fig. 1 to 5, and as shown in fig. 6, the apparatus includes:
a source code file obtaining module 601, configured to obtain a target source code file, where the target source code file includes: a plurality of lines of source code;
a regular expression identification module 602, configured to identify, for each line of the source code to be identified, the source code by using a preconfigured regular expression set, and generate a diagnostic log for the source code;
a diagnostic log writing module 603, configured to write the diagnostic logs corresponding to the source codes in the target source code file into the target source code file.
In one or more embodiments of the present description, the purpose of accurately positioning the type of a source code and a logic branch point in the source code is achieved by performing regular filtering on the source code in a target source code file, and the generation efficiency and accuracy of a diagnostic log are improved; meanwhile, the diagnosis logs are automatically generated in the running process of the target source code file, and the diagnosis logs generated aiming at each row of source codes are embedded into corresponding positions in the target source code file, so that subsequent related technicians can more intuitively perform abnormal reason troubleshooting based on the target source code file embedded with the diagnosis logs, and the abnormal reason troubleshooting efficiency is improved.
Optionally, the regular expression identification module 602 is specifically configured to
Sequentially selecting a regular expression from a pre-configured regular expression set to carry out logic filtering on the source code to obtain a corresponding logic filtering result;
determining whether the source code is matched with the selected regular expression or not according to the logic filtering result;
if yes, generating a diagnosis log aiming at the source code according to the filtering logic corresponding to the regular expression;
and if not, selecting the next regular expression until the source code is matched with the currently selected regular expression or the source code is determined not to be matched with all the regular expressions in the regular expression set.
Optionally, the regular expression identification module 602 is further specifically configured to:
determining function names and/or code statement types contained in the source codes according to the filtering logic corresponding to the regular expressions;
and generating a diagnosis log aiming at the source code according to the function name and/or the code statement type.
Optionally, the diagnostic log writing module 603 is specifically configured to:
for each line of the source code, determining a code line number identifier corresponding to the source code;
and inserting the diagnosis log into a preset position of the corresponding source code in the target source code file according to the code line number identification.
Optionally, the regular expression identification module 602 is further specifically configured to:
sorting the selection priorities of a plurality of regular expressions in a pre-configured regular expression set according to the type of the target source code file and/or a logic filtering result of a previously identified source code;
sequentially selecting a regular expression from a pre-configured regular expression set according to the sequence of the selection priority from high to low;
and performing logic filtering on the source code by using the currently selected regular expression to obtain a corresponding logic filtering result.
Optionally, as shown in fig. 7, the apparatus further includes: an object code determination module 604, configured to:
judging whether the currently identified source code is the last line of source code in the target source code file;
if so, selecting a next target source code file in a preset constructed array until the currently selected target source code file is the last target source code file in the array;
and if not, determining the next line of source codes in the target source code file as the next source code to be identified.
Optionally, the apparatus further comprises: a file array building module 605 configured to:
acquiring a plurality of target source code files under a preset file storage path;
and constructing the target source code files into an array according to the sequence of running the target source code files.
Optionally, the apparatus further comprises: :
a log obtaining and receiving module 606, configured to receive a diagnosis log obtaining request sent by a server, where the diagnosis log obtaining request carries a target source code file identifier;
the diagnostic log sending module 607 is configured to send the target source code file written with the diagnostic log corresponding to the target source code file identifier to the server.
In one or more embodiments of the present disclosure, a diagnostic log generating apparatus first obtains a target source code file, where the target source code file includes: a plurality of lines of source code; then, for each line of source code to be identified, identifying the source code by using a pre-configured regular expression set, and generating a diagnosis log for the source code; and finally, respectively writing the diagnosis logs corresponding to the source codes in the target source code file into corresponding positions in the target source code file, so that subsequent related technicians can more intuitively perform abnormal reason investigation based on the target source code file embedded with the diagnosis logs. One or more embodiments of the present specification implement the purpose of accurately positioning the type of a source code and a logic branch point in the source code by performing regular filtering on the source code in a target source code file, and improve the generation efficiency and accuracy of a diagnostic log; meanwhile, the diagnosis logs are automatically generated in the running process of the target source code file, and the diagnosis logs generated aiming at each row of source codes are embedded into corresponding positions in the target source code file, so that subsequent related technicians can more intuitively perform abnormal reason troubleshooting based on the target source code file embedded with the diagnosis logs, and the abnormal reason troubleshooting efficiency is improved.
It should be noted that the embodiment of the diagnostic log generation apparatus in this specification and the embodiment of the diagnostic log generation method in this specification are based on the same inventive concept, so that specific implementation of this embodiment may refer to implementation of the corresponding diagnostic log generation method, and repeated details are not repeated.
Further, corresponding to the methods shown in fig. 1 to 5, based on the same technical concept, one or more embodiments of the present specification further provide a diagnostic log generating apparatus for performing the diagnostic log generating method, as shown in fig. 8.
The diagnostic log generation device may vary significantly depending on configuration or performance, and may include one or more processors 801 and memory 802, where the memory 802 may have one or more stored applications or data stored therein. Wherein the memory 802 may be a transient storage or a persistent storage. The application program stored in memory 802 may include one or more modules (not shown), each of which may include a series of computer-executable instructions for a diagnostic log generation facility. Still further, the processor 801 may be configured to communicate with the memory 802 to execute a series of computer-executable instructions in the memory 802 on the diagnostic log generation device. The diagnostic log generation apparatus may also include one or more power supplies 803, one or more wired or wireless network interfaces 804, one or more input-output interfaces 805, one or more keyboards 806, and the like.
In a particular embodiment, the diagnostic log generation apparatus includes a memory, and one or more programs, wherein the one or more programs are stored in the memory, and the one or more programs may include one or more modules, and each module may include a series of computer-executable instructions for the diagnostic log generation apparatus, and the one or more programs configured to be executed by the one or more processors include computer-executable instructions for:
acquiring a target source code file, wherein the target source code file comprises: a plurality of lines of source code;
for each line of source codes to be identified, identifying the source codes by utilizing a pre-configured regular expression set, and generating a diagnosis log for the source codes;
and writing the diagnosis logs corresponding to the source codes in the target source code file into the target source code file.
In one or more embodiments of the present description, the purpose of accurately positioning the type of a source code and a logic branch point in the source code is achieved by performing regular filtering on the source code in a target source code file, and the generation efficiency and accuracy of a diagnostic log are improved; meanwhile, the diagnosis logs are automatically generated in the running process of the target source code file, and the diagnosis logs generated aiming at each row of source codes are embedded into corresponding positions in the target source code file, so that subsequent related technicians can more intuitively perform abnormal reason troubleshooting based on the target source code file embedded with the diagnosis logs, and the abnormal reason troubleshooting efficiency is improved.
Optionally, when executed, the identifying the source code with a pre-configured regular expression set, and generating a diagnostic log for the source code, include:
sequentially selecting a regular expression from a pre-configured regular expression set to carry out logic filtering on the source code to obtain a corresponding logic filtering result;
determining whether the source code is matched with the selected regular expression or not according to the logic filtering result;
if yes, generating a diagnosis log aiming at the source code according to the filtering logic corresponding to the regular expression;
and if not, selecting the next regular expression until the source code is matched with the currently selected regular expression or the source code is determined not to be matched with all the regular expressions in the regular expression set.
Optionally, when executed, the computer-executable instructions generate a diagnostic log for the source code according to the filter logic corresponding to the regular expression, including:
determining function names and/or code statement types contained in the source codes according to the filtering logic corresponding to the regular expressions;
and generating a diagnosis log aiming at the source code according to the function name and/or the code statement type.
Optionally, when executed, the writing the diagnostic logs corresponding to the source codes in the target source code file into the target source code file includes:
for each line of the source code, determining a code line number identifier corresponding to the source code;
and inserting the diagnosis log into a preset position of the corresponding source code in the target source code file according to the code line number identification.
Optionally, when the computer executable instruction is executed, sequentially selecting one regular expression from the pre-configured regular expression set to perform logic filtering on the source code to obtain a corresponding logic filtering result, where the logic filtering result includes:
sorting the selection priorities of a plurality of regular expressions in a pre-configured regular expression set according to the type of the target source code file and/or a logic filtering result of a previously identified source code;
sequentially selecting a regular expression from a pre-configured regular expression set according to the sequence of the selection priority from high to low;
and performing logic filtering on the source code by using the currently selected regular expression to obtain a corresponding logic filtering result.
Optionally, when executed, the computer-executable instructions, after writing the diagnosis logs respectively corresponding to the source codes in the target source code file into the target source code file, further include:
judging whether the currently identified source code is the last line of source code in the target source code file;
if so, selecting a next target source code file in a preset constructed array until the currently selected target source code file is the last target source code file in the array;
and if not, determining the next line of source codes in the target source code file as the next source code to be identified.
Optionally, the computer executable instructions, when executed, further comprise computer executable instructions for:
acquiring a plurality of target source code files under a preset file storage path;
and constructing the target source code files into an array according to the sequence of running the target source code files.
Optionally, when executed, the computer-executable instructions, after writing the diagnosis logs respectively corresponding to the source codes in the target source code file into the target source code file, further include:
receiving a diagnosis log obtaining request sent by a server, wherein the diagnosis log obtaining request carries a target source code file identifier;
and sending the target source code file written with the diagnosis log corresponding to the target source code file identification to the server.
In one or more embodiments of the present description, a diagnostic log generating device first obtains a target source code file, where the target source code file includes: a plurality of lines of source code; then, for each line of source code to be identified, identifying the source code by using a pre-configured regular expression set, and generating a diagnosis log for the source code; and finally, respectively writing the diagnosis logs corresponding to the source codes in the target source code file into corresponding positions in the target source code file, so that subsequent related technicians can more intuitively perform abnormal reason investigation based on the target source code file embedded with the diagnosis logs. One or more embodiments of the present specification implement the purpose of accurately positioning the type of a source code and a logic branch point in the source code by performing regular filtering on the source code in a target source code file, and improve the generation efficiency and accuracy of a diagnostic log; meanwhile, the diagnosis logs are automatically generated in the running process of the target source code file, and the diagnosis logs generated aiming at each row of source codes are embedded into corresponding positions in the target source code file, so that subsequent related technicians can more intuitively perform abnormal reason troubleshooting based on the target source code file embedded with the diagnosis logs, and the abnormal reason troubleshooting efficiency is improved.
It should be noted that the embodiment of the diagnostic log generation device in this specification and the embodiment of the diagnostic log generation method in this specification are based on the same inventive concept, so that specific implementation of this embodiment may refer to implementation of the corresponding diagnostic log generation method, and repeated details are not repeated.
Further, based on the same technical concept, corresponding to the methods shown in fig. 1 to fig. 5, one or more embodiments of the present specification further provide a storage medium for storing computer-executable instructions, where in a specific embodiment, the storage medium may be a usb disk, an optical disk, a hard disk, and the like, and the storage medium stores computer-executable instructions that, when executed by a processor, implement the following processes:
acquiring a target source code file, wherein the target source code file comprises: a plurality of lines of source code;
for each line of source codes to be identified, identifying the source codes by utilizing a pre-configured regular expression set, and generating a diagnosis log for the source codes;
and writing the diagnosis logs corresponding to the source codes in the target source code file into the target source code file.
In one or more embodiments of the present description, the purpose of accurately positioning the type of a source code and a logic branch point in the source code is achieved by performing regular filtering on the source code in a target source code file, and the generation efficiency and accuracy of a diagnostic log are improved; meanwhile, the diagnosis logs are automatically generated in the running process of the target source code file, and the diagnosis logs generated aiming at each row of source codes are embedded into corresponding positions in the target source code file, so that subsequent related technicians can more intuitively perform abnormal reason troubleshooting based on the target source code file embedded with the diagnosis logs, and the abnormal reason troubleshooting efficiency is improved.
Optionally, the computer-executable instructions stored in the storage medium, when executed by the processor, identify the source code using a pre-configured regular expression set, and generate a diagnostic log for the source code, include:
sequentially selecting a regular expression from a pre-configured regular expression set to carry out logic filtering on the source code to obtain a corresponding logic filtering result;
determining whether the source code is matched with the selected regular expression or not according to the logic filtering result;
if yes, generating a diagnosis log aiming at the source code according to the filtering logic corresponding to the regular expression;
and if not, selecting the next regular expression until the source code is matched with the currently selected regular expression or the source code is determined not to be matched with all the regular expressions in the regular expression set.
Optionally, when executed by a processor, the computer-executable instructions stored in the storage medium generate a diagnostic log for the source code according to the filter logic corresponding to the regular expression, including:
determining function names and/or code statement types contained in the source codes according to the filtering logic corresponding to the regular expressions;
and generating a diagnosis log aiming at the source code according to the function name and/or the code statement type.
Optionally, the computer-executable instructions stored in the storage medium, when executed by the processor, write the diagnosis logs corresponding to the source codes in the target source code file into the target source code file, respectively, includes:
for each line of the source code, determining a code line number identifier corresponding to the source code;
and inserting the diagnosis log into a preset position of the corresponding source code in the target source code file according to the code line number identification.
Optionally, when the computer executable instructions stored in the storage medium are executed by the processor, sequentially selecting one regular expression from the pre-configured regular expression set to perform logic filtering on the source code to obtain a corresponding logic filtering result, where the logic filtering result includes:
sorting the selection priorities of a plurality of regular expressions in a pre-configured regular expression set according to the type of the target source code file and/or a logic filtering result of a previously identified source code;
sequentially selecting a regular expression from a pre-configured regular expression set according to the sequence of the selection priority from high to low;
and performing logic filtering on the source code by using the currently selected regular expression to obtain a corresponding logic filtering result.
Optionally, the storage medium stores computer-executable instructions, which when executed by a processor, further include, after writing the diagnostic logs corresponding to the source codes in the target source code file into the target source code file, respectively:
judging whether the currently identified source code is the last line of source code in the target source code file;
if so, selecting a next target source code file in a preset constructed array until the currently selected target source code file is the last target source code file in the array;
and if not, determining the next line of source codes in the target source code file as the next source code to be identified.
Optionally, the storage medium stores computer executable instructions that, when executed by the processor, further implement the following process:
acquiring a plurality of target source code files under a preset file storage path;
and constructing the target source code files into an array according to the sequence of running the target source code files.
Optionally, the storage medium stores computer-executable instructions, which when executed by a processor, further include, after writing the diagnostic logs corresponding to the source codes in the target source code file into the target source code file, respectively:
receiving a diagnosis log obtaining request sent by a server, wherein the diagnosis log obtaining request carries a target source code file identifier;
and sending the target source code file written with the diagnosis log corresponding to the target source code file identification to the server.
In one or more embodiments of the present description, a storage medium stores computer-executable instructions that, when executed by a processor, first obtain a target source code file, where the target source code file includes: a plurality of lines of source code; then, for each line of source code to be identified, identifying the source code by using a pre-configured regular expression set, and generating a diagnosis log for the source code; and finally, respectively writing the diagnosis logs corresponding to the source codes in the target source code file into corresponding positions in the target source code file, so that subsequent related technicians can more intuitively perform abnormal reason investigation based on the target source code file embedded with the diagnosis logs. One or more embodiments of the present specification implement the purpose of accurately positioning the type of a source code and a logic branch point in the source code by performing regular filtering on the source code in a target source code file, and improve the generation efficiency and accuracy of a diagnostic log; meanwhile, the diagnosis logs are automatically generated in the running process of the target source code file, and the diagnosis logs generated aiming at each row of source codes are embedded into corresponding positions in the target source code file, so that subsequent related technicians can more intuitively perform abnormal reason troubleshooting based on the target source code file embedded with the diagnosis logs, and the abnormal reason troubleshooting efficiency is improved.
It should be noted that the embodiment of the storage medium in this specification and the embodiment of the diagnostic log generation method in this specification are based on the same inventive concept, and therefore, specific implementation of this embodiment may refer to implementation of the diagnostic log generation method described above, and repeated details are not repeated.
The foregoing description has been directed to specific embodiments of this disclosure. Other embodiments are within the scope of the following claims. In some cases, the actions or steps recited in the claims may be performed in a different order than in the embodiments and still achieve desirable results. In addition, the processes depicted in the accompanying figures do not necessarily require the particular order shown, or sequential order, to achieve desirable results. In some embodiments, multitasking and parallel processing may also be possible or may be advantageous.
In the 90 s of the 20 th century, improvements in a technology could clearly distinguish between improvements in hardware (e.g., improvements in circuit structures such as diodes, transistors, switches, etc.) and improvements in software (improvements in process flow). However, as technology advances, many of today's process flow improvements have been seen as direct improvements in hardware circuit architecture. Designers almost always obtain the corresponding hardware circuit structure by programming an improved method flow into the hardware circuit. Thus, it cannot be said that an improvement in the process flow cannot be realized by hardware physical modules. For example, a Programmable Logic Device (PLD), such as a Field Programmable Gate Array (FPGA), is an integrated circuit whose Logic functions are determined by programming the Device by a user. A digital system is "integrated" on a PLD by the designer's own programming without requiring the chip manufacturer to design and fabricate application-specific integrated circuit chips. Furthermore, nowadays, instead of manually making an integrated Circuit chip, such Programming is often implemented by "logic compiler" software, which is similar to a software compiler used in program development and writing, but the original code before compiling is also written by a specific Programming Language, which is called Hardware Description Language (HDL), and HDL is not only one but many, such as abel (advanced Boolean Expression Language), ahdl (alternate Language Description Language), traffic, pl (core unified Programming Language), Cal, jhdware Description Language, langua, mylar, pams, Hardware (Hardware Description Language), langva, Lola, HDL, palmware, Hardware (Hardware Description Language), VHDL (Hardware Description Language), and the like, which are currently used in the most popular languages. It will also be apparent to those skilled in the art that hardware circuitry that implements the logical method flows can be readily obtained by merely slightly programming the method flows into an integrated circuit using the hardware description languages described above.
The controller may be implemented in any suitable manner, for example, the controller may take the form of, for example, a microprocessor or processor and a computer-readable medium storing computer-readable program code (e.g., software or firmware) executable by the (micro) processor, logic gates, switches, an Application Specific Integrated Circuit (ASIC), a programmable logic controller, and an embedded microcontroller, examples of which include, but are not limited to, the following microcontrollers: ARC 625D, Atmel AT91SAM, Microchip PIC18F26K20, and Silicone Labs C8051F320, the memory controller may also be implemented as part of the control logic for the memory. Those skilled in the art will also appreciate that, in addition to implementing the controller as pure computer readable program code, the same functionality can be implemented by logically programming method steps such that the controller is in the form of logic gates, switches, application specific integrated circuits, programmable logic controllers, embedded microcontrollers and the like. Such a controller may thus be considered a hardware component, and the means included therein for performing the various functions may also be considered as a structure within the hardware component. Or even means for performing the functions may be regarded as being both a software module for performing the method and a structure within a hardware component.
The systems, devices, modules or units illustrated in the above embodiments may be implemented by a computer chip or an entity, or by a product with certain functions. One typical implementation device is a computer. In particular, the computer may be, for example, a personal computer, a laptop computer, a cellular telephone, a camera phone, a smartphone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.
For convenience of description, the above devices are described as being divided into various units by function, and are described separately. Of course, the functionality of the various elements may be implemented in the same one or more software and/or hardware implementations of one or more of the present descriptions.
As will be appreciated by one skilled in the art, one or more embodiments of the present description may be provided as a method, system, or computer program product. Accordingly, one or more of the present description may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, one or more of the present description may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied in the medium.
One or more of the present specification has been described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to one or more embodiments of the specification. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
In a typical configuration, a computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
The memory may include forms of volatile memory in a computer readable medium, Random Access Memory (RAM) and/or non-volatile memory, such as Read Only Memory (ROM) or flash memory (flash RAM). Memory is an example of a computer-readable medium.
Computer-readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), Static Random Access Memory (SRAM), Dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), Read Only Memory (ROM), Electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), Digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transmission medium that can be used to store information that can be accessed by a computing device. As defined herein, a computer readable medium does not include a transitory computer readable medium such as a modulated data signal and a carrier wave.
It should also be noted that the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.
As will be appreciated by one skilled in the art, one or more embodiments of the present description may be provided as a method, system, or computer program product. Accordingly, one or more of the present description may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, one or more of the present description may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied in the medium.
One or more of the present specification can be described in the general context of computer-executable instructions, such as program modules, being executed by a computer. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform particular tasks or implement particular abstract data types. One or more of the present specification can also be practiced in distributed computing environments where tasks are performed by remote processing devices that are linked through a communications network. In a distributed computing environment, program modules may be located in both local and remote computer storage media including memory storage devices.
The embodiments in the present specification are described in a progressive manner, and the same and similar parts among the embodiments are referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, for the system embodiment, since it is substantially similar to the method embodiment, the description is simple, and for the relevant points, reference may be made to the partial description of the method embodiment.
The above description is merely illustrative of one or more embodiments of the present disclosure and is not intended to limit one or more embodiments of the present disclosure. Various modifications and alterations to one or more of the present descriptions will be apparent to those skilled in the art. Any modification, equivalent replacement, improvement or the like made within the spirit and principle of one or more of the present specification should be included in the scope of one or more claims of the present specification.

Claims (18)

1. A diagnostic log generation method, comprising:
acquiring a target source code file, wherein the target source code file comprises: a plurality of lines of source code;
for each line of source codes to be identified, identifying the source codes by utilizing a pre-configured regular expression set, and generating a diagnosis log for the source codes;
and writing the diagnosis logs corresponding to the source codes in the target source code file into the target source code file.
2. The method of claim 1, wherein the identifying the source code using a pre-configured regular expression set, generating a diagnostic log for the source code, comprises:
sequentially selecting a regular expression from a pre-configured regular expression set to carry out logic filtering on the source code to obtain a corresponding logic filtering result;
determining whether the source code is matched with the selected regular expression or not according to the logic filtering result;
if yes, generating a diagnosis log aiming at the source code according to the filtering logic corresponding to the regular expression;
and if not, selecting the next regular expression until the source code is matched with the currently selected regular expression or the source code is determined not to be matched with all the regular expressions in the regular expression set.
3. The method of claim 2, wherein the generating a diagnostic log for the source code according to the filter logic corresponding to the regular expression comprises:
determining function names and/or code statement types contained in the source codes according to the filtering logic corresponding to the regular expressions;
and generating a diagnosis log aiming at the source code according to the function name and/or the code statement type.
4. The method of claim 1, wherein the writing the diagnostic logs respectively corresponding to the source codes in the target source code file to the target source code file comprises:
for each line of the source code, determining a code line number identifier corresponding to the source code;
and inserting the diagnosis log into a preset position of the corresponding source code in the target source code file according to the code line number identification.
5. The method according to claim 2, wherein the sequentially selecting one regular expression from the pre-configured regular expression set to perform the logic filtering on the source code to obtain a corresponding logic filtering result includes:
sorting the selection priorities of a plurality of regular expressions in a pre-configured regular expression set according to the type of the target source code file and/or a logic filtering result of a previously identified source code;
sequentially selecting a regular expression from a pre-configured regular expression set according to the sequence of the selection priority from high to low;
and performing logic filtering on the source code by using the currently selected regular expression to obtain a corresponding logic filtering result.
6. The method of claim 1, wherein after writing the diagnostic logs respectively corresponding to the source codes in the target source code file to the target source code file, further comprising:
judging whether the currently identified source code is the last line of source code in the target source code file;
if so, selecting a next target source code file in a preset constructed array until the currently selected target source code file is the last target source code file in the array;
and if not, determining the next line of source codes in the target source code file as the next source code to be identified.
7. The method of claim 6, further comprising:
acquiring a plurality of target source code files under a preset file storage path;
and constructing the target source code files into an array according to the sequence of running the target source code files.
8. The method of any of claims 1 to 7, wherein after writing the diagnostic logs corresponding to the source codes in the target source code file to the target source code file, further comprising:
receiving a diagnosis log obtaining request sent by a server, wherein the diagnosis log obtaining request carries a target source code file identifier;
and sending the target source code file written with the diagnosis log corresponding to the target source code file identification to the server.
9. A diagnostic log generation apparatus comprising:
a source code file obtaining module, configured to obtain a target source code file, where the target source code file includes: a plurality of lines of source code;
the regular expression identification module is used for identifying the source code to be identified in each row by utilizing a pre-configured regular expression set to generate a diagnosis log aiming at the source code;
and the diagnostic log writing module is used for writing the diagnostic logs corresponding to the source codes in the target source code file into the target source code file.
10. The apparatus of claim 9, wherein the regular expression identification module is specifically configured to
Sequentially selecting a regular expression from a pre-configured regular expression set to carry out logic filtering on the source code to obtain a corresponding logic filtering result;
determining whether the source code is matched with the selected regular expression or not according to the logic filtering result;
if yes, generating a diagnosis log aiming at the source code according to the filtering logic corresponding to the regular expression;
and if not, selecting the next regular expression until the source code is matched with the currently selected regular expression or the source code is determined not to be matched with all the regular expressions in the regular expression set.
11. The apparatus of claim 10, wherein the regular expression identification module is further specifically configured to:
determining function names and/or code statement types contained in the source codes according to the filtering logic corresponding to the regular expressions;
and generating a diagnosis log aiming at the source code according to the function name and/or the code statement type.
12. The apparatus of claim 9, wherein the diagnostic log writing module is specifically configured to:
for each line of the source code, determining a code line number identifier corresponding to the source code;
and inserting the diagnosis log into a preset position of the corresponding source code in the target source code file according to the code line number identification.
13. The apparatus of claim 10, wherein the regular expression identification module is further specifically configured to:
sorting the selection priorities of a plurality of regular expressions in a pre-configured regular expression set according to the type of the target source code file and/or a logic filtering result of a previously identified source code;
sequentially selecting a regular expression from a pre-configured regular expression set according to the sequence of the selection priority from high to low;
and performing logic filtering on the source code by using the currently selected regular expression to obtain a corresponding logic filtering result.
14. The apparatus of claim 9, further comprising: an object code determination module to:
judging whether the currently identified source code is the last line of source code in the target source code file;
if so, selecting a next target source code file in a preset constructed array until the currently selected target source code file is the last target source code file in the array;
and if not, determining the next line of source codes in the target source code file as the next source code to be identified.
15. The apparatus of claim 14, further comprising: a file array construction module for:
acquiring a plurality of target source code files under a preset file storage path;
and constructing the target source code files into an array according to the sequence of running the target source code files.
16. The apparatus of any of claims 9 to 15, further comprising: a diagnostic log sending module to:
receiving a diagnosis log obtaining request sent by a server, wherein the diagnosis log obtaining request carries a target source code file identifier;
and sending the target source code file written with the diagnosis log corresponding to the target source code file identification to the server.
17. A diagnostic log generation device comprising:
a processor; and
a memory arranged to store computer executable instructions that, when executed, cause the processor to:
acquiring a target source code file, wherein the target source code file comprises: a plurality of lines of source code;
for each line of source codes to be identified, identifying the source codes by utilizing a pre-configured regular expression set, and generating a diagnosis log for the source codes;
and writing the diagnosis logs corresponding to the source codes in the target source code file into the target source code file.
18. A storage medium storing computer-executable instructions that, when executed by a processor, implement a method of:
acquiring a target source code file, wherein the target source code file comprises: a plurality of lines of source code;
for each line of source codes to be identified, identifying the source codes by utilizing a pre-configured regular expression set, and generating a diagnosis log for the source codes;
and writing the diagnosis logs corresponding to the source codes in the target source code file into the target source code file.
CN201911132684.XA 2019-11-19 2019-11-19 Diagnostic log generation method and device Pending CN110888756A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201911132684.XA CN110888756A (en) 2019-11-19 2019-11-19 Diagnostic log generation method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201911132684.XA CN110888756A (en) 2019-11-19 2019-11-19 Diagnostic log generation method and device

Publications (1)

Publication Number Publication Date
CN110888756A true CN110888756A (en) 2020-03-17

Family

ID=69747926

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201911132684.XA Pending CN110888756A (en) 2019-11-19 2019-11-19 Diagnostic log generation method and device

Country Status (1)

Country Link
CN (1) CN110888756A (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111522708A (en) * 2020-04-10 2020-08-11 星环信息科技(上海)有限公司 Log recording method, computer equipment and storage medium
CN113778516A (en) * 2021-09-15 2021-12-10 山东派盟网络科技有限公司 Method, device and equipment for optimizing performance
CN115374737A (en) * 2022-10-25 2022-11-22 北京超摩科技有限公司 Simulation log analysis method and device based on denotation
CN115391232A (en) * 2022-10-28 2022-11-25 北京卡普拉科技有限公司 Program data stream diagnosis method, device and equipment

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107786545A (en) * 2017-09-29 2018-03-09 中国平安人寿保险股份有限公司 A kind of attack detection method and terminal device
CN108614704A (en) * 2017-01-17 2018-10-02 腾讯科技(深圳)有限公司 Code compiling method and device
CN109359028A (en) * 2018-08-22 2019-02-19 平安科技(深圳)有限公司 Code quality monitoring method, device, computer equipment and storage medium
CN109614469A (en) * 2018-12-03 2019-04-12 郑州云海信息技术有限公司 A kind of log analysis method and device
CN109800172A (en) * 2019-01-25 2019-05-24 上海创景信息科技有限公司 The system and method to be crashed based on EJTAG interface position embeded processor
CN109885478A (en) * 2018-12-30 2019-06-14 贝壳技术有限公司 A kind of localization method and system of error code
CN110427752A (en) * 2019-08-06 2019-11-08 北京智游网安科技有限公司 A kind of method, mobile terminal and the storage medium of sandbox monitoring application program

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108614704A (en) * 2017-01-17 2018-10-02 腾讯科技(深圳)有限公司 Code compiling method and device
CN107786545A (en) * 2017-09-29 2018-03-09 中国平安人寿保险股份有限公司 A kind of attack detection method and terminal device
CN109359028A (en) * 2018-08-22 2019-02-19 平安科技(深圳)有限公司 Code quality monitoring method, device, computer equipment and storage medium
CN109614469A (en) * 2018-12-03 2019-04-12 郑州云海信息技术有限公司 A kind of log analysis method and device
CN109885478A (en) * 2018-12-30 2019-06-14 贝壳技术有限公司 A kind of localization method and system of error code
CN109800172A (en) * 2019-01-25 2019-05-24 上海创景信息科技有限公司 The system and method to be crashed based on EJTAG interface position embeded processor
CN110427752A (en) * 2019-08-06 2019-11-08 北京智游网安科技有限公司 A kind of method, mobile terminal and the storage medium of sandbox monitoring application program

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111522708A (en) * 2020-04-10 2020-08-11 星环信息科技(上海)有限公司 Log recording method, computer equipment and storage medium
CN111522708B (en) * 2020-04-10 2021-08-24 星环信息科技(上海)股份有限公司 Log recording method, computer equipment and storage medium
CN113778516A (en) * 2021-09-15 2021-12-10 山东派盟网络科技有限公司 Method, device and equipment for optimizing performance
CN115374737A (en) * 2022-10-25 2022-11-22 北京超摩科技有限公司 Simulation log analysis method and device based on denotation
CN115391232A (en) * 2022-10-28 2022-11-25 北京卡普拉科技有限公司 Program data stream diagnosis method, device and equipment
CN115391232B (en) * 2022-10-28 2023-04-11 北京卡普拉科技有限公司 Program data stream diagnosis method, device and equipment

Similar Documents

Publication Publication Date Title
CN110888756A (en) Diagnostic log generation method and device
CN107274442B (en) Image identification method and device
CN110705214A (en) Automatic coding method and device
CN108363634B (en) Method, device and equipment for identifying service processing failure reason
CN109241026B (en) Data management method, device and system
CN110502227B (en) Code complement method and device, storage medium and electronic equipment
US8904352B2 (en) Systems and methods for processing source code during debugging operations
CN107066519B (en) Task detection method and device
CN110674408A (en) Service platform, and real-time generation method and device of training sample
CN110580189A (en) method and device for generating front-end page, computer equipment and storage medium
CN110635962A (en) Abnormity analysis method and device for distributed system
CN115455166A (en) Method, device, medium and equipment for detecting abnormality of intelligent dialogue system
CN113079201B (en) Information processing system, method, device and equipment
CN112364185A (en) Method and device for determining characteristics of multimedia resource, electronic equipment and storage medium
CN110968500A (en) Test case execution method and device
CN110245136B (en) Data retrieval method, device, equipment and storage equipment
CN114840427A (en) Code testing and test case generating method and device
CN110704742B (en) Feature extraction method and device
CN109376289B (en) Method and device for determining target application ranking in application search result
CN113987107A (en) Dialogue method and device based on behavior tree, electronic equipment and storage medium
CN114282586A (en) Data annotation method, system and electronic equipment
CN115757302B (en) Data analysis method, device, equipment and storage medium
CN111427870B (en) Resource management method, device and equipment
CN112527387B (en) Application processing method and device
CN111401011B (en) Information processing method and device and electronic equipment

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
RJ01 Rejection of invention patent application after publication

Application publication date: 20200317

RJ01 Rejection of invention patent application after publication