Log data processing method and device and terminal equipment
By detecting the system properties of the terminal device and using preset script files to collect log data, the problem of not being able to obtain log data in time is solved, and the function of automatic and rapid directional crawling of log data is realized, which improves the efficiency of system development and maintenance.
Patent Information
- Application Number
- CN202510229330.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-27
- Publication Date
- 2025-06-27
AI Technical Summary
During the development, debugging and maintenance process, due to the lack of tools or software serial port settings, the required log data cannot be obtained in time, affecting system development and abnormal maintenance.
By detecting whether the system attribute of the terminal device is a specified attribute, the target log data is collected based on the preset script file and stored in a specific folder. In response to the mobile storage device's request to access the terminal device, the log data is copied to the mobile storage device.
It realizes the function of automatically and quickly crawling log data in the absence of tool or software serial port setting, and promptly obtaining the required log data, providing convenience for subsequent system development and abnormal maintenance.
Smart Images

Figure CN120216472A_ABST
Abstract
Description
Technical Field
[0001] This application belongs to the field of computer technology, and particularly relates to a method, device, and terminal device for processing log data. Background Art
[0002] Log data can be considered a very important part of system development, providing developers with the ability to debug and monitor the running state of applications. For example, Android Log enables developers to record, view, and analyze the running information of applications, helping to identify and solve problems during development and maintenance. Therefore, by reasonably using log data, developers can effectively improve the stability and user experience of applications and discover and solve problems in a timely manner.
[0003] However, in the actual development, debugging, and usage processes, it is often due to the lack of tools or the closing of software serial port settings that the required log data cannot be obtained in a timely manner, which has an adverse impact on subsequent system development and exception maintenance. Summary of the Invention
[0004] Embodiments of this application provide a method, device, and terminal device for processing log data, which can realize the function of automatically and quickly capturing log data in the case of lack of tools or closing of software serial port settings, obtain the required log data in a timely manner, and provide convenience for subsequent system development and exception maintenance.
[0005] In a first aspect, embodiments of this application provide a method for processing log data, including:
[0006] When it is detected that the system attribute of the terminal device is a specified attribute, collect the target log data of the terminal device based on a preset script file, where the system attribute of the terminal device is configured by the user through the system service, and the preset script file runs continuously in the background of the terminal device;
[0007] Store the target log data in a first folder corresponding to the preset script file in the terminal device;
[0008] In response to a removable storage device requesting access to the terminal device, copy all the log data stored in the first folder to the removable storage device.
[0009] In some embodiments, before collecting the target log data of the terminal device based on the preset script file when it is detected that the system attribute of the terminal device is a specified attribute, the method further includes:
[0010] Pre-configure the preset script file to the terminal device;
[0011] Mount the log capture process to the terminal device through the system service;
[0012] In response to a user's configuration operation on the system attributes of a terminal device through the system service, detect whether the system attributes of the terminal device are specified attributes.
[0013] In some embodiments, collect target log data of a terminal device based on a preset script file, including:
[0014] Start a log grabbing process based on a preset script file, where the log grabbing process is used to collect target log data of the terminal device.
[0015] In some embodiments, a removable storage device includes a USB flash drive. In response to the removable storage device requesting access to the terminal device, copy all the log data stored in a first folder to the removable storage device, including:
[0016] In response to the USB flash drive requesting access to the terminal device, detect whether there is a mounting event of the USB flash drive and whether the storage path of the USB flash drive is accessible;
[0017] If it is detected that there is a mounting event of the USB flash drive and the storage path of the USB flash drive is accessible, then copy all the log data stored in the first folder to the USB flash drive.
[0018] In some embodiments, copy all the log data stored in the first folder to the USB flash drive, including:
[0019] Detect whether a second folder in the USB flash drive is in a normal use state;
[0020] If the second folder is in a normal use state, then copy all the log data in the first folder to the USB flash drive.
[0021] In some embodiments, store the target log data in a first folder corresponding to a preset script file in the terminal device, including:
[0022] Detect whether there is a first folder corresponding to the preset script file in the terminal device;
[0023] If it is detected that there is no first folder in the terminal device, then create a first folder in the terminal device and set the read / write permissions of the first folder;
[0024] Store the target log data in the first folder.
[0025] In some embodiments, after detecting whether there is a first folder corresponding to a preset script file in the terminal device, the method further includes:
[0026] If it is detected that there is a first folder in the terminal device, then detect whether there is historical log data stored in the first folder;
[0027] If it is detected that historical log data has been stored in the first folder, the log identifier of the historical log data is modified from the latest identifier to the historical identifier, the target log data is stored in the first folder, and the log identifier of the target log data is set to the latest identifier;
[0028] If it is detected that no historical log data is stored in the first folder, the target log data is stored in the first folder, and the log identifier of the target log data is set to the latest identifier.
[0029] In some embodiments, after copying all the log data stored in the first folder to a removable storage device, the method further includes:
[0030] Displaying a processing completion message on the display panel of the terminal device, where the processing completion message is used to prompt the user that the processing operation of the log data has been completed.
[0031] In a second aspect, an embodiment of the present application provides a log data processing apparatus, including:
[0032] An acquisition module, configured to acquire target log data of the terminal device based on a preset script file when it is detected that the system attribute of the terminal device is a specified attribute, where the system attribute of the terminal device is configured by the user in a system service manner, and the preset script file runs continuously in the background of the terminal device;
[0033] A storage module, configured to store the target log data in a first folder corresponding to the preset script file in the terminal device;
[0034] A copy module, configured to copy all the log data stored in the first folder to a removable storage device in response to a request from the removable storage device to access the terminal device.
[0035] In a third aspect, an embodiment of the present application provides a terminal device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, where when the processor executes the computer program, the method according to any item of the first aspect is implemented.
[0036] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, where the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method according to any item of the first aspect is implemented.
[0037] In a fifth aspect, an embodiment of the present application provides a computer program product, which when running on a terminal device causes the terminal device to execute the method according to any item of the first aspect.
[0038] The embodiments of the present application provide a method, an apparatus, and a terminal device for processing log data. The method includes: when it is detected that the system attribute of the terminal device is a specified attribute, collecting target log data of the terminal device based on a preset script file, where the system attribute of the terminal device is configured by the user in the manner of a system service, and the preset script file runs continuously in the background of the terminal device; storing the target log data in a first folder corresponding to the preset script file in the terminal device; and in response to a mobile storage device requesting to access the terminal device, copying all the log data stored in the first folder to the mobile storage device. By using the above technical solution, by collecting the target log data of the terminal device based on the preset script file when it is detected that the system attribute of the terminal device is the specified attribute, the function of automatically and quickly and directionally capturing log data in the case of lack of tools or software serial port setting being closed is realized. At the same time, by responding to the mobile storage device requesting to access the terminal device and copying all the log data stored in the first folder to the mobile storage device, the required log data can be obtained in time, which provides convenience for subsequent system development and exception maintenance. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following will briefly introduce the drawings required for use in the embodiments or the description of the prior art. Obviously, the following drawings are only some embodiments of the present application. For those of ordinary skill in the art, without creative efforts, other drawings can be obtained based on these drawings.
[0040] Figure 1 is a schematic flowchart of a method for processing log data provided by an embodiment of the present application;
[0041] Figure 2 is a schematic flowchart of a method for processing log data provided by another embodiment of the present application;
[0042] Figure 3 is a schematic overall architecture diagram of a method for processing log data provided by another embodiment of the present application;
[0043] Figure 4 is a structural block diagram of an apparatus for processing log data provided by an embodiment of the present application;
[0044] Figure 5 is a schematic structural diagram of a terminal device provided by an embodiment of the present application. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0045] In the following description, for the purpose of illustration rather than limitation, specific details such as specific system architectures, technologies, etc. are presented to provide a thorough understanding of the embodiments of the present application. However, those skilled in the art should understand that the present application can also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to avoid unnecessary details from obscuring the description of the present application.
[0046] It should be understood that when used in the specification of the present application and the appended claims, the term "comprising" indicates the presence of the described features, wholes, steps, operations, elements, and / or components, but does not exclude the presence or addition of one or more other features, wholes, steps, operations, elements, components, and / or their combinations.
[0047] It should also be understood that the term "and / or" as used in the specification of the present application and the appended claims refers to any combination and all possible combinations of one or more of the associated listed items, and includes these combinations.
[0048] As used in the specification of the present application and the appended claims, the term "if" can be interpreted as "when" or "once" or "in response to determining" or "in response to detecting" depending on the context. Similarly, the phrase "if determined" or "if [the described condition or event] is detected" can be interpreted as meaning "once determined" or "in response to determining" or "once [the described condition or event] is detected" or "in response to detecting [the described condition or event]" depending on the context.
[0049] In addition, in the description of the specification of the present application and the appended claims, the terms "first", "second", "third", etc. are only used for differentiating descriptions and cannot be understood as indicating or implying relative importance.
[0050] The reference to "one embodiment" or "some embodiments" or the like described in the specification of the present application means that a specific feature, structure, or characteristic described in connection with that embodiment is included in one or more embodiments of the present application. Thus, statements such as "in one embodiment", "in some embodiments", "in other some embodiments", "in still other embodiments", etc. that appear in different places in this specification do not necessarily all refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in another way. The terms "comprising", "including", "having", and their variants all mean "including but not limited to", unless otherwise specifically emphasized in another way.
[0051] It should be noted that the information collection process (such as the face image collection process, the log data collection process, etc.) / feature extraction process involved in this application is executed with the user's knowledge and permission. That is, the information collection process / feature extraction process complies with the requirements of laws and regulations and does not belong to acts that harm the public interest.
[0052] The method for processing log data provided in the embodiments of this application can be applied to terminal devices such as mobile phones, tablet computers, wearable devices, in-vehicle devices, augmented reality (AR) / virtual reality (VR) devices, laptop computers, ultra-mobile personal computers (UMPCs), netbooks, personal digital assistants (PDAs), etc. The embodiments of this application do not impose any restrictions on the specific types of terminal devices.
[0053] Figure 1 is a schematic flowchart of a method for processing log data provided in an embodiment of this application. As an example and not a limitation, this method can be applied to a terminal device, such as Figure 1 As shown, this method includes:
[0054] S101. When it is detected that the system attribute of the terminal device is a specified attribute, collect the target log data of the terminal device based on a preset script file, where the system attribute of the terminal device is configured by the user through the system service, and the preset script file runs continuously in the background of the terminal device.
[0055] The system attribute may refer to an attribute related to the system. For example, it can be a prop attribute customized by relevant personnel. In this embodiment, the system attribute of the terminal device can be configured by the user through the system service. For example, when it is currently necessary to capture log data, the user can configure the system attribute as a specified attribute through the system service, so that when the terminal device detects that the system attribute is the specified attribute, the target log data of the terminal device is collected based on the preset script file. The specific process of configuring the system attribute will not be elaborated here as long as the automatic collection of the target log data can be achieved.
[0056] Among them, the preset script file can be a pre-configured script file used to represent the content of the log data to be collected, and the specific content can be configured by relevant personnel according to requirements; it should be noted that when it is detected that the system attribute of the terminal device is a specified attribute, the preset script file can run continuously in the background of the terminal device to achieve continuous collection of the target log data.
[0057] S102. Store the target log data in the first folder corresponding to the preset script file in the terminal device.
[0058] The first folder may refer to the folder corresponding to the preset script file, such as the default folder set for the preset script file, which is used to store the target log data.
[0059] Specifically, after the target log data is collected, the target log data can be directly stored in the first folder of the terminal device, or the storage of the target log data can be based on the actual situation of the first folder. Exemplarily, in some embodiments, it can be detected whether there is a first folder corresponding to the preset script file in the terminal device; if it is detected that there is no first folder in the terminal device, a first folder is created in the terminal device, and the read-write permissions of the first folder are set; the target log data is stored in the first folder. For example, when the preset script file is the myautolog execution program, it can be set that the log is defaultly stored in the / data / media / 0 directory of the data partition. When this directory does not exist, the myautolog execution program will automatically create this folder, give the system permission of 660, and set the read-write permissions of this folder through system("chcon u:object_r:media_rw_data_file:s0 / data / media / 0"), so that the collected log information can be stored in the / data / media / 0 directory of the data partition. Or, when this directory exists, the log information can be directly stored in this directory, or the log data can be distinguished according to the actual situation of this directory. For example, the newly collected log information can be used to replace the historical log data stored in this directory, that is, the stored historical log data is deleted, and the newly collected log information is stored; the historical log data and the newly collected log information can also be stored at the same time, etc.
[0060] In some embodiments, after detecting whether there is a first folder corresponding to the preset script file in the terminal device, the method further includes:
[0061] If it is detected that there is a first folder in the terminal device, it is detected whether there is historical log data stored in the first folder;
[0062] If it is detected that there is historical log data stored in the first folder, the log identifier of the historical log data is modified from the latest identifier to the historical identifier, the target log data is stored in the first folder, and the log identifier of the target log data is set to the latest identifier;
[0063] If it is detected that the historical log data is not stored in the first folder, the target log data is stored in the first folder, and the log identifier of the target log data is set to the latest identifier.
[0064] In the specific implementation, if it is detected that the historical log data has been stored in the first folder, that is, the log information already exists in the first folder currently, the log information captured last time can be automatically modified to lastlog information, and at the same time, the current log information and the last lastlog information are saved (that is, the log identifier of the historical log data is modified from the latest identifier to the historical identifier, and the log identifier of the target log data is set to the latest identifier). On this basis, it is convenient to perform retrospective query of the log data, which helps in the abnormal maintenance of the device in the later stage and improves the stability of the device.
[0065] S103. In response to the mobile storage device requesting to access the terminal device, all the log data stored in the first folder is copied to the mobile storage device.
[0066] The mobile storage device can be understood as a portable data storage device, which has a storage medium and generally has the function of reading and writing the medium by itself. The specific types can include external hard drives, USB flash drives, and various memory cards, etc.
[0067] After storing the collected target log data in the first folder through the above steps, the extraction of the log data can be realized by means of the mobile storage device. For example, after the terminal device recognizes that the mobile storage device requests to access the terminal device, it can respond to this access request and directly copy all the log data stored in the first folder to the mobile storage device, or after a series of detection operations, then perform the copy of the log data. For example, the mobile storage device can include a USB flash drive, and the process of copying all the log data to the mobile storage device can include: in response to the USB flash drive requesting to access the terminal device, detecting whether there is a mounting event of the USB flash drive and whether the storage path of the USB flash drive is accessed; if it is detected that there is a mounting event of the USB flash drive and the storage path of the USB flash drive is accessed, then all the log data stored in the first folder can be copied to the USB flash drive.
[0068] In the specific implementation, this embodiment can further detect whether the second folder in the USB flash drive is in a normal use state, and perform different operations according to different detection results. If the second folder is in a normal use state, it means that there is a second folder in the USB flash drive and the second folder has a certain storage space, then all the log data in the first folder can be copied to the USB flash drive. Further, after copying all the log data stored in the first folder to the mobile storage device, a processing completion message can be displayed on the display panel of the terminal device to prompt the user that the processing operation of the log data has been completed currently.
[0069] If the second folder is not in a normal use state, abnormal information can be displayed on the display panel of the terminal device to prompt the user that there is an abnormality with the USB flash drive, facilitating the user to further process the USB flash drive and then copy the log data again.
[0070] As an example, when the user inserts the USB flash drive into the motherboard usb interface of the terminal device, the terminal device can determine that the USB flash drive has been successfully mounted through the usb mount event, and after being able to access the usb path, it can further determine whether the CPLOG folder of the USB flash drive can be used normally through the opendir method. If the CPLOG folder can be used normally, the terminal device can automatically copy the log information in the / data / media / 0 directory of the data partition to the corresponding CPLOG directory of the USB flash drive, and output console information through echo "\n\n!!!!COPY LOG OK!!!!\n\n"> / dev / console to prompt and complete the automatic log capture process.
[0071] A method for processing log data provided in this embodiment, when it is detected that the system attribute of the terminal device is a specified attribute, based on a preset script file, collect the target log data of the terminal device, where the system attribute of the terminal device is configured by the user through the system service method, and the preset script file runs continuously in the background of the terminal device; store the target log data in the first folder corresponding to the preset script file in the terminal device; in response to the mobile storage device requesting to access the terminal device, copy all the log data stored in the first folder to the mobile storage device. Using this method, by collecting the target log data of the terminal device based on the preset script file when it is detected that the system attribute of the terminal device is a specified attribute, the function of automatically and quickly capturing log data in the case of lack of tools or software serial port settings being closed is realized. At the same time, by responding to the mobile storage device requesting to access the terminal device and copying all the log data stored in the first folder to the mobile storage device, the required log data can be obtained in a timely manner, providing convenience for subsequent system development and exception maintenance.
[0072] Figure 2 It is a schematic flowchart of a method for processing log data provided in another embodiment of the present application. In this embodiment, the situation before collecting the target log data of the terminal device based on the preset script file when it is detected that the system attribute of the terminal device is a specified attribute is further optimized as: pre-configure the preset script file to the terminal device; mount the log capture process to the terminal device through the system service method; in response to the user's configuration operation of the system attribute of the terminal device through the system service method, detect whether the system attribute of the terminal device is a specified attribute. As Figure 2 shown, the method includes:
[0073] S201. Pre-configure a preset script file into the terminal device.
[0074] S202. Mount the log capture process to the terminal device in the way of system service.
[0075] S203. In response to the user's configuration operation on the system properties of the terminal device in the way of system service, detect whether the system properties of the terminal device are specified properties.
[0076] In this embodiment, a preset script file can be pre-configured into the terminal device, and the automatic log capture process (i.e., the log capture process) can be mounted through the system service. When log data needs to be captured, the user can perform a configuration operation on the system properties of the terminal device in the way of system service, and the terminal device can respond to this configuration operation and detect whether the system properties of the terminal device are specified properties. For example, when the system satisfies that the system prop property persist.sys.autolog is equal to 1, the automatic log capture daemon process can be started by running the executable script myautolog. The relevant code segment can be as follows:
[0077] on property:persist.sys.autolog=1
[0078] start myautolog
[0079] service myautolog / vendor / bin / myautolog
[0080] class main
[0081] disabled
[0082] oneshotseclabel u:r:myautolog_detect:s0.
[0083] S204. In the case where it is detected that the system properties of the terminal device are specified properties, collect the target log data of the terminal device based on the preset script file.
[0084] In some embodiments, collecting the target log data of the terminal device based on the preset script file includes:
[0085] Start the log capture process based on the preset script file, and the log capture process is used to collect the target log data of the terminal device.
[0086] Among them, the target log data may include at least one of log data with a time axis, log data indicating system anomalies, log data representing system memory information, and log data representing system processes.
[0087] The relevant code segments for collecting log data in the preset script file can be as follows:
[0088] if(access(" / data / media / 0",0)!=0){
[0089] LOGI("LOG DIR NOT INIT.TOUCH IT.");
[0090] system("mkdir / data / media / 0");
[0091] system("chown media_rw / data / media / 0");
[0092] system("chgrp media_rw / data / media / 0");
[0093] system("chmod 660 / data / media / 0");
[0094] system("chcon u:object_r:media_rw_data_file:s0 / data / media / 0");
[0095] }
[0096] ->> Create relevant permissions for the / data / media / 0 folder.
[0097] system("echo \"\n\n!!!!START COPY LOG!!!!\n\n\"> / dev / console");
[0098] ->> Output the information of !!!START COPY LOG!!!! to the serial terminal for display.
[0099] system(" / system / bin / logcat -v threadtime -f \"__LOGCAT_PATH\" &");
[0100] ->> Capture log information with a time axis through the logcat command and store it under / data / media / 0.
[0101] LOGI("cplogPath: %s", cplogPath.c_str());
[0102] cmd = std::string("cp / data / media / 0 / *.log") + cplogPath;
[0103] system(cmd.c_str());
[0104] ->> Copy all files with the.log suffix under / data / media / 0 to the CPLOG folder on the USB drive.
[0105] cmd = std::string("cp -rf / data / anr") + cplogPath;
[0106] system(cmd.c_str());
[0107] ->> Copy the anr content information generated by system exceptions to the CPLOG folder on the USB drive.
[0108] / / cmd = std::string("cp -rf / sys / kernel / debug / binder") + cplogPath;
[0109] / / system(cmd.c_str());
[0110] cmd = std::string("free -m >") + cplogPath + " / free_info.log";
[0111] system(cmd.c_str());
[0112] cmd = std::string(" / system / bin / busybox top -n 1 >") + cplogPath + " / top.log";
[0113] system(cmd.c_str());
[0114] cmd = std::string("ps -A T >") + cplogPath + " / thread_info.log";
[0115] system(cmd.c_str());
[0116] cmd = std::string("ps -A >") + cplogPath + " / process.log";
[0117] system(cmd.c_str());
[0118] cmd = std::string(" / system / bin / getprop >") + cplogPath + " / prop.log";
[0119] system(cmd.c_str());
[0120] cmd = std::string(" / system / bin / dumpsys >") + cplogPath + " / dumpsys.log";
[0121] system(cmd.c_str());
[0122] cmd = std::string(" / system / bin / busybox top -n 1 >>") + cplogPath + " / top.log";
[0123] system(cmd.c_str());
[0124] ->> Grab system memory information, process information, system prop information, sys service and other information, and store them in the CPLOG folder under the USB flash drive.
[0125] system("sync; echo \"\n\n!!!!COPY LOG OK!!!!\n\n\" > / dev / console");
[0126] ->> Output the information!!!!COPY LOG OK!!!! to the serial terminal for display.
[0127] S205. Store the target log data in the first folder corresponding to the preset script file in the terminal device.
[0128] S206. In response to the mobile storage device's request to access the terminal device, copy all the log data stored in the first folder to the mobile storage device.
[0129] A method for processing log data provided by this embodiment provides a basis for subsequent automatic collection of target log data by pre-configuring a preset script file to a terminal device and mounting a log capture process to the terminal device in the manner of a system service, further ensuring the function of subsequent automatic and rapid targeted capture of log data.
[0130] Figure 3 It is a schematic diagram of the overall architecture of a method for processing log data provided by another embodiment of this application. As Figure 3 shown, first, the myautolog execution file can be prefabricated into the system, and the system service is used to control the startup of the myautolog function (that is, pre-configuring a preset script file to the terminal device; mounting the log capture process to the terminal device in the manner of a system service). For example, the myautolog function can be started according to the preset condition persist.sys.autolog = 1 (that is, in response to a user's configuration operation on the system attributes of the terminal device through the system service, detecting whether the system attributes of the terminal device are specified attributes; in the case where it is detected that the system attributes of the terminal device are specified attributes, collecting the target log data of the terminal device based on the preset script file); then when myautolog runs, the required log information can be automatically captured according to the log requirements defined by myautolog, and all the log information is stored in the / data / media / 0 directory of the data partition (that is, starting the log capture process based on the preset script file, and the log capture process is used to collect the target log data of the terminal device; storing the target log data in the first folder corresponding to the preset script file on the terminal device).
[0131] Subsequently, the user can use a USB flash drive and insert it into the corresponding motherboard port at the same time. The system can then follow up on the USB flash drive mounting event. In the case where the USB flash drive mounting is detected, the corresponding log can be copied to the corresponding directory of the USB flash drive (that is, in response to a removable storage device requesting access to the terminal device, copying all the log data stored in the first folder to the removable storage device); finally, the system can prompt that the log capture is successful, and the user can then remove the USB flash drive, thus ending the automatic log capture function.
[0132] As can be seen from the above description, the method for processing log data of the present invention provides a fully automatic solution for capturing and storing Android system logs. It can automatically run the log capture function to the data partition under any circumstances where logs need to be captured, realizing the function of automatically and quickly capturing logs, with fast response speed, accurate and efficient targeted information. At the same time, by using the mounting broadcast of the USB flash drive to start copying log information to the USB flash drive, the function of extracting various required log information through the USB flash drive is realized. It is convenient to use, highly extensible, meets the requirements of quickly copying logs in various abnormal situations, improves the efficiency of testing and development docking, reduces labor costs, and thus provides convenience for end-users to use and subsequent abnormal maintenance.
[0133] Corresponding to the method for processing log data in the above embodiment, Figure 4 is a structural block diagram of a log data processing device provided by an embodiment of the present application. For the sake of convenience of description, only the parts related to the embodiment of the present application are shown.
[0134] Referring to Figure 4 , the device includes:
[0135] An acquisition module 301, configured to acquire target log data of the terminal device based on a preset script file when it is detected that the system attribute of the terminal device is a specified attribute. The system attribute of the terminal device is configured by the user through the system service, and the preset script file runs continuously in the background of the terminal device;
[0136] A storage module 302, configured to store the target log data in a first folder corresponding to the preset script file in the terminal device;
[0137] A copy module 303, configured to copy all the log data stored in the first folder to a removable storage device in response to a request from the removable storage device to access the terminal device.
[0138] A processing device for log data provided in this embodiment, when the acquisition module detects that the system attribute of the terminal device is a specified attribute, collects the target log data of the terminal device based on a preset script file, wherein the system attribute of the terminal device is configured by the user in the manner of a system service, and the preset script file runs continuously in the background of the terminal device; the storage module stores the target log data in the first folder corresponding to the preset script file in the terminal device; the copy module, in response to the mobile storage device requesting to access the terminal device, copies all the log data stored in the first folder to the mobile storage device. By using this device, when it is detected that the system attribute of the terminal device is a specified attribute, the target log data of the terminal device is collected based on a preset script file, realizing the function of automatically and quickly capturing log data in the case of lack of tools or the software serial port setting being closed. At the same time, in response to the mobile storage device requesting to access the terminal device, all the log data stored in the first folder is copied to the mobile storage device, enabling the timely acquisition of the required log data, which provides convenience for subsequent system development and exception maintenance.
[0139] Optionally, a processing device for log data provided in this embodiment further includes:
[0140] A configuration module, configured to pre-configure the preset script file to the terminal device before collecting the target log data of the terminal device based on the preset script file when it is detected that the system attribute of the terminal device is a specified attribute;
[0141] A mounting module, configured to mount the log capture process to the terminal device in the manner of a system service before collecting the target log data of the terminal device based on the preset script file when it is detected that the system attribute of the terminal device is a specified attribute;
[0142] A detection module, configured to detect whether the system attribute of the terminal device is a specified attribute in response to the user's configuration operation on the system attribute of the terminal device in the manner of a system service before collecting the target log data of the terminal device based on the preset script file when it is detected that the system attribute of the terminal device is a specified attribute.
[0143] Optionally, the acquisition module is specifically configured to:
[0144] Start the log capture process based on the preset script file, and the log capture process is used to collect the target log data of the terminal device.
[0145] Optionally, the mobile storage device includes a USB flash drive. In response to the mobile storage device requesting to access the terminal device, copying all the log data stored in the first folder to the mobile storage device includes:
[0146] In response to a USB flash drive requesting access to a terminal device, detect whether there is a mounting event of the USB flash drive and whether the storage path of the USB flash drive is accessed;
[0147] If it is detected that there is a mounting event of the USB flash drive and the storage path of the USB flash drive is accessed, copy all the log data stored in the first folder to the USB flash drive.
[0148] Optionally, the copying module is specifically configured to:
[0149] Detect whether the second folder in the USB flash drive is in a normal use state;
[0150] If the second folder is in a normal use state, copy all the log data in the first folder to the USB flash drive.
[0151] Optionally, the storage module includes:
[0152] A first detection unit, configured to detect whether there is a first folder corresponding to a preset script file in the terminal device;
[0153] A creation unit, configured to create a first folder in the terminal device and set the read-write permission of the first folder if it is detected that there is no first folder in the terminal device;
[0154] A first storage unit, configured to store target log data in the first folder.
[0155] Optionally, the storage module further includes:
[0156] A second detection unit, configured to detect whether there is historical log data stored in the first folder if it is detected that there is a first folder corresponding to a preset script file in the terminal device after detecting whether there is a first folder corresponding to a preset script file in the terminal device;
[0157] A modification unit, configured to modify the log identifier of the historical log data from the latest identifier to the historical identifier if it is detected that there is historical log data stored in the first folder, store the target log data in the first folder, and set the log identifier of the target log data to the latest identifier;
[0158] A second storage unit, configured to store the target log data in the first folder and set the log identifier of the target log data to the latest identifier if it is detected that there is no historical log data stored in the first folder.
[0159] Optionally, a log data processing device provided in this embodiment further includes:
[0160] A display module is configured to display a processing completion message on a display panel of a terminal device after copying all log data stored in a first folder to a removable storage device. The processing completion message is used to prompt the user that the processing operation of the log data has been completed.
[0161] It should be noted that for the information interaction, execution process, etc. between the above-mentioned devices / units, since they are based on the same concept as the method embodiments of the present application, their specific functions and the technical effects brought about can be specifically referred to in the method embodiment section, and will not be elaborated here.
[0162] Those skilled in the art can clearly understand that for the convenience and simplicity of description, only the above-mentioned division of each functional unit and module is used as an example. In actual applications, the above-mentioned functions can be allocated to different functional units and modules according to needs, that is, the internal structure of the device is divided into different functional units or modules to complete all or part of the functions described above. Each functional unit and module in the embodiment can be integrated into one processing unit, or each unit can exist physically alone, or two or more units can be integrated into one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of a software functional unit. In addition, the specific names of each functional unit and module are only for the convenience of mutual distinction and do not limit the protection scope of the present application. The specific working process of the units and modules in the above system can refer to the corresponding process in the foregoing method embodiments and will not be elaborated here.
[0163] The embodiment of the present application also provides a terminal device. Figure 5 FIG. is a schematic structural diagram of a terminal device provided by an embodiment of the present application. As Figure 5 shown, the terminal device includes: at least one processor 401, a memory 402, an input device 403, an output device 404, and a computer program stored in the memory 402 and executable on at least one processor 401. When the processor 401 executes the computer program, the steps in any of the above method embodiments are implemented.
[0164] The input device 403 can be used to receive input digital or character information, and generate key signal inputs related to the user settings and function controls of the terminal device. The output device 404 can include a display device such as a display screen.
[0165] The embodiment of the present application also provides a computer-readable storage medium. The computer-readable storage medium stores a computer program, and when the computer program is executed by the processor 401, the steps in any of the above method embodiments can be implemented.
[0166] An embodiment of the present application provides a computer program product. When the computer program product runs on a terminal device, the terminal device can execute the steps in the above-mentioned method embodiments when executed.
[0167] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on such an understanding, to implement all or part of the processes in the above-mentioned method embodiments of the present application, a computer program can be used to instruct relevant hardware to complete. The computer program can be stored in a computer-readable storage medium. When the computer program is executed by the processor 401, the steps in the above-mentioned method embodiments can be implemented. Among them, the computer program includes computer program code, and the computer program code can be in the form of source code, object code, executable file or some intermediate form, etc. The computer-readable storage medium can at least include: any entity or device that can carry the computer program code to the device / terminal device, recording medium, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signal, telecommunication signal, and software distribution medium. For example, a USB flash drive, a mobile hard disk, a magnetic disk, or an optical disc, etc. In some jurisdictions, according to legislation and patent practice, the computer-readable storage medium cannot be an electrical carrier signal and a telecommunication signal.
[0168] In the above embodiments, the descriptions of the respective embodiments have their own focuses. For the parts not detailed or recorded in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0169] Those of ordinary skill in the art can realize that the units and algorithm steps of the examples described in combination with the embodiments disclosed herein can be implemented by electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are executed in a hardware or software manner depends on the specific application and design constraints of the technical solution. Professional technicians can use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of the present application.
[0170] In the embodiments provided in the present application, it should be understood that the disclosed device / terminal device and method can be implemented in other ways. For example, the device / terminal device embodiments described above are merely illustrative. For example, the division of modules or units is only a logical function division. In actual implementation, there may be other division methods. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the displayed or discussed coupling or direct coupling or communication connection between each other can be through some interfaces. The indirect coupling or communication connection of the device or unit can be in electrical, mechanical or other forms.
[0171] The units described as separate components may or may not be physically separated. The components displayed as units may or may not be physical units, that is, they can be located in one place or distributed to multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0172] The above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them; although the present application has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that they can still modify the technical solutions recorded in the foregoing embodiments, or perform equivalent replacements for some of the technical features; and these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.
Claims
1. A method for processing log data, characterized in that: include: When it is detected that the system attribute of the terminal device is a specified attribute, collecting target log data of the terminal device based on a preset script file, wherein the system attribute of the terminal device is configured by the user through a system service, and the preset script file continuously runs in the background of the terminal device; storing the target log data in a first folder corresponding to the preset script file in the terminal device; In response to a mobile storage device requesting access to the terminal device, all log data stored in the first folder is copied to the mobile storage device.
2. The method for processing log data according to claim 1, characterized in that: In the case where it is detected that the system attribute of the terminal device is a specified attribute, before collecting the target log data of the terminal device based on the preset script file, the method also includes: Pre-configuring the preset script file to the terminal device; Mounting the log capture process to the terminal device by means of system services; In response to the user configuring the system attribute of the terminal device through the system service, it is detected whether the system attribute of the terminal device is a specified attribute.
3. The method for processing log data according to claim 2, characterized in that: The collecting target log data of the terminal device based on a preset script file includes: The log grabbing process is started based on the preset script file, and the log grabbing process is used to collect target log data of the terminal device.
4. The method for processing log data according to claim 1, characterized in that: The mobile storage device includes a USB flash drive, and in response to the mobile storage device requesting access to the terminal device, copying all log data stored in the first folder to the mobile storage device includes: In response to the U disk requesting access to the terminal device, detecting whether there is a mounting event of the U disk and whether a storage path of the U disk is accessed; If a mounting event of the U disk is detected and the storage path of the U disk is accessed, all log data stored in the first folder are copied to the U disk.
5. The method for processing log data according to claim 4, characterized in that: The step of copying all log data stored in the first folder to the U disk includes: Detecting whether the second folder in the USB flash drive is in normal use; If the second folder is in normal use, all log data in the first folder are copied to the U disk.
6. The method for processing log data according to claim 1, characterized in that: The storing the target log data into a first folder corresponding to the preset script file in the terminal device includes: Detecting whether there is a first folder corresponding to the preset script file in the terminal device; If it is detected that the first folder does not exist in the terminal device, create the first folder in the terminal device and set the read and write permissions of the first folder; The target log data is stored in the first folder.
7. The method for processing log data according to claim 6, characterized in that: After detecting whether a first folder corresponding to the preset script file exists in the terminal device, the method further includes: If it is detected that the first folder exists in the terminal device, detecting whether historical log data has been stored in the first folder; If it is detected that historical log data has been stored in the first folder, the log identifier of the historical log data is changed from the latest identifier to the historical identifier, the target log data is stored in the first folder, and the log identifier of the target log data is set to the latest identifier; If it is detected that no historical log data is stored in the first folder, the target log data is stored in the first folder, and the log identifier of the target log data is set to the latest identifier.
8. The method for processing log data according to claim 1, characterized in that: After copying all log data stored in the first folder to the mobile storage device, the method further includes: The processing completion information is displayed on the display panel of the terminal device, and the processing completion information is used to prompt the user that the processing operation of the log data has been completed.
9. A log data processing device, characterized in that: include: A collection module, configured to collect target log data of the terminal device based on a preset script file when it is detected that the system attribute of the terminal device is a specified attribute, wherein the system attribute of the terminal device is configured by a user through a system service, and the preset script file continuously runs in the background of the terminal device; A storage module, used for storing the target log data in a first folder corresponding to the preset script file in the terminal device; The copy module is used for copying all log data stored in the first folder to the mobile storage device in response to a mobile storage device requesting to access the terminal device.
10. A terminal device comprising a processor, a memory, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the terminal device implements the method according to any one of claims 1 to 8.