A method, apparatus, and computing device for logging and outputting data.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-08
- Publication Date
- 2026-08-11
AI Technical Summary
[0003]现有日志系统在大量系统事件需要进行记录存储的情况下,记录大量的日志信息会导致频繁的IO(输入输出)、大量的字符转换等操作,需要消耗大量的硬件性能,从而降低日志记录的效率
[0032]输出单元,用于将所述格式化字符串的占位符填充所述参数后输出。
Smart Images

Figure CN115840675B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of application logging technology, specifically a logging recording and output method, apparatus, and computing device. Background Technology
[0002] Application logging methods are instructions injected into the application's own code during application development. They are used to record various events that occur during program execution, monitor program operation, and thus help understand the system and program's running status and diagnose problems.
[0003] When existing logging systems need to record and store a large number of system events, recording a large amount of log information leads to frequent I / O (input / output) operations and a large number of character conversions, which consume a lot of hardware performance and reduce the efficiency of log recording. Summary of the Invention
[0004] In view of the above-mentioned problems of the prior art, this application provides a log recording and output method, apparatus and computing device, which replaces the method of recording all strings and parameters by recording the address and parameters of constant strings, thereby reducing the amount of data recorded, improving the recording efficiency of system logs, and reducing the impact of log recording itself on system performance.
[0005] To achieve the above objectives, the first aspect of this application provides a log recording method, comprising:
[0006] Retrieve the events to be logged;
[0007] Determine the constant string and parameters when the event is recorded as a log, wherein the constant string includes a format string, and the parameters are used to fill the placeholders in the format string;
[0008] The storage address of the constant string and the parameter are recorded as the log of the event.
[0009] This implementation reduces the performance overhead of log recording by only recording the address and parameters of the constant string corresponding to the log, effectively improving the recording efficiency of the system log and reducing the impact of log recording itself on the overall system performance. As one possible implementation of the first aspect, the parameter includes another constant string, and the parameter is recorded using the storage address corresponding to the other constant string.
[0010] As one possible implementation of the first aspect, it also includes: outputting a constant string segment, wherein the constant string segment includes the constant string, and the constant string segment is used to obtain the constant string corresponding to the address of the constant string from the constant string segment when logging output.
[0011] In this implementation, by including all the constant strings used in the formatted output in the same segment, it facilitates the subsequent output and management of formatted strings, while reducing the transmission of invalid content when transmitting constant strings.
[0012] A second aspect of this application provides a log output method, including:
[0013] Obtain a constant string segment, wherein different constant strings are stored at different addresses in the constant string segment;
[0014] Obtain a log, which includes the address and parameters of a constant string representing an event;
[0015] The constant string corresponding to the address of the constant string is obtained from the constant string segment, and the constant string includes a format string;
[0016] The format string is filled with placeholders for the parameters and then output.
[0017] In this embodiment, by obtaining the address and parameters of the constant string of the log event, and obtaining the corresponding constant string from the constant string segment based on the address of the constant string, and performing formatted output, the performance overhead required for log output is reduced.
[0018] As a possible implementation of the second aspect, it also includes:
[0019] Each constant string is stored in the form of a constant string segment, and different constant strings are stored at different addresses in the constant string segment. The constant string segment is used to send to the execution log output.
[0020] A third aspect of this application provides a log output method, including:
[0021] Perform the logging method as described above, and perform the log output method as described above.
[0022] As one possible implementation of the third aspect, the logging method is executed by a real-time system.
[0023] The log output method is executed by a non-real-time system.
[0024] A fourth aspect of this application provides a log recording device, comprising:
[0025] The first acquisition unit is used to acquire the events to be recorded;
[0026] A determining unit is used to determine a constant string and parameters when the event is recorded as a log, wherein the constant string includes a format string, and the parameters are used to fill placeholders in the format string;
[0027] A recording unit is used to record the storage address of the constant string and the parameters as a log of the event.
[0028] The fifth aspect of this application provides a log output device, comprising:
[0029] The second acquisition unit is used to acquire a constant string segment, wherein different constant strings are stored at different addresses of the constant string segment;
[0030] The third acquisition unit is used to acquire a log, which includes the address and parameters of a constant string of an event;
[0031] The parsing unit is used to obtain the constant string corresponding to the address of the constant string from the constant string segment, wherein the constant string includes a format string;
[0032] The output unit is used to fill the parameters with placeholders of the format string and then output them.
[0033] A sixth aspect of this application provides a computing device, comprising:
[0034] processor, and
[0035] A memory that stores program instructions that, when executed by the processor, cause the processor to perform the method described above.
[0036] The log management solution provided in this application allows the target machine to parse the logs by recording only the addresses and preset parameters of constant strings. This effectively improves the efficiency of system log recording, reduces the performance overhead required for log recording, minimizes the impact of log recording itself on the overall system performance and timing, and enables comprehensive event recording and analysis in the case of a large number of events.
[0037] These and other aspects of the invention will become more apparent from the following description of several embodiments. Attached Figure Description
[0038] The various features of the present invention and the relationships between them are further explained below with reference to the accompanying drawings. The drawings are exemplary; some features are not shown to scale, and some drawings may omit conventional features in the field of this application that are not essential to this application, or additional features that are not essential to this application may be shown. The combination of features shown in the drawings is not intended to limit the present application. Furthermore, throughout this specification, the same reference numerals refer to the same things. Specific descriptions of the drawings are as follows:
[0039] Figure 1A This is a flowchart of a log recording method provided in one embodiment of this application;
[0040] Figure 1B This is a flowchart of a log output method provided in another embodiment of this application;
[0041] Figure 2 This is a flowchart of a log recording and output method provided in one embodiment of this application;
[0042] Figure 3 This is a schematic diagram of a log recording and output method provided in one embodiment of this application;
[0043] Figure 4 This is a schematic diagram of the structure of a log recording device provided in one embodiment of this application;
[0044] Figure 5 This is a schematic diagram of the structure of a log output device provided in one embodiment of this application;
[0045] Figure 6 This is a schematic diagram of a computing device provided in one embodiment of this application. Detailed Implementation
[0046] The technical solutions provided in this application will be further described below with reference to the accompanying drawings and embodiments. It should be understood that the system architecture and business scenarios provided in the embodiments of this application are mainly for illustrating possible implementations of the technical solutions of this application and should not be construed as the sole limitation on the technical solutions of this application. Those skilled in the art will recognize that the technical solutions provided in this application are equally applicable to similar technical problems as system architectures evolve and new business scenarios emerge.
[0047] It should be understood that the log management solution provided in this application includes a log recording and output method, apparatus, and computing device. Since these technical solutions solve problems based on the same or similar principles, some repetitive details may not be repeated in the following description of specific embodiments. However, it should be considered that these specific embodiments have mutual references and can be combined with each other.
[0048] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. In case of any inconsistency, the meaning set forth in this specification or derived from the content described herein shall prevail. Furthermore, the terminology used herein is for the purpose of describing embodiments of this application only and is not intended to limit this application. To accurately describe the technical content of this application and to accurately understand the invention, the following explanations or definitions of the terms used in this specification are provided before describing specific embodiments:
[0049] 1) Event block: A specific data structure used to record log events.
[0050] 2) Event flow: refers to the order in which the page receives events.
[0051] 3) Log recording interfaces such as quicklyLog, quicklyInfo, and quicklyWarn are logging tools.
[0052] 4) Formatted string: This is a data format that reserves several positions (or placeholders, which can be represented by %) in a string, and these positions will be filled with corresponding content as needed.
[0053] An example of a format string is "a quikly warning record:%d%d%d%s\n",110,2200,3,"warning msg". Here, the four % symbols represent four reserved positions. The letter immediately following the % symbol indicates the data type of the reserved positions; for example, 'd' indicates a decimal data type, and 's' indicates a character data type. '110,2200,3,"warning msg" represents the data to be filled into the four positions, which can be real-time retrieved data.
[0054] 5) Constant strings: In this embodiment of the application, some unchanging strings are called constant strings.
[0055] In this embodiment of the application, the constant string is relatively long. It is stored in a specified location and the constant string is recorded or transmitted instead of being recorded or transmitted by recording or transmitting the address corresponding to the specified location, so as to reduce the amount of data recorded or transmitted in the log.
[0056] For example, "a quikly warning record:%d%d%d%s\n" in the format string can be used as a constant string, and "warning msg" can also be used as a constant string.
[0057] 6) Constant string segment: A constant string segment is formed by linking all constant strings into the same segment by the compiler. The purpose of forming a constant string segment is to facilitate storage and indexing of the address of constant strings.
[0058] Traditional character stream logging systems require the target machine to expend significant CPU resources to parse each parameter of the format string and convert it into a corresponding string for storage. On low-performance processors requiring high real-time performance, adding debug logs can have a substantial impact on the overall system.
[0059] The solution provided in this application can solve the above-mentioned technical problems. The embodiments of this application provide a log recording and output scheme that can be applied to embedded systems, such as the Intewell system. The Intewell system can simultaneously run a real-time operating system (RTOS) and a non-real-time operating system (GPOS) on the same device. Through the embodiments of this application, log parameters can be recorded by the real-time system, and the logs can be parsed by the non-real-time system. This effectively improves the efficiency of system log recording and management, reduces the performance overhead required for log recording, and minimizes the impact of log recording itself on the overall system performance and timing.
[0060] Furthermore, the log management solution provided in this application can also be applied to distributed systems. Typically, a distributed system can include a target machine and a host machine, where the target machine and host machine can be different systems running on the same device, or they can be separate devices. In this application's embodiment, log recording is performed on the target machine, and the logs are parsed by the host machine.
[0061] The present application will now be described in detail with reference to the accompanying drawings.
[0062] like Figure 1A As shown, Figure 1A This is a flowchart of the log recording method provided in this embodiment. It includes the following steps:
[0063] S101: Get the events to be recorded.
[0064] When the target machine or real-time system is running, it will obtain the corresponding events to be recorded when the log recording conditions are triggered.
[0065] In some implementations, the conditions that trigger logging include, for example, a change in the running state of a process (such as starting, interrupting, or ending), generating an alarm message, or detecting a login.
[0066] In some implementations, the information to be recorded includes, for example: when a process's running status changes, the process ID, status data, and trigger time will be obtained; when an alarm is detected, the alarm type or ID, alarm level, and trigger time will be obtained; when a login is detected, the login ID and trigger time will be obtained, etc.
[0067] S102: Determine the constant string and parameters when the event is recorded as a log, wherein the constant string includes a format string, and the parameters are used to fill the placeholders in the format string.
[0068] When the event is determined to be a log, it can be recorded through a logging interface, such as quicklyLog, quicklyInfo, quicklyWarn, etc.
[0069] In some embodiments, the above parameters can be numbers, functions, strings, etc.
[0070] S103: Record the storage address of the constant string and the parameter as the log of the event.
[0071] For example, the quicklyLog3 logging interface can be used: quicklyLog3(“a quickly log record:%d%d%d\n”,v1,v2,v3); where “a quickly log record:%d%d%d\n” is a constant string, %d is the formatting character, or placeholder, in this implementation; v1, v2, and v3 are the three parameters corresponding to the three placeholders; the parameters can be another constant string. The storage address of the above constant string will be obtained during the compilation process.
[0072] Then, the addresses of the aforementioned event constant strings and the parameters can be stored in the event recording block to complete the logging process.
[0073] In some implementations, all constant strings can be chained into a constant string segment before the events to be logged are retrieved. Since the valid content (constant strings) in the log event file only constitutes a portion and may be scattered, the compiler can chain all constant strings into a single segment, ensuring that all constant strings used for formatted output are in the same segment, reducing the conversion and transmission of invalid content. For example, the compiler could be armcc, which, through the `--no_string_literal_pools` compilation option, can recognize constant strings and chain them into a constant string segment.
[0074] The embodiments of this application can effectively improve the recording efficiency of system logs by only recording the addresses and corresponding parameters of constant strings in log events, reduce the performance overhead required for log recording, and reduce the impact of log recording itself on the overall system performance and timing.
[0075] This application also provides a log output method, such as... Figure 1B As shown, Figure 1B This is a flowchart of the log output method provided in this embodiment. It includes the following steps:
[0076] S104: Get the constant string segment. Different constant strings are stored at different addresses in the constant string segment.
[0077] Log events recorded in the event block can be obtained through high-speed transmission channels such as Universal Serial Bus (USB), Secure Digital Input and Output (SDIO), Peripheral Component Interconnect Express (PCIE), and networks. In other implementations, log events recorded in the event block can be obtained by searching and reading local file directories.
[0078] In this embodiment, the real-time system and the non-real-time system reside on the same device. The generated log events can be transmitted through shared underlying hardware, such as PCIe cards, virtual network cards, or shared memory. In other embodiments, the log events generated by the real-time system can also be stored in a shared storage space with the non-real-time system, such as a shared file directory, for the non-real-time system to access.
[0079] S105: Retrieve a log file containing the address and parameters of a constant string representing an event.
[0080] The method for obtaining logs is similar to that for obtaining constant string segments, and will not be repeated here.
[0081] S106: Obtain the constant string corresponding to the address from the constant string segment based on the address of the constant string, wherein the constant string includes a format string.
[0082] Specifically, the constant string is located within the constant string segment based on its address. In some implementations, the constant string and its corresponding address can be stored as a key in a hash table for management, allowing the constant string and its address to be found by searching the hash table.
[0083] S107: After filling the placeholders of the format string with the parameters, output the output.
[0084] The formatting operation is performed based on a constant string and parameters, that is, the parameters are filled with placeholders in the format string. For example, the formatting operation could be to replace the format character d% in "a quickly log record:%d%d%d\n" with the actual values corresponding to v1, v2, and v3, respectively.
[0085] The low-overhead log management scheme provided in this embodiment allows the target machine to parse the logs by only recording the addresses and parameters of constant strings, which effectively improves the recording efficiency of system logs and reduces the performance overhead required for log recording.
[0086] The following describes a specific implementation method for the log recording and output method provided in this application. This implementation is illustrated using a device that simultaneously runs a real-time system and a non-real-time system as an example. For instance, this device could be the aforementioned device running the Intewell system. In this implementation, the real-time system records the log parameters, and the non-real-time system parses and outputs the parameters. Please refer to... Figure 2 and Figure 3 , Figure 2 This is a flowchart of the log recording and output method provided in this embodiment. Figure 3 This is a schematic diagram of the log recording and output method provided in this embodiment.
[0087] like Figure 2 The implementation shown includes the following steps S201-S208, wherein S201 is to construct the correspondence between each constant string and its storage address and provide it to the non-real-time system. This step needs to be completed in advance before generating the log. S202-S204 is the log recording process of the real-time system, and S205-S208 is the log parsing and output process of the non-real-time system.
[0088] S201: Concatenate the constant strings into a constant string segment and store it. Different constant strings correspond to different storage addresses. Then, transfer the constant string segment to the non-real-time system storage.
[0089] In log event files, constant strings only constitute a portion and may be scattered. Therefore, the compiler can chain all constant strings into a single segment, reducing the conversion and transmission of invalid content. Furthermore, since the content of constant strings is fixed, real-time systems can record them only once and perform a single transmission to non-real-time systems.
[0090] For example, the compiler could be armcc. Using the `--no_string_literal_pools` option of the armcc compiler, constant strings can be recognized and linked into constant string segments. If the target machine does not have a compiler that supports the above-mentioned fixed-parameter formatted printing interface, it can be installed and configured via network, local files, etc.
[0091] S202: The real-time system acquires the events to be recorded.
[0092] In the real-time system, when logging is triggered, the system acquires the corresponding events to be logged. In some implementations, events that trigger logging include: a change in the running state of a process (such as starting, interrupting, or ending), generating alarm information, detecting login, etc.
[0093] In this example, after the real-time system enables logging, the events to be logged can have different categories, and these categories can have different levels. For example, they can include the following categories, and the corresponding categories can be recorded in the log:
[0094] Emerg: Critical error that causes the system to crash and become unusable; Alert: Alert error that must be corrected immediately; Crit: Critical error that exceeds a critical value; Err: General error; Warn: Warning error that requires a warning; Notice: Notification that the program can run but is not perfect; Info: Program output information, etc.
[0095] S203: Obtain the corresponding constant string and parameters for recording the above events through the logging interface, such as the fixed parameter logging interface.
[0096] The fixed parameter logging interface can be a quick parameter logging interface, used to output the events to be logged. Examples of quick parameter logging interfaces include quicklyLog, quicklyInfo, and quicklyWarn. Different quick parameter logging interfaces can be used to record different events. For example, quicklyInfo can be used to record Info event one, and quicklyWarn can be used to record Warn event two, as shown in the following example:
[0097] The implementation of recording event one can be: quicklyInfo3("a quikly info record:%d%c%x\n",100,'A',0x1234).
[0098] Here, quicklyInfo is a quick parameterized logging interface, and the adjacent 3 indicates that it includes 3 parameters. "a quikly info record:%d%c%x\n" is a constant string in this application, and 100, 'A', 0x1234 are the 3 parameters.
[0099] The second event can be recorded as follows: quicklyWarn4("a quikly warning record:%d%d%d%s\n",110,2200,3,"warning msg").
[0100] Here, quicklyWarn is a quick parameterized logging interface. The adjacent 4 indicates that it includes 4 parameters. "a quikly warning record:%d%d%d%s\n" is a constant string in this application, and 110,2200,3,"warning msg" are the 4 parameters. The parameter "warning msg" is also a constant string in this application.
[0101] S204: Record the address of the constant string and the corresponding parameters into the event logging block to complete the logging, and use the event ID to uniquely identify the record of the event.
[0102] For example, in the Intewell system, the compiler can compile the above constant string into the Intewell system's executable image to obtain the address of the constant string and the corresponding parameters. Then, by passing the constant string value to the function, the address of the constant string and the corresponding parameters are passed to the event log block.
[0103] The event record block, also known as the event pool, is a storage area for recording events. In this example, the storage area is located in the shared memory of the real-time system and the non-real-time system.
[0104] Assuming that the addresses of the three constant strings "a quikly info record:%d%c%x\n", "a quikly warning record:%d%d%d%s\n", and "warning msg" contained in Event 1 and Event 2 are 0x1000, 0x1100, and 0x1200 respectively, the following records can be made in the event record block respectively. The content in parentheses below is not recorded, but is used here to illustrate the recorded content.
[0105] The content recorded in the event log block for event 1 may include:
[0106] +EventID:0x203(Event ID, where the last digit of the Event ID indicates the number of parameters: 3);
[0107] +FormatStrAddr:0x1000(address of constant string);
[0108] +Param1:100 (parameter 1);
[0109] +Param2:'A'(parameter2);
[0110] +Param3:0x1234 (parameter 3);
[0111] +Class: 7 (7 indicates that the event category is info, or the category can be represented by a certain digit in the event ID).
[0112] The content recorded in the event block for event two may include:
[0113] +EventID:0x304(Event ID, where the last digit of the Event ID indicates the number of parameters: 4);
[0114] +FormatStrAddr:0x1100 (address of constant string);
[0115] +Param1:110(parameter1);
[0116] +Param2:2200 (parameter 2);
[0117] +Param3:3(parameter3);
[0118] +Param4:0x1200 (the address of the constant string for parameter 4);
[0119] +Class: 5 (5 indicates that the event category is warn, or the category can be represented by a certain digit in the event ID).
[0120] At this point, the real-time system has completed its log recording.
[0121] S205: The non-real-time system obtains events recorded in the log. The content of these events can be found in step S204 and will not be repeated here.
[0122] In this example, the real-time system and the non-real-time system exchange data using shared memory. The non-real-time system can access the event blocks in the shared memory to obtain logs and thus obtain the recorded events.
[0123] S206: The non-real-time system selects events recorded in the acquired logs according to the set filtering rules to obtain the target events.
[0124] The filtering rules can be set and changed by the user. For example, in this case, the user only focuses on events at the warn level and sets the corresponding filtering rules. Thus, the non-real-time system filters out event one and selects event two as the target event based on the filtering rules set by the user and the corresponding category (Class) parameter in the log event.
[0125] S207: The non-real-time system parses the content of the target event (i.e., the second event), including:
[0126] Based on the address of the recorded constant string, read the corresponding constant string from the corresponding constant string segment. For example, based on addresses 0x1100 and 0x1200, get "a quikly warning record:%d%d%d%s\n" and "warning msg" from the constant string segment.
[0127] The obtained constant string is combined with each parameter to obtain the complete log of the target event. This process includes placing each parameter into the placeholders in the format string in sequence, so that the complete log can be obtained as: "a quikly warningrecord:11022003warning msg".
[0128] In some implementations, constant strings and their corresponding storage addresses can be stored as keys in a hash table for management, and the constant strings and their corresponding addresses can also be found by searching the hash table.
[0129] S208: Saves the complete log output to the hard disk file system and can display it to the user.
[0130] As can be seen from the above, the logging process described in this embodiment records a long constant string as the address of the constant string, and there is no need to perform format string parsing (that is, the process of replacing the corresponding placeholders in the format string with parameters to obtain the complete string) during logging. The data volume of the constant string address and the fixed number of parameters is small, the performance overhead of logging is small, the logging efficiency is improved, and the impact of logging itself on system performance and timing is reduced.
[0131] Based on an inventive concept, this application also provides a log recording device 400, such as... Figure 4 As shown, Figure 4This is a schematic diagram of the log recording device 400 provided in this embodiment. The log management device 400 in this embodiment is specifically used to execute steps S101-S103 and any optional examples thereof. For details, please refer to the detailed description in the method embodiments; a brief summary is provided below:
[0132] The log recording device 400 includes:
[0133] The first acquisition unit 401 is used to acquire the events to be recorded;
[0134] The determining unit 402 is used to determine a constant string and parameters when the event is recorded as a log, wherein the constant string includes a format string, and the parameters are used to fill the placeholders in the format string;
[0135] The recording unit 403 is used to record the storage address of the constant string and the parameters as a log of the event.
[0136] Based on an inventive concept, this application also provides a log output device 500, such as... Figure 5 As shown, Figure 5 This is a schematic diagram of the log output device 500 provided in this embodiment. The log output device 500 in this embodiment is specifically used to perform steps S104-S107 and any optional examples thereof. For details, please refer to the detailed description in the method embodiments; a brief summary is provided below:
[0137] The second acquisition unit 501 is used to acquire a constant string segment, wherein different constant strings are stored in different addresses of the constant string segment;
[0138] The third acquisition unit 502 is used to acquire a log, wherein the log includes the address and parameters of a constant string of an event;
[0139] The parsing unit 503 is used to obtain the constant string corresponding to the address of the constant string from the constant string segment, wherein the constant string includes a format string.
[0140] Output unit 504 is used to fill the parameters with placeholders of the format string and then output them.
[0141] In some embodiments, the log output device 500 further includes:
[0142] Log display unit 505 is configured to display the log text obtained after parsing the parameters;
[0143] Storage unit 506 is configured to store the log text and the event record block, and storage module 406 can also be used to perform log backup.
[0144] In some implementations, the aforementioned logging device 400 and log output device 500 can be based on an embedded system, particularly an Intewell system. The Intewell system enables the simultaneous operation of a real-time system and a non-real-time system on the same device. The logging device 400 can be a real-time system, and the log output device 500 can be a non-real-time system. This allows the real-time system (target machine) to record only the addresses and parameters of constant strings, while the non-real-time system (host machine) parses the logs. This effectively improves the efficiency of system log recorder management, reduces the performance overhead required for log recording, and minimizes the impact of log recording itself on overall system performance and timing.
[0145] Figure 6 This is a schematic structural diagram of a computing device 900 provided in an embodiment of this application. This computing device can execute various optional embodiments of the above-described log management method. The computing device can be a terminal, or a chip or chip system within the terminal. Figure 6 As shown, the computing device 900 includes: a processor 910, a memory 920, and a communication interface 930.
[0146] It should be understood that Figure 6 The communication interface 930 in the computing device 900 shown can be used to communicate with other devices, and may specifically include one or more transceiver circuits or interface circuits.
[0147] The processor 910 can be connected to the memory 920. The memory 920 can be used to store the program code and data. Therefore, the memory 920 can be a storage unit inside the processor 910, an external storage unit independent of the processor 910, or a component that includes both the storage unit inside the processor 910 and the external storage unit independent of the processor 910.
[0148] Optionally, the computing device 900 may also include a bus. The memory 920 and communication interface 930 can be connected to the processor 910 via the bus. The bus can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 6The symbol is represented by a line without an arrow, but this does not mean that there is only one bus or one type of bus.
[0149] It should be understood that in the embodiments of this application, the processor 910 may be a central processing unit (CPU). The processor may also be other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or any conventional processor. Alternatively, the processor 910 may employ one or more integrated circuits to execute relevant programs to implement the technical solutions provided in the embodiments of this application.
[0150] The memory 920 may include read-only memory and random access memory, and provides instructions and data to the processor 910. A portion of the processor 910 may also include non-volatile random access memory. For example, the processor 910 may also store device type information.
[0151] When the computing device 900 is running, the processor 910 executes computer execution instructions stored in the memory 920 to perform any of the operational steps of the above method and any of the optional embodiments thereof.
[0152] It should be understood that the computing device 900 according to the embodiments of this application can correspond to the corresponding subject in executing the methods according to the various embodiments of this application, and the above and other operations and / or functions of each module in the computing device 900 are respectively for implementing the corresponding processes of the methods of this embodiment. For the sake of brevity, they will not be described in detail here.
[0153] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0154] Those skilled in the art will understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.
[0155] In the several embodiments provided in this application, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or units may be electrical, mechanical, or other forms.
[0156] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0157] In addition, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.
[0158] If the aforementioned functions are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0159] This application also provides a computer-readable storage medium storing a computer program thereon, which, when executed by a processor, is used to perform the above-described method, which includes at least one of the schemes described in the above embodiments.
[0160] The computer storage medium in this application embodiment can be any combination of one or more computer-readable media. A computer-readable medium can be a computer-readable signal medium or a computer-readable storage medium. For example, a computer-readable storage medium can be, but is not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of computer-readable storage media (a non-exhaustive list) include: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this document, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device.
[0161] Computer-readable signal media may include data signals propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such propagated data signals may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, capable of sending, propagating, or transmitting programs for use by or in connection with an instruction execution system, apparatus, or device.
[0162] The program code contained on a computer-readable medium may be transmitted using any suitable medium, including, but not limited to, wireless, wire, optical fiber, RF, etc., or any suitable combination thereof.
[0163] Computer program code for performing the operations of this application can be written in one or more programming languages or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, and C++, and conventional procedural programming languages such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network, including a local area network (LAN) or a wide area network (WAN), or it can be connected to an external computer (e.g., via the Internet using an Internet service provider). Furthermore, the terms "first," "second," "third," etc., or similar terms such as module A, module B, module C, etc., used in the specification and claims are only used to distinguish similar objects and do not represent a specific ordering of objects. It is understood that a specific order or sequence can be interchanged where permitted, so that the embodiments of this application described herein can be implemented in an order other than that illustrated or described herein.
[0164] In the above description, the labels of the steps involved, such as S110, S120, etc., do not mean that the steps will necessarily be executed. The order of the steps can be interchanged or executed simultaneously if permitted.
[0165] The term "comprising" as used in the specification and claims should not be construed as limiting itself to what follows; it does not exclude other elements or steps. Therefore, it should be interpreted as specifying the presence of the mentioned feature, integral, step, or component, but does not exclude the presence or addition of one or more other features, integrals, steps, or components, or groups thereof. Thus, the statement "device comprising means A and B" should not be limited to a device consisting solely of components A and B.
[0166] The terms "an embodiment" or "an embodiment" as used in this specification mean that a particular feature, structure, or characteristic described in conjunction with that embodiment is included in at least one embodiment of this application. Therefore, the terms "in one embodiment" or "in an embodiment" appearing throughout this specification do not necessarily refer to the same embodiment, but may refer to the same embodiment. Furthermore, in one or more embodiments, the particular features, structures, or characteristics can be combined in any suitable manner, as will be apparent to those skilled in the art from this disclosure.
[0167] Note that the above are merely preferred embodiments and the technical principles employed in this application. Those skilled in the art will understand that this application is not limited to the specific embodiments described herein, and various obvious changes, readjustments, and substitutions can be made without departing from the scope of protection of this application. Therefore, although this application has been described in detail through the above embodiments, this application is not limited to the above embodiments, and may include many other equivalent embodiments without departing from the concept of this application, all of which fall within the scope of protection of this application.
Claims
1. A log output method characterized by, Applied to devices including real-time systems and non-real-time systems, the method includes: The real-time system acquires events to be recorded; The real-time system determines the constant string and parameters when the event is recorded as a log, wherein the constant string includes a format string, and the parameters are used to fill the placeholders in the format string; The real-time system records the storage address of the constant string and the parameters as the log of the event; The parameter includes another constant string, and the parameter is recorded by using the storage address corresponding to the other constant string to represent the parameter. The real-time system outputs a constant string segment, which includes the constant string. The constant string segment is used to obtain the constant string corresponding to the address of the constant string from the constant string segment when the log is output. The non-real-time system acquires the constant string segment, and different constant strings are stored in different addresses of the constant string segment; The non-real-time system obtains the log, which includes the address and parameters of the constant string of the event; The non-real-time system obtains the constant string corresponding to the address of the constant string and the storage address corresponding to the other constant string from the constant string segment respectively. The constant string includes a format string. The non-real-time system fills the parameters with placeholders from the format string before outputting them.
2. The method of claim 1, wherein, Also includes: Each constant string is stored in the form of a constant string segment, and different constant strings are stored at different addresses in the constant string segment. The constant string segment is used to send to the execution log output.
3. An apparatus for implementing the log output method according to claim 1 or 2, characterized by The device includes both real-time and non-real-time systems: The real-time system includes: a first acquisition unit, used to acquire events to be recorded; A determining unit is configured to determine a constant string and parameters when the event is recorded as a log, wherein the constant string includes a format string, and the parameters are used to fill placeholders in the format string; and A recording unit is used to record the storage address of the constant string and the parameters as a log of the event; The parameter includes another constant string, and the parameter is recorded by using the storage address corresponding to the other constant string to represent the parameter. The real-time system outputs a constant string segment, which includes the constant string. The constant string segment is used to obtain the constant string corresponding to the address of the constant string from the constant string segment when the log is output. Non-real-time systems include: The second acquisition unit is used to acquire a constant string segment, wherein different constant strings are stored at different addresses of the constant string segment; The third acquisition unit is used to acquire a log, which includes the address and parameters of a constant string of an event; A parsing unit is configured to obtain a constant string corresponding to the address of the constant string from the constant string segment, wherein the constant string includes a format string; and The output unit is used to fill the parameters with placeholders of the format string and then output them.
4. A computing device, comprising: include: processor, and A memory having stored program instructions that, when executed by the processor, cause the processor to perform the method of claim 1 or 2.
Citation Information
Patent Citations
Generation method and generation device of log data, and analysis method and analysis device of log data
CN106484728A