CN112445896A - Method, device, terminal and storage medium for inquiring log - Google Patents
Method, device, terminal and storage medium for inquiring log Download PDFInfo
- Publication number
- CN112445896A CN112445896A CN202011381544.9A CN202011381544A CN112445896A CN 112445896 A CN112445896 A CN 112445896A CN 202011381544 A CN202011381544 A CN 202011381544A CN 112445896 A CN112445896 A CN 112445896A
- Authority
- CN
- China
- Prior art keywords
- target
- keyword
- log
- keywords
- queried
- 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
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/30—Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
- G06F16/33—Querying
- G06F16/3331—Query processing
- G06F16/3332—Query translation
- G06F16/3334—Selection or weighting of terms from queries, including natural language queries
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/30—Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
- G06F16/33—Querying
- G06F16/3331—Query processing
- G06F16/334—Query execution
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Computational Linguistics (AREA)
- Data Mining & Analysis (AREA)
- Databases & Information Systems (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Artificial Intelligence (AREA)
- Debugging And Monitoring (AREA)
Abstract
The invention is suitable for the technical field of computers, and provides a method, a device, a terminal and a storage medium for inquiring logs, wherein the method comprises the following steps: splitting the target log based on the keywords to be queried to obtain a plurality of non-target keywords; determining the ending position of each non-target keyword; determining the position of each target keyword based on the ending position and the length of the character string corresponding to the keyword to be queried; each target keyword in the target log is queried based on the location. By the method, all query results can be obtained without inquiring the target logs for many times, developers and testers can search corresponding log contents at the terminal anytime and anywhere conveniently, convenience is brought to development and test of application programs, small programs and the like, and development and test efficiency is improved. And no matter which character string is taken as the initial position to traverse, the final finding of the parcel is not influenced by the query mode, and the accuracy of the log query result is improved.
Description
Technical Field
The invention belongs to the technical field of computers, and particularly relates to a log query method, a log query device, a log query terminal and a storage medium.
Background
In the process of developing a mobile Application (APP), in order to better locate problems occurring in the APP and monitor indexes of various performances in the APP, logs corresponding to the APP need to be stored and checked, developers and testers can know the running condition of the APP at any time, and bugs (bugs) generated in the APP are located.
In the prior art, a log corresponding to an APP is usually imported into a computer terminal through copying, forwarding, troubleshooting (Debug) and other modes, and the specified log is checked by opening and searching a corresponding keyword through the computer.
If the mobile terminal needs to search corresponding log contents, the position of the keyword in the whole log system is searched through a system function, or the whole character string is traversed, the log is compared with the searched keywords one by one, and the keyword search in the log is realized. The two methods for searching the designated log content at the mobile terminal only can obtain one searching result in each searching, if all the searching results are to be searched, recursive cyclic processing is required, the terminal performance is consumed, and resources are wasted; the latter will cause the search result to change if the initial position of the character string changes every time the character string is traversed. Therefore, developers and testers cannot search corresponding log contents at the mobile terminal anytime and anywhere, obstruction is brought to development and testing of the APP, and the efficiency of development and testing of the APP is reduced.
Disclosure of Invention
In view of this, embodiments of the present invention provide a method, an apparatus, a terminal and a storage medium for querying a log, so as to solve the problems in the prior art that a query manner of querying a log is complicated, or a query result is inaccurate, so that developers and testers cannot search for corresponding log content at a mobile terminal anytime and anywhere, thereby bringing obstacles to developing and testing an APP and reducing efficiency of developing and testing the APP.
A first aspect of an embodiment of the present invention provides a method for querying a log, including:
splitting the target log based on the keywords to be queried to obtain a plurality of non-target keywords;
determining the ending position of each non-target keyword in the target log based on the character string length corresponding to each non-target keyword and the character string length corresponding to the keyword to be queried;
determining the position of each target keyword in the target log based on the ending position and the length of the character string corresponding to the keyword to be queried, wherein the target log comprises at least one target keyword;
querying each target keyword in the target log based on the location.
According to the method and the device for searching the target logs, the target logs are split to obtain a plurality of non-target keywords, the ending positions of the non-target keywords in the target logs are determined according to the character string lengths corresponding to the non-target keywords and the character string lengths corresponding to the keywords to be searched, the positions of the target keywords in the target logs are determined according to the ending positions and the character string lengths corresponding to the keywords to be searched, and the target keywords in the target logs are searched based on the positions. The target log is not required to be queried for many times, all query results can be obtained, consumption of terminal performance is saved, resources are saved, developers and testers can conveniently find corresponding log contents at the terminal anytime and anywhere, convenience is brought to development and testing of application programs, small programs and the like, and development and testing efficiency is improved. Because the target logs are split based on the keywords to be queried and the position of each target keyword is further obtained, the final finding of the parcel cannot be influenced no matter which character string is traversed as the initial position in the query mode, and the accuracy of the log query result is improved.
Optionally, the non-target keywords and the target keywords are arranged alternately, and the determining the position of each target keyword in the target log based on the ending position and the length of the character string corresponding to the keyword to be queried includes:
aiming at each target keyword, acquiring an ending position corresponding to a previous non-target keyword of the target keyword;
adding a numerical value corresponding to the ending position of the previous non-target keyword with a preset numerical value to obtain a first numerical value, wherein the first numerical value is used for representing the starting position corresponding to the target keyword;
and adding a numerical value corresponding to the ending position of the previous non-target keyword and the length of the character string corresponding to the keyword to be inquired to obtain a second numerical value, wherein the second numerical value is used for representing the ending position corresponding to the target keyword.
Optionally, the determining, based on the length of the character string corresponding to each non-target keyword and the length of the character string corresponding to the keyword to be queried, an ending position of each non-target keyword in the target log includes:
adding a numerical value corresponding to the end position of the i-1 th non-target keyword, the length of a character string corresponding to the i-th non-target keyword and the length of a character string corresponding to the keyword to be queried to obtain a numerical value used for representing the end position corresponding to the i-th non-target keyword, wherein the value of i is 2, 3.. N;
and the numerical value corresponding to the ending position of the 1 st non-target keyword is the same as the length of the character string corresponding to the 1 st non-target keyword.
Optionally, the splitting the target log based on the keyword to be queried to obtain a plurality of non-target keywords includes:
and calling a preset function to split the target log according to the keywords to be inquired to obtain a plurality of non-target keywords.
Optionally, the content of the character string corresponding to the keyword to be queried is the same as the content of the character string corresponding to each target keyword.
Optionally, after querying each target keyword in the target log based on the location, the method further includes:
each target keyword is prominently labeled.
Optionally, before splitting the target log based on the keyword to be queried to obtain a plurality of non-target keywords, the method further includes:
when a log query request is acquired, displaying a plurality of query keywords on a query interface;
and determining the keywords to be queried in the plurality of query keywords.
Optionally, after determining the position of each target keyword in the target log based on the ending position and the length of the character string corresponding to the keyword to be queried, the method further includes:
and uploading the keywords to be queried, the target logs and the positions of each target keyword in the target logs to a block chain.
A second aspect of an embodiment of the present application provides an apparatus for querying a log, including:
the splitting unit is used for splitting the target log based on the keywords to be inquired to obtain a plurality of non-target keywords;
a first determining unit, configured to determine an end position of each non-target keyword in the target log based on a character string length corresponding to each non-target keyword and a character string length corresponding to the keyword to be queried;
a second determining unit, configured to determine, based on the ending position and a length of a character string corresponding to the keyword to be queried, a position of each target keyword in the target log, where the target log includes at least one target keyword;
and the query unit is used for querying each target keyword in the target log based on the position.
A third aspect of the embodiments of the present application provides a terminal for querying a log, including a memory, a processor, and a computer program stored in the memory and executable on the processor, where the processor executes the computer program to implement the steps of the method for querying a log according to the first aspect.
A fourth aspect of embodiments of the present application provides a computer storage medium storing a computer program which, when executed by a processor, implements the steps of the method for querying a log as described in the first aspect.
A fifth aspect of embodiments of the present application provides a computer program product, which, when running on a terminal for querying a log, causes the terminal for querying the log to execute the steps of the method for querying the log according to the first aspect.
The method for inquiring the log, the device for inquiring the log, the terminal for inquiring the log and the storage medium have the following advantages that:
according to the method and the device for searching the target logs, the target logs are split to obtain a plurality of non-target keywords, the ending positions of the non-target keywords in the target logs are determined according to the character string lengths corresponding to the non-target keywords and the character string lengths corresponding to the keywords to be searched, the positions of the target keywords in the target logs are determined according to the ending positions and the character string lengths corresponding to the keywords to be searched, and the target keywords in the target logs are searched based on the positions. The target log is not required to be queried for many times, all query results can be obtained, consumption of terminal performance is saved, resources are saved, developers and testers can conveniently find corresponding log contents at the terminal anytime and anywhere, convenience is brought to development and testing of application programs, small programs and the like, and development and testing efficiency is improved. Because the target logs are split based on the keywords to be queried and the position of each target keyword is further obtained, the final finding of the parcel cannot be influenced no matter which character string is traversed as the initial position in the query mode, and the accuracy of the log query result is improved.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings needed to be used in the embodiments or the prior art descriptions will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without inventive exercise.
FIG. 1 is a flowchart illustrating an implementation of a method for querying a log according to an embodiment of the present invention;
FIG. 2 is a schematic flow chart diagram illustrating a method for querying a log according to another embodiment of the present application;
FIG. 3 is a schematic flow chart diagram illustrating a method for querying a log according to another embodiment of the present application;
FIG. 4 is a diagram illustrating an apparatus for querying a log according to an embodiment of the present invention;
fig. 5 is a schematic diagram of a terminal for querying a log according to another embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
In the development APP process, for the better problem that appears in the location APP and the index of each performance in the monitoring APP, the log that this APP corresponds need to be preserved and checked, the operating conditions of APP, the leak bug that produces in the location APP are known at any time to the developer of being convenient for and testing personnel. In the prior art, a log corresponding to an APP is usually imported into a computer terminal through copying, forwarding, eliminating a fault and the like, and the specified log is checked by opening and searching a corresponding keyword through the computer.
If the mobile terminal needs to search corresponding log contents, the position of the keyword in the whole log system is searched through a system function, or the whole character string is traversed, the log is compared with the searched keywords one by one, and the keyword search in the log is realized. The two methods for searching the designated log content at the mobile terminal only can obtain one searching result in each searching, if all the searching results are to be searched, recursive cyclic processing is required, the terminal performance is consumed, and resources are wasted; the latter will cause the search result to change if the initial position of the character string changes every time the character string is traversed. In the prior art, the log query mode is complicated, or the query result is inaccurate, so that developers and testers cannot find corresponding log contents at the mobile terminal anytime and anywhere, the development and test APP are hindered, and the efficiency of the development and test APP is reduced.
In view of this, the present application provides a method for querying a log, in which a target log is split based on a keyword to be queried to obtain a plurality of non-target keywords; determining the ending position of each non-target keyword in the target log based on the character string length corresponding to each non-target keyword and the character string length corresponding to the keyword to be queried; determining the position of each target keyword in the target log based on the ending position and the length of the character string corresponding to the keyword to be queried, wherein the target log comprises at least one target keyword; querying each target keyword in the target log based on the location. According to the scheme, all query results can be obtained without inquiring the target logs for many times, so that the consumption of the terminal performance is saved, resources are saved, developers and testers can conveniently search corresponding log contents at any time and any place in the terminal, convenience is brought to development and testing of application programs, small programs and the like, and the development and testing efficiency is improved. Because the target logs are split based on the keywords to be queried and the position of each target keyword is further obtained, the final finding of the parcel cannot be influenced no matter which character string is traversed as the initial position in the query mode, and the accuracy of the log query result is improved.
Referring to fig. 1, fig. 1 is a schematic flow chart of a method for querying a log according to an embodiment of the present invention. The execution main body of the method for querying the log in the embodiment is a terminal, and the terminal includes but is not limited to a mobile terminal such as a smart phone, a tablet computer, a Personal Digital Assistant (PDA), and the like, and may also include a terminal such as a desktop computer, a server, and the like. The method for querying the log as shown in fig. 1 may include steps S101 to S103, which are as follows:
s101: and splitting the target log based on the keywords to be queried to obtain a plurality of non-target keywords.
The target log may be a log generated by a developer in the process of developing the APP, a log generated by a tester in the process of testing the APP, or a log which is acquired in advance and needs to be subjected to keyword query. The keywords to be queried are the contents to be queried in the target log, and the keywords to be queried can be preset or can be determined according to the selection of developers. Illustratively, the keywords to be queried may be characters, Chinese characters, numbers, etc., and the contrast is not limited.
The terminal splits the target log based on the keywords to be inquired, and a plurality of non-target keywords can be obtained. Specifically, the target log can be split through a preset computer program to obtain a plurality of non-target keywords. And calling a preset function to split the target log according to the keywords to be queried to obtain a plurality of non-target keywords. The target log comprises a plurality of non-target keywords and target keywords, the target keywords are keywords which are required to be inquired in the target log finally, and the non-target keywords are character strings in the target log except the target keywords.
Illustratively, the preset function may be: components Separated By String. And splitting the target log through a preset function by taking the keywords to be inquired as a basis to obtain a plurality of ordered character strings excluding the target keywords, namely a plurality of non-target keywords.
For example, the keywords to be queried are: 123, the target log may be: jhge123kh4tn123ngo6eh1233nrge3123ehgf12 es. At this time, the target keyword we need to find in the target log is 123. It should be noted that the content of the character string corresponding to the keyword to be queried is the same as the content of the character string corresponding to each target keyword. For example, the keywords to be queried are: 123, the target keywords to be queried in the target log are also: 123. the number of the target keywords is not limited, and may be zero, one, or multiple, subject to the content actually existing in the target log.
Illustratively, the terminal calls a preset function [ log components Separated By String: key ], based on the keyword "123" to be queried, splits the target log "jhge 123kh4tn123ngo6eh1233nrge3123ehgf12 es" to obtain a plurality of ordered non-target keywords excluding the target keyword "123", specifically, "jhge, kh4tn, ngo6eh, 3nrge3, ehgf12 es". It can be clearly seen that after splitting, a plurality of non-target keywords are obtained after the target keyword "123" is removed, and the non-target keywords are orderly arranged according to the sequence in the target log. In order to facilitate the terminal to process the non-target keywords subsequently, an array arr may be established for the plurality of non-target keywords, that is, the array arr [ jhge, kh4tn, ngo6eh, 3nrge3, ehgf12es ].
S102: and determining the ending position of each non-target keyword in the target log based on the character string length corresponding to each non-target keyword and the character string length corresponding to the keyword to be queried.
And acquiring the length of the character string corresponding to each non-target keyword. The target log may include a plurality of non-target keywords, and the non-target keywords and the target keywords are arranged alternately in the target log. The non-target keywords are the character strings in the target log except the target keywords. And the terminal acquires the length of the character string corresponding to each non-target keyword.
For example, the target log is jhge123kh4tn123ngo6eh1233nrge3123ehgf12es, and the target keywords are: 123, the non-target keywords are: jhge, kh4tn, ngo6eh, 3nrge3 and ehgf12 es. The terminal traverses an array arr [ jhge, kh4tn, ngo6eh, 3nrge3 and ehgf12es ], and the lengths of the character strings corresponding to the obtained non-target keywords are respectively as follows: 4. 5, 6 and 8.
For the 1 st non-target keyword, the length of the character string corresponding to the non-target keyword can be used to indicate the end position of the non-target keyword in the target log. For example, when the non-target keyword is jhge, the string length corresponding to jhge is 4, and the numeric value corresponding to the end position in the target log is also 4.
Except for the 1 st non-target keyword, adding the character string length corresponding to the non-target keyword, the character string length corresponding to the keyword to be queried and the numerical value corresponding to the ending position of the previous non-target keyword adjacent to the character string length corresponding to the non-target keyword to each of the rest non-target keywords, wherein the obtained numerical value is used for representing the ending position of the non-target keyword in the target log. For example, for the 2 nd non-target keyword kh4tn, the corresponding string length is 5, the string length corresponding to the keyword 123 to be queried is 3, the string length corresponding to the adjacent non-target keyword jhge is 4, the sum of the three is 12, and 12 is used to indicate the end position of the 2 nd non-target keyword in the target log.
Optionally, in a possible implementation manner, the number of non-target keywords is N, where N is an integer greater than or equal to 1, and the S102 may include: adding a numerical value corresponding to the end position of the i-1 th non-target keyword, the length of a character string corresponding to the i-th non-target keyword and the length of a character string corresponding to the keyword to be queried to obtain a numerical value used for representing the end position corresponding to the i-th non-target keyword, wherein the value of i is 2, 3.. N;
and the numerical value corresponding to the ending position of the 1 st non-target keyword is the same as the length of the character string corresponding to the 1 st non-target keyword.
Illustratively, the string length corresponding to the 1 st non-target keyword may be used to indicate the end position of the 1 st non-target keyword in the target log.
Illustratively, with the non-target keywords as: jhge, kh4tn, ngo6eh, 3nrge3 and ehgf12es are given as examples. The length of the character string corresponding to the 1 st non-target keyword jhge is 4, and the numerical value corresponding to the ending position in the target log is also 4.
And when the value of i is 2, adding a numerical value corresponding to the ending position of the 1 st non-target keyword, the length of the character string corresponding to the 2 nd non-target keyword and the length of the character string corresponding to the keyword to be inquired, and using the obtained numerical value to represent the ending position corresponding to the 2 nd non-target keyword. Illustratively, the 2 nd non-target keyword kh4tn has a corresponding string length of 5, the value corresponding to the end position of the 1 st non-target keyword is 4, the length of the string corresponding to the keyword 123 to be queried is 3, and the sum of the three values is 12, where 12 is used to indicate the end position of the 2 nd non-target keyword kh4tn in the target log.
And when the value of i is 3, adding a numerical value corresponding to the end position of the 2 nd non-target keyword, the length of the character string corresponding to the 3 rd non-target keyword and the length of the character string corresponding to the keyword to be inquired, and using the obtained numerical value to represent the end position corresponding to the 3 rd non-target keyword. Illustratively, the 3 rd non-target keyword ngo6eh corresponds to a string length of 6, the end position of the 2 nd non-target keyword corresponds to a numerical value of 12, the length of the string corresponding to the keyword 123 to be queried is 3, and the sum of the three numerical values is 21, and 21 is used to indicate the end position of the 3 rd non-target keyword ngo6eh in the target log.
Similarly, it can be obtained that the value corresponding to the end position of the 4 th non-target keyword 3nrge3 is 30, and the value corresponding to the end position of the 5 th non-target keyword ehgf12es is 40. Optionally, in a possible implementation, in order to increase the query speed, the end position of the last non-target keyword may not be obtained.
S103: and determining the position of each target keyword in the target log based on the ending position and the length of the character string corresponding to the keyword to be queried, wherein the target log comprises at least one target keyword.
The target keywords are contents to be searched in the target log, and the number of the target keywords is not limited. That is, there may be only one target keyword in the target log, or there may be a plurality of target keywords in the target log, subject to the content actually existing in the target log. In this embodiment, an example in which the target log includes at least one target keyword is described.
Specifically, adding a preset numerical value to a numerical value corresponding to the end position of each non-target keyword in the target log, wherein the obtained numerical value is used for representing the starting position of the next target keyword adjacent to the non-target keyword in the target log; adding a numerical value corresponding to the ending position of each non-target keyword in the target log and the length of a character string corresponding to the keyword to be inquired to obtain a numerical value used for indicating the ending position of the next target keyword adjacent to the non-target keyword in the target log; the start and end positions may collectively represent the location of the target keyword in the target log.
It should be noted that the content of the character string corresponding to the keyword to be queried is the same as the content of the character string corresponding to each target keyword. That is, the specific content corresponding to the keyword to be queried is the same as the specific content corresponding to each target keyword. For example, the keywords to be queried are: 42d7, each target keyword is also: 42d 7. In contrast, in each query process, only one keyword to be queried is usually determined, and the keyword to be queried is taken as a basis for querying in the target log, and the number of the target keywords is determined by the content actually existing in the target log. When only one target keyword exists in the target log, the target keyword is searched and obtained; when a plurality of target keywords exist in the target log, the plurality of target keywords can be found; and when the target key word is not in the target log, the search result is null.
Referring to fig. 2, fig. 2 is a schematic flowchart of a method for querying a log according to another embodiment of the present application, and optionally in a possible implementation manner, the S103 includes S1031 to S1033, which are as follows:
s1031: and acquiring the ending position corresponding to the previous non-target keyword of the target keyword aiming at each target keyword.
The non-target keywords and the target keywords are arranged alternately in the target log, and for each target keyword, when the position of the target keyword in the target log is determined, the end position corresponding to the previous non-target keyword adjacent to the target keyword can be obtained first.
For example, the target log is jhge123kh4tn123ngo6eh1233nrge3123ehgf12es, and the target keywords are: 123, the non-target keywords are: jhge, kh4tn, ngo6eh, 3nrge3 and ehgf12 es. For the 1 st target keyword 123 in the target log, the adjacent previous non-target keyword is jhge, the ending position corresponding to the jhge is obtained, and the numerical value 4 corresponding to the ending position of the jhge is obtained. For the 2 nd target keyword 123 in the target log, the adjacent previous non-target keyword is kh4tn, the end position corresponding to kh4tn is obtained, and the value 12 corresponding to the end position of kh4tn is obtained. By analogy, the same process is performed for each target keyword.
S1032: and adding a numerical value corresponding to the ending position of the previous non-target keyword with a preset numerical value to obtain a first numerical value, wherein the first numerical value is used for representing the starting position corresponding to the target keyword.
The preset value may be set to 1 in general. And for each target keyword, adding the value corresponding to the ending position of the previous non-target keyword of the target keyword to 1 to obtain a first value. At this time, the first numerical value is used to indicate the starting position of the target keyword in the target log.
Illustratively, continuing the above example, for the 1 st target keyword 123 in the target log, the numerical value 4 corresponding to the end position of the previous non-target keyword jhge adjacent to the target keyword is obtained, and the numerical value 4 is added to 1 to obtain the first numerical value 5. The first value 5 is used to indicate the starting position of the 1 st target keyword 123 in the target log.
For the 2 nd target keyword 123 in the target log, obtaining the numerical value 12 corresponding to the end position of the previous non-target keyword kh4tn adjacent to the target keyword, and adding the numerical value 12 and 1 to obtain a first numerical value 13. The first value 13 is used to indicate the starting position of the 2 nd target key 123 in the target log. And determining the corresponding starting position of each target keyword in the target log by analogy. For example, the starting position of the 3 rd target keyword 123 in the target log corresponds to a value of 22, and the starting position of the 4 th target keyword 123 in the target log corresponds to a value of 31.
S1033: and adding a numerical value corresponding to the ending position of the previous non-target keyword and the length of the character string corresponding to the keyword to be inquired to obtain a second numerical value, wherein the second numerical value is used for representing the ending position corresponding to the target keyword.
And for each target keyword, adding a numerical value corresponding to the ending position of the previous non-target keyword of the target keyword and the length of the character string corresponding to the keyword to be inquired to obtain a second numerical value. At this time, the second value is used to indicate the end position of the target keyword in the target log.
Illustratively, continuing with the above example, the length of the character string corresponding to the keyword 123 to be queried is 3. For the 1 st target keyword 123 in the target log, obtaining a numerical value 4 corresponding to the end position of the previous adjacent non-target keyword jhge, and adding the numerical value 4 and 3 to obtain a second numerical value 7. The second value 7 is used to indicate the beginning and end positions of the 1 st target keyword 123 in the target log.
For the 2 nd target keyword 123 in the target log, the numerical value 12 corresponding to the end position of the previous non-target keyword kh4tn adjacent to the target keyword is obtained, and the numerical value 12 and 3 are added to obtain a second numerical value 15. The second value 15 is used to indicate the beginning and end positions of the 2 nd target key 123 in the target log. And determining the corresponding ending position of each target keyword in the target log by analogy. For example, the value corresponding to the end position of the 3 rd target keyword 123 in the target log is 24, and the value corresponding to the end position of the 4 th target keyword 123 in the target log is 33.
S104: querying each target keyword in the target log based on the location.
The position includes a start position and an end position. Each target keyword may be queried in the target log based on the corresponding start and end positions of each target keyword.
Illustratively, continuing with the above example, the 1 st target key 123 has a value of [5, 7] corresponding to the position in the target log (5 for indicating the start position and 7 for indicating the end position); the position of the 2 nd target keyword 123 in the target log corresponds to a numerical value of [13, 15] (13 is used for indicating the starting position, and 15 is used for indicating the ending position); the 3 rd target keyword 123 has a value of [22, 24] corresponding to the position in the target log (22 is used for indicating the start position, and 24 is used for indicating the end position); the 4 th target key 123 has a value of [31, 33] corresponding to the position in the target log (31 for indicating the start position and 33 for indicating the end position). And inquiring each target keyword in the target log according to the positions. The description is given for illustrative purposes only and is not intended to be limiting.
According to the method, the keywords to be queried are taken as a basis, a preset function is called to split the target log to obtain a plurality of non-target keywords, the ending position of each non-target keyword in the target log is determined according to the character string length corresponding to each non-target keyword and the character string length corresponding to the keywords to be queried, the position of each target keyword in the target log is determined according to the ending position and the character string length corresponding to the keywords to be queried, and each target keyword in the target log is queried based on the position. The target log is not required to be queried for many times, all query results can be obtained, consumption of terminal performance is saved, resources are saved, developers and testers can conveniently find corresponding log contents at the terminal anytime and anywhere, convenience is brought to development and testing of application programs, small programs and the like, and development and testing efficiency is improved. Because the target logs are split based on the keywords to be queried and the position of each target keyword is further obtained, the final finding of the parcel cannot be influenced no matter which character string is traversed as the initial position in the query mode, and the accuracy of the log query result is improved.
The method for inquiring the log has better effect when being used on mobile terminal equipment such as a smart phone and a tablet personal computer. For example, the APP and the applet of the IOS version or the android version are developed on the terminal devices, or the APP and the applet of the IOS version or the android version are tested on the terminal devices, and the method for querying the log facilitates developers or testers to search corresponding log contents at any time and any place on the terminal, brings convenience to development and testing of the APP and the applet, and improves development and testing efficiency.
Referring to fig. 3, fig. 3 is a schematic flowchart of a method for querying a log according to another embodiment of the present application. The method for querying the log shown in fig. 3 may include S201 to S207, where S203 to S206 in this embodiment are the same as S101 to S104 in the corresponding embodiment of fig. 1, and are not repeated here, and S201, S202, and S207 will be described in detail below.
S201: when the log query request is acquired, displaying a plurality of query keywords on a query interface.
In this embodiment, when a user needs to query log content, a log query request may be triggered through a terminal interface, and when the terminal obtains the log query request input by the user, a corresponding log query parameter selection box is displayed on a query display interface, that is, a plurality of query keywords are displayed.
S202: and determining the keywords to be queried in the plurality of query keywords.
The user can select one query keyword from the displayed query keywords as a keyword to be queried according to actual requirements. The length of the character string of the keyword to be queried can be preset as a preset threshold value, the length of the character string corresponding to each query keyword is obtained, and the query keyword with the length of the character string matched with the preset threshold value is selected as the keyword to be queried.
Optionally, in a possible implementation manner, the terminal interface may also display an input box, so that the user can freely input the query keyword. At this time, the query keyword input and determined by the user is the keyword to be queried.
In the embodiment, the keywords to be queried are determined in the plurality of query keywords, so that the flexibility and diversity of log query are improved.
Optionally, in a possible implementation manner, S207 may be further included after S206, in order to facilitate a developer or a tester to visually see each target keyword queried.
S207: each target keyword is prominently labeled.
Each target keyword queried can be marked by any one or more of highlighting, bolding, underlining, color marking, frame selection and the like. The description is given for illustrative purposes only and is not intended to be limiting. For example, each target keyword may be marked with yellow, green, red, and the like, so that developers or testers can visually check the target keywords.
Optionally, in a possible implementation manner, each queried target keyword may also be derived in a form of a document, so that a developer or a tester can count the number of the target keywords, and then determine the number of bugs generated by developing the APP, the applet, and the like according to a statistical result.
Optionally, in a possible implementation manner, the keywords to be queried, the target log, and the position of each target keyword in the target log may also be uploaded to the blockchain.
In this embodiment, the keywords to be queried, the target logs and the positions of each target keyword in the target logs are uploaded to the block chain, so that the security and the fair transparency to the user can be ensured. And the keywords to be queried, the target log and the position of each target keyword in the target log are uploaded to the block chain, and by means of the characteristic that files on the block chain cannot be tampered randomly, the keywords to be queried, the target log and the position of each target keyword in the target log can be prevented from being maliciously tampered, so that subsequent developers and testers can detect the target log according to the files recorded in the block chain, and further detect and optimize the APP, the small programs and the like associated with the target log.
The blockchain referred to in this example is a novel application mode of computer technologies such as distributed data storage, point-to-point transmission, consensus mechanism, encryption algorithm, and the like. A block chain (Blockchain), which is essentially a decentralized database, is a series of data blocks associated by using a cryptographic method, and each data block contains information of a batch of network transactions, so as to verify the validity (anti-counterfeiting) of the information and generate a next block. The blockchain may include a blockchain underlying platform, a platform product service layer, an application service layer, and the like.
Referring to fig. 4, fig. 4 is a schematic diagram of an apparatus for querying a log according to an embodiment of the present disclosure. The device comprises units for performing the steps in the embodiments corresponding to fig. 1,2, 3. Please refer to the related descriptions in the corresponding embodiments of fig. 1, fig. 2, and fig. 3. For convenience of explanation, only the portions related to the present embodiment are shown. Referring to fig. 4, including:
the splitting unit 310 is configured to split the target log based on the keyword to be queried to obtain a plurality of non-target keywords;
a first determining unit 320, configured to determine an end position of each non-target keyword in the target log based on a character string length corresponding to each non-target keyword and a character string length corresponding to the keyword to be queried;
a second determining unit 330, configured to determine, based on the ending position and a length of a character string corresponding to the keyword to be queried, a position of each target keyword in the target log, where the target log includes at least one target keyword;
a querying unit 340, configured to query each target keyword in the target log based on the location.
Optionally, the non-target keywords and the target keywords are arranged alternately, and the second determining unit 330 is specifically configured to:
aiming at each target keyword, acquiring an ending position corresponding to a previous non-target keyword of the target keyword;
adding a numerical value corresponding to the ending position of the previous non-target keyword with a preset numerical value to obtain a first numerical value, wherein the first numerical value is used for representing the starting position corresponding to the target keyword;
and adding a numerical value corresponding to the ending position of the previous non-target keyword and the length of the character string corresponding to the keyword to be inquired to obtain a second numerical value, wherein the second numerical value is used for representing the ending position corresponding to the target keyword.
Optionally, the number of the non-target keywords is N, where N is an integer greater than or equal to 1, and the first determining unit 320 is specifically configured to:
adding a numerical value corresponding to the end position of the i-1 th non-target keyword, the length of a character string corresponding to the i-th non-target keyword and the length of a character string corresponding to the keyword to be queried to obtain a numerical value used for representing the end position corresponding to the i-th non-target keyword, wherein the value of i is 2, 3.. N;
and the numerical value corresponding to the ending position of the 1 st non-target keyword is the same as the length of the character string corresponding to the 1 st non-target keyword.
Optionally, the splitting unit 310 is specifically configured to:
and calling a preset function to split the target log according to the keywords to be inquired to obtain a plurality of non-target keywords.
Optionally, the content of the character string corresponding to the keyword to be queried is the same as the content of the character string corresponding to each target keyword.
Optionally, the apparatus further comprises:
and the marking unit is used for obviously marking each target keyword.
Optionally, the apparatus further comprises:
the display unit is used for displaying a plurality of query keywords on a query interface when the log query request is acquired;
and the keyword to be queried determining unit is used for determining the keyword to be queried in the plurality of query keywords.
Optionally, the apparatus further comprises:
and the uploading unit is used for uploading the keywords to be queried, the target logs and the positions of the target keywords in the target logs to a block chain.
Referring to fig. 5, fig. 5 is a schematic diagram of a terminal for querying a log according to another embodiment of the present application. As shown in fig. 5, the terminal 4 for querying logs of this embodiment includes: a processor 40, a memory 41, and computer instructions 42 stored in the memory 41 and executable on the processor 40. The processor 40, when executing the computer instructions 42, implements the steps in the various query log method embodiments described above, such as S101-S104 shown in fig. 1. Alternatively, the processor 40, when executing the computer instructions 42, implements the functions of the units in the embodiments described above, such as the functions of the units 310 to 340 shown in fig. 4.
Illustratively, the computer instructions 42 may be divided into one or more units that are stored in the memory 41 and executed by the processor 40 to accomplish the present application. The one or more units may be a series of computer instruction segments capable of performing specific functions, which are used to describe the execution of the computer instructions 42 in the terminal 4 of the query log. For example, the computer instructions 42 may be divided into a splitting unit, a first determining unit, a second determining unit, and a querying unit, each unit functioning as described above.
The terminal end of the query log may include, but is not limited to, a processor 40, a memory 41. It will be understood by those skilled in the art that fig. 5 is only an example of the terminal 4 for the query log, and does not constitute a limitation to the terminal for the query log, and may include more or less components than those shown, or some components in combination, or different components, for example, the terminal for the query log may further include an input-output terminal, a network access terminal, a bus, etc.
The Processor 40 may be a Central Processing Unit (CPU), other general purpose Processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), an off-the-shelf Programmable Gate Array (FPGA) or other Programmable logic device, discrete Gate or transistor logic, discrete hardware components, etc. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
The memory 41 may be an internal storage unit of the terminal of the query log, such as a hard disk or a memory of the terminal of the query log. The memory 41 may also be an external storage terminal of the terminal for querying the log, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), and the like, which are equipped on the terminal for querying the log. Further, the memory 41 may also include both an internal storage unit of the terminal of the query log and an external storage terminal. The memory 41 is used for storing the computer instructions and other programs and data required by the terminal. The memory 41 may also be used to temporarily store data that has been output or is to be output.
The above-mentioned embodiments are only used for illustrating the technical solutions of the present application, and not for limiting the same; although the present application has been described in detail with reference to the foregoing embodiments, it should be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; such modifications and substitutions do not cause the essential features of the corresponding technical solutions to depart from the spirit scope of the technical solutions of the embodiments of the present application, and are intended to be included within the scope of the present application.
Claims (10)
1. A method of querying a log, comprising:
splitting the target log based on the keywords to be queried to obtain a plurality of non-target keywords;
determining the ending position of each non-target keyword in the target log based on the character string length corresponding to each non-target keyword and the character string length corresponding to the keyword to be queried;
determining the position of each target keyword in the target log based on the ending position and the length of the character string corresponding to the keyword to be queried, wherein the target log comprises at least one target keyword;
querying each target keyword in the target log based on the location.
2. The method of claim 1, wherein the non-target keywords alternate with the target keywords, and wherein determining the position of each target keyword in the target log based on the ending position and the length of the character string corresponding to the keyword to be queried comprises:
aiming at each target keyword, acquiring an ending position corresponding to a previous non-target keyword of the target keyword;
adding a numerical value corresponding to the ending position of the previous non-target keyword with a preset numerical value to obtain a first numerical value, wherein the first numerical value is used for representing the starting position corresponding to the target keyword;
and adding a numerical value corresponding to the ending position of the previous non-target keyword and the length of the character string corresponding to the keyword to be inquired to obtain a second numerical value, wherein the second numerical value is used for representing the ending position corresponding to the target keyword.
3. The method of claim 1, wherein the number of the non-target keywords is N, where N is an integer greater than or equal to 1, and the determining the ending position of each non-target keyword in the target log based on the string length corresponding to each non-target keyword and the string length corresponding to the keyword to be queried comprises:
adding a numerical value corresponding to the end position of the i-1 th non-target keyword, the length of a character string corresponding to the i-th non-target keyword and the length of a character string corresponding to the keyword to be queried to obtain a numerical value used for representing the end position corresponding to the i-th non-target keyword, wherein the value of i is 2, 3.. N;
and the numerical value corresponding to the ending position of the 1 st non-target keyword is the same as the length of the character string corresponding to the 1 st non-target keyword.
4. The method of claim 1, wherein splitting the target log based on the keywords to be queried to obtain a plurality of non-target keywords comprises:
and calling a preset function to split the target log according to the keywords to be inquired to obtain a plurality of non-target keywords.
5. The method of any of claims 1 to 4, wherein after querying each target keyword in the target log based on the location, the method further comprises:
each target keyword is prominently labeled.
6. The method of claim 5, wherein before splitting the target log based on the keyword to be queried to obtain a plurality of non-target keywords, the method further comprises:
when a log query request is acquired, displaying a plurality of query keywords on a query interface;
and determining the keywords to be queried in the plurality of query keywords.
7. The method of claim 1, wherein after determining the position of each target keyword in the target log based on the ending position and the length of the character string corresponding to the keyword to be queried, the method further comprises:
and uploading the keywords to be queried, the target logs and the positions of each target keyword in the target logs to a block chain.
8. An apparatus for querying a log, comprising:
the splitting unit is used for splitting the target log based on the keywords to be inquired to obtain a plurality of non-target keywords;
a first determining unit, configured to determine an end position of each non-target keyword in the target log based on a character string length corresponding to each non-target keyword and a character string length corresponding to the keyword to be queried;
a second determining unit, configured to determine, based on the ending position and a length of a character string corresponding to the keyword to be queried, a position of each target keyword in the target log, where the target log includes at least one target keyword;
and the query unit is used for querying each target keyword in the target log based on the position.
9. A terminal for querying logs, comprising a memory, a processor and a computer program stored in said memory and executable on said processor, characterized in that said processor implements the method according to any one of claims 1 to 7 when executing said computer program.
10. A computer storage medium storing a computer program, characterized in that the computer program, when executed by a processor, implements the method according to any one of claims 1 to 7.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202011381544.9A CN112445896A (en) | 2020-12-01 | 2020-12-01 | Method, device, terminal and storage medium for inquiring log |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202011381544.9A CN112445896A (en) | 2020-12-01 | 2020-12-01 | Method, device, terminal and storage medium for inquiring log |
Publications (1)
Publication Number | Publication Date |
---|---|
CN112445896A true CN112445896A (en) | 2021-03-05 |
Family
ID=74739162
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202011381544.9A Pending CN112445896A (en) | 2020-12-01 | 2020-12-01 | Method, device, terminal and storage medium for inquiring log |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN112445896A (en) |
-
2020
- 2020-12-01 CN CN202011381544.9A patent/CN112445896A/en active Pending
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US9798648B2 (en) | Transitive source code violation matching and attribution | |
US11048798B2 (en) | Method for detecting libraries in program binaries | |
CN111352902A (en) | Log processing method and device, terminal equipment and storage medium | |
CN109271315B (en) | Script code detection method, script code detection device, computer equipment and storage medium | |
WO2017028789A1 (en) | Network attack detection method and device | |
US9690690B1 (en) | Scalable transitive violation matching | |
CN110474900B (en) | Game protocol testing method and device | |
CN108388509B (en) | Software testing method, computer readable storage medium and terminal equipment | |
US8862556B2 (en) | Difference analysis in file sub-regions | |
CN111078276B (en) | Application redundant resource processing method, device, equipment and storage medium | |
CN108427580B (en) | Configuration pair naming repetition detection method, storage medium and intelligent device | |
WO2023241529A1 (en) | Vulnerability information processing method, service apparatus and vulnerability detection module | |
CN117992357A (en) | Query statement detection method, device, equipment and medium for distributed database | |
CN111221690B (en) | Model determination method and device for integrated circuit design and terminal | |
CN117056347A (en) | SQL sentence true injection detection method, SQL sentence true injection detection device, SQL sentence true injection detection computer equipment and SQL sentence true injection detection storage medium | |
CN112445896A (en) | Method, device, terminal and storage medium for inquiring log | |
US9286348B2 (en) | Dynamic search system | |
WO2023044445A1 (en) | Metadata-driven data ingestion | |
CN116192462A (en) | Malicious software analysis method and device based on PE file format | |
CN115878671A (en) | Sensitive data analysis method and device, electronic equipment and storage medium | |
US8935200B2 (en) | Dynamic database dump | |
CN113742208A (en) | Software detection method, device, equipment and computer readable storage medium | |
US10853217B2 (en) | Performance engineering platform using probes and searchable tags | |
CN109710305B (en) | Development information acquisition method and device, storage medium and terminal equipment | |
CN111158994A (en) | Pressure testing performance testing method and device |
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 |