[go: up one dir, main page]
More Web Proxy on the site http://driver.im/

CN106815128A - Log-output method and device, electronic equipment - Google Patents

Log-output method and device, electronic equipment Download PDF

Info

Publication number
CN106815128A
CN106815128A CN201611135409.XA CN201611135409A CN106815128A CN 106815128 A CN106815128 A CN 106815128A CN 201611135409 A CN201611135409 A CN 201611135409A CN 106815128 A CN106815128 A CN 106815128A
Authority
CN
China
Prior art keywords
log
kernel
logs
preset
user space
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN201611135409.XA
Other languages
Chinese (zh)
Inventor
郑小兵
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
LeTV Holding Beijing Co Ltd
LeTV Mobile Intelligent Information Technology Beijing Co Ltd
Original Assignee
LeTV Holding Beijing Co Ltd
LeTV Mobile Intelligent Information Technology Beijing Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by LeTV Holding Beijing Co Ltd, LeTV Mobile Intelligent Information Technology Beijing Co Ltd filed Critical LeTV Holding Beijing Co Ltd
Priority to CN201611135409.XA priority Critical patent/CN106815128A/en
Publication of CN106815128A publication Critical patent/CN106815128A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/34Recording or statistical evaluation of computer activity, e.g. of down time, of input/output operation ; Recording or statistical evaluation of user activity, e.g. usability assessment
    • G06F11/3466Performance evaluation by tracing or monitoring
    • G06F11/3476Data logging
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/11File system administration, e.g. details of archiving or snapshots
    • G06F16/113Details of archiving
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/13File access structures, e.g. distributed indices

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The present embodiments relate to technical field of data processing, a kind of log-output method and device, electronic equipment are disclosed.In the embodiment of the present invention, log-output method includes:Kernel log in kernel spacing is moved to the default queue being pre-created;The kernel log in the default queue is sent to user's space;The user's space stores system journal;The kernel log in the user's space is exported simultaneously with the system journal.The embodiment of the present invention enables that kernel log together with system journal is while export, meets user's request, for the quick problem analysis of user is provided conveniently, improves operating efficiency.

Description

Log output method and device and electronic equipment
Technical Field
The embodiment of the invention relates to the technical field of data processing, in particular to a log output method and device and electronic equipment.
Background
Currently, debugging is one of the indispensable means in the process of developing various operating systems applied to electronic products such as mobile phones and tablet computers. In the debugging process, the system can output some key information, namely log information, which is one of the key ways for developers to solve the problem. In various existing operating systems, an Android system (Android) is widely applied, and in the Android system, logs comprise logs of the Android system and logs of a linux kernel.
In the existing versions of the android system 5.0 and 5.0 or above, the log of the android system and the log of the linux kernel have respective buffer areas, the log of the linux kernel is output in a kernel space, and the log of the android system is output in a user space.
However, in the process of implementing the present invention, the inventors found that the following problems exist in the prior art: under the operation of the existing high-speed processor, hundreds of lines of log information can be output every second, in the versions of the android system 5.0 and 5.0, the logs of the android system and the logs of the linux kernel are respectively stored in different buffer areas and are respectively output in a user space and a kernel space, the two spaces cannot be directly interacted, the logic sequence of the two spaces is difficult to analyze, the problem is very unfavorable for the rapid analysis, and the working efficiency is greatly influenced; moreover, when a developer analyzes some problems, the developer needs to acquire the log of the android system and the log of the linux kernel at the same time, and the prior art cannot meet the requirement of outputting the two logs together at the same time.
Disclosure of Invention
Embodiments of the present invention provide a log output method and apparatus, and an electronic device, so that a kernel log and a system log can be simultaneously output together, a user requirement is met, convenience is provided for a user to quickly analyze a problem, and work efficiency is improved.
In a first aspect, an embodiment of the present invention provides a log output method, including: moving the kernel logs in the kernel space to a preset queue established in advance; sending the kernel log in the preset queue to a user space; the user space stores system logs; and simultaneously outputting the kernel log and the system log in the user space.
In a second aspect, an embodiment of the present invention further provides a log output apparatus, including: the log moving module is used for moving the kernel logs in the kernel space to a preset queue which is established in advance; the log sending module is used for sending the kernel logs in the preset queue to a user space; the user space stores system logs; and the log output module is used for simultaneously outputting the kernel log and the system log in the user space.
In a third aspect, an embodiment of the present invention further provides an electronic device, including: at least one processor; and a memory communicatively coupled to the at least one processor; wherein the memory stores instructions executable by the one processor to be executed by the at least one processor to enable the at least one processor to perform the log output method described above.
In a fourth aspect, the present invention provides a computer program product including a computer program stored on a non-transitory computer readable storage medium, the computer program including program instructions, which, when executed by a computer, cause the computer to execute the log output method of the present invention.
In a fifth aspect, an embodiment of the present invention provides a non-transitory computer storage medium storing computer-executable instructions for performing a log output method according to an embodiment of the present invention.
Compared with the prior art, the embodiment of the invention adopts the preset queue pre-established in the kernel space to process the kernel log, then sends the kernel log in the preset queue to the user space, and finally simultaneously outputs the kernel log and the system log in the user space; the kernel log is output by the user space instead of the existing kernel space, interaction between the kernel space and the user space can be achieved, the kernel log from the kernel space and the system log stored in the user space are simultaneously output together by the user space, a logical relation is formed between the output kernel log and the system log, the requirement that a user needs to obtain two logs at the same time is met, convenience is brought to the user for rapidly analyzing the problems, and the working efficiency is improved.
In addition, the moving the kernel log in the kernel space to a preset queue created in advance specifically includes: filtering the kernel log according to a preset rule; moving the filtered kernel logs to the preset queue; in the simultaneously outputting the kernel log and the system log in the user space, the method specifically includes: acquiring a system log meeting the preset rule; and simultaneously outputting the kernel logs meeting the preset rules and the system logs meeting the preset rules. In the embodiment, the kernel logs filtered according to the preset rule are moved to the preset queue, so that the user space only needs to output the kernel logs meeting the preset rule and the system logs meeting the preset rule, and does not need to output all the kernel logs and the system logs at the same time, and the data processing burden of the user space is reduced; and the user requirements are further met, so that the user only needs to output the required log information, and convenience is further provided for the user to quickly analyze the problems.
In addition, the log output method further includes: and emptying the kernel logs in the preset queue when the kernel logs and the system logs are judged not to be output at the same time in the user space. In the embodiment, the function of simultaneous output is started only when the user needs to output the kernel log and the system log simultaneously; when the user does not need to output, the function is stopped, namely the two logs are respectively output in the existing mode so as to meet the requirement of high instantaneity of the kernel log as much as possible; in addition, the kernel logs in the preset queue are emptied to release space, so that the processing speed of receiving the kernel logs next time is improved.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, and it is obvious that the drawings in the following description are some embodiments of the present invention, and those skilled in the art can also obtain other drawings according to the drawings without creative efforts.
Fig. 1 is a detailed flowchart of a log output method according to a first embodiment;
fig. 2 is a detailed flowchart of a log output method according to a second embodiment;
fig. 3 is a detailed flowchart of a log output method according to a third embodiment;
fig. 4 is a detailed flowchart of a log output method according to a fourth embodiment;
fig. 5 is a schematic diagram of a log output apparatus according to a fifth embodiment;
fig. 6 is a schematic diagram of a log output apparatus according to a sixth embodiment;
fig. 7 is a schematic diagram of a log output apparatus according to a seventh embodiment;
fig. 8 is a schematic diagram of a log output apparatus according to an eighth embodiment;
fig. 9 is a schematic diagram of an electronic device according to a ninth embodiment.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, embodiments of the present invention will be described in detail below with reference to the accompanying drawings. However, it will be appreciated by those of ordinary skill in the art that numerous technical details are set forth in order to provide a better understanding of the present application in various embodiments of the present invention. However, the technical solution claimed in the present application can be implemented without these technical details and various changes and modifications based on the following embodiments.
A first embodiment of the present invention relates to a log output method, which is applied to an operating system, such as an android system, and a specific flow of the embodiment is shown in fig. 1, and includes:
step 101, moving the kernel log in the kernel space to a preset queue created in advance.
In this embodiment, in the android system, the kernel log is a log of a linux kernel.
In this embodiment, a preset queue is created in the kernel space in advance, and is used for caching the kernel log. Since the kernel log may be in an atomic context (i.e., the kernel log is in the context of an interrupt or various locks) during the kernel log output, this situation may affect the output process of the kernel log, resulting in a delay in the kernel log output. Therefore, each kernel log is processed by adopting the preset queue, the output process of the kernel logs can be prevented from being influenced as much as possible, and the instantaneity of the kernel log output process is ensured.
In fact, in this embodiment, a kernel driver may be added to the kernel space for maintaining the preset queue.
In this embodiment, after the kernel log is moved to the preset queue, the kernel log may be packaged. Furthermore, some redundant bytes, such as packet header, check byte, etc., may be added to the encapsulated data packet to ensure the reliability and integrity of data transmission.
And 102, sending the kernel logs in the preset queue to a user space.
In this embodiment, the user space stores system logs. In the android system, the system log is the log of the android system.
In this embodiment, a communication mechanism between a kernel space and a user space is established in advance; the kernel driver can establish communication between the kernel space and the user space based on the kernel and communication mechanism, so that the kernel log in the kernel space is sent to the user space. In this embodiment, the communication mechanism is, for example, a socket (Netlink) communication mechanism, but in practice, the communication mechanism is not limited to this, and other communication mechanisms that can implement communication between kernel space and user space may also be used.
In this embodiment, an interactive interface function between the kernel space and the user space may be called to send the kernel log to the user space, but actually, the method is not limited thereto.
And step 103, outputting the kernel log and the system log in the user space simultaneously.
In the present embodiment, if the kernel log is encapsulated in the kernel space, the received kernel log can be analyzed in the user space.
In this embodiment, the user space has a plurality of device files, each device file is located under a device node/dev/log, and various system logs are stored in each device file. The working principle of outputting the system log is mainly to open a device file (for example,/dev/log/events,/dev/log/radio,/dev/log/system,/dev/log/main, etc.), read the system log in the device file, and output the system log.
In this embodiment, a device file (for example, a newly added device file/dev/log/kernel) may be newly added below the device node/dev/log, and the kernel log may be moved to the newly added device file, so that when the user space outputs the system log, the kernel log in the newly added device file is output together.
Compared with the prior art, the embodiment of the invention adopts the preset queue pre-established in the kernel space to process the kernel log, then sends the kernel log in the preset queue to the user space, and finally simultaneously outputs the kernel log and the system log in the user space; the kernel log is output by the user space instead of the existing kernel space, so that the kernel space and the user space can be interacted, the user space outputs the kernel log from the kernel space and the system log stored in the user space together, the output kernel log and the system log have clear logic sequence, the requirement that a user needs to obtain two logs simultaneously is met, convenience is provided for the user to analyze the problem quickly, and the working efficiency is improved.
The steps of the above methods are divided for clarity, and the implementation may be combined into one step or split some steps, and the steps are divided into multiple steps, so long as the same logical relationship is included, which are all within the protection scope of the present patent; it is within the scope of the patent to add insignificant modifications to the algorithms or processes or to introduce insignificant design changes to the core design without changing the algorithms or processes.
A second embodiment of the present invention relates to a log output method. The second embodiment is improved on the basis of the first embodiment, and the main improvement lies in that: in the second embodiment of the present invention, the kernel log filtered according to the preset rule is moved to the preset queue.
A specific flow of the second embodiment of the present invention is shown in fig. 2, and includes:
step 201, moving the kernel log in the kernel space to a preset queue created in advance.
As follows, step 201 includes:
sub-step 2011, filtering the kernel log according to a preset rule.
In this embodiment, in the android system, the kernel log is a log of a linux kernel.
In this embodiment, a filter is configured in the kernel space in advance, and the preset rule is that the kernel log meets the preset log level and/or module, but in practice, the preset rule is not limited to this, and other preset rules may also be set according to actual needs.
For example, in this embodiment, the preset rule is that the kernel log meets a preset log level. For example, the first two bytes of each kernel log are message headers, and the second byte stores a log level, the second byte of the kernel log is obtained first (i.e., the log level is obtained), and then it is determined whether the log level of the kernel log matches a preset log level, so as to filter out the kernel logs meeting preset rules. Specifically, if the preset log level is an error level, a kernel log is stored in the text array; the second byte text [1] of the text array holds the level of the kernel log, and if the text [1] ═ 3 represents an error level, the kernel log at the error level can be filtered by judging whether the text [1] is equal to 3. However, this is merely an example and is not limited thereto.
For example, in this embodiment, the preset rule is that the kernel logs meet the preset module, the first two bytes of each kernel log are the message headers, the message headers can be extended (for example, the third byte is added), special characters (used for distinguishing kernel logs of different modules) are stored in the message headers, and the kernel logs meeting the preset rule are filtered by judging whether the module information of the kernel logs is matched with the preset module; and adding corresponding special characters at the beginning of the printing character string of the corresponding module so as to match the kernel log with the corresponding module. Specifically, if the preset module is a camera module and a kernel log is stored in the text array, the third byte text [2] of the text array stores the module information of the kernel log, and if the text [2] is equal to 1 and represents the camera module, the kernel log of the camera module can be filtered out by judging whether the text [2] is equal to 1. However, this is merely an example and is not limited thereto.
For example, in this embodiment, the preset rule is that the kernel log satisfies a preset log level and module. The kernel logs meeting the preset rules can be filtered out by judging whether the log grade and the module information of the kernel logs are matched with the preset log grade and the module. Specifically, a kernel log is stored in the text array, and if the text [1] ═ 3 represents an error level and the text [2] ═ 1 represents a camera module, the kernel log of the camera module at the error level can be filtered by judging that the text [1] & & 3& & text [2] &1.
And a substep 2012 of moving the filtered kernel log to a preset queue.
In this embodiment, a preset queue is created in the kernel space in advance, and is used for caching the kernel log. Since the kernel log may be in an atomic context (i.e., the kernel log is in the context of an interrupt or various locks) during the kernel log output process, this situation may affect the output process of the kernel log; therefore, each kernel log is processed by adopting the preset queue, the output process of the kernel logs can be prevented from being influenced as much as possible, and the instantaneity of the kernel log output process is ensured.
In fact, in this embodiment, a kernel driver may be added to the kernel space for maintaining the preset queue.
In this embodiment, after the kernel log is moved to the preset queue, the kernel log may be packaged. Further, some redundant bytes, such as packet header, check byte, etc., may be added to ensure the reliability and integrity of data transmission.
Step 202, judging whether a kernel log exists in a preset queue; if yes, go to step 203, otherwise continue to judge.
In this embodiment, the preset queue may be scanned to determine whether a kernel log exists.
Step 203, sending the kernel log in the preset queue to a user space.
In this embodiment, when it is determined that the kernel log exists in the preset queue, the kernel log in the preset queue is sent to the user space.
In this embodiment, the user space stores system logs. In the android system, the system log is the log of the android system.
In the embodiment, a communication mechanism between a kernel space and a user space is established; the kernel driver can establish communication between the kernel space and the user space based on the kernel and the communication mechanism, and after the driver is loaded, the kernel object of the communication mechanism is created and initialized. In this embodiment, the communication mechanism is, for example, a socket (Netlink) communication mechanism, but in practice, the communication mechanism is not limited to this, and other communication mechanisms that can implement communication between kernel space and user space may also be used.
In this embodiment, the kernel log may be sent to the user space through a communication mechanism, but is not limited thereto in practice.
And step 204, simultaneously outputting the kernel log and the system log in the user space.
In this embodiment, the received kernel log may be analyzed in the user space.
As follows, step 204 includes the following sub-steps:
and a substep 2041 of obtaining a system log satisfying a preset rule.
In this embodiment, a filter may be configured in the user space, and the system log may be filtered according to a preset rule, so as to obtain the system log meeting the preset rule. However, the embodiment does not limit the manner of obtaining the system log that meets the preset rule.
Substep 2042, outputting the kernel log meeting the preset rule and the system log meeting the preset rule at the same time;
in the present embodiment, if the kernel log is encapsulated in the kernel space, the received kernel log can be analyzed in the user space.
In this embodiment, the user space has a plurality of device files, each device file is located under a device node/dev/log, and various system logs are stored in each device file. The working principle of outputting the system log is mainly to open a device file (for example,/dev/log/events,/dev/log/radio,/dev/log/system,/dev/log/main, etc.), read the system log in the device file, and output the system log.
In this embodiment, a device file (for example, a newly added device file/dev/log/kernel) may be newly added below the device node/dev/log, and the kernel log may be moved to the newly added device file, so that when the user space outputs the system log, the kernel log in the newly added device file is output together.
Compared with the first implementation mode, the embodiment of the invention moves the kernel logs filtered according to the preset rules to the preset queue, so that the user space only needs to output the kernel logs meeting the preset rules and the system logs meeting the preset rules, and the data processing burden of the user space is reduced; and the user requirements are further met, so that the user only needs to output the required log information, and convenience is further provided for the user to quickly analyze the problems.
A third embodiment of the present invention relates to a log output method. The third embodiment is a refinement of the first embodiment, and the main refinement is as follows: in the second embodiment of the present invention, receiving a kernel log of a kernel space is performed through a preset interaction thread.
A specific flow of the third embodiment of the present invention is shown in fig. 3, and includes:
step 301, moving the kernel log in the kernel space to a preset queue created in advance.
In this embodiment, in the android system, the kernel log is a log of a linux kernel.
In this embodiment, a preset queue is created in the kernel space in advance, and is used for caching the kernel log. Since the kernel log may be in an atomic context (i.e., the kernel log is in the context of an interrupt or various locks) during the kernel log output process, this situation may affect the output process of the kernel log; therefore, each kernel log is processed by adopting the preset queue, the output process of the kernel logs can be prevented from being influenced as much as possible, and the instantaneity of the kernel log output process is ensured.
In fact, in this embodiment, a kernel driver may be added to the kernel space for maintaining the preset queue.
In this embodiment, after the kernel log is moved to the preset queue, the kernel log may be packaged. Further, some redundant bytes, such as packet header, check byte, etc., may be added to ensure the reliability and integrity of data transmission.
Step 302, sending the kernel log in the preset queue to a user space.
In this embodiment, the user space stores system logs. In the android system, the system log is the log of the android system.
In this embodiment, a communication mechanism between a kernel space and a user space is established in advance; the kernel driver can establish communication between the kernel space and the user space based on the kernel and communication mechanism, so that the kernel log in the kernel space is sent to the user space. In this embodiment, the communication mechanism is, for example, a socket (Netlink) communication mechanism, but in practice, the communication mechanism is not limited to this, and other communication mechanisms that can implement communication between kernel space and user space may also be used.
In this embodiment, the kernel log may be sent to the user space through a communication mechanism, but is not limited thereto in practice.
As follows, step 302 includes:
and a substep 3021 of sending the kernel log to an interaction thread preset in the user space.
In this embodiment, an interaction thread interacting with the kernel space is pre-established in the user space, and is used to receive the kernel log from the kernel space.
Sub-step 3022, encapsulating the kernel log according to the format of the system data packet in the interaction thread.
In this embodiment, in the preset interaction thread, the kernel log is encapsulated according to the format of the data packet of the encapsulated system log, so that the data packet of the kernel log corresponds to the format of the data packet of the system log.
Illustratively, the system log includes a log level. The kernel logs of different levels can be mapped to the level corresponding to the system log, or the kernel logs of different modules can be mapped to the module corresponding to the system log. However, this embodiment is only an example, and the format of the data packet is not limited in any way.
Sub-step 3023, sending the encapsulated kernel log from the interaction thread to a daemon process that receives the system log. The system log is stored in the daemon process.
In this embodiment, the system log is stored in a daemon process that receives the system log. The system can call an interface function of the system log and send the packaged kernel log to the daemon process.
Step 303, the kernel log and the system log in the user space are output simultaneously.
In the present embodiment, if the kernel log is encapsulated in the kernel space, the received kernel log can be analyzed in the user space.
In this embodiment, the user space has a plurality of device files, each device file is located under a device node/dev/log, and various system logs are stored in each device file. The working principle of outputting the system log is mainly to open a device file (for example,/dev/log/events,/dev/log/radio,/dev/log/system,/dev/log/main, etc.), read the system log in the device file, and output the system log.
In this embodiment, a device file (for example, a newly added device file/dev/log/kernel) may be newly added below the device node/dev/log, and the kernel log may be moved to the newly added device file, so that when the user space outputs the system log, the kernel log in the newly added device file is output together.
In fact, this embodiment can be modified from the second embodiment.
Compared with the first implementation mode, the embodiment of the invention has the advantages that the interactive thread created in advance by the user space receives the kernel log from the kernel space, the kernel log is packaged according to the format of the data packet of the system log, and finally the daemon process receiving the system log outputs the kernel log and the system log together at the same time.
A fourth embodiment of the present invention relates to a log output method. The fourth embodiment is improved on the basis of the first embodiment, and the main improvement lies in that: in the fourth embodiment of the present invention, when the user stops outputting the kernel log and the system log at the same time, the function of outputting the kernel log and the system log at the same time is closed.
Step 401, judging whether a kernel log and a system log need to be output simultaneously in a user space; if yes, go to step 402, otherwise go to step 405.
In this embodiment, usually, an operator determines whether it is necessary to output the kernel log and the system log in the user space at the same time according to the recurrence situation of the problem.
In this embodiment, a checking mechanism may be performed in advance in the control module of the kernel space. Because the kernel log of the kernel space is continuously output all the time, when the user stops outputting at the same time, the kernel cannot know the log; thus, the checking mechanism may determine whether the user needs to output simultaneously, and thus respond to the system.
Specifically, when the user needs to output simultaneously, the system receives the response and starts the function of outputting simultaneously. And when the user does not need to output simultaneously, the system does not receive a response, and the function is not started.
It should be noted that, in this embodiment, step 401 is executed before step 402, however, this embodiment does not limit the order of step 401, and may also be executed between other steps.
Step 402, moving the kernel log in the kernel space to a preset queue created in advance.
In this embodiment, in the android system, the kernel log is a log of a linux kernel.
In this embodiment, a preset queue is created in the kernel space in advance, and is used for caching the kernel log. Since the kernel log may be in an atomic context (i.e., the kernel log is in the context of an interrupt or various locks) during the kernel log output process, this situation may affect the output process of the kernel log; therefore, each kernel log is processed by adopting the preset queue, the output process of the kernel logs can be prevented from being influenced as much as possible, and the instantaneity of the kernel log output process is ensured.
In fact, in this embodiment, a kernel driver may be added to the kernel space for maintaining the preset queue.
In this embodiment, after the kernel log is moved to the preset queue, the kernel log may be packaged. Further, some redundant bytes, such as packet header, check byte, etc., may be added to ensure the reliability and integrity of data transmission.
Step 403, sending the kernel log in the preset queue to the user space.
In this embodiment, when it is determined that the kernel log and the system log need to be output in the user space at the same time, the kernel log in the preset queue is sent to the user space.
In this embodiment, the user space stores system logs. In the android system, the system log is the log of the android system.
In this embodiment, a communication mechanism between a kernel space and a user space is established in advance; the kernel driver can establish communication between the kernel space and the user space based on the kernel and communication mechanism, so that the kernel log in the kernel space is sent to the user space. In this embodiment, the communication mechanism is, for example, a socket (Netlink) communication mechanism, but in practice, the communication mechanism is not limited to this, and other communication mechanisms that can implement communication between kernel space and user space may also be used.
In this embodiment, an interactive interface function between the kernel space and the user space may be called to send the kernel log to the user space, but actually, the method is not limited thereto.
And step 404, outputting the kernel log and the system log in the user space at the same time.
In the present embodiment, if the kernel log is encapsulated in the kernel space, the received kernel log can be analyzed in the user space.
In this embodiment, the user space has a plurality of device files, each device file is located under a device node/dev/log, and various system logs are stored in each device file. The working principle of outputting the system log is mainly to open a device file (for example,/dev/log/events,/dev/log/radio,/dev/log/system,/dev/log/main, etc.), read the system log in the device file, and output the system log.
In this embodiment, a device file (for example, a newly added device file/dev/log/kernel) may be newly added below the device node/dev/log, and the kernel log may be moved to the newly added device file, so that when the user space outputs the system log, the kernel log in the newly added device file is output together.
Step 405, emptying the kernel log in the preset queue.
In this embodiment, when it is determined that the kernel log and the system log need to be output in the user space at the same time, the kernel log in the preset queue is emptied to release the space, so that the kernel log is received when the function is started next time.
In fact, the present embodiment may be a modification of the second or third embodiment.
Compared with the first embodiment, the present embodiment can start the function of simultaneous output only when the user needs to output the kernel log and the system log simultaneously; when the user does not need to output, the function is stopped, namely, the two logs are respectively output in the existing mode, so that the requirement of high instantaneity of the kernel log is met as much as possible. In addition, the kernel logs in the preset queue are emptied to release space, so that the processing speed of receiving the kernel logs next time is improved.
A fifth embodiment of the present invention relates to a log output device, as shown in fig. 5, including:
and the log moving module 51 is configured to move the kernel log in the kernel space to a preset queue 50 created in advance.
A log sending module 52, configured to send the kernel log in the preset queue 50 to the user space; the user space stores system logs.
And a log output module 53, configured to output the kernel log and the system log in the user space at the same time.
Compared with the prior art, the log moving module moves the kernel logs to the preset queue to process the kernel logs, then the log sending module sends the kernel logs in the preset queue to the user space, and finally the log output module simultaneously outputs the kernel logs and the system logs in the user space; the log output module in the user space outputs the kernel logs from the kernel space and the system logs stored in the user space together, so that the output kernel logs and the system logs have clear logical sequence, the requirement that a user needs to obtain two logs simultaneously is met, convenience is provided for the user to analyze the problems quickly, and the working efficiency is improved.
It should be understood that this embodiment is a system example corresponding to the first embodiment, and may be implemented in cooperation with the first embodiment. The related technical details mentioned in the first embodiment are still valid in this embodiment, and are not described herein again in order to reduce repetition. Accordingly, the related-art details mentioned in the present embodiment can also be applied to the first embodiment.
It should be noted that each module referred to in this embodiment is a logical module, and in practical applications, one logical unit may be one physical unit, may be a part of one physical unit, and may be implemented by a combination of multiple physical units. In addition, in order to highlight the innovative part of the present invention, elements that are not so closely related to solving the technical problems proposed by the present invention are not introduced in the present embodiment, but this does not indicate that other elements are not present in the present embodiment.
A sixth embodiment of the present invention relates to a log output device. The sixth embodiment is an improvement of the fifth embodiment, and the main improvement is that: as shown in fig. 6, in the sixth embodiment of the present invention, the log output apparatus further includes a log existence judging module 54; the log moving module 51 comprises a filtering unit 511 and a moving unit 512; the log output module 53 includes an acquisition unit 531 and an output unit 532.
The log moving module 51 includes:
the filtering unit 511 is configured to filter the kernel log according to a preset rule.
A moving unit 512, configured to move the filtered kernel log to the preset queue 50.
The log existence determining module 54 determines whether a kernel log exists in the preset queue 50.
A log sending module 52, configured to send the kernel log in the preset queue 50 to the user space; the user space stores system logs;
the log output module 53 includes:
an obtaining unit 531, configured to obtain a system log that meets a preset rule;
the output unit 532 is configured to output the kernel log meeting the preset rule and the system log meeting the preset rule at the same time.
Compared with the fifth embodiment, the log filtering unit moves the kernel logs filtered according to the preset rule to the preset queue, so that the log output unit in the user space only needs to output the kernel logs meeting the preset rule and the system logs meeting the preset rule, and the data processing burden of the user space is reduced; and the user requirements are further met, so that the user only needs to output the required log information, and convenience is further provided for the user to quickly analyze the problems.
Since the second embodiment corresponds to the present embodiment, the present embodiment can be implemented in cooperation with the second embodiment. The related technical details mentioned in the second embodiment are still valid in this embodiment, and the technical effects that can be achieved in the second embodiment can also be achieved in this embodiment, and are not described herein again in order to reduce the repetition. Accordingly, the related-art details mentioned in the present embodiment can also be applied to the second embodiment.
A seventh embodiment of the present invention relates to a log output device. The seventh embodiment is improved on the basis of the fifth embodiment, and the main improvement lies in that: as shown in fig. 7, in the seventh embodiment of the present invention, the log transmission module 52 includes a first transmission unit 521, an encapsulation unit 522, and a second transmission unit 523.
And the log moving module 51 is configured to move the kernel log in the kernel space to a preset queue 50 created in advance.
The log sending module 52 includes:
the first sending unit 521 is configured to send the kernel log to an interaction thread 55 preset in the user space.
And an encapsulating unit 522, configured to encapsulate the kernel log in the interaction thread according to a format of the system data packet.
A second sending unit 523, configured to send the encapsulated kernel log from the interaction thread to the daemon 56 that receives the system log; the system log is stored in the daemon process.
And a log output module 53, configured to output the kernel log and the system log in the user space at the same time.
The present embodiment may be a modification of the sixth embodiment.
Compared with the fifth embodiment, in the present embodiment, the log sending unit sends the kernel log to an interactive thread created in advance in the user space, the log encapsulating unit encapsulates the kernel log according to the format of a data packet of the system log, and the log sending unit sends the kernel log from the interactive thread to a daemon process that receives the system log.
Since the third embodiment corresponds to the present embodiment, the present embodiment can be implemented in cooperation with the third embodiment. The related technical details mentioned in the third embodiment are still valid in this embodiment, and the technical effects that can be achieved in the third embodiment can also be achieved in this embodiment, and are not described herein again in order to reduce the repetition. Accordingly, the related-art details mentioned in the present embodiment can also be applied to the third embodiment.
An eighth embodiment of the present invention relates to a log output device. The eighth embodiment is an improvement of the fifth embodiment, and the main improvement is that: as shown in fig. 8, in the eighth embodiment of the present invention, the log output device further includes a log output determination module 57 and a day clearing module 58.
And a log output judging module 57, configured to judge whether the kernel log and the system log need to be output in the user space at the same time.
The log moving module 51 is configured to move the kernel log in the kernel space to the pre-set queue 50 created in advance when the log output judging module 57 judges that the kernel log and the system log need to be output in the user space at the same time.
A log emptying module 58, configured to empty the kernel logs in the preset queue 50 when the log output judging module 55 judges that it is not necessary to output the kernel logs and the system logs at the same time in the user space.
A log sending module 52, configured to send the kernel log in the preset queue 50 to the user space; the user space stores system logs.
And a log output module 53, configured to output the kernel log and the system log in the user space at the same time.
In fact, this embodiment can be modified from the sixth or seventh embodiment.
Compared with the fifth embodiment, the log output judging module starts the function of simultaneous output when judging that the user needs to output the kernel log and the system log simultaneously; when the user does not need to output, the log stop moving module stops the function, namely, the two logs are respectively output in the existing mode so as to meet the requirement of high instantaneity of the kernel log as much as possible. In addition, the log emptying module empties the kernel logs in the preset queue to release space, so that the processing speed of receiving the kernel logs next time is improved.
Since the fourth embodiment corresponds to the present embodiment, the present embodiment can be implemented in cooperation with the fourth embodiment. The related technical details mentioned in the fourth embodiment are still valid in the present embodiment, and the technical effects that can be achieved in the fourth embodiment can also be achieved in the present embodiment, and are not described herein again in order to reduce the repetition. Accordingly, the related-art details mentioned in the present embodiment can also be applied to the fourth embodiment.
A ninth embodiment of the present invention relates to an electronic apparatus, as shown in fig. 9, including: at least one processor 61 and a memory 62 communicatively coupled to the at least one processor 61, one processor 61 being illustrated in fig. 9.
The electronic device may further include: an input device 63 and an output device 64.
The processor 61, the memory 62, the input device 63 and the output device 64 may be connected by a bus or other means, and the bus connection is exemplified in fig. 9.
The memory 62, which is a non-transitory computer readable storage medium, may be used to store non-transitory software programs, non-transitory computer executable programs, and modules, such as program instructions/modules corresponding to the journal output method in the embodiment of the present invention (for example, the journal moving module 51, the journal sending module 52, and the journal output module 53 shown in fig. 5). The processor 61 executes various functional applications of the server and data processing, i.e., implements the log output method in the above-described method embodiment, by executing the non-transitory software programs, instructions, and modules stored in the memory 62.
The memory 62 may include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required for at least one function; the storage data area may store data created according to use of the log output device, and the like. Further, the memory 62 may include high speed random access memory, and may also include non-transitory memory, such as at least one magnetic disk storage device, flash memory device, or other non-transitory solid state storage device. In some embodiments, the memory 62 may optionally include a memory remotely located from the processor 61, and these remote memories may be connected to the processor 61 for the log output method through a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The input device 63 may receive input numeric or character information and generate key signal inputs related to user settings and function control of the log output device. The output device 64 may include a display device such as a display screen.
In the present embodiment, when one or more modules (e.g., the log moving module 51, the log sending module 52, and the log outputting module 53 shown in fig. 5) stored in the memory 62 are executed by the one or more processors 61, the processors 61 execute the log outputting method in any of the above-described method embodiments, that is, execute: moving the kernel logs in the kernel space to a preset queue established in advance; sending the kernel logs in the preset queue to a user space; the user space stores system logs; and simultaneously outputting the kernel log and the system log in the user space.
The product can execute the method provided by the embodiment of the application, and has the corresponding functional modules and beneficial effects of the execution method. For technical details that are not described in detail in this embodiment, reference may be made to the methods provided in the embodiments of the present application.
The electronic device of embodiments of the present invention exists in a variety of forms, including but not limited to:
(1) mobile communication devices, which are characterized by mobile communication capabilities and are primarily targeted at providing voice and data communications. Such terminals include smart phones (e.g., iphones), multimedia phones, functional phones, and low-end phones, among others.
(2) The ultra-mobile personal computer equipment belongs to the category of personal computers, has calculation and processing functions and generally has the characteristic of mobile internet access. Such terminals include PDA, MID, and UMPC devices, such as ipads.
(3) Portable entertainment devices such devices may display and play multimedia content. Such devices include audio and video players (e.g., ipods), handheld game consoles, electronic books, as well as smart toys and portable car navigation devices.
Compared with the prior art, the method has the advantages that the preset queue created in the kernel space in advance is adopted to process the kernel logs, then the kernel logs in the preset queue are sent to the user space, and finally the kernel logs and the system logs are simultaneously output in the user space; the kernel log is output by the user space instead of the existing kernel space, so that the kernel space and the user space can be interacted, the user space outputs the kernel log from the kernel space and the system log stored in the user space together, the output kernel log and the system log have clear logic sequence, the requirement that a user needs to obtain two logs simultaneously is met, convenience is provided for the user to analyze the problem quickly, and the working efficiency is improved.
A tenth embodiment of the present invention is directed to a non-transitory computer storage medium having stored thereon computer-executable instructions that are executable to perform the method of log output in any of the method embodiments described above.
Compared with the prior art, the method has the advantages that the preset queue created in the kernel space in advance is adopted to process the kernel logs, then the kernel logs in the preset queue are sent to the user space, and finally the kernel logs and the system logs are simultaneously output in the user space; the kernel log is output by the user space instead of the existing kernel space, so that the kernel space and the user space can be interacted, the user space outputs the kernel log from the kernel space and the system log stored in the user space together, the output kernel log and the system log have clear logic sequence, the requirement that a user needs to obtain two logs simultaneously is met, convenience is provided for the user to analyze the problem quickly, and the working efficiency is improved.
An eleventh embodiment of the present invention is directed to a computer program product including a computer program stored on a non-transitory computer-readable storage medium, the computer program including program instructions that, when executed by a computer, cause the computer to execute the above-described log output method of the embodiment of the present invention.
Compared with the prior art, the method has the advantages that the preset queue created in the kernel space in advance is adopted to process the kernel logs, then the kernel logs in the preset queue are sent to the user space, and finally the kernel logs and the system logs are simultaneously output in the user space; the kernel log is output by the user space instead of the existing kernel space, so that the kernel space and the user space can be interacted, the user space outputs the kernel log from the kernel space and the system log stored in the user space together, the output kernel log and the system log have clear logic sequence, the requirement that a user needs to obtain two logs simultaneously is met, convenience is provided for the user to analyze the problem quickly, and the working efficiency is improved.
Those skilled in the art can understand that all or part of the steps in the method according to the above embodiments may be implemented by a program to instruct related hardware, where the program is stored in a storage medium and includes several instructions to enable a device (which may be a single chip, a chip, etc.) or a processor (processor) to execute all or part of the steps in the method according to the embodiments of the present application. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes.
It will be understood by those of ordinary skill in the art that the foregoing embodiments are specific examples for carrying out the invention, and that various changes in form and details may be made therein without departing from the spirit and scope of the invention in practice.

Claims (10)

1. A log output method, comprising:
moving the kernel logs in the kernel space to a preset queue established in advance;
sending the kernel log in the preset queue to a user space; the user space stores system logs;
and simultaneously outputting the kernel log and the system log in the user space.
2. The log output method according to claim 1, wherein moving the kernel log in the kernel space to a preset queue created in advance specifically includes:
filtering the kernel log according to a preset rule;
moving the filtered kernel logs to the preset queue;
in the simultaneously outputting the kernel log and the system log in the user space, the method specifically includes:
acquiring a system log meeting the preset rule;
and simultaneously outputting the kernel logs meeting the preset rules and the system logs meeting the preset rules.
3. The log output method according to claim 2, wherein before the sending the kernel log in the preset queue to a user space, the method further comprises:
and judging that the kernel log exists in the preset queue.
4. The log output method according to claim 1, wherein, in sending the kernel log in the preset queue to a user space, specifically comprising:
sending the kernel log to an interaction thread preset in the user space;
packaging the kernel log in the interactive thread according to the format of a system data packet;
sending the packaged kernel log from the interaction thread to a daemon process for receiving the system log; the system log is stored in the daemon process.
5. The log output method according to claim 1, further comprising, in the log output method:
and emptying the kernel logs in the preset queue when the kernel logs and the system logs are judged not to be output at the same time in the user space.
6. A log output apparatus, comprising:
the log moving module is used for moving the kernel logs in the kernel space to a preset queue which is established in advance;
the log sending module is used for sending the kernel logs in the preset queue to a user space; the user space stores system logs;
and the log output module is used for simultaneously outputting the kernel log and the system log in the user space.
7. The log output apparatus of claim 6, wherein the log moving module comprises:
the filtering unit is used for filtering the kernel log according to a preset rule;
the mobile unit is used for moving the filtered kernel logs to the preset queue;
the log output module includes:
the acquisition unit is used for acquiring the system logs meeting the preset rule;
and the output unit is used for simultaneously outputting the kernel logs meeting the preset rules and the system logs meeting the preset rules.
8. The log output apparatus according to claim 7, further comprising:
and the log existence judging module is used for judging whether the kernel logs exist in the preset queue or not before the log sending module sends the kernel logs in the preset queue to the user space.
9. The log output apparatus of claim 6, wherein the log transmission module comprises:
the first sending unit is used for sending the kernel log to an interaction thread preset in the user space;
the encapsulation unit is used for encapsulating the kernel log in the interactive thread according to the format of a system data packet;
the second sending unit is also used for sending the packaged kernel log from the interaction thread to a daemon process for receiving the system log; the system log is stored in the daemon process.
10. An electronic device, comprising:
at least one processor; and the number of the first and second groups,
a memory communicatively coupled to the at least one processor; wherein,
the memory stores instructions executable by the one processor to cause the at least one processor to perform the method of any one of claims 1-5.
CN201611135409.XA 2016-12-11 2016-12-11 Log-output method and device, electronic equipment Pending CN106815128A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201611135409.XA CN106815128A (en) 2016-12-11 2016-12-11 Log-output method and device, electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201611135409.XA CN106815128A (en) 2016-12-11 2016-12-11 Log-output method and device, electronic equipment

Publications (1)

Publication Number Publication Date
CN106815128A true CN106815128A (en) 2017-06-09

Family

ID=59108836

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201611135409.XA Pending CN106815128A (en) 2016-12-11 2016-12-11 Log-output method and device, electronic equipment

Country Status (1)

Country Link
CN (1) CN106815128A (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108132868A (en) * 2018-01-15 2018-06-08 政采云有限公司 A kind of data monitoring method, device, computing device and storage medium
CN108170538A (en) * 2017-12-08 2018-06-15 北京奇艺世纪科技有限公司 A kind of information processing method, device and electronic equipment
CN108388496A (en) * 2018-01-23 2018-08-10 晶晨半导体(上海)股份有限公司 A kind of collection method of system log
CN108647131A (en) * 2018-04-08 2018-10-12 广州视源电子科技股份有限公司 Output system of running log

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108170538A (en) * 2017-12-08 2018-06-15 北京奇艺世纪科技有限公司 A kind of information processing method, device and electronic equipment
CN108170538B (en) * 2017-12-08 2021-05-28 北京奇艺世纪科技有限公司 Information processing method and device and electronic equipment
CN108132868A (en) * 2018-01-15 2018-06-08 政采云有限公司 A kind of data monitoring method, device, computing device and storage medium
CN108388496A (en) * 2018-01-23 2018-08-10 晶晨半导体(上海)股份有限公司 A kind of collection method of system log
WO2019144670A1 (en) * 2018-01-23 2019-08-01 晶晨半导体(上海)股份有限公司 System log collection method
US11520681B2 (en) 2018-01-23 2022-12-06 Amlogic (Shanghai) Co., Ltd. System log collection method
CN108647131A (en) * 2018-04-08 2018-10-12 广州视源电子科技股份有限公司 Output system of running log

Similar Documents

Publication Publication Date Title
CN108028833B (en) NAS data access method, system and related equipment
CN104618155B (en) A kind of virtual machine fault-tolerant method, apparatus and system
CN108023829B (en) Message processing method and device, storage medium and electronic equipment
CN111831538B (en) Debugging method, device and storage medium
CN106815128A (en) Log-output method and device, electronic equipment
CN112817617A (en) Software upgrading method, device and system
CN105677282B (en) A kind of method of Image Rendering, user equipment, server and system
CN105190530A (en) Transmitting hardware-rendered graphical data
CN112749113A (en) Data interaction method, system, device and medium
WO2021134418A1 (en) Data checking method and apparatus
CN113498597B (en) PCIe-based data transmission method and device
CN106681714A (en) Method and device for setting program environments and electronic equipment
CN114328183A (en) Debugging method, device, equipment and computer readable storage medium
CN109800202B (en) PCIE (peripheral component interface express) -based data transmission system, method and device
CN105727556A (en) Image drawing method, related equipment and system
CN114270309A (en) Resource acquisition method and device and electronic equipment
US20230029796A1 (en) Stateful service processing method and apparatus
CN112910910B (en) Method, device, equipment and storage medium for processing OPCDA protocol message
CN112764761A (en) Program interruption file analysis method, storage medium, electronic device and system
CN113778774A (en) Test data transmission method and device, test method and communication module
CN113051212A (en) Graphics processor, data transmission method, data transmission device, electronic device, and storage medium
CN111770074A (en) Data path test message generation device and method
CN111371799A (en) Method, device and equipment for controlling data transmission and reception of MCTP (Multi-channel media processing protocol) controller
CN111026579A (en) Method, device, terminal equipment and medium for verifying data error detection capability
CN115617370B (en) Data refreshing method and device, electronic equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
WD01 Invention patent application deemed withdrawn after publication
WD01 Invention patent application deemed withdrawn after publication

Application publication date: 20170609