Disclosure of Invention
To solve the problems in the prior art, embodiments of the present invention provide a method, an apparatus, a device, and a storage medium for outputting a browser log based on a page.
Specifically, the embodiment of the invention provides the following technical scheme:
in a first aspect, an embodiment of the present invention provides a method for outputting a browser log based on a page, where the method is applied to a browser and includes:
receiving a first input of a user to the browser;
and responding to the first input, opening a target internal page in the browser, collecting a first browser log through a browser kernel, and outputting the first browser log to the target internal page.
Further, the first input is a text input of a website of the target internal page in the browser by a user; or
The first input is the triggering operation of a user on a specified button displayed by the browser.
Further, the opening a target internal page in the browser in response to the first input, collecting a first browser log through a browser kernel, and outputting the first browser log to the target internal page includes:
and responding to the first input, opening a target internal page in the browser, triggering a global variable switch configured in the browser to be opened, starting to acquire a first browser log through the browser kernel, and outputting the first browser log to the target internal page.
Further, the method further comprises:
receiving a second input of the user;
and responding to the second input, closing the target internal page, and stopping collecting the first browser log through the browser kernel.
Further, the method further comprises:
in a case where the first browser log is stored in a first cache, in response to the second input, the first browser log stored in the first cache is also deleted.
Further, the method further comprises:
receiving a third input of the user;
and responding to the third input, and sending the first browser log output to the target internal page to a server corresponding to the browser.
Further, before receiving the first input of the user to the browser, the method further comprises:
displaying the running error prompt information of the target task in the browser through the browser;
before collecting the first browser log by the browser kernel, the method further comprises:
receiving a fourth input of a user to the browser under the condition that a target internal page is opened in the browser;
in response to the fourth input, running the target task in the browser;
the collecting of the first browser log by the browser kernel includes:
and collecting a first browser log generated in the process of running the target task in the browser through the browser kernel.
Further, the acquiring, by the browser kernel, the first browser log and outputting the first browser log to the target internal page includes:
collecting a first browser log through a browser kernel, and putting the first browser log into a first cache;
and when the data volume of the first browser log put into the first cache reaches a preset value, extracting the first browser log from the first cache and outputting the first browser log to the target internal page.
Further, before the receiving the first input of the user to the browser, the method further comprises:
receiving a fifth input of the user;
responding to the fifth input, starting the browser, starting to acquire a second browser log through the browser kernel, and putting the acquired second browser log into a second cache;
the responding to the first input, opening a target internal page in the browser, collecting a first browser log through a browser kernel, and outputting the first browser log to the target internal page includes:
and responding to the first input, opening a target internal page in the browser, extracting the second browser log from the second cache, outputting the second browser log to the target internal page, collecting a first browser log through a browser kernel, and outputting the first browser log to the target internal page.
Further, the extracting the second browser log from the second cache includes:
and if the time interval from the browser starting to the first input receiving does not exceed the target time length, extracting a second browser log from a second cache.
Further, before receiving the first input of the user, the method further comprises:
and if the time interval from the browser starting to the first input receiving exceeds the target time length, deleting the second browser log exceeding the target time length from the second cache.
Further, the method further comprises:
and when the second browser log exceeding the target duration is deleted from the second cache, returning to the beginning of acquiring the second browser log through the browser kernel, and putting the acquired second browser log into the second cache.
Further, the collecting, by the browser kernel, the first browser log includes:
a first browser log is collected by the browser kernel based on a target single thread created in the browser.
In a second aspect, an embodiment of the present invention further provides a device for outputting a browser log based on a page, where the device is applied to a browser, and includes:
the first receiving module is used for receiving a first input of a user to the browser;
and the first log processing module responds to the first input, opens a target internal page in the browser, collects a first browser log through a browser kernel, and outputs the first browser log to the target internal page.
In a third aspect, an embodiment of the present invention further provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, where the processor implements the steps of the page-based browser log output method according to the first aspect when executing the program.
In a fourth aspect, the present invention further provides a non-transitory computer readable storage medium, on which a computer program is stored, where the computer program, when executed by a processor, implements the steps of the page-based browser log output method according to the first aspect.
In a fifth aspect, the present invention further provides a computer program product, on which executable instructions are stored, and when executed by a processor, the instructions cause the processor to implement the steps of the page-based browser log output method according to the first aspect.
According to the method, the device, the equipment and the storage medium for outputting the browser logs based on the pages, the browser logs are directly output by utilizing the internal pages of the browser, wherein the browser logs are acquired and output by triggering the internal pages of the browser to be opened, so that the problems that the browser needs to be restarted and a command line switch is arranged to output the browser logs in the prior art are avoided, any external tool does not need to be installed, the acquisition and output control program of the browser logs is simple, and the efficiency is high. Moreover, the scheme has little disturbance to the user, the user only needs to start the internal page of the browser without opening a special tool, the page display effect is controllable, and the user experience is good.
Meanwhile, the browser logs are presented through the browser pages, the method and the system are a cross-platform general scheme, consistent experience can be kept on each platform, and the method and the system have good universality.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, but not all, embodiments of the present invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
Fig. 1 is a flowchart of a method for outputting a browser log based on a page according to an embodiment of the present invention, where an execution subject of the method is a browser or a control module disposed in the browser, and is not limited in detail herein. In addition, the type of browser is not limited.
The method comprises the following steps:
step 110: receiving a first input of a user to the browser;
step 120: and responding to the first input, opening a target internal page in the browser, collecting a first browser log through a browser kernel, and outputting the first browser log to the target internal page.
In an embodiment of the present invention, the first input is intended to launch a target internal page in the browser. The internal page of the browser is a local page which is carried by the browser and can be displayed without interaction with the server, and can be a page for configuring, managing and reporting the browser.
The target internal page mentioned in the embodiment of the invention is specifically used for triggering and collecting the browser log when the target internal page is opened, and displaying the output browser log.
By utilizing the embodiment of the invention, the first input triggers the browser to open the target internal page, and starts to collect the first browser log when the target internal page is opened and outputs the first browser log to the target internal page for display.
In an alternative embodiment, the first input may be a trigger operation or an input operation to the browser.
When a virtual button or a bookmark page related to a target internal page is set in a browser, a user can directly click and trigger, and then the first input is the trigger operation of the user on a specified button displayed by the browser, so that the trigger operation is realized.
The first input is the text input of the user to the website of the target internal page in the browser.
In an alternative embodiment, the browser may be a chrome-based browser, which, using a chrome local page interface, is capable of providing an operation interface in the form of a Web page, where the content (html), format (css) and interactive communication with the browser kernel of the page are all provided immediately inside the browser program. This provides a feasible technique for embodiments of the present invention to output a browser log using the browser internal page.
For example, at this point, the first input may be a website entry for chrome:// log, at which point the browser may immediately open the target internal page that originally displayed the browser log.
In an optional embodiment, a global variable switch may be configured in the browser, and the collection and output of the first browser log are controlled through the global variable switch.
Specifically, in response to the first input, opening a target internal page in the browser, collecting a first browser log through a browser kernel, and outputting the first browser log to the target internal page, specifically including:
and responding to the first input, opening a target internal page in the browser, triggering a global variable switch configured in the browser to be opened, starting to acquire a first browser log through a browser kernel, and outputting the first browser log to the target internal page.
In a specific application scenario of the present invention, the production part of the log may not need to be generated by adding code separately for this purpose. For example, the Chromium code library provides a convenient C/C + + macro function way to generate LOGs, such as LOG/VLOG/PLOG, etc. The embodiment of the invention intervenes in the places where LOG formatted contents are formed and distributed TO different output channels, and a new LOG _ TO _ PAGE form is added. For example, whether to output a log to an internal page is controlled in the manner of a global variable switch, and whether the chrome:// log page is open is used to control this variable.
Optionally, referring to an alternative embodiment shown in fig. 2, the method comprises the following steps:
step 210: receiving a first input of a user to the browser;
step 220: responding to the first input, opening a target internal page in the browser, collecting a first browser log through a browser kernel, and outputting the first browser log to the target internal page;
step 230: receiving a second input of the user;
step 240: and responding to the second input, closing the target internal page, and stopping collecting the first browser log through the browser kernel.
For steps 210 and 220, reference may be made to steps 110 and 120 above, respectively, and details thereof are not repeated.
In this embodiment, the second input is a closing operation on the target internal page, and the closing of the target internal page triggers stopping collecting the first browser log.
The embodiment provides the browser log collection which is immediately turned on and off, so that the time length of the browser log collection can be controlled at any time, and the generation of long log contents can be avoided. Meanwhile, the on-off mode brings great convenience to the operation of the user.
Specifically, referring to the global variable switch mentioned above, in this embodiment, in response to the second input, the target internal page is closed, the global variable switch configured in the browser is triggered to be closed, and the collection of the first browser log is stopped.
Optionally, in a case where the first browser log is stored in a first cache, in response to the second input, the first browser log stored in the first cache is also deleted. This may avoid storage redundancy caused by the first cache.
In an optional embodiment, the collecting, by the browser kernel, the first browser log specifically includes:
a first browser log is collected by the browser kernel based on a target single thread created in the browser.
In a specific application, a browser is a typical multi-process/multi-thread architecture, so that a source generated by the browser is also multi-threaded, and in order to make collected browser logs ordered and not confused, the embodiment uses a special single thread to receive the browser logs in a serialized manner.
Specifically, due to the special browser log processing thread, the log module sends the browser log to the log processing thread after the browser log is formed, specifically, the browser log can be processed through a task queue of chrome, and the browser log is cached by the log thread and then submitted to an internal page of the log in batches to be displayed.
In an alternative embodiment, referring to fig. 3, the page-based browser log output method includes:
step 310: receiving a first input of a user to the browser;
step 320: responding to the first input, opening a target internal page in the browser, collecting a first browser log through a browser kernel, and outputting the first browser log to the target internal page;
step 330: receiving a third input of the user;
step 340: and responding to the third input, and sending the first browser log output to the target internal page to a server corresponding to the browser.
In practical application, the browser faces to the user side, and when the browser runs with an error, the user can obtain the browser log based on the scheme of the embodiment of the invention and send the browser log to a back-end developer at the server side or send the browser log according to the instruction of the back-end developer.
The embodiment of the invention provides a convenient browser log output scheme, a user can acquire a browser log more conveniently and intuitively, and the browser log output scheme can stimulate the user to provide the browser log, so that a developer at a server side can find out the reason causing the problem in time according to the browser log, thereby updating the browser configuration and providing more timely service for the user. Therefore, the embodiment of the invention can bring good user experience.
In this embodiment, the third input is a sending operation to the first browser log. Specifically, the third input may also be a selection and transmission operation of the first browser log.
For the first browser log output to the target internal page display, the user can select the browser log content to be transmitted, and then the browser receives the user's selection operation and transmission operation, and transmits the selected part of the browser log to the server.
The sending operation of the user to the first browser log may specifically be that a sending button is displayed on the target internal page or on the browser window, and the triggering operation of the user is received, so as to send out the first browser log.
Referring to fig. 4, an embodiment of the present invention provides a browser log output method based on a specific application scenario, which specifically includes the following steps:
step 410: displaying the running error prompt information of the target task in the browser through the browser;
step 420: receiving a first input of a user to a browser;
step 430: responding to the first input, opening a target internal page in a browser, collecting a first browser log through a browser kernel, and outputting the first browser log to the target internal page;
step 440: receiving a fourth input of a user to the browser under the condition that a target internal page is opened in the browser;
step 450: in response to the fourth input, running the target task in the browser;
step 460: and collecting a first browser log generated in the process of running the target task in the browser through the browser kernel.
By utilizing the embodiment of the invention, the specific problems in the running process of the browser can be positioned. When a browser operation error is generated, a user can be prompted to feed back a first browser log corresponding to the problem through target task operation error prompt information. When the target internal page is opened, the wrong target task is run again before the target internal page is run, the problem generated when the target task is run by the browser can be reproduced, and then the problem is reflected in the first browser log, so that the problem can be accurately positioned through the browser log.
In one scenario, when a user discovers and reports a problem, if a log is needed for positioning, a chrome:// log page is opened, the problem is reproduced to generate a relevant log, then the log can be sent (or copied and stored) by one key, and then the log generation is stopped when the page is closed, namely the log is started and used, so that the method is more convenient.
In addition, when the target internal page of the browser is in an open state, the browser has an operation error, and at the moment, the corresponding browser page can be acquired in real time and output to the target internal page for display, and can be sent in time.
The target task in the browser may be a display error of another web page, a browser network connection error, or the like, which is not limited herein.
The fourth input is associated with a specific type of target task. If the target task is a display error of other web pages, the fourth input may be a text input to a web address or a refresh operation to a web page, etc.
In an optional embodiment, referring to fig. 5, the acquiring, by a browser kernel, a first browser log and outputting the first browser log to the target internal page specifically includes the following steps:
step 510: collecting a first browser log through a browser kernel, and putting the first browser log into a first cache;
step 520: and when the data volume of the first browser log put into the first cache reaches a preset value, extracting the first browser log from the first cache and outputting the first browser log to the target internal page.
By using the embodiment, the first browser logs are output in batches by adopting a cache strategy, so that the influence on the performance caused by frequent refreshing of transition due to the peak value of the logs is avoided, and the timeliness and the performance of the log display need to be balanced.
Thus, when a new browser log is received, a timer can be started, a log output task is triggered after a period of time is delayed, the browser log is collected and cached in the process, and then the browser log is output to a target internal page and page refreshing (partial or whole rendering) is triggered, the content of the new browser log is displayed, and if necessary, the updated browser log can be displayed by automatically scrolling the page.
In specific application, the collected browser Log can be sent To a Log To Page Service for caching and is waited To be output To a target internal Page for display.
In an optional embodiment of the present invention, referring to fig. 6, a method for outputting a browser log based on a page specifically includes the following steps:
step 610: receiving a fifth input of the user;
step 620: responding to the fifth input, starting the browser, starting to acquire a second browser log through the browser kernel, and putting the acquired second browser log into the second cache;
step 630: receiving a first input of a user to the browser;
step 640: and responding to the first input, opening a target internal page in the browser, extracting the second browser log from the second cache, outputting the second browser log to the target internal page, collecting a first browser log through a browser kernel, and outputting the first browser log to the target internal page.
In this embodiment, the second cache stores a second browser log which may be generated between the browser startup and the target internal page opening, so that when the target internal page is opened, the second browser log can be output immediately, and thus if the browser generates an operation error before the target internal page is opened (i.e., at the browser startup stage), the corresponding browser log can be acquired and analyzed to find the cause of the error. The embodiment solves the problem that the browser logs between the browser starting and the target internal page opening are possibly missed.
In this embodiment, the fifth input is a starting operation on the browser, and specifically may be a triggering operation on a browser icon, such as clicking or double-clicking, which is not limited herein.
In an optional embodiment, the extracting the second browser log from the second cache specifically includes:
and if the time interval from the browser starting to the fifth input receiving does not exceed the target time length, extracting a second browser log from a second cache.
In practical application, if the target duration is exceeded, it can be considered that the second browser log in the second cache is outdated and cannot reflect the current running error of the browser, so that the timing for extracting the second browser log from the second cache is controlled by setting the target duration, and the accuracy and the reliability of browser log output can be improved.
The target duration is preset duration configured in advance, and can be set by combining a cache mechanism and the requirement for the browser log.
In an alternative embodiment, before receiving the fifth input by the user, if a time interval from starting the browser to receiving the fifth input exceeds a target time period, deleting the second browser log exceeding the target time period from the second cache.
Therefore, data redundancy in the second cache can be avoided, and invalid logs in the cache can be cleared in time.
In an optional embodiment, when the second browser log exceeding the target duration is deleted from the second cache, returning to the beginning of collecting the second browser log through the browser kernel, and placing the collected second browser log into the second cache. This can enable the old browser log to be deleted while the latest browser log is collected.
In the embodiment of the invention, the collected browser logs are basically formatted plain text contents. Html, a simple html container (such as log _ page. html) can be used to dynamically add the formatted plain text content, and then send it to the target internal page for rendering output through js interface communication. Js module may implement this logic, which dynamically generates corresponding html page elements. In addition to the content directly provided by the user, the browser log may also include metadata such as rating, time, source such as file name, source code line, etc., and finally form a log.
Referring to fig. 7, an embodiment of the present invention provides a page-based browser log output apparatus, where the apparatus may include:
a first receiving module 710 for receiving a first input of the browser from a user;
and the first log processing module 720, in response to the first input, opens a target internal page in the browser, collects a first browser log through a browser kernel, and outputs the first browser log to the target internal page.
Optionally, the first input is a text input of a website of the target internal page in the browser by a user; or
The first input is the triggering operation of a user on a specified button displayed by the browser.
Optionally, the first log processing module 720 is specifically configured to:
and responding to the first input, opening a target internal page in the browser, triggering a global variable switch configured in the browser to be opened, starting to acquire a first browser log through a browser kernel, and outputting the first browser log to the target internal page.
Optionally, the first log processing module 720 is specifically configured to:
collecting a first browser log through a browser kernel, and putting the first browser log into a first cache;
and when the data volume of the first browser log put into the first cache reaches a preset value, extracting the first browser log from the first cache and outputting the first browser log to the target internal page.
Optionally, the first log processing module 720 is specifically configured to:
a first browser log is collected by the browser kernel based on a target single thread created in the browser.
Optionally, referring to fig. 8 and as shown in fig. 7, the device for outputting a browser log based on a page according to an embodiment of the present invention further includes:
a second receiving module 810 for receiving a second input of the user;
and the second log processing module 820, in response to the second input, closes the target internal page and stops collecting the first browser log through the browser kernel.
Optionally, referring to fig. 9, as shown in fig. 8, the device for outputting a browser log based on a page according to an embodiment of the present invention further includes:
the first deleting module 910, in response to the second input, further deletes the first browser log stored in the first cache in a case where the first browser log is stored in the first cache.
Optionally, referring to fig. 10, as shown in fig. 7, the device for outputting a browser log based on a page according to an embodiment of the present invention further includes:
a third receiving module 1010 for receiving a third input from the user;
the sending module 1020, in response to the third input, sends the first browser log output to the target internal page to a server corresponding to the browser.
Optionally, referring to fig. 11 and as shown in fig. 7, the device for outputting a browser log based on a page according to an embodiment of the present invention further includes:
the display module 1110 displays the target task operation error prompt information in the browser through the browser before receiving a first input of a user to the browser;
a fourth receiving module 1120, configured to receive a fourth input of the browser from the user when a target internal page is opened in the browser before the first browser log is collected by the browser kernel;
a running module 1130, responsive to a fourth input, running the target task in the browser;
the first log processing module 1140 is specifically configured to: and collecting a first browser log generated in the process of running the target task in the browser through the browser kernel.
Alternatively, referring to fig. 12, compared with fig. 7, the page-based browser log output apparatus provided in this embodiment may include:
a fifth receiving module 1210 for receiving a fifth input from the user before the receiving the first input from the user to the browser;
the third log processing module 1220, in response to the fifth input, starts the browser, starts to collect a second browser log through the browser kernel, and places the collected second browser log into a second cache;
the first log processing module 1230 is specifically configured to:
and responding to the first input, opening a target internal page in the browser, extracting the second browser log from the second cache, outputting the second browser log to the target internal page, collecting a first browser log through a browser kernel, and outputting the first browser log to the target internal page.
Optionally, the first log processing module 1220 is specifically configured to:
and if the time interval from the browser starting to the fifth input receiving does not exceed the target time length, extracting a second browser log from a second cache.
Optionally, referring to fig. 13, compared with fig. 12, the page-based browser log output apparatus according to the embodiment of the present invention may further include:
a second deletion module 1310 that deletes a second browser log from a second cache that exceeds a target duration if a time interval from the starting of the browser to the receiving of the fifth input exceeds the target duration before receiving the fifth input of the user.
Optionally, the second deleting module 1310 is further specifically configured to:
and when the second browser log exceeding the target duration is deleted from the second cache, returning to the beginning of acquiring the second browser log through the browser kernel, and putting the acquired second browser log into the second cache.
An example is as follows:
fig. 14 illustrates a physical structure diagram of an electronic device, and as shown in fig. 14, the electronic device may include: a processor (processor)1410, a communication Interface (Communications Interface)1420, a memory (memory)1430 and a communication bus 1440, wherein the processor 1410, the communication Interface 1420 and the memory 1430 communicate with each other via the communication bus 1440. Processor 1410 may call logic instructions in memory 1430 to perform the following method: receiving a first input of a user to the browser; and responding to the first input, opening a target internal page in the browser, collecting a first browser log through a browser kernel, and outputting the first browser log to the target internal page. .
In addition, the logic instructions in the memory 1430 may be implemented in software functional units and stored in a computer readable storage medium when sold or used as a stand-alone product. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present invention. 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.
In another aspect, an embodiment of the present invention further provides a non-transitory computer-readable storage medium, on which a computer program is stored, where the computer program is implemented to, when executed by a processor, perform the page-based browser log output method provided in the foregoing embodiments, for example, including: receiving a first input of a user to the browser; and responding to the first input, opening a target internal page in the browser, collecting a first browser log through a browser kernel, and outputting the first browser log to the target internal page.
In another aspect, an embodiment of the present invention further provides a computer program product, on which executable instructions are stored, where the instructions, when executed by a processor, cause the processor to implement a method for outputting a browser log based on a page, for example, including: receiving a first input of a user to the browser; and responding to the first input, opening a target internal page in the browser, collecting a first browser log through a browser kernel, and outputting the first browser log to the target internal page.
The above-described embodiments of the apparatus are merely illustrative, and the units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the present embodiment. One of ordinary skill in the art can understand and implement it without inventive effort.
Through the above description of the embodiments, those skilled in the art will clearly understand that each embodiment can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware. With this understanding in mind, the above-described technical solutions may be embodied in the form of a software product, which can be stored in a computer-readable storage medium such as ROM/RAM, magnetic disk, optical disk, etc., and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute the methods described in the embodiments or some parts of the embodiments.
Finally, it should be noted that: the above examples are only intended to illustrate the technical solution of the present invention, but not to limit it; although the present invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; and such modifications or substitutions do not depart from the spirit and scope of the corresponding technical solutions of the embodiments of the present invention.