CN111198855A - Method and device for processing log data - Google Patents

Method and device for processing log data Download PDF

Info

Publication number
CN111198855A
CN111198855A CN201911409299.5A CN201911409299A CN111198855A CN 111198855 A CN111198855 A CN 111198855A CN 201911409299 A CN201911409299 A CN 201911409299A CN 111198855 A CN111198855 A CN 111198855A
Authority
CN
China
Prior art keywords
serial port
log data
port channel
current
file
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.)
Granted
Application number
CN201911409299.5A
Other languages
Chinese (zh)
Other versions
CN111198855B (en
Inventor
梁荣波
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shenzhen Queclink Communication Technology Co ltd
Original Assignee
Shenzhen Queclink Communication 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 Shenzhen Queclink Communication Technology Co ltd filed Critical Shenzhen Queclink Communication Technology Co ltd
Priority to CN201911409299.5A priority Critical patent/CN111198855B/en
Publication of CN111198855A publication Critical patent/CN111198855A/en
Application granted granted Critical
Publication of CN111198855B publication Critical patent/CN111198855B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

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/17Details of further file system functions
    • G06F16/172Caching, prefetching or hoarding of files
    • 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/16File or folder operations, e.g. details of user interfaces specifically adapted to 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/16File or folder operations, e.g. details of user interfaces specifically adapted to file systems
    • G06F16/162Delete operations
    • 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
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Abstract

The application provides a method and a device for processing log data. The method comprises the following steps: detecting whether each serial port receives log data sent by the connecting equipment or not; if at least one serial port is detected to receive the log data sent by the connecting equipment, the obtained log data is stored in a serial port channel folder corresponding to the serial port for each serial port through the serial port, and the detected log data is stored in the serial port channel folder corresponding to the serial port in the secure digital card by virtue of the secure digital card, so that the received log data can be stored in a partition mode, and the convenience of log data detection and storage is effectively improved.

Description

Method and device for processing log data
Technical Field
The embodiment of the application relates to the technical field of serial port data processing, in particular to a method and a device for processing log data.
Background
In the process of testing large-scale mobile equipment, serial port log data of each equipment is often required to be recorded, so that users and developers can conveniently know the running condition of the system or software, development and analysis of data resources are assisted, the system is better improved, and the efficiency of troubleshooting and problem solving is improved.
The general method for recording serial port log data is that each device is connected with a serial port line, then the serial port lines are connected to a computer, then the log data is recorded on a serial port communication assistant of the computer, and the serial port data is recorded by the serial port assistant and is artificially detected and stored in real time.
However, because a user is required to manually detect and store the log data in the device through a computer, the detection and storage of the log data are inconvenient.
Disclosure of Invention
The embodiment of the application provides a method and a device for processing log data, and aims to solve the problem that in the prior art, serial port log data is not convenient to detect and store.
In a first aspect, an embodiment of the present application provides a method for processing log data, including:
detecting whether each serial port receives log data sent by the connecting equipment or not;
if at least one serial port is detected to receive the log data sent by the connecting equipment, storing the received log data in a serial port channel folder corresponding to the serial port through the serial port;
the serial port channel folder is arranged in a local secure digital card.
Optionally, the method further comprises:
when the connection equipment is determined to be connected, firstly detecting whether a serial port channel folder corresponding to each serial port exists in a local secure digital card;
and if not, respectively establishing a corresponding serial port channel folder in the safety data card for each serial port.
Optionally, for each serial port, storing, by the serial port, the received log data in a serial port channel folder corresponding to the serial port, includes:
when determining that no serial port channel file exists in a serial port channel folder corresponding to the serial port, establishing a corresponding first serial port channel file, determining a current first time, and naming the first serial port channel file according to the first time and a preset file format;
and storing the log data acquired by the serial port in the first serial port channel file.
Optionally, the storing the log data acquired by the serial port in the first serial port channel file includes:
packaging the log data received by the serial port, and recording a current serial port identifier and a current timestamp corresponding to the packaged log data;
storing the packed log data, the current serial port identification and the current time corresponding to the packed log data into a cache queue corresponding to the current serial port identification;
when the log data received by the serial port meets the preset condition, determining whether the current time corresponding to the packed log data stored in the cache queue is the same as the time of a first serial port channel file corresponding to the identifier of the current serial port;
and when the log data are determined to be the same, storing the packaged log data into the first serial port channel file.
Optionally, the method further comprises:
if the current time corresponding to the packed log data stored in the cache queue is determined to be different from the time of the first serial port channel file corresponding to the current serial port identification, establishing a second serial port channel file corresponding to the serial port;
and determining the current second time, naming the second serial port channel file according to the second time and a preset file format, and storing the packaged log data in the second serial port channel file.
Optionally, the method further comprises:
acquiring a log data calling request, wherein the log data calling request comprises time information to be called;
and inquiring the secure digital card according to the log data calling request, acquiring a serial port channel file matched with the called time information, and reporting the packaged log data stored in the file.
Optionally, the determining that the log data received by the serial port meets the preset condition includes:
when detecting that the connection equipment sends a data byte interval and analyzing an idle identification bit based on the data byte interval, determining that log data received by the serial port meets a preset condition;
alternatively, the first and second electrodes may be,
and analyzing the received log data, and if the analyzed log data comprises characters which are the same as preset characters, determining that the log data received by the serial port meets preset conditions.
Optionally, the method further comprises:
and deleting the serial port channel file stored in the secure data card according to the timestamp corresponding to the packed log data when the capacity of the log data stored in the secure digital card is determined to be larger than a preset storage threshold value.
In a second aspect, an embodiment of the present application provides an apparatus for processing log data, including:
the detection module is used for detecting whether each serial port receives log data sent by the connecting equipment;
the processing module is used for storing the received log data in a serial port channel folder corresponding to the serial port through the serial port if at least one serial port is detected to receive the log data sent by the connecting equipment;
the serial port channel folder is arranged in a local secure digital card.
Optionally, the detecting module is further configured to, when it is determined that the connection device is connected, first detect whether a serial port channel folder corresponding to each serial port exists in a local secure digital card.
The processing module is further configured to establish a corresponding serial port channel folder in the secure data card for each serial port when a serial port channel folder corresponding to each serial port does not exist in the secure digital card, and establish a first serial port channel file under each serial port channel folder.
Optionally, the processing module is specifically configured to:
when determining that no serial port channel file exists in a serial port channel folder corresponding to the serial port, establishing a corresponding first serial port channel file, determining a current first time, and naming the first serial port channel file according to the first time and a preset file format;
and storing the log data acquired by the serial port in the first serial port channel file.
Optionally, the processing module is specifically configured to:
packaging the log data received by the serial port, and recording a current serial port identifier and a current timestamp corresponding to the packaged log data;
storing the packed log data, the current serial port identification and the current time corresponding to the packed log data into a cache queue corresponding to the current serial port identification;
when the log data received by the serial port meets the preset condition, determining whether the current time corresponding to the packed log data stored in the cache queue is the same as the time of a first serial port channel file corresponding to the identifier of the current serial port;
and when the log data are determined to be the same, storing the packaged log data into the first serial port channel file.
Optionally, the processing module is further configured to:
when the current time corresponding to the packed log data stored in the cache queue is different from the time of a first serial port channel file corresponding to the identifier of the current serial port, establishing a second serial port channel file corresponding to the serial port;
and determining the current second time, naming the second serial port channel file according to the second time and a preset file format, and storing the packaged log data in the second serial port channel file.
Optionally, the processing module is further configured to obtain a log data retrieval request, where the log data retrieval request includes time information to be retrieved;
the processing module is further configured to query the secure digital card according to a log data retrieval request, obtain a serial port channel file matched with the retrieved time information, and report the packed log data stored in the file.
Optionally, the processing module is specifically configured to:
when detecting that the connection equipment sends a data byte interval and analyzing an idle identification bit based on the data byte interval, determining that log data received by the serial port meets a preset condition;
alternatively, the first and second electrodes may be,
and analyzing the received log data, and if the analyzed log data comprises characters which are the same as preset characters, determining that the log data received by the serial port meets preset conditions.
Optionally, the processing module is further configured to delete the serial port channel file stored in the secure data card according to a timestamp corresponding to the packed log data when it is determined that the capacity of the log data stored in the secure digital card is greater than a preset storage threshold.
In a third aspect, an embodiment of the present application provides an electronic device, including:
a memory for storing program instructions;
and the processor is used for calling and executing the program instructions in the memory to execute the processing method of the log data according to the first aspect of the application.
In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, where a computer program is stored, and when the computer program is executed by a processor, the computer program implements the method for processing log data according to the first aspect of the present application.
According to the log data processing method and device, the data are sent to each serial port through the connecting device, whether the log data sent by the connecting device are received by each serial port is detected, if the fact that the log data sent by the connecting device are received by at least one serial port is detected, the received log data are stored in the serial port channel folder corresponding to the serial port through the serial port, the connecting device is automatically detected through the safe digital card, and the detected log data are stored in the serial port channel folder corresponding to the serial port in the safe digital card, so that the received log data can be stored in a partitioned mode, and convenience in log data detection and storage is effectively improved.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings needed to be used in the description of the embodiments or the prior art will be briefly introduced below, and it is obvious that the drawings in the following description are some embodiments of the present application, and for those skilled in the art, other drawings can be obtained according to these drawings without inventive exercise.
FIG. 1 is a diagram of a scene architecture to which various embodiments of the present application are applied;
fig. 2 is a schematic flowchart of a method for processing log data according to an embodiment of the present application;
fig. 3 is a schematic flowchart of a log data processing method according to another embodiment of the present application;
fig. 4 is a flowchart illustrating a method for processing log data according to yet another embodiment of the present application;
fig. 5 is a schematic flowchart of a log data processing method according to another embodiment of the present application;
fig. 6 is a schematic structural diagram of a log data processing apparatus according to an embodiment of the present application;
fig. 7 is a schematic structural diagram of an electronic device according to an embodiment of the present application.
Detailed Description
Reference will now be made in detail to the exemplary embodiments, examples of which are illustrated in the accompanying drawings. When the following description refers to the accompanying drawings, like numbers in different drawings represent the same or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present application. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the present application, as detailed in the appended claims.
In the prior art, a serial port log data recording method is to access a serial port line for each device, connect the serial port lines to a computer, record the log data on a serial port communication assistant of the computer, record serial port data through the serial port assistant, and artificially detect and store the serial port data in real time. However, because a user is required to manually detect and store the log data in the device through a computer, the detection and storage of the log data are inconvenient.
Based on the technical problem, the method mainly adopts convenient detection equipment to automatically detect and store the log data on the connection equipment. Specifically, the detection device is provided with a plurality of serial ports and a secure digital card, the connection device is also provided with a corresponding serial port channel, after the detection device is connected with the connection device through the serial ports, the connection device sends data to each serial port, then whether log data sent by the connection device is received by each serial port of the detection device is detected, if at least one serial port of the detection device receives the log data sent by the connection device, the obtained log data is stored in a serial port channel file corresponding to the serial port through the serial port of the detection device, the serial port channel file is arranged in the secure digital card, because the connection device is automatically detected by the secure digital card, and the detected log data is stored in the serial port channel file corresponding to the serial port in the secure digital card, therefore, the convenience of log data detection and storage is effectively improved.
Fig. 1 is a scene architecture diagram applied in various embodiments of the present application, as shown in fig. 1, which mainly includes: a detection device 11, and a connection device 12 connected to the detection device; wherein, the detection device 11 is provided with a secure digital card 110 and a multi-path serial port 111; the connection device 12 includes a multi-path serial port 121; the detection device 11 and the connection device 12 are connected through respective serial ports.
The technical solution of the present application is described below with reference to several specific embodiments.
Fig. 2 is a schematic flowchart of a processing method of log data according to an embodiment of the present application, and as shown in fig. 2, the method according to the embodiment of the present application may include:
s201, detecting whether each serial port receives log data sent by the connecting device.
In this embodiment, after the detection device 11 is connected to the connection device 12, when the connection device 12 detects that a device is connected to the detection device 11 through a serial port, the detection device may power on the detection device 11, so that the detection device may detect whether each serial port receives log data sent by the connection device based on the serial port.
S202, if it is detected that at least one serial port receives the log data sent by the connecting device, the received log data is stored in a serial port channel folder corresponding to the serial port through the serial port. The serial port channel folder is arranged in a local secure digital card.
In this embodiment, the log data sent by the connection device is detected, and if it is detected that at least one serial port in the multiple serial ports receives the log data sent by the connection device, the detected log data sent by the connection device is stored in a corresponding serial port channel folder, and because the serial port channel folder is arranged in a local secure digital card, the detected log data sent by the connection device can be stored in a local secure digital card in a partitioned manner. The local secure digital CARD can be a TF-CARD storage CARD.
In this embodiment, the detection device is connected with the connection device through the serial ports, and detects whether each serial port receives log data sent by the connection device, if it is detected that at least one serial port receives the log data sent by the connection device, the obtained log data is stored in a serial port channel file corresponding to the serial port through the serial port, and because the log data detected by each serial port is stored in a serial port channel folder corresponding to the serial port by means of the secure digital card, the received log data can be stored in a partitioned manner, and convenience in log data detection and storage is effectively improved.
Fig. 3 is a schematic flowchart of a log data processing method according to another embodiment of the present application, and as shown in fig. 3, the method according to the embodiment of the present application may include:
s301, when the connection equipment is determined to be connected, whether a serial port channel folder corresponding to each serial port exists in a local secure digital card or not is detected.
In this embodiment, the detection device provided with the secure digital card is connected to the connection device, and after the connection device powers on the detection device, the detection device may determine whether there is a corresponding serial port channel folder for each serial port in the local secure digital card.
And S302, if the serial port channel folder does not exist, establishing a corresponding serial port channel folder in the safety data card for each serial port.
In this embodiment, if it is detected that at least one serial port does not establish a serial port channel folder corresponding to the serial port, a serial port channel folder corresponding to the serial port is established for the serial port without establishing the serial port channel folder in the local secure digital card.
S303, detecting whether each serial port receives log data sent by the connecting equipment.
In this embodiment, it is determined whether each serial port of the detection device receives log data sent by a connection device. If the log data sent by the connection device is received, executing step S304, and if the log data sent by the connection device is not received, looping the step until the serial port corresponding to the detection device receives the log data sent by the connection device, and then executing step S304.
S304, if it is detected that at least one serial port receives log data sent by the connecting device, establishing a corresponding first serial port channel file when determining that no serial port channel file exists in a serial port channel folder corresponding to the serial port for each serial port, and determining the current first time so as to name the first serial port channel file according to the first time and a preset file format. The serial port channel folder is arranged in a local secure digital card.
In this embodiment, the detection device detects each serial port, and after it is detected that at least one serial port channel in the plurality of serial ports receives serial port log data sent by the connection device, it is determined whether a corresponding serial port channel file exists in the serial port channel folder established in the security data card for each serial port. And if the fact that the corresponding serial port channel file does not exist in the serial port channel folder is determined, newly establishing a first serial port channel file corresponding to the serial port channel folder. For the newly-built serial port channel file, the current first time can be further determined, and the serial port channel file is named according to the first time and a preset file format. For example, the serial channel file name may be: CHANNEL1_ 2019-01. TXT, CHANNEL1 represents a serial port; 2019-01-01 represents the time of the first serial port channel file established, namely the first time; TXT denotes a preset file format.
Based on this, when check out test set detected and stored log data information the connecting device, all was provided with its serial ports channel file that corresponds to every way serial ports. After the serial port receives serial port log data sent by the connecting equipment, a serial port channel file is newly built under a serial port channel folder corresponding to the serial port; the name of the serial port channel file is related to the time for storing the serial port log data.
In addition, for each serial port channel file, the time of log data stored in the serial port channel file is matched with the time of establishing the serial port channel file.
S305, storing the log data acquired by the serial port in the first serial port channel file.
In this embodiment, according to the first serial port channel file established in S304, the log data sent by the connection device and received by the detection device is stored in the serial port channel file corresponding to the serial port, and the serial port channel file is established in the corresponding serial port channel folder, that is, the received log data is finally stored in the serial port channel folder corresponding to the serial port, and the partition storage of the log data can be realized through the association thereof.
In this embodiment, first, a detection device provided with a local secure digital card is connected to a connection device, and after the connection, whether a serial port channel folder corresponding to each serial port exists in the local secure digital card is detected; if not, establishing a corresponding serial port channel folder in the safety data card for each serial port respectively; detecting whether each serial port of the detection equipment receives log data sent by the connection equipment; if it is detected that at least one serial port receives log data sent by the connection equipment, establishing a corresponding first serial port channel file when determining that no serial port channel file exists in a serial port channel folder corresponding to the serial port for each serial port, determining the current first time, and naming the first serial port channel file according to the first time and a preset file format; and then storing the log data acquired by the serial port in the first serial port channel file. The connecting device is automatically detected by the aid of the secure digital card, the detected log data are stored in the serial port channel files corresponding to the serial port in the secure digital card, and the time of the log data stored in each serial port channel file is matched with the time of the serial port channel file, so that the log data can be stored in a partitioned mode through the relevance between the serial port channel file and the corresponding serial port channel folder, and the convenience of log data detection and storage is effectively improved.
Fig. 4 is a flowchart illustrating a method for processing log data according to yet another embodiment of the present application, as shown in fig. 4, on the basis of the embodiment of fig. 3, optionally, a specific implementation manner of S305 is:
s305a, packaging the log data received by the serial port, and recording the current serial port identification and the current timestamp corresponding to the packaged log data.
If at least one serial port channel in the plurality of serial ports is detected to receive serial port log data sent by the connecting equipment, whether the received log data exceed 512 bytes or the byte interval exceeds 200ms is detected, if the received log data exceed 512 bytes or the byte interval exceeds 200ms, for each path of serial ports, the received serial port log data sent by the connecting equipment are packaged, and current serial port identification and current time stamp corresponding to the packaged log data are recorded. The current serial port identifier may be a CHANNEL number of a current CHANNEL, for example, the current serial port identifier corresponding to the packed log data is CHANNEL1, and the current timestamp may be a time of the received log data, for example, the current timestamp corresponding to the packed log data is 2019-01-01.
S305b, storing the packaged log data, the current serial port identification and the current time corresponding to the log data into a buffer queue corresponding to the current serial port identification.
And storing the packaged log data with the current serial port identification and the current timestamp in the step S305a into a cache queue corresponding to the identification of the current serial port. The received log data are packaged and then are cached and stored, the phenomenon that the received log data are written into the local secure digital card for many times is reduced, the received log data are written after the received packaged log data reach the specified receiving amount, and the storage efficiency is improved. The buffer queue can be vividly described by a transfer station, namely if the received log data are more, the log data can not be received by a storage area, the log data are stored in the transfer station for buffering, the queue is a large container, all the received log data are stored in the queue, and before the log data are stored, each serial port log data packet is marked.
S305c, when it is determined that the log data received by the serial port meets a preset condition, determining whether a current time corresponding to the packaged log data stored in the buffer queue is the same as a time of the first serial port channel file corresponding to the identifier of the current serial port. If yes, go to step S305 d; if not, go to step S305 e.
When it is detected that the log data received by the serial port meets the preset condition, according to the packaged log data with the current serial port identifier and the current timestamp stored in S305b, it is determined whether the current time corresponding to the packaged log data stored in the cache queue is the same as the time of the first serial port channel file corresponding to the current serial port identifier, so as to create a new first serial port channel file corresponding to the current serial port identifier in real time.
The preset condition may be that the interval of the received log data bytes exceeds a certain preset time, and the preset time may be specifically set according to the situation, and is set to 200ms in this embodiment.
S305d, storing the packaged data in the first serial port channel file, and ending the processing flow.
If it is determined that the current time corresponding to the packed log data stored in the cache queue is the same as the time of the first serial port channel file corresponding to the identifier of the current serial port, the packed log data with the current serial port identifier and the current timestamp stored in the cache queue can be directly stored in the current first serial port channel file. For example, if the current time corresponding to the packaged log data stored in the cache queue is 2019-01-01, and the time of the corresponding first serial port CHANNEL file with the current serial port identifier of CHANNEL1 is also 2019-01-01, the packaged log data with the current serial port identifier of CHANNEL1 and the current timestamp of 2019-01-01 stored in the cache queue may be directly stored in the first serial port CHANNEL file named as CHANNEL1_2019-01-01. TXT.
S305e, establishing a second serial port channel file corresponding to the serial port.
And if the current time corresponding to the packed log data stored in the cache queue is determined to be different from the time of the first serial port channel file corresponding to the identifier of the current serial port, establishing a second serial port channel file corresponding to the serial port. For example, if the current time corresponding to the packed log data stored in the cache queue is 2019-01-02 and the time of the first serial port CHANNEL file corresponding to the serial port identifier CHANNEL1 is 2019-01-01, a second serial port CHANNEL file corresponding to the serial port needs to be established, and the current serial port identifier of the established second serial port CHANNEL file is CHANNEL 1.
S305f, determining the current second time, naming the second serial port channel file according to the second time and the preset file format, and storing the packaged log data in the second serial port channel file.
When it is detected that the current time corresponding to the packaged log data stored in the cache queue is different from the time of the first serial port channel file corresponding to the identifier of the current serial port, obtaining a current second time, that is, the time of the established second serial port channel file, according to a second serial port channel file corresponding to a serial port channel folder established in S305e, naming the second serial port channel file corresponding to each established serial port according to the second time and a preset file format of the second serial port channel file, and storing the packaged log data stored in the cache queue into the second serial port channel file newly created currently. For example, the name of the second serial port channel file established in the first serial port channel in the multi-path serial port channel file may be: CHANNEL1_2019-01-02.TXT, wherein CHANNEL1 represents a first serial port CHANNEL in the multiple serial port CHANNELs; 2019-01-02 represents the time of the established second serial port channel file, namely the second time; TXT represents a preset file format, the packed log data stored in the buffer queue may be stored into the second serial CHANNEL file named CHANNEL1_2019-01-02. TXT.
Optionally, one possible implementation manner of S305c is:
and when detecting that the connection equipment sends a data byte interval and analyzing an idle identification bit based on the data byte interval, determining that the log data received by the serial port meets a preset condition.
Analyzing the received packed log data, that is, detecting the data byte interval sent by the connection device, that is, determining whether the byte interval in the received log data exceeds 200 ms. If the fact that the data byte interval sent by the connecting device exceeds 200ms is detected, setting an idle flag bit based on the data byte interval, determining that the log data byte interval received by the serial port exceeds 200ms based on the idle identification bit analyzed by the data byte interval, then recording the current time, and storing the received log data into a serial port channel file corresponding to the serial port.
Optionally, another possible implementation manner of S305c is:
and analyzing the received log data, and if the analyzed log data comprises characters which are the same as preset characters, determining that the log data received by the serial port meets preset conditions.
Analyzing the received packed log data, judging whether the analyzed log data contains characters which are the same as preset characters or not, if the analyzed log data contains the characters which are the same as the preset characters, determining that the log data received by the serial port meets preset conditions, recording the current time, and storing the received log data into a serial port channel file corresponding to the serial port.
The preset character can be a carriage return character, and the application is not limited to the carriage return character.
Fig. 5 is a schematic flowchart of a method for processing log data according to another embodiment of the present application, as shown in fig. 5, on the basis of the embodiment of fig. 3, optionally, the method includes:
s306, obtaining a log data calling request, wherein the log data calling request comprises time information to be called.
The connection equipment sends a log data calling request to the detection equipment provided with the local safe digital card, and the detection equipment provided with the local safe digital card can receive the log data calling request, wherein the log data calling request contains time information to be called.
S307, according to the log data calling request, inquiring the secure digital card, acquiring a serial port channel file matched with the called time information, and reporting the packaged log data stored in the file.
When the detection equipment detects the connection equipment and stores the log data information, each serial port is provided with a corresponding serial port channel folder, and a serial port channel file under the serial port channel folder, and there is a correlation between the file name and the time of storing log data, when receiving the log data retrieval request acquired in S306, traversing and inquiring the packed log data which is mostly stored in the local secure digital and has serial port identification and time information according to the relevance to acquire a serial port channel file matched with the called time information, and then the packed log data stored in the serial port channel file is reported, so that the problem time point can be better positioned, and the problem log data can be conveniently and quickly inquired by taking the time point as a reference so as to find out the log data with problems.
On the basis of the embodiment of fig. 3, optionally, the method further includes:
and S308, when the capacity of the log data stored in the secure digital card is determined to be larger than a preset storage threshold value, deleting the serial port channel file stored in the secure digital card according to the timestamp corresponding to the packaged log data.
In this embodiment, when it is detected that at least one serial port receives log data sent by the connection device, before the acquired log data is stored in a serial port channel file corresponding to the serial port through the serial port, whether the capacity of the log data stored in the local secure digital card is larger than a preset storage threshold value or not needs to be judged, if the capacity of the log data stored in the secure digital card is larger than the preset storage threshold value, according to a timestamp corresponding to the packaged log data, deleting some serial port channel log files with earlier time information corresponding to the packed log data to obtain enough capacity to continue to store the log data, the preset storage threshold may be a difference between a total capacity value of the secure digital card and the received capacity value of the log data to be stored.
In this embodiment, first, a detection device provided with a local secure digital card is connected to a connection device, and after the connection, it is detected whether a serial port channel folder corresponding to a multi-channel serial port exists in the local secure digital card; if not, respectively establishing a corresponding serial port channel folder in the safety data card for each path of serial port, and establishing a first serial port channel file under each serial port channel folder; naming the first serial port channel file corresponding to each serial port according to the first time and a preset file format; sending data to each serial port through a connecting device, detecting whether each serial port receives log data sent by the connecting device or not, if at least one serial port receives the log data sent by the connecting device, packaging the received log data, recording a current serial port identifier and a current timestamp corresponding to the packaged log data, and storing the current serial port identifier and the current timestamp into a cache queue corresponding to the identifier of the current serial port; when the serial port is determined not to receive the log data sent by the connection equipment, determining whether the current time corresponding to the packed log data stored in the cache queue is the same as the time of a first serial port channel file corresponding to the identifier of the current serial port; and when the packed data are determined to be the same, storing the packed data into the first serial port channel file. If the log data are different, a second serial port channel file is newly established, the current second time is determined, the second serial port channel file is named according to the second time and a preset file format, the packaged log data are stored in the second serial port channel file and then stored in the second serial port channel file corresponding to the serial port, therefore, more log data can be processed, more log files can be stored, and the analysis efficiency of the serial port data is improved. Meanwhile, the safety digital card can be inquired according to the sent log data calling request, a serial port channel file matched with the called time information is obtained, and the packed data stored in the file is reported, so that the problem time point is better positioned, and the convenience of log data detection and storage is effectively improved.
Fig. 6 is a schematic structural diagram of a log data processing apparatus according to an embodiment of the present application, and as shown in fig. 6, an apparatus 600 according to an embodiment of the present application may include: a detection module 610 and a processing module 620.
The detecting module 610 is configured to detect whether each serial port receives log data sent by a connection device.
The processing module 620 is configured to, if it is detected that at least one serial port receives log data sent by the connection device, store the received log data in a serial port channel folder corresponding to the serial port through the serial port.
The serial port channel folder is arranged in a local secure digital card.
Optionally, the detecting module 610 is further configured to, when determining to connect the connection device, first detect whether a serial port channel folder corresponding to each serial port exists in a local secure digital card.
The processing module 620 is further configured to establish a serial port channel folder in the secure data card for each serial port when a serial port channel folder corresponding to each serial port does not exist in the local secure digital card.
The processing module 620 is specifically configured to:
when determining that no serial port channel file exists in a serial port channel folder corresponding to the serial port, establishing a corresponding first serial port channel file, determining a current first time, and naming the first serial port channel file according to the first time and a preset file format;
and storing the log data acquired by the serial port in the first serial port channel file.
Optionally, the processing module 620 is specifically configured to:
and packaging the log data received by the serial port, and recording a current serial port identifier and a current timestamp corresponding to the packaged log data.
And storing the packed log data, the current serial port identification corresponding to the packed log data and the current time into a cache queue corresponding to the current serial port identification.
And when determining that the log data received by the serial port meets the preset condition, determining whether the current time corresponding to the packaged log data stored in the cache queue is the same as the time of the first serial port channel file corresponding to the identifier of the current serial port.
And when the packed data are determined to be the same, storing the packed data into the first serial port channel file.
Optionally, the processing module 620 is further configured to:
and if the serial port is different, establishing a second serial port channel file corresponding to the serial port.
And determining the current second time, naming the second serial port channel file according to the second time and a preset file format, and storing the packaged log data in the second serial port channel file.
Optionally, the processing module 620 is further configured to obtain a log data retrieval request, where the log data retrieval request includes time information to be retrieved.
The processing module 620 is further configured to query the secure digital card according to the log data retrieval request, obtain a serial port channel file matched with the retrieved time information, and report the packed data stored in the file.
Optionally, the processing module 620 is specifically configured to:
when detecting that the connection equipment sends a data byte interval and analyzing an idle identification bit based on the data byte interval, determining that log data received by the serial port meets a preset condition;
alternatively, the first and second electrodes may be,
and analyzing the received log data, and if the analyzed log data comprises characters which are the same as preset characters, determining that the log data received by the serial port meets preset conditions.
Optionally, the processing module 620 is further configured to delete the serial port channel file stored in the secure data card according to the timestamp corresponding to the packed log data when it is determined that the capacity of the log data stored in the secure digital card is greater than a preset storage threshold.
The apparatus of this embodiment may be configured to implement the technical solutions of the above method embodiments, and the implementation principle and the technical effect are similar, which are not described herein again.
Fig. 7 is a schematic structural diagram of an electronic device according to an embodiment of the present application, and as shown in fig. 7, an electronic device 700 according to this embodiment may include: memory 710, processor 720.
A memory 710 for storing program instructions;
a processor 720, configured to call and execute the program instructions in the memory, and perform:
and detecting whether each serial port receives log data sent by the connecting equipment.
And if at least one serial port is detected to receive the log data sent by the connecting equipment, storing the obtained log data in a serial port channel folder corresponding to the serial port through the serial port.
The serial port channel folder is arranged in a local secure digital card.
Optionally, the processor 720 is further configured to:
when the connection equipment is determined to be connected, whether a serial port channel folder corresponding to each serial port exists in a local secure digital card or not is detected.
And if not, respectively establishing a corresponding serial port channel folder in the safety data card for each serial port.
Optionally, the processor 720 is specifically configured to:
when determining that no serial port channel file exists in a serial port channel folder corresponding to the serial port, establishing a corresponding first serial port channel file, and determining the current first time so as to name the first serial port channel file according to the first time and a preset file format.
And storing the log data acquired by the serial port in the first serial port channel file.
Optionally, the processor 720 is specifically configured to:
and packaging the log data received by the serial port, and recording a current serial port identifier and a current timestamp corresponding to the packaged log data.
And storing the packed log data, the current serial port identification corresponding to the packed log data and the current time into a cache queue corresponding to the current serial port identification.
And when determining that the log data received by the serial port meets the preset condition, determining whether the current time corresponding to the packaged log data stored in the cache queue is the same as the time of the first serial port channel file corresponding to the identifier of the current serial port.
And when the packed data are determined to be the same, storing the packed data into the first serial port channel file.
Optionally, the processor 720 is further configured to:
and if the serial port is different, establishing a second serial port channel file corresponding to the serial port.
And determining the current second time, naming the second serial port channel file according to the second time and a preset file format, and storing the packaged log data in the second serial port channel file.
Optionally, the processor 720 is further configured to:
acquiring a log data calling request, wherein the log data calling request comprises time information to be called;
and inquiring the secure digital card according to the log data calling request, acquiring a serial port channel file matched with the called time information, and reporting the log data stored in the file.
Optionally, the processor 720 is specifically configured to:
when detecting that the connection equipment sends a data byte interval and analyzing an idle identification bit based on the data byte interval, determining that log data received by the serial port meets a preset condition;
alternatively, the first and second electrodes may be,
and analyzing the received log data, and if the analyzed log data comprises characters which are the same as preset characters, determining that the log data received by the serial port meets preset conditions.
Optionally, the processor 720 is further configured to:
and deleting the serial port channel file stored in the secure data card according to the timestamp corresponding to the packed log data when the capacity of the log data stored in the secure digital card is determined to be larger than a preset storage threshold value.
The electronic device of this embodiment may be configured to execute the technical solutions of the above method embodiments, and the implementation principle and the technical effect are similar, which are not described herein again.
Those of ordinary skill in the art will understand that: all or a portion of the steps of implementing the above-described method embodiments may be performed by hardware associated with program instructions. The program may be stored in a computer-readable storage medium. When executed, the program performs steps comprising the method embodiments described above; and the aforementioned storage medium includes: various media capable of storing program codes, such as a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk, and an optical disk.
Finally, it should be noted that: the above 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 or all of the technical features may be equivalently replaced; and the modifications or the substitutions do not make the essence of the corresponding technical solutions depart from the scope of the technical solutions of the embodiments of the present application.

Claims (10)

1. A method for processing log data is characterized by comprising the following steps:
detecting whether each serial port receives log data sent by the connecting equipment or not;
if at least one serial port is detected to receive the log data sent by the connecting equipment, storing the received log data in a serial port channel folder corresponding to the serial port through the serial port;
the serial port channel folder is arranged in a local secure digital card.
2. The method of claim 1, further comprising:
when the connection equipment is determined to be connected, detecting whether a serial port channel folder corresponding to each serial port exists in a local secure digital card;
and if not, respectively establishing a corresponding serial port channel folder in the safety data card for each serial port.
3. The method of claim 2, wherein the storing, via the serial port, the received log data in a serial port channel folder corresponding to the serial port comprises:
when determining that no serial port channel file exists in a serial port channel folder corresponding to the serial port, establishing a corresponding first serial port channel file, determining a current first time, and naming the first serial port channel file according to the first time and a preset file format;
and storing the log data acquired by the serial port in the first serial port channel file.
4. The method according to claim 3, wherein the storing the log data obtained by the serial port in the first serial port channel file comprises:
packaging the log data received by the serial port, and recording a current serial port identifier and a current timestamp corresponding to the packaged log data;
storing the packed log data, the current serial port identification and the current time corresponding to the packed log data into a cache queue corresponding to the current serial port identification;
when the log data received by the serial port meets the preset condition, determining whether the current time corresponding to the packed log data stored in the cache queue is the same as the time of the first serial port channel file corresponding to the current serial port identifier;
and when the log data are determined to be the same, storing the packaged log data into the first serial port channel file.
5. The method of claim 4, further comprising:
if the current time corresponding to the packed log data stored in the cache queue is determined to be different from the time of the first serial port channel file corresponding to the current serial port identification, establishing a second serial port channel file corresponding to the serial port;
and determining the current second time, naming the second serial port channel file according to the second time and a preset file format, and storing the packaged log data in the second serial port channel file.
6. The method according to claim 4, wherein the determining that the log data received by the serial port meets the preset condition comprises:
when detecting that the connection equipment sends a data byte interval and analyzing an idle identification bit based on the data byte interval, determining that log data received by the serial port meets a preset condition;
alternatively, the first and second electrodes may be,
and analyzing the received log data, and if the analyzed log data comprises characters which are the same as preset characters, determining that the log data received by the serial port meets preset conditions.
7. The method of any one of claims 1-6, further comprising:
and deleting the serial port channel file stored in the secure data card according to the timestamp corresponding to the packed log data when the capacity of the log data stored in the secure digital card is determined to be larger than a preset storage threshold value.
8. An apparatus for processing log data, comprising:
the detection module is used for detecting whether each serial port receives log data sent by the connecting equipment;
the processing module is used for storing the received log data in a serial port channel folder corresponding to the serial port for each serial port through the serial port if the fact that the log data sent by the connecting device is received by at least one serial port is detected;
the serial port channel folder is arranged in a local secure digital card.
9. An electronic device, comprising:
a memory for storing program instructions;
a processor for calling and executing the program instructions in the memory to execute the processing method of the log data according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that the computer storage medium stores a computer program which, when executed by a processor, implements the processing method of log data according to any one of claims 1 to 7.
CN201911409299.5A 2019-12-31 2019-12-31 Log data processing method and device Active CN111198855B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201911409299.5A CN111198855B (en) 2019-12-31 2019-12-31 Log data processing method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201911409299.5A CN111198855B (en) 2019-12-31 2019-12-31 Log data processing method and device

Publications (2)

Publication Number Publication Date
CN111198855A true CN111198855A (en) 2020-05-26
CN111198855B CN111198855B (en) 2023-07-25

Family

ID=70746472

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201911409299.5A Active CN111198855B (en) 2019-12-31 2019-12-31 Log data processing method and device

Country Status (1)

Country Link
CN (1) CN111198855B (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113485661A (en) * 2021-07-01 2021-10-08 深圳市同泰怡信息技术有限公司 Four-way server and method for outputting log information by four-way server
WO2023043370A3 (en) * 2021-09-17 2023-04-27 Envision Digital International Pte. Ltd. Method and apparatus for sending logs, and log management system

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20120254120A1 (en) * 2011-03-31 2012-10-04 International Business Machines Corporation Logging system using persistent memory
CN109002547A (en) * 2018-07-30 2018-12-14 努比亚技术有限公司 Journal file storage method, mobile terminal and computer readable storage medium
CN109376129A (en) * 2018-10-08 2019-02-22 郑州云海信息技术有限公司 A method of storage log is collected when locking by SYS_TF automatically
CN109783417A (en) * 2019-01-11 2019-05-21 四川长虹电器股份有限公司 A kind of serial communication device and method
CN110337017A (en) * 2019-07-05 2019-10-15 深圳市康冠技术有限公司 Television set and its log processing method, log processing device and readable storage medium storing program for executing
US20190372829A1 (en) * 2018-05-30 2019-12-05 International Business Machines Corporation Determining a storage network path utilizing log data
CN110609818A (en) * 2018-05-29 2019-12-24 视联动力信息技术股份有限公司 Log processing method and device

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20120254120A1 (en) * 2011-03-31 2012-10-04 International Business Machines Corporation Logging system using persistent memory
CN110609818A (en) * 2018-05-29 2019-12-24 视联动力信息技术股份有限公司 Log processing method and device
US20190372829A1 (en) * 2018-05-30 2019-12-05 International Business Machines Corporation Determining a storage network path utilizing log data
CN109002547A (en) * 2018-07-30 2018-12-14 努比亚技术有限公司 Journal file storage method, mobile terminal and computer readable storage medium
CN109376129A (en) * 2018-10-08 2019-02-22 郑州云海信息技术有限公司 A method of storage log is collected when locking by SYS_TF automatically
CN109783417A (en) * 2019-01-11 2019-05-21 四川长虹电器股份有限公司 A kind of serial communication device and method
CN110337017A (en) * 2019-07-05 2019-10-15 深圳市康冠技术有限公司 Television set and its log processing method, log processing device and readable storage medium storing program for executing

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113485661A (en) * 2021-07-01 2021-10-08 深圳市同泰怡信息技术有限公司 Four-way server and method for outputting log information by four-way server
CN113485661B (en) * 2021-07-01 2023-08-22 深圳市同泰怡信息技术有限公司 Four-way server and method for outputting log information thereof
WO2023043370A3 (en) * 2021-09-17 2023-04-27 Envision Digital International Pte. Ltd. Method and apparatus for sending logs, and log management system

Also Published As

Publication number Publication date
CN111198855B (en) 2023-07-25

Similar Documents

Publication Publication Date Title
US10652265B2 (en) Method and apparatus for network forensics compression and storage
CN102045772B (en) Data transmission method and device
CN111711546B (en) Device throughput testing method, device, system and computer readable storage medium
CN108133008A (en) The processing method of business datum, device, equipment and storage medium in database
CN111211980B (en) Transmission link management method, transmission link management device, electronic equipment and storage medium
RU2010135523A (en) METHOD AND DEVICE FOR IDENTIFICATION OF A CHANNEL IN A WIRELESS COMMUNICATION SYSTEM
CN111198855A (en) Method and device for processing log data
CN111541521B (en) Data packet length identification method and system
US9654491B2 (en) Network filtering apparatus and filtering method
CN110248379B (en) Performance test method and device for base station in wireless local area network
CN106790299B (en) Wireless attack defense method and device applied to wireless Access Point (AP)
CN112436998B (en) Data transmission method and electronic equipment
CN108881124B (en) Method, system, storage medium and device for realizing high-performance communication between modules
CN113014510B (en) Data caching method and device in distributed test of inertial navigation system
CN106557535B (en) Method and system for processing big data level Pcap file
CN110351274B (en) Network attack surface tracking method, server and system
CN108076070B (en) FASP (fast open shortest Path protocol) blocking method, device and analysis system
CN113422760B (en) Data transmission method, device, electronic device and storage medium
CN111740996B (en) Method for rapidly splitting HTTP request and response in flow analysis scene
CN113364793A (en) ICMP hidden tunnel detection method, device and storage medium
CN111625412A (en) Flume-based data acquisition method, system, device and storage medium
CN108243323B (en) Software upgrading method and device
CN110196862B (en) Data scene construction method, device, server and system
CN113965384B (en) Network security anomaly detection method, device and computer storage medium
CN112817536B (en) Data packet capturing method and related 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
GR01 Patent grant
GR01 Patent grant