Log processing method, device, equipment and system

By dividing the resident and dynamic log modules in the mobile application, and dynamically opening and initializing the log module, the problem of low problem location efficiency and high resource consumption in the interaction between the mobile application and the NAS device is solved, and efficient log processing and resource consumption are achieved. manage.

CN118733382APending Publication Date: 2024-10-01HANGZHOU HIKSTORAGE TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410815458.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-21
Publication Date
2024-10-01

AI Technical Summary

Technical Problem

During the interaction between mobile applications and NAS devices, it is difficult to quickly and accurately locate problems that arise, and existing technology causes excessive consumption of terminal resources, affecting user experience.

Method used

By dividing the resident log module and the dynamic log module in the mobile application, the target dynamic log module is dynamically opened according to the application environment, and the log system is initialized to improve problem location efficiency and reduce resource consumption.

Benefits of technology

It improves the efficiency of problem locating when mobile applications interact with NAS devices, reduces terminal resource consumption, and ensures normal user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118733382A_ABST
    Figure CN118733382A_ABST
Patent Text Reader

Abstract

The invention provides a log processing method, device, equipment and system. According to one embodiment of the invention, the log processing method comprises the following steps: when a mobile terminal application is started, determining a target dynamic log module needing to be started according to a current application environment; and setting the target dynamic log module and a resident log module corresponding to the mobile terminal application to be in an open state, and initializing a log system. According to the method, the problem positioning efficiency can be improved when a problem occurs in the interaction process of the mobile terminal application and the NAS equipment.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of data processing technology, and in particular to a log processing method, device, equipment and system. Background Art

[0002] NAS (Network Attached Storage) devices are connected to the network and have data storage functions, so they are also called "network storage."

[0003] For a mobile application that has been launched, some problems that were not discovered during the test may occur during its interaction with the NAS device. For such problems, how to accurately locate them is one of the key points to solve the problem. Summary of the invention

[0004] In view of this, the present application provides a log processing method, device, equipment and system.

[0005] Specifically, the present application is implemented through the following technical solutions:

[0006] According to a first aspect of an embodiment of the present application, a log processing method is provided, which is applied to a mobile terminal device, and the method includes:

[0007] When the mobile application is started, the target dynamic log module to be opened is determined according to the current application environment; wherein; the log module corresponding to the mobile application includes a resident log module and a dynamic log module; the log module corresponding to the mobile application is divided according to the functions between the mobile application and the network attached storage NAS device;

[0008] The target dynamic log module and the resident log module corresponding to the mobile application are set to an open state, and the log system is initialized.

[0009] According to a second aspect of an embodiment of the present application, a log processing device is provided, which is deployed on a mobile terminal device, and the device includes:

[0010] The determination unit is used to determine the target dynamic log module to be started according to the current application environment when the mobile application is started; wherein; the log module corresponding to the mobile application includes a resident log module and a dynamic log module; the log module corresponding to the mobile application is divided according to the functions between the mobile application and the network attached storage NAS device;

[0011] The processing unit is used to set the target dynamic log module and the resident log module corresponding to the mobile terminal application to an open state and initialize the log system.

[0012] According to a third aspect of an embodiment of the present application, there is provided an electronic device, including a processor and a memory, wherein:

[0013] Memory, used to store computer programs;

[0014] The processor is used to implement the method provided in the first aspect when executing the program stored in the memory.

[0015] According to a fourth aspect of an embodiment of the present application, a log processing system is provided, including a NAS device and a mobile terminal device; wherein:

[0016] The log module corresponding to the mobile application on the mobile device includes a resident log module and a dynamic log module; the log module corresponding to the mobile application is divided according to the functions between the mobile application and the NAS device;

[0017] During the interaction between the NAS device and the mobile terminal device, the mobile terminal device performs log processing using the method provided in the first aspect.

[0018] According to the log processing method of the embodiment of the present application, when the mobile application is started, the target dynamic log module that needs to be turned on is determined according to the current application environment, and the target dynamic log module and the resident log module corresponding to the mobile application are set to the on state, and the log system is initialized. By dividing the log modules for the mobile application according to the functions between the mobile application and the NAS device, the efficiency of locating problems when problems arise during the interaction between the mobile application and the NAS device can be improved; in addition, by dividing the log module corresponding to the mobile application into a resident log module and a dynamic log module, when the mobile application is started, the dynamic log module can be turned on as needed according to the application environment, thereby reducing terminal resource consumption. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] Figure 1 A flow chart of a log processing method shown as an exemplary embodiment of the present application;

[0020] Figure 2 A schematic diagram of module configuration parameters shown in an exemplary embodiment of the present application;

[0021] Figure 3 A schematic diagram of a local log file hierarchical architecture is shown as an exemplary embodiment of the present application;

[0022] Figure 4 A schematic diagram of a log system initialization process is shown as an exemplary embodiment of the present application;

[0023] Figure 5A schematic diagram of the main flow of opening a dynamic log module is shown as an exemplary embodiment of the present application;

[0024] Figure 6 A schematic diagram of a log system initialization process for a compatible mobile terminal component is shown as an exemplary embodiment of the present application;

[0025] Figure 7 A log module recording process diagram is shown for an exemplary embodiment of the present application;

[0026] Figure 8 A schematic diagram of a process for securely encrypting log information is shown as an exemplary embodiment of the present application;

[0027] Fig. 9 A schematic diagram of a process of performing log cleaning based on log file creation time is shown as an exemplary embodiment of the present application;

[0028] Fig.10 A schematic diagram of a process of performing log cleaning based on log file size is shown as an exemplary embodiment of the present application;

[0029] Fig.11 A schematic diagram of a log reporting implementation process shown as an exemplary embodiment of the present application;

[0030] Fig.12 This is a structural schematic diagram of a log processing device shown as an exemplary embodiment of the present application;

[0031] Fig.13 The figure is a schematic diagram of the hardware structure of an electronic device shown as an exemplary embodiment of the present application. DETAILED DESCRIPTION

[0032] In order to enable those skilled in the art to better understand the technical solutions provided by the embodiments of the present application and to make the above-mentioned purposes, features and advantages of the embodiments of the present application more obvious and understandable, the technical solutions in the embodiments of the present application are further described in detail below in conjunction with the accompanying drawings.

[0033] See also Figure 1 , is a flow chart of a log processing method provided in an embodiment of the present application, wherein the log processing method can be applied to a mobile terminal device, such as Figure 1 As shown, the log processing method may include:

[0034] Step S100: When the mobile application is started, the dynamic log module that needs to be enabled is determined based on the current application environment; wherein; the log module corresponding to the mobile application includes a resident log module and a dynamic log module; the log module corresponding to the mobile application is divided according to the functions between the mobile application and the NAS device.

[0035] For example, the mobile application (hereinafter referred to as APP) does not specifically refer to a fixed APP, but may refer to any APP on any mobile device that uses the technical solution provided in the embodiment of the present application to perform log processing and interacts with a NAS device.

[0036] In the embodiment of the present application, in order to quickly locate the problems that occur during the interaction between the APP and the NAS device, the log modules of the APP can be divided according to the functions between the APP and the NAS device.

[0037] For example, functions such as file transfer between APP and NAS devices and device connection can correspond to different log modules respectively.

[0038] Based on this, if a problem occurs when the APP interacts with the NAS device, you can quickly query the relevant log information based on the function where the problem occurs, and analyze and locate the problem.

[0039] In addition, considering that there are many functions between the APP and NAS, there will be many log modules that need to be configured. If all configured log modules are enabled to record logs during the APP operation, the terminal resources will be consumed more, which will affect the user's normal use of the APP.

[0040] Correspondingly, the log module corresponding to the APP can be divided into a resident log module and a dynamic log module.

[0041] That is, in the embodiment of the present application, the log modules of the APP can be divided according to the functions between the APP and the NAS device; and the log modules obtained according to the functional division can be divided into resident log modules or dynamic log modules.

[0042] Exemplarily, when the APP is started, the resident log module remains enabled, and the dynamic log module can be enabled as needed according to the application environment.

[0043] Exemplarily, the division between the resident log module and the dynamic log module can be defined as needed.

[0044] For example, a log module that generates a small amount of log data and is highly important may be set as a resident log module.

[0045] Alternatively, for functions with a higher priority in interaction between the APP and the NAS device, such as the connection between the APP and the NAS device, interface request error information, formatting and data migration in the NAS, and other important functions, the corresponding log module can be set as a resident log module.

[0046] Accordingly, in the embodiment of the present application, when the APP is started, the dynamic log module (which may be referred to as the target dynamic log module) that needs to be enabled may be determined based on the current application environment.

[0047] Step S110: Set the target dynamic log module and the resident log module corresponding to the mobile application to an on state, and initialize the log system.

[0048] In the embodiment of the present application, when the target dynamic log module is determined, the target dynamic log module and the resident log module corresponding to the target APP can be set to an open state, and the log system can be initialized.

[0049] Exemplarily, when the log system is initialized, the log module in the enabled state can generate log information as needed.

[0050] It can be seen that in Figure 1 In the method flow shown, when the mobile application is started, the target dynamic log module that needs to be turned on can be determined based on the current application environment, and the target dynamic log module and the resident log module corresponding to the mobile application can be set to the on state, and the log system is initialized. By dividing the log modules for the mobile application according to the functions between the mobile application and the NAS device, the efficiency of locating problems when problems arise during the interaction between the mobile application and the NAS device can be improved; in addition, by dividing the log module corresponding to the mobile application into a resident log module and a dynamic log module, when the mobile application is started, the dynamic log module can be turned on as needed according to the application environment, reducing terminal resource consumption.

[0051] In some embodiments, the above-mentioned determination of the target dynamic log module that needs to be enabled based on the current application environment may include: when the current application environment is a test environment, all dynamic log modules in the log module corresponding to the mobile application are determined as dynamic log modules that need to be enabled; when the current application environment is a release environment, the target dynamic log module that needs to be enabled is determined based on the obtained server configuration parameters.

[0052] For example, considering that in a DEBUG environment (which can be called a test environment or debugging environment), the device resources for running the APP are usually sufficient, and in order to ensure that the problems between the APP and the NAS device can be more comprehensively discovered in the test environment, for the test environment, all dynamic log modules of the APP can be turned on.

[0053] For example, for the RELEASE environment (which can be called the release environment or online environment), that is, the operating environment of the APP after the APP is actually delivered for use (such as the user downloads the APP through the application store, etc. for use), in order to avoid the log module consuming too much resources of the terminal device and affecting the user's normal use of the mobile application, the dynamic log module can be enabled on demand.

[0054] Exemplarily, a dynamic log module that needs to be enabled in the APP in the publishing environment can be configured through a server, such as a backend server.

[0055] Accordingly, when the current application environment is a release environment, the target dynamic log module that needs to be enabled can be determined based on the acquired server configuration parameters.

[0056] Exemplarily, the server configuration parameter may indicate a dynamic log module that needs to be enabled for the target mobile application.

[0057] In an example, the server configuration parameters may include NAS device identification information and corresponding dynamic log module identification information.

[0058] The target dynamic log module to be enabled is determined based on the obtained server configuration parameters, which may include:

[0059] Query the NAS device identification information included in the server configuration parameters to determine whether the NAS device identification information contains the identification information of the target NAS device to which the mobile terminal application is currently connected;

[0060] If it exists, then according to the dynamic log module identification information corresponding to the identification information of the target NAS device in the server configuration parameters, the corresponding dynamic log module is determined as the target dynamic log module that needs to be enabled;

[0061] If it does not exist, it is determined that the target dynamic log module to be opened is empty.

[0062] For example, when the APP interacts with different NAS devices, the dynamic log modules that need to be enabled may be different.

[0063] The dynamic log module that needs to be enabled when the APP interacts with different NAS devices can be configured through the server.

[0064] Exemplarily, the server configuration parameters may include NAS device identification information (such as a NAS device serial number) and corresponding dynamic log module identification information (ie, identification information of a dynamic log module that needs to be enabled and corresponds to the NAS device).

[0065] Accordingly, when the current application environment is a publishing environment, the server configuration parameters can be obtained, and the NAS device identification information included in the obtained configuration parameters can be queried to determine whether the NAS device identification information contains the identification information of the NAS device (which can be called the target NAS device) to which the target APP is currently connected.

[0066] If it exists, the corresponding dynamic log module can be determined as the target dynamic log module that needs to be enabled according to the dynamic log module identification information corresponding to the identification information of the target NAS device in the server configuration parameters.

[0067] If it does not exist, it can be determined that the dynamic log module does not need to be enabled.

[0068] In some embodiments, the log module corresponding to the mobile application includes large log modules corresponding to different functions between the mobile application and the NAS device. For any large log module, the function corresponding to the large log module is divided into at least one sub-function, and one sub-function corresponds to a small log module; the small log module corresponding to the mobile application includes a resident log module and a dynamic log module;

[0069] The above log system initialization may include:

[0070] For any enabled log module, determine whether the log module to which the log module belongs has created a corresponding large module folder;

[0071] If the log module to which the small log module belongs does not have a corresponding large module folder created, create a large module folder corresponding to the log module to which the small log module belongs;

[0072] In the case that the log large module to which the log small module belongs has created a corresponding large module folder, determining whether the log small module has created a corresponding small module folder;

[0073] If the small module folder is not created for the log small module, a small module folder corresponding to the log small module is created, and a corresponding log file is created in the small module folder.

[0074] Exemplarily, in order to further improve the efficiency of problem location, the functions between the APP and the NAS device can be decomposed into at least one sub-function.

[0075] For example, for a file transfer (or transfer list) function, corresponding sub-functions may include file upload, file download, and file transfer.

[0076] For the device connection function, the corresponding sub-functions may include different connection modes.

[0077] Exemplarily, the functions between the APP and the NAS device may correspond to a large log module. For any large log module, the function corresponding to the large log module is divided into at least one sub-function, and one sub-function corresponds to a small log module.

[0078] Accordingly, during the log system initialization process, for any enabled log module, the log module to which the log module belongs can be determined, and it can be determined whether the log module has created a corresponding folder (which can be called a large module folder).

[0079] In the case that the log large module to which the log small module belongs has not created a corresponding large module folder, a large module folder corresponding to the log large module to which the log small module belongs can be created.

[0080] When the log large module to which the log small module belongs has created a corresponding large module folder (including the case where it has been created before the APP is started, or created during the APP startup process), it can be determined whether the log small module has created a corresponding small module folder.

[0081] If the small module folder is not created for the log small module, a small module folder corresponding to the log small module is created, and a corresponding log file is created in the small module folder.

[0082] In some embodiments, the mobile application is provided with at least one small component that has business interaction with the NAS device, and the log module corresponding to the mobile application includes a first type of log module corresponding to the function between the main program and the NAS device, and a second type of log module corresponding to the function between the small component and the NAS device; the first type of log module includes a resident log module and a dynamic log module; the second type of log module includes a resident log module and a dynamic log module;

[0083] The folder corresponding to the first type of log module is created in the APP sandbox;

[0084] The folder corresponding to the second type of log module is created in the shared space; wherein the shared space is shared by the main program and the widget of the mobile application.

[0085] For example, in actual applications, an APP may be provided with widgets, and may interact with a NAS device through the widgets. For example, there is a function between the APP and the NAS that requires displaying information in the NAS device through the desktop widget of the APP.

[0086] Due to the relevant mechanism of the component, the log information in the component cannot be written into the APP sandbox. Therefore, it is necessary to apply for a shared space between the component and the mobile terminal to store the log information in the component.

[0087] Exemplarily, the log module corresponding to the mobile application includes a log module corresponding to the function between the main program and the NAS device (which may be called a first type of log module), and a log module corresponding to the function between the widget and the NAS device (which may be called a second type of log module).

[0088] The first type of log module includes a resident log module and a dynamic log module; the second type of log module includes a resident log module and a dynamic log module.

[0089] The folder corresponding to the first type of log module is created in the APP sandbox; the folder corresponding to the second type of log module is created in the shared space.

[0090] In some embodiments, after the log system is initialized, the following steps may also be performed:

[0091] For the log information generated by the log system, the log information is associated with the identification information of the log module that generated the log information and added to the log queue;

[0092] When the number of log information in the log queue reaches a preset upper limit, or when the preset timer time is reached, the log information in the log queue is written into the corresponding log file according to the identification information of the log module associated with each log information in the log queue.

[0093] For example, when logging, if each log message is written to the log file, it will increase the local file IO (input and output) reading and writing pressure. Therefore, a log queue can be introduced. The log information generated by the log system can be added to the log queue first.

[0094] A recording scheme is designed. When the number of log entries in the memory reaches a certain level, a file write operation is performed uniformly. This method can effectively reduce the frequency of local file reading and writing.

[0095] If the log information is written only when a certain number is reached, if the user manually closes the mobile application or the mobile application is suspended in the background, but the number of log information does not reach the set number, the last batch of log information will most likely be lost. In this case, you can also introduce a design that writes the log information in the log queue to the log file at a fixed time.

[0096] Correspondingly, for the log information generated by the log system, the log information can be associated with the identification information of the log module that generates the log information and added to the log queue.

[0097] When the number of log information in the log queue reaches a preset upper limit, or the preset timer time is reached, the log information in the log queue can be written into the corresponding log file according to the identification information of the log module associated with each log information in the log queue.

[0098] In some embodiments, after the log system is initialized, the following steps may also be performed:

[0099] For the log information generated by the log system, the log information is encrypted to obtain the log information ciphertext, and the log information ciphertext is written into the corresponding log file.

[0100] For example, considering that in mobile terminal development, log files may contain sensitive information, in order to protect this information from being leaked, the log information needs to be encrypted.

[0101] Exemplarily, an AES (Advanced Encryption Standard) encryption algorithm may be used for encryption.

[0102] Correspondingly, for the log information generated by the log system, the log information is encrypted to obtain the log information ciphertext, and the log information ciphertext is written into the corresponding log file.

[0103] In some embodiments, the log processing method provided by the embodiments of the present application may also include:

[0104] For any log module, when the creation time of the log file corresponding to the log module reaches a preset time threshold, the log file is deleted and a new log file is created.

[0105] For example, considering that with the continuous iteration of functions between the APP and the NAS device, the amount of log information will continue to increase. If the log file is not restricted, the size of the log file will continue to increase over time, occupying too much local space.

[0106] To prevent log files from occupying too much storage resources, you can clean up log files regularly.

[0107] Correspondingly, for any log module, when the creation time of the log file corresponding to the log module reaches a preset time threshold (which can be set according to actual needs), the log file is deleted and a new log file is created.

[0108] In an example, when the creation time of the log file corresponding to the log module reaches a preset time threshold, deleting the log file and creating a new log file may include:

[0109] If the log module is a resident log module and the creation time of the log file corresponding to the log module reaches a first preset time threshold, delete the log file and create a new log file;

[0110] When the log module is a dynamic log module and the creation time of the log file corresponding to the log module reaches a second preset time threshold, the log file is deleted and a new log file is created.

[0111] Exemplarily, considering that the importance of log information of different types of log modules (such as a resident log module or a dynamic log module) is different, the cleaning cycles of log information of different types of log modules may be different.

[0112] Correspondingly, for a resident log module, when the creation time of a log file corresponding to the log module reaches a first preset time threshold, the log file may be deleted and a new log file may be created.

[0113] For a dynamic log module, when the creation time of a log file corresponding to the log module reaches a second preset time threshold, the log file may be deleted and a new log file may be created.

[0114] Exemplarily, the first preset time threshold is different from the second preset time threshold.

[0115] In one example, considering that the log information of the resident log module is usually more important, the first preset time threshold may be greater than the second preset time threshold.

[0116] In some embodiments, when the creation time of the log file corresponding to the log module reaches a preset time threshold, deleting the log file and creating a new log file may include:

[0117] For any log module, when the size of the log file corresponding to the log module exceeds a preset size threshold, the log file is cleared.

[0118] For example, considering that with the continuous iteration of functions between the APP and the NAS device, the amount of log information will continue to increase. If the log file is not restricted, the size of the log file will continue to increase over time, occupying too much local space.

[0119] To prevent log files from occupying too much storage resources, you can clear log files based on their size.

[0120] Correspondingly, for any log module, when the size of the log file corresponding to the log module exceeds a preset size threshold, the log file is cleared.

[0121] In an example, when the size of the log file corresponding to the log module exceeds a preset size threshold, clearing the log file may include:

[0122] If the log is a resident log module and the size of the log file corresponding to the log module exceeds a first preset size threshold, clear the log file;

[0123] When the log is a dynamic log module and the size of the log file corresponding to the log module exceeds a second preset size threshold, the log file is cleared.

[0124] For example, considering that different types of log modules (such as resident log modules or dynamic log modules) may generate different amounts of logs, the sizes of log files that trigger clearing of different types of log modules may be different.

[0125] Correspondingly, for a resident log module, when the size of a log file corresponding to the log module exceeds a first preset size threshold, the log file may be cleared.

[0126] For a dynamic log module, when the size of a log file corresponding to the log module exceeds a second preset size threshold, the log file may be cleared.

[0127] Exemplarily, the first preset size threshold is different from the second preset size threshold.

[0128] In one example, considering that the number of logs generated by the resident log module is usually smaller, the first preset size threshold may be greater than the second preset size threshold.

[0129] In some embodiments, the log processing method provided by the embodiments of the present application may also include:

[0130] When a log reporting trigger instruction is detected, the root directory folder to which the log file belongs is packaged to obtain a log file compression package, the log file compression package is uploaded to the server, and the local log file compression package is deleted.

[0131] For example, in order to reduce the resources consumed by log reporting, when performing log reporting, the log files of the same APP can be packaged and reported.

[0132] Accordingly, when a log reporting trigger instruction is detected, for example, when a user triggers log reporting by specifying an operation instruction, the root directory folder to which the log file belongs can be packaged to obtain a log file compression package, the log file compression package can be uploaded to the server, and the local log file compression package can be deleted.

[0133] In order to enable those skilled in the art to better understand the technical solutions provided in the embodiments of the present application, the technical solutions provided in the embodiments of the present application are described below with reference to specific examples.

[0134] In this embodiment, for a product that has been launched (i.e., released), problems that were not discovered during the testing process may occur. For such problems, if the project does not have a log system, it is difficult to locate the cause of the problem. Therefore, the log system is crucial to locating APP problems.

[0135] In order to solve the problem that APP online problems are difficult to locate, the embodiment of the present application provides an APP log recording and reporting solution, which can be used for locating APP online problems.

[0136] 1. Division of log modules in the log system

[0137] In the log system, the business functions between the APP and the NAS device can be decomposed into at least one large module (i.e., the log large module), and each large module can be further decomposed into multiple small modules (i.e., log small modules).

[0138] For example, if the large module is file transfer, the file transfer can be decomposed into multiple small modules, including file upload, file download, internal copy, etc. Each small module records logs as the minimum log recording unit.

[0139] The division of each large and small module is recorded in a unified configuration file, and developers can add it to the configuration file as needed.

[0140] For example, the module configuration parameter settings can be found in Figure 2 .like Figure 2 As shown, the key values ​​1000 and 1001 represent the unique identifier of each small module, mainModule represents the name of a large module, subModule represents the name of a small module, and Enable indicates whether the log information of the small module is recorded.

[0141] Exemplarily, Enable is YES, indicating that the log information of the small module needs to be recorded (ie, the enabled state); Enable is NO, indicating that the log information of the small module does not need to be recorded (ie, the disabled state).

[0142] After the log module is configured, log files will be created locally according to the names of the large module and the small module, and the small module folder will be created in the corresponding large module folder.

[0143] For example, the local log file hierarchy structure can be as follows: Figure 3 shown.

[0144] For example, the log system initialization process can be as follows: Figure 4 As shown, when the APP is started, the log configuration list is read, and then for each log module in the enabled state, it is first determined locally whether the log large module folder is created; if not, a large module folder is created; then, it is determined whether the small module folder is created, if not, a small module folder is created, and a log file is created until all log modules are traversed and the log system is initialized.

[0145] 2. Online log module configuration

[0146] Considering that there are many functions between the APP and the NAS device, there are also many log modules that need to be configured. If all configured log modules turn on log recording in the publishing environment, the terminal resource consumption will be relatively large, which will affect the user's normal use of the APP. To address this problem, the embodiment of the present application provides a solution for controlling log recording in the APP in the publishing environment.

[0147] 2.1. The log module configured above can be further subdivided into a resident log module and a dynamic log module.

[0148] Exemplarily, the resident log module is enabled in both the test environment and the release environment, that is, the log information in this type of log module is always recorded.

[0149] Exemplarily, when configuring the type of log module, it can ensure that the log information recording frequency of the resident log module does not exceed the preset frequency threshold (that is, the log information recording frequency exceeding the preset frequency threshold can be set as a dynamic log module), avoiding too frequent log information recording in the resident log module.

[0150] Exemplarily, whether it is a resident log module or a dynamic log module can be distinguished by the unique identifier of the small module.

[0151] For example, a unique identification value greater than or equal to 10000 is a resident log module, and a unique identification value less than 10000 is a dynamic log module.

[0152] 2.2. The division between the resident log module and the dynamic log module can be defined by the developer.

[0153] Exemplarily, the principle of dividing the resident log module and the dynamic log module may include: a log module that generates a small amount of log data and is important is used as a resident log module.

[0154] For example, the log modules corresponding to the functions with higher interaction priority between the APP and the NAS device, such as the connection between the APP and the NAS device, interface request error information, formatting and data migration in the NAS device, etc., can all be set as resident log modules.

[0155] 2.3. In the test environment, the dynamic log module is kept enabled like the resident log module; in the release environment, the backend server configuration is requested to determine which log modules (dynamic log modules) need to be enabled.

[0156] 2.4. The backend server configuration parameters can include two parameters: one is the serial number of the NAS device, and the other is the unique identifier of the dynamic log module that needs to be enabled. By configuring these two parameters, in the release environment, the APP determines the dynamic log module that needs to be enabled based on the configured device serial number and identifier.

[0157] For example, the main process of opening the dynamic log module can be as follows: Figure 5 As shown in the figure, when the APP is started, the resident log module can be read and each resident log module can be added to the list of log modules that need to be enabled. Then, different processing is performed according to the current application environment.

[0158] If the current application environment is a test environment, all dynamic log modules are read and enabled, added to the list of log modules that need to be enabled, and the log system is initialized, and then log recording can be performed.

[0159] If the current application environment is a publishing environment, you need to first read the configuration information from the server (that is, the above-mentioned server configuration parameters), parse the configuration information, and obtain the device list of the dynamic log module that needs to be enabled. If the serial number of the currently connected NAS device is not in the device list, it means that the current NAS device does not need to enable the dynamic log module; if the current NAS device serial number is in the device list, continue to parse the log module list, enable the corresponding dynamic log module, and then initialize the log system, and then, you can perform log recording.

[0160] 3. Logging in Mobile Components

[0161] For example, considering that there is a need to display the information in the NAS through the desktop widget on the mobile terminal between the APP and the NAS device, due to the relevant mechanism of the component, the log information in the component cannot be written into the sandbox of the mobile terminal. Therefore, it is necessary to apply for a shared space between the component and the mobile terminal to store the log information in the component.

[0162] For the log system, during initialization, on the one hand, the main program needs to be initialized; on the other hand, small components need to be initialized.

[0163] For main program initialization, the log system creates a corresponding folder in the APP sandbox.

[0164] For widget initialization, the log system creates corresponding folders in the shared directory.

[0165] Exemplarily, the log system initialization process of the compatible mobile terminal component can be as follows: Figure 6 shown.

[0166] 4. Log module records

[0167] For example, when performing log recording, if each log message is written into a log file, the local file IO read and write pressure will increase. Therefore, a recording scheme can be designed to introduce a log queue. When the number of log messages in the log queue reaches a certain number, a file write operation is performed uniformly. In this way, the frequency of local file read and write can be effectively reduced.

[0168] In addition, if the log information is written only when the number of log information in the log queue reaches a certain number, if the user manually closes the APP or the APP is suspended in the background, and the log information does not reach the set number, the last batch of log information will most likely be lost. In this case, you can add a design that writes the log information in the log queue to the log file at a fixed time, such as writing the log information in the log queue to the log file every 60 seconds.

[0169] For example, the log module records the process as follows: Figure 7 shown.

[0170] 5. Log Information Security Encryption

[0171] For example, in APP development, log information may contain sensitive information. In order to protect this information from being leaked, the log information needs to be encrypted.

[0172] For example, the AES encryption algorithm may be used, which may encrypt the log information into a ciphertext that can only be decrypted by a person who has a key.

[0173] For example, the flow chart of log information security encryption can be as follows: Figure 8 shown.

[0174] 6. Log file cleaning

[0175] For example, with the continuous iteration of functions between the APP and the NAS device, the log information will continue to increase. If the log file is not restricted, the size of the log file will continue to increase over time, occupying too much local space.

[0176] Exemplarily, different configurations may be made for the log file sizes in the resident log module and the dynamic log module. The configuration content includes clearing the file when the file size reaches a certain upper limit and clearing the file when the file creation time reaches a certain period.

[0177] For example, since the resident log module is always used in the test environment and the release environment, and is usually used to record small but important information, the size can be configured to reach 2 MB, or the cycle can be cleared once every 30 days.

[0178] The dynamic log module will also remain enabled in the test environment and will be enabled only when needed in the release environment. It is usually used to record some detailed logs. Therefore, the size can be configured to reach 20MB, or it can be cleaned up every 3 days. The cleanup process can be as follows Fig. 9 and Fig.10 shown.

[0179] For example, Fig. 9 In the process of initializing the log system when the APP is started, each log module is traversed. If the log module belongs to a resident log module, it is determined whether the log file creation time is greater than 30 days from the current time. If it is greater than 30 days, the log file is deleted and recreated; if the log module belongs to a dynamic log module, it is determined whether the log file creation time is greater than 3 days from the current time. If it is greater than 3 days, the file is deleted and recreated.

[0180] like Fig.10 When writing log information to a local file, determine the log module and file size of the log file to be written. If the log file belongs to the resident log module and the file size is greater than 2MB, clear the log file content before writing the log information. If the log file belongs to the dynamic log module and the file size is greater than 20MB, clear the log file content before writing the log information.

[0181] 7. Log reporting

[0182] For example, since the log files are recorded in multiple modules, there are multiple files locally. When the log needs to be reported, the root directory to which the log belongs (such as Figure 3 The APPLog folder in the folder is packaged, the compressed package is uploaded to the server, and the locally generated compressed package needs to be deleted after the upload is completed.

[0183] For example, the implementation process of log reporting can be as follows: Fig.11 shown.

[0184] The method provided by the present application is described above. The device provided by the present application is described below:

[0185] See also Fig.12, is a schematic diagram of the structure of a log processing device provided in an embodiment of the present application, wherein the log processing can be deployed on a mobile device, such as Fig.12 As shown, the log processing may include:

[0186] The determining unit 1210 is used to determine the target dynamic log module to be started according to the current application environment when the mobile application is started; wherein the log module corresponding to the mobile application includes a resident log module and a dynamic log module; the log module corresponding to the mobile application is divided according to the functions between the mobile application and the network attached storage NAS device;

[0187] The processing unit 1220 is used to set the target dynamic log module and the resident log module corresponding to the mobile application to an open state and initialize the log system.

[0188] In some embodiments, the determining unit 1210 determines the target dynamic log module to be enabled according to the current application environment, including:

[0189] In the case where the current application environment is a test environment, all dynamic log modules in the log module corresponding to the mobile terminal application are determined as dynamic log modules that need to be enabled;

[0190] When the current application environment is a publishing environment, the target dynamic log module that needs to be enabled is determined based on the acquired server configuration parameters; wherein the server configuration parameters are used to indicate the dynamic log module that needs to be enabled for the mobile application.

[0191] In some embodiments, the server configuration parameters include NAS device identification information and corresponding dynamic log module identification information;

[0192] The determining unit 1210 determines the target dynamic log module to be enabled according to the acquired server configuration parameters, including:

[0193] Querying the NAS device identification information included in the server configuration parameters, and determining whether the NAS device identification information contains the identification information of the target NAS device to which the mobile terminal application is currently connected;

[0194] If it exists, then according to the dynamic log module identification information corresponding to the identification information of the target NAS device in the server configuration parameter, the corresponding dynamic log module is determined as the target dynamic log module that needs to be enabled;

[0195] If it does not exist, it is determined that the target dynamic log module to be opened is empty.

[0196] In some embodiments, the log module corresponding to the mobile application includes large log modules corresponding to different functions between the mobile application and the NAS device, and for any large log module, the function corresponding to the large log module is divided into at least one sub-function, and one sub-function corresponds to a small log module; the small log module corresponding to the mobile application includes the resident log module and the dynamic log module;

[0197] The processing unit 1220 performs log system initialization, including:

[0198] For any enabled log module, determine whether the log module to which the log module belongs has created a corresponding large module folder;

[0199] If the log module to which the small log module belongs does not have a corresponding large module folder created, create a large module folder corresponding to the log module to which the small log module belongs;

[0200] In the case that the log large module to which the log small module belongs has created a corresponding large module folder, determining whether the log small module has created a corresponding small module folder;

[0201] If the small module folder is not created for the log small module, a small module folder corresponding to the log small module is created, and a corresponding log file is created in the small module folder.

[0202] In some embodiments, the mobile application is provided with at least one small component that has business interaction with the NAS device, and the log module corresponding to the mobile application includes a first type of log module corresponding to the function between the main program and the NAS device, and a second type of log module corresponding to the function between the small component and the NAS device; the first type of log module includes a resident log module and a dynamic log module; the second type of log module includes a resident log module and a dynamic log module;

[0203] The folder corresponding to the first type of log module is created in the APP sandbox;

[0204] The folder corresponding to the second type log module is created in a shared space; wherein the shared space is shared by the main program of the mobile application and the widget.

[0205] In some embodiments, after the processing unit 1220 initializes the log system, the processing unit 1220 further includes:

[0206] For the log information generated by the log system, the log information is associated with the identification information of the log module that generated the log information and added to the log queue;

[0207] When the number of log information in the log queue reaches a preset upper limit, or when the preset timer time is reached, the log information in the log queue is written into the corresponding log file according to the identification information of the log module associated with each log information in the log queue.

[0208] In some embodiments, after the processing unit 1220 initializes the log system, the processing unit 1220 further includes:

[0209] For the log information generated by the log system, the log information is encrypted to obtain the log information ciphertext, and the log information ciphertext is written into the corresponding log file.

[0210] In some embodiments, the processing unit 1220 is further configured to delete any log file and create a new log file when the creation time of the log file corresponding to the log module reaches a preset time threshold.

[0211] In some embodiments, when the creation time of the log file corresponding to the log module reaches a preset time threshold, the processing unit 1220 deletes the log file and creates a new log file, including:

[0212] If the log module is a resident log module and the creation time of the log file corresponding to the log module reaches a first preset time threshold, delete the log file and create a new log file;

[0213] When the log module is a dynamic log module and the creation time of the log file corresponding to the log module reaches a second preset time threshold, the log file is deleted and a new log file is created;

[0214] The first preset time threshold is different from the second preset time threshold.

[0215] In some embodiments, the processing unit 1220 is further configured to clear any log file corresponding to the log module when the size of the log file exceeds a preset size threshold.

[0216] In some embodiments, when the size of the log file corresponding to the log module exceeds a preset size threshold, the processing unit 1220 clears the log file, including:

[0217] If the log is a resident log module and the size of the log file corresponding to the log module exceeds a first preset size threshold, clear the log file;

[0218] When the log is a dynamic log module and the size of the log file corresponding to the log module exceeds a second preset size threshold, the log file is cleared.

[0219] In some embodiments, the processing unit 1220 is also used to package the root directory folder to which the log file belongs when a log reporting trigger instruction is detected to obtain a log file compression package, upload the log file compression package to the server, and delete the local log file compression package.

[0220] An embodiment of the present application further provides an electronic device, including a processor and a memory, wherein the memory is used to store a computer program; and the processor is used to implement the log processing method described above when executing the program stored in the memory.

[0221] See also Fig.13 , is a schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present application. The electronic device may include a processor 1301 and a memory 1302 storing machine executable instructions. The processor 1301 and the memory 1302 may communicate via a system bus 13013. In addition, by reading and executing the machine executable instructions corresponding to the log processing logic in the memory 1302, the processor 1301 may execute the log processing method described above.

[0222] The memory 1302 mentioned herein may be any electronic, magnetic, optical or other physical storage device that may contain or store information, such as executable instructions, data, etc. For example, the machine-readable storage medium may be: RAM (RadomAccess Memory), volatile memory, non-volatile memory, flash memory, storage drive (such as hard disk drive), solid state drive, any type of storage disk (such as optical disk, DVD, etc.), or similar storage medium, or a combination thereof.

[0223] In some embodiments, a machine-readable storage medium is also provided. Fig.13 The memory 1302 in the machine-readable storage medium stores machine executable instructions, and when the machine executable instructions are executed by the processor, the log processing method described above is implemented. For example, the machine-readable storage medium can be ROM, RAM, CD-ROM, magnetic tape, floppy disk, optical data storage device, etc.

[0224] The embodiment of the present application also provides a computer program product, which stores a computer program, and when a processor executes the computer program, it prompts the processor to execute the log processing method described above.

[0225] The embodiment of the present application also provides a log processing system, including a NAS device and a mobile terminal device; wherein:

[0226] The log module corresponding to the mobile application on the mobile device includes a resident log module and a dynamic log module; the log module corresponding to the mobile application is divided according to the functions between the mobile application and the NAS device;

[0227] During the interaction between the NAS device and the mobile terminal device, the mobile terminal device performs log processing in the manner described in the above method embodiment.

[0228] For example, the hardware structure of the mobile terminal device can be as follows: Fig.13 shown.

[0229] For example, the functional module diagram of the mobile terminal device can be as follows: Fig.12 shown.

Claims

1. A log processing method, characterized in that: Applied to a mobile device, the method comprises: When the mobile application is started, the target dynamic log module to be opened is determined according to the current application environment; wherein; the log module corresponding to the mobile application includes a resident log module and a dynamic log module; the log module corresponding to the mobile application is divided according to the functions between the mobile application and the network attached storage NAS device; The target dynamic log module and the resident log module corresponding to the mobile terminal application are set to an open state, and the log system is initialized.

2. The method according to claim 1, characterized in that The target dynamic log module to be enabled according to the current application environment is determined, including: In the case where the current application environment is a test environment, all dynamic log modules in the log module corresponding to the mobile terminal application are determined as dynamic log modules that need to be enabled; When the current application environment is a release environment, determine the target dynamic log module that needs to be enabled based on the obtained server configuration parameters.

3. The method according to claim 2, characterized in that The server configuration parameters include NAS device identification information and corresponding dynamic log module identification information; Determining the target dynamic log module to be enabled based on the acquired server configuration parameters includes: Querying the NAS device identification information included in the server configuration parameters, and determining whether the NAS device identification information contains the identification information of the target NAS device to which the mobile terminal application is currently connected; If it exists, then according to the dynamic log module identification information corresponding to the identification information of the target NAS device in the server configuration parameter, the corresponding dynamic log module is determined as the target dynamic log module that needs to be enabled; If it does not exist, it is determined that the target dynamic log module to be opened is empty.

4. The method according to claim 1, characterized in that The log module corresponding to the mobile application includes large log modules corresponding to different functions between the mobile application and the NAS device. For any large log module, the function corresponding to the large log module is divided into at least one sub-function, and one sub-function corresponds to one small log module; The log module corresponding to the mobile application includes the resident log module and the dynamic log module; The log system initialization includes: For any enabled log module, determine whether the log module to which the log module belongs has created a corresponding large module folder; If the log module to which the small log module belongs does not have a corresponding large module folder created, create a large module folder corresponding to the log module to which the small log module belongs; In the case that the log large module to which the log small module belongs has created a corresponding large module folder, determining whether the log small module has created a corresponding small module folder; If the small module folder is not created for the log small module, a small module folder corresponding to the log small module is created, and a corresponding log file is created in the small module folder.

5. The method according to claim 1, characterized in that The mobile application is provided with at least one small component that has business interaction with the NAS device, and the log module corresponding to the mobile application includes a first type of log module corresponding to the function between the main program and the NAS device, and a second type of log module corresponding to the function between the small component and the NAS device; the first type of log module includes a resident log module and a dynamic log module; the second type of log module includes a resident log module and a dynamic log module; The folder corresponding to the first type of log module is created in the APP sandbox; The folder corresponding to the second type log module is created in a shared space; wherein the shared space is shared by the main program of the mobile application and the widget.

6. The method according to claim 1, characterized in that After the log system is initialized, the following steps are also included: For the log information generated by the log system, the log information is associated with the identification information of the log module that generated the log information and added to the log queue; When the number of log information in the log queue reaches a preset upper limit, or when the preset timer time is reached, the log information in the log queue is written into the corresponding log file according to the identification information of the log module associated with each log information in the log queue.

7. The method according to claim 1, characterized in that After the log system is initialized, the following steps are also included: For the log information generated by the log system, the log information is encrypted to obtain the log information ciphertext, and the log information ciphertext is written into the corresponding log file.

8. The method according to claim 1, characterized in that: The method further comprises: For any log module, when the creation time of the log file corresponding to the log module reaches a preset time threshold, the log file is deleted and a new log file is created.

9. The method according to claim 8, characterized in that When the creation time of the log file corresponding to the log module reaches a preset time threshold, the log file is deleted and a new log file is created, including: If the log module is a resident log module and the creation time of the log file corresponding to the log module reaches a first preset time threshold, delete the log file and create a new log file; When the log module is a dynamic log module and the creation time of the log file corresponding to the log module reaches a second preset time threshold, the log file is deleted and a new log file is created; The first preset time threshold is different from the second preset time threshold.

10. The method according to claim 1, characterized in that The method further comprises: For any log module, when the size of the log file corresponding to the log module exceeds a preset size threshold, the log file is cleared.

11. The method according to claim 10, characterized in that When the size of the log file corresponding to the log module exceeds a preset size threshold, clearing the log file includes: If the log is a resident log module and the size of the log file corresponding to the log module exceeds a first preset size threshold, clear the log file; When the log is a dynamic log module and the size of the log file corresponding to the log module exceeds a second preset size threshold, the log file is cleared.

12. The method according to claim 1, characterized in that The method further comprises: When a log reporting trigger instruction is detected, the root directory folder to which the log file belongs is packaged to obtain a log file compression package, the log file compression package is uploaded to the server, and the local log file compression package is deleted.

13. A log processing device, characterized in that: Deployed on a mobile device, the device includes: The determination unit is used to determine the target dynamic log module to be started according to the current application environment when the mobile application is started; wherein; the log module corresponding to the mobile application includes a resident log module and a dynamic log module; the log module corresponding to the mobile application is divided according to the functions between the mobile application and the network attached storage NAS device; The processing unit is used to set the target dynamic log module and the resident log module corresponding to the mobile terminal application to an open state and initialize the log system.

14. An electronic device, characterized in that: comprising a processor and a memory, wherein: Memory, used to store computer programs; A processor, for implementing the method according to any one of claims 1 to 12 when executing a program stored in a memory.

15. A log processing system, characterized in that: Including network attached storage NAS devices and mobile devices; among which: The log module corresponding to the mobile application on the mobile device includes a resident log module and a dynamic log module; the log module corresponding to the mobile application is divided according to the functions between the mobile application and the NAS device; During the interaction between the NAS device and the mobile terminal device, the mobile terminal device performs log processing using the method described in any one of claims 1 to 12.