CN111026730A - Log file detection method and device - Google Patents

Log file detection method and device Download PDF

Info

Publication number
CN111026730A
CN111026730A CN201911330309.6A CN201911330309A CN111026730A CN 111026730 A CN111026730 A CN 111026730A CN 201911330309 A CN201911330309 A CN 201911330309A CN 111026730 A CN111026730 A CN 111026730A
Authority
CN
China
Prior art keywords
data
log file
log
index
byte number
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
CN201911330309.6A
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.)
Guangdong Topstar Technology Co Ltd
Original Assignee
Guangdong Topstar 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 Guangdong Topstar Technology Co Ltd filed Critical Guangdong Topstar Technology Co Ltd
Priority to CN201911330309.6A priority Critical patent/CN111026730A/en
Publication of CN111026730A publication Critical patent/CN111026730A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/18File system types
    • G06F16/1805Append-only file systems, e.g. using logs or journals to store data
    • G06F16/1815Journaling file systems
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/13File access structures, e.g. distributed indices
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/17Details of further file system functions
    • G06F16/1734Details of monitoring file system events, e.g. by the use of hooks, filter drivers, logs

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The invention provides a log file detection method, which comprises the following steps: acquiring the original byte number of the log file; after triggering operation, acquiring the byte number of the log file at preset time intervals in a preset time period, and comparing the byte number with the original byte number; if the byte number is different, the log is judged to be generated. The log file detection method and device can accurately know whether data is input or not.

Description

Log file detection method and device
Technical Field
The invention relates to the technical field of log file processing, in particular to a log file detection method and device.
Background
In the process of carrying out the job, after the operating device is triggered, the generated data is recorded into a log file. After new data is entered, the modification time of the log file changes, and whether the log is updated is generally determined by manually checking the modification time. However, it may occur that the modification time of the log file is not updated to the latest time, resulting in a determination that no data is entered.
Disclosure of Invention
The invention aims to provide a log file detection method and device, which can accurately know whether data is input or not.
In order to achieve the purpose, the invention adopts the following technical scheme:
in a first aspect, the present invention provides a log file detection method, including:
acquiring the original byte number of the log file;
after triggering operation, acquiring the byte number of the log file at preset time intervals in a preset time period, and comparing the byte number with the original byte number;
if the byte number is different, the log is judged to be generated.
Further, after the log is determined to be generated, the method further includes:
and judging a test result according to the log.
Further, the determining a test result according to the log includes:
extracting data generated after triggering operation from the log;
if the data is null, judging that the product is failed;
and if the data is not null, judging that the test is correct.
Further, and comparing with the original byte number, the method also comprises the following steps:
if the byte number is the same, the test is judged to be wrong.
Further, extracting the data generated after the operation from the log comprises:
intercepting bytes with preset length from the tail of the log file, and forming index bytes;
indexing according to the position of data generated by triggering operation in the index byte so as to obtain the data;
wherein the index bytes contain all bytes of the log.
Further, indexing the position of the data generated by the trigger operation in the index byte to obtain the data, including:
determining the position of the data in the index byte according to the relative position of the data and the tail-most data in the log file;
and indexing from the extreme end of the index byte to acquire the data.
Further, according to the relative position of the data and the endmost data in the log file, the method also includes the following steps:
segmenting the intercepted bytes and obtaining a plurality of unit data;
sequentially storing the unit data in units of an array;
correspondingly, the position of the data in the index byte is determined as follows:
determining a location of the data in the array;
the index from the very end of the index byte is:
the index starts from the very end of the array.
In a second aspect, the present invention provides a log file detection apparatus, including:
the acquisition module is used for acquiring the original byte number of the log file;
after the triggering operation, acquiring the byte number of the log file at preset time intervals in a preset time period;
the judging module is used for comparing the byte number of the log file acquired after the triggering operation with the original byte number;
and if the byte number is different, judging that the log is generated.
Further, the judging module is further configured to judge a test result according to the log.
Further, the device also comprises an index module;
the index module is used for intercepting bytes with preset length from the tail of the log file and forming index bytes;
and indexing according to the position of the data generated by the trigger operation in the index byte so as to acquire the data.
The invention has the beneficial effects that:
according to the method and the device, the number of bytes of the log file after the trigger operation is compared with the number of original bytes, the update of the log file is automatically detected according to the change of the number of bytes, the update condition of the log file can be accurately known, and the condition that the recorded data is judged to be not updated is prevented.
Drawings
Fig. 1 is a schematic flowchart of a log file detection method according to an embodiment of the present invention.
Fig. 2 is a schematic structural diagram of a log file detection apparatus according to a second embodiment of the present invention.
Detailed Description
In order to make the technical problems solved, technical solutions adopted and technical effects achieved by the present invention clearer, the technical solutions of the embodiments of the present invention will be described in further detail below with reference to the accompanying drawings, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all embodiments.
Example one
The embodiment provides a log file detection method, which can automatically detect the update of a log file, can accurately acquire the update condition of the log file, and can prevent the condition that the log file is not updated when the log file is recorded.
Fig. 1 is a schematic flowchart of a log file detection method according to an embodiment of the present invention. As shown in fig. 1, the method specifically includes the following steps:
s11, the original byte number of the log file is obtained.
Taking the stress machine as an example for explanation, before triggering the stress machine, the log file only contains the log generated after the previous triggering operation. In this example, the log file is in the format of an Excel table.
And S12, after the triggering operation, acquiring the byte number of the log file at preset time intervals in a preset time period.
And S13, comparing with the original byte number.
In this example, a period of time after the stress machine is triggered may be set as a preset period of time, and the log file may be added with data of several KB, which is a log generated after the trigger, recorded with information of the time, and added at the end of the log file. Therefore, during the period of time, the number of bytes of the log file acquired at the preset time interval is compared with the number of original bytes.
S14a, if the number of bytes is the same, it is determined as a test error.
After comparison, the number of bytes is the same, which indicates that no log is generated, and the trigger operation error is a test error.
S14b, if the number of bytes is different, it is determined that a log is generated.
Since a few KB of data is added after the trigger, the number of bytes is different, indicating that a log is generated.
And S15, judging the test result according to the log.
Specifically, S151 extracts data generated after the trigger operation from the log.
Preferably, a byte of a preset length is first intercepted from the end of the log file, and an index byte is formed.
The preset length can be set according to actual conditions, but must be longer than the bytes of the log. So that the index bytes contain all the bytes of the log.
And then indexing according to the position of the data generated by the trigger operation in the index byte so as to acquire the data.
Preferably, the intercepted bytes are first segmented to obtain a plurality of unit data.
The segmentation may be performed according to tab characters, one tab character corresponding to one unit of data. The number of the unit data after the segmentation determines the length of the array.
The cell data is then stored sequentially in the cells of the array.
And storing the data of each unit in the corresponding unit according to the position sequence of the data of each unit in the index byte, and realizing that the sequence in the array is consistent with the sequence in the index byte.
And then determining the position of the data in the index byte according to the relative position of the data and the tail-most data in the log file. The position of the data generated by the trigger operation can be determined according to the relative position with the endmost data, so that the data can be quickly acquired and provided for the subsequent steps, and the working efficiency is improved.
Correspondingly, the position of the data in the array is determined according to the relative position of the data and the tail-most data in the log file.
And finally, indexing from the tail end of the index byte to obtain the data.
Accordingly, the data is obtained by indexing from the very end of the array. The relative position determines the displacement of the index, controls the pointer to move forward from the extreme end, and when the displacement is moved, the pointer reaches the unit storing the data, and then acquires the data.
For example, the index bytes include 12345 in sequence, and the data generated after the trigger operation is 3. After the segmentation, five data units of 1, 2, 3, 4 and 5 are obtained, and then the data units are sequentially stored in the units of the array, wherein str [0] is 1, str [1] is 2, str [2] is 3, str [3] is 4 and str [4] is 5, then the data "3" is 1 data unit away from the endmost data "5", so that the data is determined to be moved by two displacement amounts in the third last unit in the array, then the pointer is controlled to start indexing from the endmost str [4] of the array, and after the data is moved by two displacement amounts, str [2] is reached, and finally the data "3" stored in str [2] is obtained, so that the data generated after the trigger operation is extracted.
And S152a, if the data is null, determining that the product is not good.
In this embodiment, the data may be set to be empty and represented by ng (not good) in the log, so as to express the product failing.
And S152b, if the data is not null, judging that the test is correct.
The data is not null, so that the test result can be determined quickly and accurately.
According to the embodiment, the updating of the log file is automatically detected by comparing the byte number of the log file after the trigger operation with the original byte number and according to whether the byte number changes, the updating condition of the log file can be accurately known, and the condition that the recorded data is judged to be not updated is prevented.
Example two
The embodiment provides a log file detection device, which is used for executing the log file detection method described in the embodiment, so that the same technical problems are solved, and the same technical effects are achieved.
Fig. 2 is a schematic structural diagram of a log file detection apparatus according to a second embodiment of the present invention. As shown in fig. 2, the apparatus includes:
the acquiring module 10 is used for acquiring the original byte number of the log file;
and after triggering operation, acquiring the byte number of the log file at preset time intervals in a preset time period.
The preset time is set according to the actual situation.
The judging module 20 is configured to compare the number of bytes of the log file obtained after the triggering operation with the number of original bytes;
and if the byte number is different, judging that the log is generated.
Preferably, the judging module 20 is further configured to judge the test result according to the log.
Preferably, the test result is judged according to the data in the log.
Correspondingly, the device also comprises an index module;
the index module is used for intercepting bytes with preset length from the tail of the log file and forming index bytes;
and indexing according to the position of the data generated by the trigger operation in the index byte so as to acquire the data.
The data generated after the triggering operation can be quickly acquired through the indexing module.
According to the embodiment, through the matching of the acquisition module and the judgment module, the updating of the log file can be automatically detected, the updating condition of the log file can be accurately known, and the condition that the recorded data is judged not to be updated is prevented.
The technical principle of the present invention is described above in connection with specific embodiments. The description is made for the purpose of illustrating the principles of the invention and should not be construed in any way as limiting the scope of the invention. Based on the explanations herein, those skilled in the art will be able to conceive of other embodiments of the present invention without inventive effort, which would fall within the scope of the present invention.

Claims (10)

1. A log file detection method is characterized by comprising the following steps:
acquiring the original byte number of the log file;
after triggering operation, acquiring the byte number of the log file at preset time intervals in a preset time period, and comparing the byte number with the original byte number;
if the byte number is different, the log is judged to be generated.
2. The method of claim 1, wherein determining that a log is generated further comprises:
and judging a test result according to the log.
3. The method according to claim 2, wherein the determining a test result according to the log comprises:
extracting data generated after triggering operation from the log;
if the data is null, judging that the product is failed;
and if the data is not null, judging that the test is correct.
4. The log file detecting method according to claim 1, wherein comparing with the original byte number further comprises:
if the byte number is the same, the test is judged to be wrong.
5. The log file detection method of claim 3, wherein extracting post-operation data from the log comprises:
intercepting bytes with preset length from the tail of the log file, and forming index bytes;
indexing according to the position of data generated by triggering operation in the index byte so as to obtain the data;
wherein the index bytes contain all bytes of the log.
6. The log file detection method as claimed in claim 5, wherein indexing the data generated by the trigger operation according to the position of the data in the index byte to obtain the data comprises:
determining the position of the data in the index byte according to the relative position of the data and the tail-most data in the log file;
and indexing from the extreme end of the index byte to acquire the data.
7. The log file detection method of claim 6, wherein based on the relative position of the data to the endmost data in the log file, further comprising:
segmenting the intercepted bytes and obtaining a plurality of unit data;
sequentially storing the unit data in units of an array;
correspondingly, the position of the data in the index byte is determined as follows:
determining a location of the data in the array;
the index from the very end of the index byte is:
the index starts from the very end of the array.
8. A log file detection apparatus, comprising:
the acquisition module is used for acquiring the original byte number of the log file;
after the triggering operation, acquiring the byte number of the log file at preset time intervals in a preset time period;
the judging module is used for comparing the byte number of the log file acquired after the triggering operation with the original byte number;
and if the byte number is different, judging that the log is generated.
9. The log file detecting device according to claim 8, wherein:
the judging module is also used for judging a test result according to the log.
10. The log file detecting device according to claim 9, wherein: the system also comprises an index module;
the index module is used for intercepting bytes with preset length from the tail of the log file and forming index bytes;
and indexing according to the position of the data generated by the trigger operation in the index byte so as to acquire the data.
CN201911330309.6A 2019-12-20 2019-12-20 Log file detection method and device Pending CN111026730A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201911330309.6A CN111026730A (en) 2019-12-20 2019-12-20 Log file detection method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201911330309.6A CN111026730A (en) 2019-12-20 2019-12-20 Log file detection method and device

Publications (1)

Publication Number Publication Date
CN111026730A true CN111026730A (en) 2020-04-17

Family

ID=70211336

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201911330309.6A Pending CN111026730A (en) 2019-12-20 2019-12-20 Log file detection method and device

Country Status (1)

Country Link
CN (1) CN111026730A (en)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1645336A (en) * 2005-01-20 2005-07-27 上海复旦光华信息科技股份有限公司 Automatic extraction and analysis for formwork based on heterogenerous logbook
CN105335406A (en) * 2014-07-30 2016-02-17 阿里巴巴集团控股有限公司 Log data processing method and device
US20170249449A1 (en) * 2014-11-25 2017-08-31 Feitian Technologies Co., Ltd. Dynamic token having log function and working method therefor
CN109802990A (en) * 2018-12-10 2019-05-24 视联动力信息技术股份有限公司 A kind of resource log reading/writing method and device reducing data redundancy

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1645336A (en) * 2005-01-20 2005-07-27 上海复旦光华信息科技股份有限公司 Automatic extraction and analysis for formwork based on heterogenerous logbook
CN105335406A (en) * 2014-07-30 2016-02-17 阿里巴巴集团控股有限公司 Log data processing method and device
US20170249449A1 (en) * 2014-11-25 2017-08-31 Feitian Technologies Co., Ltd. Dynamic token having log function and working method therefor
CN109802990A (en) * 2018-12-10 2019-05-24 视联动力信息技术股份有限公司 A kind of resource log reading/writing method and device reducing data redundancy

Similar Documents

Publication Publication Date Title
CN104700033B (en) The method and device of viral diagnosis
CN107025224B (en) Method and equipment for monitoring task operation
CN110297767B (en) Automatic execution method, device, equipment and storage medium for test cases
CN112256635B (en) Method and device for identifying file type
CN102541679A (en) Method and system for testing GPU (graphic processing unit) cards
CN108180935B (en) Fault detection method and device of sensor
CN112628006A (en) Engine intake pressure credibility detection method, device, equipment and storage medium
CN106874196B (en) Automatic test exception handling method and automatic test system
CN111026730A (en) Log file detection method and device
CN105630657A (en) Temperature detection method and device
EP3859528A3 (en) Method and apparatus for handling memory failure, electronic device and storage medium
CN109542778A (en) A kind of method and device of resource leak detection
CN110456089B (en) Full-automatic sample analyzer, reagent adding method and calculating device thereof
KR940008608B1 (en) Method and apparatus for detecting and processing abnormal message output
CN110399132B (en) Method, device, computer equipment and storage medium for maintaining project codes
CN111309584B (en) Data processing method, device, electronic equipment and storage medium
CN111538755A (en) Equipment operation state anomaly detection method based on normalized cross correlation and unit root detection
CN104704227A (en) Device and method for controlling engine
EP0452080A2 (en) System for controlling restoration from failure in a queue structure of control data
CN108198326B (en) Method and device for transmitting paper money data, electronic equipment and storage medium
CN111159051A (en) Deadlock detection method and device, electronic equipment and readable storage medium
CN111124809A (en) Test method and device for server sensor system
CN115269288A (en) Fault determination method, device, equipment and storage medium
CN112069006B (en) Method and device for detecting and analyzing GPU (graphics processing Unit) rate state and computer readable medium
CN105824824B (en) Standby call ticket collection equipment and call ticket file collection method thereof

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: 20200417

RJ01 Rejection of invention patent application after publication