Process log management method and device, computer device, and storage medium
By calling the preload script of the child process in the target window to collect and parse log information, the log printing primary key is determined, which solves the problem of chaotic multi-process log management, realizes classified printing and storage, and improves the management efficiency of the system.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- CHINA MERCHANTS FINANCE HLDG CO LTD
- Filing Date
- 2022-07-29
- Publication Date
- 2026-05-29
AI Technical Summary
Existing log printing technology prints logs from multiple processes to the same folder, leading to management chaos and hindering system testing and maintenance.
By listening for the opening command of the target window, the preload script of the child process is called to collect the target log information, parse the log information to determine the process log, category and file name, and determine the log printing primary key based on this information, and print the log to the corresponding log folder.
It enables the categorized printing and storage of multi-process logs, improving the efficiency of operators in testing and maintaining the system.
Smart Images

Figure CN115269535B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of process log management, and more particularly to a process log management method, apparatus, computer device, and storage medium. Background Technology
[0002] With the development of internet technology, client applications generate numerous processes during runtime, including the main process, rendering process, and lightweight application processes. Each process corresponds to a window, and each window corresponds to multiple tasks. When the client executes tasks across multiple processes, it generates various process logs. A unified process log management mechanism is needed to support these multiple processes, including a mechanism for collecting and reporting process logs from various processes. Existing log printing technologies typically print multiple process logs to the same folder, leading to chaotic management of these logs and hindering system testing and maintenance. Therefore, classifying and storing process logs for different processes is a problem that needs to be solved in managing multi-process logs. Summary of the Invention
[0003] This invention provides a process log management method, apparatus, computer device, and storage medium to classify and print process logs of multiple processes and store them accordingly.
[0004] A process log management method, comprising:
[0005] When an open command corresponding to the target window is detected, the child process corresponding to the target window is invoked to obtain the target log information collected by the preload script pre-injected by the child process.
[0006] Parse the target log information to determine the process log, process category, and file name in the target log information;
[0007] Determine the log printing primary key based on the process category and filename in the target log information;
[0008] Print the process logs from the target log information to the log folder corresponding to the log printing primary key.
[0009] A process log management device, comprising:
[0010] The target log information collection module is used to call the subprocess corresponding to the target window when the open command corresponding to the target window is detected, and to obtain the target log information collected by the preload script pre-injected by the subprocess.
[0011] The target log information parsing module is used to parse the target log information and determine the process log, process category, and file name in the target log information.
[0012] The log printing primary key determination module is used to determine the log printing primary key based on the process category and file name in the target log information;
[0013] The process log printing module prints the process logs from the target log information to the log folder corresponding to the log printing primary key.
[0014] A computer device includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the above-described process log management method.
[0015] A computer-readable storage medium storing a computer program that, when executed by a processor, implements the above-described process log management method.
[0016] The aforementioned process log management method, device, computer, and storage medium, upon detecting an open command corresponding to a target window, call the child process corresponding to the target window, collect target log information according to the preload script pre-injected by the child process, parse the target log information, determine the process log, process category, and file name in the target log information, determine the log printing primary key, and print the process log in the target log information to the log folder corresponding to the log printing primary key. This achieves the function of classifying and printing process logs of multiple processes and storing them accordingly. Attached Figure Description
[0017] To more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings used in the description of the embodiments of the present invention will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0018] Figure 1 This is a schematic diagram of an application environment for a process log management method according to an embodiment of the present invention;
[0019] Figure 2 This is a flowchart of a process log management method according to an embodiment of the present invention;
[0020] Figure 3 This is another flowchart of a process log management method in one embodiment of the present invention;
[0021] Figure 4 This is another flowchart of a process log management method in one embodiment of the present invention;
[0022] Figure 5This is another flowchart of a process log management method in one embodiment of the present invention;
[0023] Figure 6 This is another flowchart of a process log management method in one embodiment of the present invention;
[0024] Figure 7 This is another flowchart of a process log management method in one embodiment of the present invention;
[0025] Figure 8 This is another flowchart of a process log management method in one embodiment of the present invention;
[0026] Figure 9 This is a schematic diagram of a process log management device according to an embodiment of the present invention;
[0027] Figure 10 This is a schematic diagram of a computer device according to an embodiment of the present invention. Detailed Implementation
[0028] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0029] The process log management method provided in this embodiment of the invention can be applied to, for example... Figure 1 The application environment shown. Specifically, this process log management method is applied in a process log management system, which includes, for example,... Figure 1 The diagram illustrates a client and server. The client and server communicate over a network to categorize and store process logs for multiple processes. The client, also known as the user terminal, is the program that provides local services to the client, corresponding to the server. The client can be installed on, but is not limited to, various personal computers, laptops, smartphones, tablets, and portable wearable devices. The server can be a standalone server or a server cluster consisting of multiple servers.
[0030] In one embodiment, such as Figure 2 As shown, a process log management method is provided, which is applied to... Figure 1 Taking the client as an example, the following steps are included:
[0031] S201: When the open command corresponding to the target window is detected, the child process corresponding to the target window is called to obtain the target log information collected by the preload script pre-injected by the child process.
[0032] S202: Parse the target log information to determine the process log, process type, and file name in the target log information;
[0033] S203: Determine the log printing primary key based on the process category and filename in the target log information;
[0034] S204: Print the process logs from the target log information to the log folder corresponding to the log printing primary key.
[0035] Here, the target window refers to the window monitored by the client, which can be a window or a webview. The child process corresponding to the target window refers to the process of the task corresponding to that target window. The preload script is a script preloaded by the child process corresponding to the target window to collect target log information. Target log information refers to the log information generated by the child process corresponding to the target window during its operation, including but not limited to application logs, process communication logs, network logs, and crash logs.
[0036] As an example, in step S201, when the client detects an open command for the target window, it calls the child process corresponding to the target window and uses a pre-injected preload script in the child process to collect target log information. In this example, the client runs multiple processes, each corresponding to a window, and listens to each window; the window being listened to is called the target window. The client listens to the target window, and when it detects an open command for the target window, it calls the child process corresponding to the target window. This child process contains a pre-injected preload script, which is used to collect target log information generated by the child process during its execution. In this example, the client uses the pre-injected preload script to collect target log information from the child process corresponding to the target window, providing feasibility for subsequent parsing of the target log information.
[0037] The process logs in the target log information refer to the logs of the child processes corresponding to the target window, including but not limited to application logs, inter-process communication logs, network logs, and crash logs. The process category in the target log information refers to the category information of the child processes after process classification. The filename in the target log information refers to the name of the folder where the logs of the child processes corresponding to the target window are stored.
[0038] As an example, in step S202, the client parses the target log information to determine the process logs, process categories, and filenames within the target log information. In this example, after collecting the target log information using the preload script, the target log information needs to be parsed to obtain the process logs, process categories, and filenames. This prepares for subsequently obtaining the log printing primary key and classifying and printing the process logs according to the log printing primary key.
[0039] The log printing primary key is a unique identifier used to categorize and print process logs within the target log information. In essence, when the client categorizes and prints process logs, this log printing primary key is the sole basis for determining the printing location of process logs within the target log information.
[0040] As an example, in step S203, the client determines the log printing primary key based on the process category and filename in the target log information. Understandably, determining the log printing primary key based on the process category and filename in the target log information specifically includes: processing the two input parameters, process category and filename, using pre-set printing primary key determination rules, and determining the log printing primary key based on the processing result, thus providing feasibility for classifying and printing process logs according to the log printing primary key.
[0041] The log folder is a folder in the local cache that corresponds to the log printing primary key and is used to categorize and store process logs.
[0042] As an example, in step S204, the client prints the process logs from the target log information to the log folder corresponding to the log printing primary key. Understandably, in this example, the process logs, process categories, and filenames in the target log information have a one-to-one correspondence. For a specific process log, its corresponding process category and filename are also specific. That is, the log printing primary key determined by the process category and filename also has a one-to-one correspondence with the process logs; each process log corresponds to a specific log printing primary key. Therefore, the client can print different process logs from the target log information to the log folder corresponding to the specific log printing primary key.
[0043] In the process log management method provided in this embodiment, when the open command corresponding to the target window is detected, the child process corresponding to the target window is called. The target log information is collected according to the preload script pre-injected by the child process, and the target log information is parsed to determine the process log, process category and file name in the target log information. The log printing primary key is determined, and the process log in the target log information is printed to the log folder corresponding to the log printing primary key. This realizes the function of classifying and printing process logs of multiple processes and storing them in a classified manner.
[0044] In one embodiment, such as Figure 3 As shown, before step S201, that is, before calling the child process corresponding to the target window when the open command corresponding to the target window is detected, and before obtaining the target log information from the preload script corresponding to the child process, the process log management method further includes:
[0045] S301: When an open command corresponding to a target window is detected, the process type is determined based on the target window;
[0046] S302: Create a child process corresponding to the process type;
[0047] S303: Retrieve the log configuration file from the local cache;
[0048] S304: Employs a preload mechanism to inject the preload script corresponding to the log configuration file into the child process.
[0049] The process category refers to the category information of the target window, including but not limited to the main process, rendering process, and lightweight application process.
[0050] As an example, in step S301, when the client hears an open command corresponding to a target window, it determines the process category based on the target window. Understandably, the client listens for each target window, and upon hearing an open command for each target window, determines the window category corresponding to that target window and its corresponding process category. For example, if the client pre-sets the process category corresponding to a window to be A, and pre-sets the process category corresponding to a webview to be B, then upon hearing an open command corresponding to a webview, it can determine that the process category corresponding to the target window is B.
[0051] As an example, in step S302, after determining the process category corresponding to the target window, the client creates a child process corresponding to the process category. Understandably, this child process is the same as the child process corresponding to the target window. In this example, creating a corresponding child process based on the process category of the target window makes subsequent classification, collection, and printing of log information generated by different categories of child processes simpler and more convenient.
[0052] The log configuration file is used to obtain the preload script corresponding to the child process.
[0053] As an example, in step S303, after creating the child process corresponding to the process category, the client retrieves the preloaded log configuration file from the local cache. In this example, retrieving the log configuration file from the local cache provides the feasibility for retrieving the preload script corresponding to the child process.
[0054] The preload mechanism refers to the preloading mechanism, specifically the preload script of the child process.
[0055] As an example, in step S304, the client uses a preload mechanism to inject the preload script corresponding to the log configuration file into the child process. In this example, the client uses a preload mechanism to configure the preload script corresponding to the log configuration file in the child process corresponding to the target window, based on the log configuration file, thus providing feasibility for subsequently using the preload script to collect target log information.
[0056] In the process log management method provided in this embodiment, when the open command corresponding to the target window is detected, the process category is determined according to the target window, and a child process corresponding to the process category is created. The preload script is injected into the child process according to the log configuration file, making it feasible to collect target log information from the child process in the future. At the same time, the creation of child processes corresponding to the process category makes it simpler and more convenient to classify, collect and print log information generated by different types of child processes in the future.
[0057] In one embodiment, such as Figure 4 As shown, before step S301, that is, before determining the process category based on the target window when the open command corresponding to the target window is detected, the process log management method further includes:
[0058] S401: Obtain the log initialization request. The log initialization request includes the process type, file name, output stream, log level, and log provider.
[0059] S402: Based on the process type and filename, retrieve the log printing primary key and the log folder corresponding to the log printing primary key;
[0060] S403: Obtain the log instance based on the log level and log provider;
[0061] S404: Based on the output stream and log instance, obtain the log configuration file and store it in the local cache.
[0062] The log initialization request refers to the request to initialize the log management configuration. Process category refers to the pre-defined category information for each process. Filename refers to the name of the folder where the logs for each process are stored. Output stream refers to the pre-defined data flow for printing process logs; log level refers to the pre-defined different log levels, including level, info, and debug levels, or low-risk, medium-risk, and high-risk levels. The log provider (LogProvider) provides a single core method that implements the operation of writing to the log table. Generally, information about the log provider can be obtained from the object container ObjectContainer.Resolve. <logprovider>In this example, a log instance for the corresponding process can be created based on the log provider determined during the initialization process.
[0063] As an example, in step S401, the client obtains a log initialization request. This log initialization request includes the process type, filename, output stream, log level, and log provider. In this example, the client obtains the log initialization request input by the operator, preparing for a series of subsequent initialization configurations.
[0064] As an example, in step S402, after obtaining the log initialization request, the client retrieves the log printing primary key and the corresponding log folder based on the process category and filename. In this example, the initialization configuration is performed based on the log initialization request input by the operator. Specifically, the client uses pre-set printing primary key determination rules to process the two input parameters, process category and filename, create a directory structure corresponding to the process category and filename, and determine the log printing primary key based on the created directory structure; after determining each log printing primary key, a log folder corresponding to each log printing primary key is created in the local file system.
[0065] Different processes correspond to different log instances.
[0066] As an example, in step S403, after receiving the log initialization request, the client obtains a log instance based on the log level and log provider. In this example, the client obtains different log instances for different processes based on their respective log levels and log providers.
[0067] The log configuration file includes the log configuration information for the process logs corresponding to the process.
[0068] As an example, in step S404, the client obtains the log configuration file based on the output stream and the log instance, and stores the log configuration file in a local cache. In this example, the client obtains the log configuration information for the process logs of different processes based on the output streams and log instances corresponding to different processes. This log configuration file is then stored in the local cache, facilitating the subsequent injection of the preload script corresponding to the log configuration file into the child process using the preload mechanism. Simultaneously, the client binds the output of the output streams corresponding to different processes to the log instance, enabling the redirection of process logs printed via the output stream to the log instance for processing. This makes it feasible to categorize and print process logs that conform to the corresponding process level into the log folders corresponding to the log printing primary keys of different processes after processing by the log instance.
[0069] In the process log management method provided in this embodiment, the client is initialized and configured according to the log initialization request sent by the operator, and finally the log configuration files corresponding to different processes are obtained, making it feasible to obtain the preload script corresponding to the log configuration file in the future.
[0070] In one embodiment, such as Figure 5 As shown, step S204 involves printing the process logs from the target log information to the log folder corresponding to the log printing primary key, including:
[0071] S501: Count the frequency of printing corresponding to the process category;
[0072] S502: Determine the backup log size and number of backup logs based on the printing frequency corresponding to the process category;
[0073] S503: Based on the backup log size and number of backup logs, create backups of the process logs in the target log information, obtain the backup logs, and print the backup logs to the log folder corresponding to the log printing primary key.
[0074] Among them, the frequency of printing reflects the frequency of the execution of subprocesses corresponding to a certain process category.
[0075] As an example, in step S501, the client statistically analyzes the printing frequency corresponding to each process category to obtain the printing frequency for each process category. In this example, each process log has a corresponding process category. The process logs in the target log information are classified according to the process category, and the printing frequency corresponding to different process categories is statistically analyzed. The printing frequency in this example can be represented as the number of times the process logs corresponding to each process category are printed within a preset time period, or it can be represented as the printing frequency of the process logs corresponding to each process category within a preset time period.
[0076] The backup log size refers to the size of the backup logs obtained subsequently, and the backup log quantity refers to the quantity of backup logs obtained subsequently.
[0077] As an example, in step S502, the client determines the backup log size and number of backup logs based on the printing frequency corresponding to the process category. In this example, in order to ensure that the subsequently obtained backup logs can be printed to the corresponding log folder, the client determines the backup log size and number of backup logs based on the printing frequency of the obtained process categories.
[0078] The backup log corresponds to the process log of the child process and contains the same log information as the process log.
[0079] As an example, in step S503, the client creates a backup of the process log in the target log information based on the backup log size and the number of backup logs, obtains the backup logs, and prints the backup logs to the log folder corresponding to the log printing primary key. In this example, the client creates a backup of the process log in the target log information according to the obtained backup log size and the number of backup logs, and obtains the backup logs. The backup creation process includes, but is not limited to, copying the process logs. Subsequently, the obtained backup logs are categorized and printed to the log folder corresponding to the log printing primary key, and stored accordingly.
[0080] In the process log management method provided in this embodiment, the client counts the frequency of printing corresponding to the process category, obtains the size and number of backup logs, creates backups of the process logs in the target log information, obtains the backup logs, and prints the backup logs to the log folder corresponding to the log printing primary key, thereby realizing the classification printing and classification storage of different process logs.
[0081] In one embodiment, such as Figure 6 As shown, step S204 involves printing the process logs from the target log information to the log folder corresponding to the log printing primary key, including:
[0082] S601: Retrieve the log configuration file from the local cache;
[0083] S602: Determine whether scrolling printing is supported based on the log configuration file;
[0084] S603: If scrolling printing is supported, the process logs in the target log information will be scrolled to the log folder corresponding to the log printing primary key.
[0085] As an example, in step S601, the client retrieves the log configuration file from its local cache. In this example, retrieving the log configuration file prepares the client for subsequent determination of whether it supports scrolling printing.
[0086] Rolling printing refers to the process where, since the log folder has a fixed size, once the log files reach a certain size, the oldest process logs in the log folder will be deleted while the latest process logs are printed to the corresponding log folder.
[0087] As an example, in step S602, the client determines, based on the log configuration file, whether the process logs to be printed to the log folder support scrolling printing. In this example, the client determines whether the process logs to be printed to the log folder support scrolling printing based on the log configuration information obtained from the log configuration file. Understandably, the log configuration information in the log configuration file contains the printing information for the process logs. The client can determine, based on the log configuration information corresponding to the process logs, whether the process logs support deleting older process logs in the log folder when printing the latest process log to the corresponding log folder after the printed log folder reaches a certain size.
[0088] As an example, in step S603, if scrolling printing is supported, the process logs in the target log information are scrolled to the log folder corresponding to the log printing primary key. In this example, when the client determines that the process logs to be printed support scrolling printing, it scrolls the process logs in the target log information to the log folder corresponding to the log printing primary key. Understandably, if the process logs support deleting older process logs in the log folder when printing the latest process logs to the corresponding log folder after the printed log folder reaches a certain size, then the process logs are scrolled to the log folder corresponding to the log printing primary key.
[0089] In the process log management method provided in this embodiment, the client determines whether the process log supports scrolling printing. If scrolling printing is supported, the process log is scrolled to the log folder corresponding to the log printing primary key, and process logs that have been stored for a long time are deleted. This method not only saves storage space but also removes redundant information, making it convenient for operators to check the process logs.
[0090] In one embodiment, such as Figure 7 As shown, step S602, which determines whether scrolling printing is supported based on the log configuration file, includes:
[0091] S701: Obtain the log provider based on the log configuration file;
[0092] S702: Determine the target type based on the log provider;
[0093] S703: If the target type is the first type, then scrolling printing is supported;
[0094] S704: If the target type is type 2, then the scrolling printing function is not supported.
[0095] As an example, in step S701, the client obtains the log provider based on the log configuration file. Understandably, different processes have different log providers for their log configuration files, making it feasible to subsequently determine the target type based on the log provider.
[0096] The target type refers to the type of process logs that will be categorized and printed, including but not limited to the log size, process category, and number of process logs of the same process category.
[0097] As an example, in step S702, the target type is determined based on the log provider. In this example, the client determines different target types based on the log provider corresponding to the log configuration file of different processes, providing feasibility for subsequently determining different printing methods based on different target types.
[0098] The first type includes, but is not limited to, target types such as excessively large log sizes, excessive number of logs for a specific process category, and excessive number of process logs for the same process category.
[0099] As an example, in step S703, if the target type corresponding to the process log is the first type, then it is determined that the process log supports the rolling printing function. In this example, when the client judges the target type, if the target type corresponding to the process log is the first type, that is, when the log size is too large, or there are too many process logs of a specific process category and the same process category, then it is determined that the process log supports the rolling printing function. That is, the older process logs in the log folder to be printed are deleted, and the process logs with the target type of the first type are printed to the log folder corresponding to the log printing primary key.
[0100] The second type includes, but is not limited to, target types that are not of a specific process category and have a small number of process logs of the same process category.
[0101] As an example, in step S704, if the target type corresponding to the process log is the second type, then it is determined that the process log does not support the scrolling printing function. In this example, when the client judges the target type, if the target type corresponding to the process log is the second type, that is, when the log size is small, and the number of non-specific process categories and process logs of the same process category is not large, then it is determined that the process log does not support the scrolling printing function, that is, the process log with the target type of the second type is directly printed to the log folder corresponding to the log printing primary key.
[0102] In the process log management method provided in this embodiment, the method determines whether the process logs to be categorized and printed support scrolling printing based on the target type. This method not only preserves the printed process logs to the maximum extent, but also performs scrolling printing of specific types of process logs, making it more convenient and faster for operators to check the corresponding process logs.
[0103] In one embodiment, such as Figure 8 As shown, in step S204, after printing the process logs from the target log information to the log folder corresponding to the log printing primary key, the process log management method further includes:
[0104] S801: Obtain log reporting request. The log reporting request includes process type, file name, and log level.
[0105] S802: Determine the log printing primary key based on the process type and filename;
[0106] S803: Select the process logs corresponding to the log level in the log folder corresponding to the log print primary key, identify them as logs to be reported, and upload them to the backend server.
[0107] As an example, in step S801, the client obtains a log reporting request. In this example, after the client completes the process logs by classifying and printing them to log folders corresponding to different log printing primary keys, it also needs to report the classified and printed process logs to the corresponding backend server. At this time, the client can obtain a log reporting request triggered by the user or triggered on a timer. This log reporting request includes the process category, file name, and log level corresponding to the classified and printed process logs.
[0108] As an example, in step S802, the client determines the log printing primary key based on the process type and filename. In this example, the client determines the corresponding log printing primary key based on the process type and filename in the obtained log reporting request. This log printing primary key is a unique identifier for the printing position of the process log. Understandably, when the client prints the process log, this log printing primary key is the sole basis for determining the printing position of the process log.
[0109] Among them, the logs to be reported refer to the process logs that need to be reported to the backend server.
[0110] As an example, in step S803, the client identifies the process logs corresponding to the log level within the log folder corresponding to the log printing primary key as logs to be reported, and then uploads these logs to the backend server. In this example, after determining the log printing primary key corresponding to the process log in the log reporting request, the client searches for the corresponding log folder, further locates the corresponding process log based on the log level, identifies this process log as a log to be reported, and then uploads it to the corresponding backend server, thus realizing the function of classifying and managing the reporting of process logs.
[0111] In the process log management method provided in this embodiment, the log printing primary key corresponding to the process log to be reported is determined according to the log reporting request. The corresponding log folder is determined according to the log printing primary key. Then, the log to be reported corresponding to the log level is found in the log folder, so as to report the log to be reported to the backend server and complete the reporting management of process logs. This method directly determines the process logs corresponding to the log level in the log folder corresponding to the log printing primary key as the logs to be reported, which increases the accuracy of finding the location of process logs that need to be reported to the backend server. At the same time, this method directly determines the log folder corresponding to the log printing primary key, without traversing all log folders storing process logs, which improves the search speed of process logs that need to be reported to the backend server.
[0112] It should be understood that the sequence number of each step in the above embodiments does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present invention.
[0113] In one embodiment, a process log management device is provided, which corresponds one-to-one with the process log management method described in the above embodiments. For example... Figure 9 As shown, the process log management device includes a target log information acquisition module 901, a target log information parsing module 902, a log printing primary key determination module 903, and a process log printing module 904. Detailed descriptions of each functional module are as follows:
[0114] The target log information collection module 901 is used to call the child process corresponding to the target window when the open command corresponding to the target window is detected, and to obtain the target log information collected by the preload script pre-injected by the child process.
[0115] The target log information parsing module 902 is used to parse the target log information and determine the process log, process category, and file name in the target log information.
[0116] The log printing primary key determination module 903 is used to determine the log printing primary key based on the process category and file name in the target log information;
[0117] The process log printing module 904 prints the process logs from the target log information to the log folder corresponding to the log printing primary key.
[0118] In one embodiment, the process log management device further includes:
[0119] The process category determination module is used to determine the process category based on the target window when an open command corresponding to the target window is detected.
[0120] The child process creation module is used to create child processes corresponding to the process type.
[0121] The log configuration file retrieval module is used to retrieve the log configuration file from the local cache;
[0122] The preload script injection module is used to inject the preload script corresponding to the log configuration file into the child process using the preload mechanism.
[0123] In one embodiment, the process log management device further includes:
[0124] The log initialization request acquisition module is used to acquire log initialization requests, which include process type, file name, output stream, log level, and log provider.
[0125] The log folder retrieval module is used to retrieve the log printing primary key and the corresponding log folder based on the process type and file name;
[0126] The log instance acquisition module is used to obtain log instances based on the log level and log provider.
[0127] The log configuration file retrieval module is used to retrieve the log configuration file based on the output stream and the log instance, and store the log configuration file in the local cache.
[0128] In one embodiment, the process log printing module 904 includes:
[0129] The print frequency statistics submodule is used to count the print frequency of process categories.
[0130] The backup log information determination submodule is used to determine the backup log size and number of backup logs based on the printing frequency corresponding to the process category.
[0131] The backup log printing submodule is used to create backups of process logs in the target log information based on the backup log size and number of backup logs, obtain backup logs, and print the backup logs to the log folder corresponding to the log printing primary key.
[0132] In one embodiment, the process log printing module 904 further includes:
[0133] The log configuration file retrieval submodule is used to retrieve the log configuration file from the local cache;
[0134] The scrolling print function determination submodule is used to determine whether the scrolling print function is supported based on the log configuration file.
[0135] The scrolling print submodule is used to scroll the process logs in the target log information to the log folder corresponding to the log printing primary key, if scrolling print functionality is supported.
[0136] In one embodiment, the scrolling printing function determination submodule includes:
[0137] The log provider acquisition unit is used to acquire the log provider based on the log configuration file;
[0138] The target type determination unit is used to determine the target type based on the log provider.
[0139] The first type determination unit is used to determine whether the scrolling printing function is supported if the target type is the first type.
[0140] The second type determination unit is used to determine that the scrolling printing function is not supported if the target type is the second type.
[0141] In one embodiment, the process log management device further includes:
[0142] The log reporting request acquisition module is used to acquire log reporting requests, which include process type, file name, and log level.
[0143] The log printing primary key determination module is used to determine the log printing primary key based on the process type and file name;
[0144] The pending log upload module is used to identify the log folder corresponding to the log printing primary key and the process log corresponding to the log level as pending logs, and then upload the pending logs to the backend server.
[0145] For specific limitations regarding the process log management device, please refer to the limitations of the process log management method above, which will not be repeated here. Each module in the aforementioned process log management device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in the processor of the computer device in hardware form or independent of it, or stored in the memory of the computer device in software form, so that the processor can call and execute the operations corresponding to each module.
[0146] In one embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as follows: Figure 10 As shown, the computer device includes a processor, memory, network interface, and database connected via a system bus. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and database. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The database stores data used or generated during the execution of a process log management method. The network interface communicates with external terminals via a network connection. The computer program, when executed by the processor, implements a process log management method.
[0147] In one embodiment, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the process log management method described in the above embodiment, for example... Figure 2 As shown in S201-S204, or Figures 2 to 8 As shown, to avoid repetition, it will not be described again here. Alternatively, when the processor executes a computer program, it implements the functions of each module / unit in this embodiment of the process log management device, for example... Figure 9 The functions of the target log information acquisition module 901, target log information parsing module 902, log printing primary key determination module 903, and process log printing module 904 shown are not described again here to avoid duplication.
[0148] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When executed by a processor, the computer program implements the process log management method described in the above embodiment, for example... Figure 2 As shown in S201-S204, or Figures 2 to 8 As shown, to avoid repetition, it will not be described again here. Alternatively, when the computer program is executed by the processor, it implements the functions of each module / unit in this embodiment of the process log management device, for example... Figure 9 The functions of the target log information acquisition module 901, target log information parsing module 902, log printing primary key determination module 903, and process log printing module 904 shown are not described again here to avoid repetition. The computer-readable storage medium can be non-volatile or volatile.
[0149] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. This computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the embodiments of the above methods. Any references to memory, storage, databases, or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), dual data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), RAMbus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and RAMbus dynamic RAM (RDRAM), etc.
[0150] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the above-described division of functional units and modules is used as an example. In practical applications, the above functions can be assigned to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above.
[0151] The above-described embodiments are only used to illustrate the technical solutions of the present invention, and are not intended to limit it. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions 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 invention, and should all be included within the protection scope of the present invention.< / logprovider>
Claims
1. A process log management method, characterized in that, include: When an open command corresponding to the target window is detected, the child process corresponding to the target window is invoked to obtain the target log information collected by the preload script pre-injected by the child process. Parse the target log information to determine the process log, process category, and file name in the target log information; Determine the log printing primary key based on the process category and filename in the target log information; The step of determining the log printing primary key based on the process category and file name in the target log information includes: processing the two input parameters, process category and file name, using a pre-set primary key determination rule, and determining the log printing primary key based on the processing result; The log printing primary key refers to the unique identifier used when classifying and printing process logs in the target log information. Print the process logs from the target log information to the log folder corresponding to the log printing primary key.
2. The process log management method as described in claim 1, characterized in that, Before invoking the child process corresponding to the target window when an open command corresponding to the target window is detected, and obtaining the target log information from the preload script pre-injected by the child process, the process log management method further includes: When an open command corresponding to a target window is detected, the process category is determined based on the target window; the process category is determined based on the target window when an open command corresponding to a target window is detected, which includes: listening to each target window, and when an open command for each target window is detected, determining the window category corresponding to each target window, and determining the process category corresponding to the window category; Based on the process category, create the child process corresponding to the process category; Retrieve the log configuration file from the local cache; A preload mechanism is used to inject the preload script corresponding to the log configuration file into the child process.
3. The process log management method as described in claim 2, characterized in that, Before determining the process category based on the target window upon detecting an open command corresponding to the target window, the process log management method further includes: Obtain a log initialization request, which includes process category, filename, output stream, log level, and log provider; the process category refers to the pre-set category information corresponding to each process. Based on the process category and the filename, obtain the log printing primary key and the corresponding log folder; the step of obtaining the log printing primary key and the corresponding log folder based on the process category and the filename includes: processing the two input parameters, process the process category and filename, using a pre-set primary key determination rule, creating a directory structure corresponding to the process category and filename, determining the log printing primary key based on the created directory structure; after determining each log printing primary key, creating a log folder corresponding to each log printing primary key in the local file system; Obtain the log instance based on the log level and the log provider; Based on the output stream and the log instance, obtain the log configuration file and store the log configuration file in the local cache.
4. The process log management method as described in claim 1, characterized in that, The step of printing the process logs from the target log information to the log folder corresponding to the log printing primary key includes: Calculate the frequency of printing corresponding to the process categories; The size and number of backup logs are determined based on the printing frequency corresponding to the process category. Based on the backup log size and the number of backup logs, a backup is created for the process log in the target log information, the backup log is obtained, and the backup log is printed to the log folder corresponding to the log printing primary key.
5. The process log management method as described in claim 1, characterized in that, The step of printing the process logs from the target log information to the log folder corresponding to the log printing primary key includes: Retrieve the log configuration file from the local cache; Based on the log configuration file, determine whether the scrolling printing function is supported; If scrolling printing is supported, the process logs in the target log information will be scrolled to the log folder corresponding to the log printing primary key.
6. The process log management method as described in claim 5, characterized in that, The step of determining whether scrolling printing is supported based on the log configuration file includes: Based on the log configuration file, obtain the log provider; Determine the target type based on the log provider; If the target type is the first type, then the scrolling printing function is supported; If the target type is the second type, then the scrolling printing function is not supported.
7. The process log management method as described in claim 1, characterized in that, After printing the process logs from the target log information to the log folder corresponding to the log printing primary key, the process log management method further includes: Obtain a log reporting request, wherein the log reporting request includes process type, file name, and log level; Determine the log printing primary key based on the process category and file name; The log folder corresponding to the primary key of the log print and the process log corresponding to the log level are identified as logs to be reported, and the logs to be reported are uploaded to the backend server.
8. A process log management device, characterized in that, include: The target log information collection module is used to call the subprocess corresponding to the target window when the open command corresponding to the target window is detected, and to obtain the target log information collected by the preload script pre-injected by the subprocess. The target log information parsing module is used to parse the target log information and determine the process log, process category, and file name in the target log information. The log printing primary key determination module is used to determine the log printing primary key based on the process category and file name in the target log information; The process log printing module prints the process logs from the target log information to the log folder corresponding to the log printing primary key. The log printing primary key determination module includes: processing the two input parameters, process type and file name, using a pre-set printing primary key determination rule, and determining the log printing primary key based on the processing result; The log printing primary key refers to a unique identifier used when classifying and printing process logs in the target log information.
9. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the process log management method as described in any one of claims 1 to 7.
10. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by the processor, it implements the process log management method as described in any one of claims 1 to 7.