CN110795303A - Log output method and device, storage medium and terminal - Google Patents

Log output method and device, storage medium and terminal Download PDF

Info

Publication number
CN110795303A
CN110795303A CN201910913850.3A CN201910913850A CN110795303A CN 110795303 A CN110795303 A CN 110795303A CN 201910913850 A CN201910913850 A CN 201910913850A CN 110795303 A CN110795303 A CN 110795303A
Authority
CN
China
Prior art keywords
service
statement
business
environment
log
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
CN201910913850.3A
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.)
Beijing Wenyuanjia Technology Co Ltd
Original Assignee
Beijing Wenyuanjia Technology 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 Beijing Wenyuanjia Technology Co Ltd filed Critical Beijing Wenyuanjia Technology Co Ltd
Priority to CN201910913850.3A priority Critical patent/CN110795303A/en
Publication of CN110795303A publication Critical patent/CN110795303A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/3003Monitoring arrangements specially adapted to the computing system or computing system component being monitored
    • G06F11/302Monitoring arrangements specially adapted to the computing system or computing system component being monitored where the computing system component is a software system
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/3065Monitoring arrangements determined by the means or processing involved in reporting the monitored data

Abstract

The application discloses a log output method, a log output device, a storage medium and a terminal, and relates to the technical field of computers. Firstly, acquiring a business statement, and executing the business statement in a first business environment; then triggering a log output statement, establishing a second service environment, and packaging an evaluation code aiming at the service statement into the second service environment; the evaluation code is used for evaluating the business statement and outputting a log; and finally returning to the first business environment, and continuing to execute the business statement in the first business environment. When the business statement is executed in the first business environment and the log related to the business statement needs to be output, a second business environment can be established, and the log output of the business statement is executed in the second business environment.

Description

Log output method and device, storage medium and terminal
Technical Field
The present application relates to the field of computer technologies, and in particular, to a method and an apparatus for outputting a log, a storage medium, and a terminal.
Background
With the development of science and technology, people use software systems more and more, and the software systems greatly improve the convenience of life and study of people, so that the safety and the stability of the software systems become the key points of research of people in the field.
In the related art, a software system may include a plurality of service statements, in order to record relevant parameters of the service statements as data for production, or facilitate debugging of the software system at a later stage, a log function may be added to the service statements, and the log function evaluates or otherwise processes the parameters in the service statements and outputs a log, and then continues to execute the service statements.
Disclosure of Invention
However, in the related art, since the business statement must be executed continuously after the log output is completed in the execution process of the business statement, when a problem occurs in the log output process, the business statement cannot be executed continuously, and in a serious case, the whole software system is crashed.
The application provides a log output method, a log output device, a storage medium and a terminal, which can solve the technical problem that when a problem occurs in the log output process in the related art, a service statement cannot be continuously executed, so that a software system is crashed.
In a first aspect, an embodiment of the present application provides a log output method, where the method includes:
acquiring a business statement, and executing the business statement in a first business environment;
triggering a log output statement, establishing a second service environment, and packaging an evaluation code aiming at the service statement into the second service environment; the evaluation code is used for evaluating the business statement and outputting a log;
and returning to the first business environment, and continuing to execute the business statement in the first business environment.
Optionally, the second business environment comprises at least one asynchronous queue; and the second service environment is different from the first service environment, and the running priority of the second service environment is smaller than that of the first service environment.
Optionally, the encapsulating the evaluation code for the business statement into the second business environment includes: acquiring a service type corresponding to the service statement; acquiring an evaluation code corresponding to the service type; calling an anonymous function to encapsulate the evaluation code into the second business environment.
Optionally, after returning to the first business environment and continuing to execute the business statement in the first business environment, the method further includes: triggering a parameter evaluation statement to acquire a service parameter corresponding to the service statement; calling the anonymous function in the second service environment to execute the evaluation code to evaluate the service parameter and obtain an evaluation result; and saving the evaluation result.
Optionally, the second business environment comprises at least one log thread; wherein the second business environment is different from the first business environment.
Optionally, each of the at least one log thread corresponds to an anonymity function; wherein the anonymity function is to encapsulate evaluation code for a business statement into the second business context.
Optionally, after returning to the first business environment and continuing to execute the business statement in the first business environment, the method includes: triggering parameter evaluation statements, acquiring service parameters corresponding to all service statements, and performing priority ordering on all service parameters according to a preset rule; acquiring the utilization rate of a processor, and if the utilization rate of the processor is smaller than a utilization rate threshold value, acquiring the service parameter with high priority; obtaining the anonymous function corresponding to the service parameter with high priority, calling the anonymous function to execute the evaluation code to evaluate the service parameter, and obtaining an evaluation result; and saving the evaluation result.
In a second aspect, an embodiment of the present application provides a log output apparatus, including:
the service execution module is used for acquiring a service statement and executing the service statement in a first service environment;
the service environment establishing module is used for triggering a log output statement, establishing a second service environment and packaging an evaluation code aiming at the service statement into the second service environment; the evaluation code is used for evaluating the business statement and outputting a log;
and the business continuous execution module is used for returning to the first business environment and continuously executing the business statement in the first business environment.
In a third aspect, an embodiment of the present application provides a computer storage medium storing a plurality of instructions adapted to be loaded by a processor and to execute steps implementing the above-mentioned method.
In a fourth aspect, embodiments of the present application provide a terminal, including a memory, a processor, and a computer program stored on the memory and executable on the processor, where the processor executes the computer program to implement the steps of the method described above.
The beneficial effects brought by the technical scheme provided by some embodiments of the application at least comprise:
the application provides a log output method, a log output device, a storage medium and a terminal. Firstly, acquiring a business statement, and executing the business statement in a first business environment; then triggering a log output statement, establishing a second service environment, and packaging an evaluation code aiming at the service statement into the second service environment; the evaluation code is used for evaluating the business statement and outputting a log; and finally returning to the first business environment, and continuing to execute the business statement in the first business environment. When the business statement is executed in the first business environment and the log related to the business statement needs to be output, a second business environment can be established, and the log output of the business statement is executed in the second business environment.
Drawings
In order to more clearly illustrate the embodiments of the present application 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, it is obvious that the drawings in the following description are only some embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative efforts.
Fig. 1 is a schematic flowchart of a log output method according to an embodiment of the present application;
fig. 2 is a schematic flowchart of a log output method according to another embodiment of the present application;
fig. 3 is a schematic flowchart of a log output method according to another embodiment of the present application;
fig. 4 is a schematic structural diagram of a log output device according to an embodiment of the present disclosure;
fig. 5 is a schematic structural diagram of a log output device according to another embodiment of the present application;
fig. 6 is a schematic structural diagram of a log output device according to another embodiment of the present application;
fig. 7 is a schematic structural diagram of a terminal according to an embodiment of the present application.
Detailed Description
In order to make the features and advantages of the present application more obvious and understandable, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is apparent that the described embodiments are only a part of the embodiments of the present application, and not all the embodiments. 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 application.
When the following description refers to the accompanying drawings, like numbers in different drawings represent the same or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present application. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the application, as detailed in the appended claims.
In the description of the embodiments of the present application, it is to be understood that, in the description of the present application, "a plurality" means two or more unless otherwise specified. "and/or" describes the association relationship of the associated objects, meaning that there may be three relationships, e.g., a and/or B, which may mean: a exists alone, A and B exist simultaneously, and B exists alone. The character "/" generally indicates that the former and latter associated objects are in an "or" relationship.
Referring to fig. 1, fig. 1 is a schematic flow chart illustrating a log output method according to an embodiment of the present application.
As shown in fig. 1, the method includes:
s101, obtaining a business statement, and executing the business statement in a first business environment.
Optionally, in the embodiment of the present application, a log output method may be applied to a plurality of assembly languages, including but not limited to JavaScript, Java, C + +, and Python languages. Based on the above language, a software system meeting different requirements can be designed, the software system can be composed of program codes, and different codes can be composed of business statements handling different businesses, where a business can refer to a certain function or a certain event, for example, in the field of network online education, a certain business can be a student entering a virtual classroom to practice learning of a certain subject, so each business statement can include one or more groups of program codes and also include one or more character strings.
Optionally, a plurality of business statements may be included in a software system, and a business environment for the business statement is required for implementation or execution of the business statement, where the business environment may be a virtual concept and may be formed by execution of program code and/or invocation of a function, for example, the business environment may be a queue in a JavaScript language, or the business environment may be a thread in a Java language. The business language may be run or executed in a business environment to implement data processing or business processing.
Optionally, the execution main body of the embodiment of the present application may be a processor, and the processor first establishes a first service environment as an environment for processing a service statement. When the processor needs to process a certain data or implement a certain service, the processor acquires the data or a service statement corresponding to the service, the service statement may be stored in the register in advance, and after acquiring the service statement, the processor executes the service statement in the first service environment, that is, runs the program code included in the service statement in the first service environment.
S102, triggering a log output statement, establishing a second service environment, and packaging an evaluation code aiming at the service statement into the second service environment; the evaluation code is used to evaluate the business statement and log the output.
It can be understood that when the service statement is executed in the first service environment, sometimes the parameter of the execution process of the service statement needs to be recorded or evaluated, and then the parameter is output to a designated position or printed out in the form of a log, on one hand, the log can reflect the operation condition of the service statement, so that the subsequent debugging or debugging of the whole software system is facilitated, and the safety of the software system is improved; on the other hand, the log can be used for data production, so that calling and using of other business statements of the software system are facilitated, and therefore log output plays an important role in the software system.
Optionally, there may be a corresponding log statement for the output of the log, and the log statement includes a program code for logging the service statement. The program code included in the log statement can be set in the program code included in a certain service statement according to the service logic, so that the service statement, the log statement and the service statement can be output in a log mode through the log statement when the service statement, the log statement and the service statement are sequentially executed according to the execution logic in the process of executing the service statement.
In the related art, when a log statement is executed according to logic, the log statement acquires a service parameter corresponding to the service statement and evaluates the service parameter, but if an error occurs in the evaluation process, for example, the service parameter is erroneous or the evaluation process is crashed, the log statement is executed in a stuck state, so that subsequent service statements cannot be continuously executed, and if the error is more serious, the whole system software is crashed or a security hole is formed.
Optionally, in this embodiment of the present application, when the log statement is logically executed, a log output statement in the log statement is triggered, and the log output statement may include one or more sets of program codes, so that the log output statement may include an environment building program code, and after the log output statement is triggered, the environment building program code is immediately executed to build a second service environment different from the current first service environment. Because the log output process needs to use the correlation function to evaluate the service parameters corresponding to the service statements, the log output statements also include evaluation codes, and the evaluation codes are used for evaluating the service statements and outputting logs.
Optionally, since log output for the service statement is not necessary for service statement operation, the evaluation code may be encapsulated in the second service environment by calling a related function, and when the whole software system is in an idle state, the evaluation code is executed to realize log output corresponding to the service statement, so that the processing task amount of the processor at different times may be balanced, the processing speed of the processor for the service statement may be increased, and the stability of the software system may be improved.
S103, returning to the first business environment, and continuing to execute the business statement in the first business environment.
Optionally, since the evaluation processing of the service statement and the log output are both performed in the second service environment, and the second service environment and the first service environment are different service environments, that is, the execution of the service statement and the parameter evaluation of the log statement and the log output are isolated to different service environments for execution, when the parameter evaluation and the log output are performed in the second service environment, even if a parameter evaluation and log output error occurs in the second service environment, the execution of the service statement in the first service environment is not affected, and the stability of the whole software system is effectively improved.
In the embodiment of the application, firstly, a business statement is obtained, and the business statement is executed in a first business environment; then triggering a log output statement, establishing a second service environment, and packaging an evaluation code aiming at the service statement into the second service environment; the evaluation code is used for evaluating the business statement and outputting a log; and finally returning to the first business environment, and continuing to execute the business statement in the first business environment. When the service statement is executed in the first service environment and the log related to the service statement needs to be output, a second service environment can be established, and the log output of the service statement is executed in the second service environment.
Referring to fig. 2, fig. 2 is a schematic flowchart illustrating a log output method according to another embodiment of the present application.
As shown in fig. 2, the method steps include:
s201, obtaining a business statement, and executing the business statement in a first business environment.
For a detailed description of the step S201, reference may be made to the description of the step S101, which is not described herein again.
S202, triggering a log output statement, and establishing at least one asynchronous queue as a second service environment; the second service environment is different from the first service environment, and the operation priority of the second service environment is smaller than that of the first service environment.
Optionally, there may be a corresponding log statement for the output of the log, and the log statement includes a program code for logging the service statement. The program code included in the log statement can be set in the program code included in a certain service statement according to the service logic, so that the service statement, the log statement and the service statement can be output in a log mode through the log statement when the service statement, the log statement and the service statement are sequentially executed according to the execution logic in the process of executing the service statement.
For describing the log output process in more detail, the following description is given by taking the example in the JavaScript language. In the JavaScript language, the first service environment in which each service statement operates is a queue, that is, one queue includes service statements that implement each service or data processing, and each service statement operates in sequence in one queue. When the log statement is executed according to logic, the log output statement in the log statement is triggered, the log output statement can comprise one or more groups of program codes, so that the log output statement can comprise environment establishing program codes, and after the log output statement is triggered, the environment establishing program codes can establish at least one asynchronous queue different from the first service environment and use the asynchronous queue as a second service environment. The asynchronous queue and the queue in the first service environment may be two different queues, and the processor may execute the service statements in each queue asynchronously, so that the queue in the first service environment is different from the queue in the second service environment, and the second service environment is different from the first service environment.
Optionally, after the processor executes the environment establishment program, an asynchronous queue different from the first service environment, that is, a second service environment, may be established, and the processor may execute the statements in the queues asynchronously, where the execution of the service statements in the first service environment is an important link in the operation process of the entire software system, and therefore the service statements in the first service environment need to be executed preferentially, and the processor processes the log statements in the second service environment when the processor is idle. Therefore, after the processor establishes the second service environment, the operation priority of the second service environment is set to be low, the operation priority of the first service environment is set to be high, and the operation priority of the second service environment is smaller than the operation priority of the first service environment, so that after the processor establishes the second service environment, the service statements in the first service environment can be preferentially executed according to the operation priorities of different service environments, thereby avoiding the real-time operation of the log statements in the second service environment, and if the parameter evaluation error or the log output error occurs in the operation log statements, the service statements in the first service environment cannot be executed, further influencing the operation of the whole software system, and further improving the stability of the software system.
S203, acquiring the service type corresponding to the service statement, and acquiring an evaluation code corresponding to the service type.
Optionally, the service types, the service parameters, the evaluation manners, and the log output types corresponding to different service statements in the first service environment may be different, so as to output different logs, and therefore when the service statements in the first service environment need to be evaluated, the service types corresponding to the service statements need to be obtained first.
And S204, calling an anonymous function to package the evaluation code into a second service environment.
Optionally, multiple types of anonymous functions with different functions may be included in the JavaScript language, and the anonymous functions may be composed of program codes or character strings for implementing different functions. The processor calls an anonymous function corresponding to a preset log statement, and encapsulates the obtained evaluation code through the anonymous function, wherein the encapsulation means that the obtained evaluation code is subjected to memorability to hide the attribute and implementation details of an object, only an interface is exposed to the outside, the access level of reading and modifying of the attribute in a program is controlled, the evaluation code is not immediately executed, and only the anonymous function is required to execute evaluation on the evaluation code next time.
S205, returning to the first business environment, and continuing to execute the business statement in the first business environment.
Optionally, since the evaluation processing of the service statement and the log output are both performed in the second service environment, and the second service environment and the first service environment are different service environments, that is, the execution of the service statement and the parameter evaluation of the log statement and the log output are isolated to different service environments for execution, when the parameter evaluation and the log output are performed in the second service environment, even if a parameter evaluation and log output error occurs in the second service environment, the execution of the service statement in the first service environment is not affected, and the stability of the whole software system is effectively improved.
S206, triggering the parameter evaluation statement and acquiring the service parameter corresponding to the service statement.
Optionally, the log statement may further include a parameter evaluation statement, where triggering of the parameter evaluation statement may be triggered after the processor executes the service statement in the first service environment, and at this time, the processor acquires the service statement that needs to be logged and the service parameter corresponding to the service statement, for example, in the field of network online education, if a service executed by a certain service statement may be a service that a student object is named as student entering a room, a value needs to be taken for the service statement to acquire the service parameter corresponding to the service statement, and the service parameter corresponding to the service statement may be student name.
S207, calling an anonymous function in the second service environment to execute an evaluation code to evaluate the service parameter, and obtaining an evaluation result.
Optionally, after the service parameter corresponding to the service statement is acquired, the anonymous function may be called in the second service environment to execute the evaluation code encapsulated by the anonymous function, and execute the evaluation code, and after the evaluation code is run, evaluation processing may be performed according to the service parameter corresponding to the acquired service statement. For example, in the field of online network education, a service executed by a service statement may be that a student object is named student's name entering a room, a service parameter corresponding to the service statement may be student's name, an evaluation code may be log (═ student ' + student's name + ') entering the room, and after the evaluation code is processed, an evaluation result is finally obtained that "student $ { student's name } enters the room", that is, a log corresponding to the service statement is "student $ { student's name } entering the room", and the log may be output and/or printed.
And S208, saving the evaluation result.
Optionally, in order to facilitate later debugging or troubleshooting of errors, the evaluation result, that is, the output log, may also be stored in a designated local location or in a server.
In the embodiment of the application, a log output statement is triggered, and an asynchronous queue is established as a second service environment; the second service environment is different from the first service environment, and the operation priority of the second service environment is smaller than that of the first service environment. When the business statement is executed in the first business environment and the log related to the business statement needs to be output, a second business environment can be established, and the log output of the business statement is executed in the second business environment.
Referring to fig. 3, fig. 3 is a schematic flowchart illustrating a log output method according to another embodiment of the present application.
As shown in fig. 3, the method steps include:
s301, obtaining a business statement, and executing the business statement in the first business environment.
For the detailed description of the step S301, reference may be made to the description of the step S101, which is not described herein again.
S302, triggering a log output statement, and establishing at least one log thread as a second service environment; wherein the second service environment is different from the first service environment.
Optionally, there may be a corresponding log statement for the output of the log, and the log statement includes a program code for logging the service statement. The program code included in the log statement can be set in the program code included in a certain service statement according to the service logic, so that the service statement can be log-output through the log statement when the service statement, the log statement and the service statement are sequentially executed according to the execution logic in the process of executing the service statement.
To describe the log output process in more detail, the following description is given by way of example in the Java language. In the Java language, the first service environment in which each service statement runs is a thread, that is, a thread may include at least one service statement that implements service or data processing, and the processor may process multiple threads simultaneously or sequentially process service statements in threads. When the log statement is executed according to the logic, a log output statement in the log statement is triggered, and the log output statement may include one or more groups of program codes, so that the log output statement may include an environment establishing program code, and after the log output statement is triggered, the environment establishing program code may establish at least one thread different from the first service environment, and use the established thread as a second service environment. The established threads can be two threads different from the threads in the first service environment, and the processor can asynchronously execute the program codes in the different threads, so that the second service environment is different from the first service environment due to the difference between the threads in the first service environment and the established threads in the second service environment.
Optionally, the second service environment may include multiple log threads, that is, each time there is a service statement that requires to output a log, one thread may be established as a log thread for implementing log output of the service statement, and all the established log threads share one memory, so that all the log threads are placed in the second service environment.
S303, packaging the evaluation code aiming at the service statement into a second service environment; the evaluation code is used to evaluate the business statement and log the output.
Optionally, multiple types of anonymous functions with different functions may be included in the Java language, and the anonymous functions may be composed of program codes or character strings for implementing different functions. Therefore, each log thread in the at least one log thread can correspond to an anonymous function, the processor calls the anonymous function corresponding to a preset log statement, the evaluation code is packaged into different log threads through the anonymous function, the packaging means that the acquired evaluation code is subjected to memorability and hiding the attribute and implementation details of an object, only an interface is exposed to the outside, the access level of reading and modifying of the attribute in the program is controlled, the evaluation code cannot be executed immediately, and only the anonymous function is subjected to execution evaluation on the evaluation code next time.
S304, returning to the first business environment, and continuing to execute the business statement in the first business environment.
Optionally, since the evaluation processing of the service statement and the log output are both performed in the second service environment, and the second service environment and the first service environment are different service environments, that is, the execution of the service statement and the parameter evaluation of the log statement and the log output are isolated to different service environments for execution, when the parameter evaluation and the log output are performed in the second service environment, even if a parameter evaluation and log output error occurs in the second service environment, the execution of the service statement in the first service environment is not affected, and the stability of the whole software system is effectively improved.
S305, triggering the parameter evaluation statement, acquiring the service parameters corresponding to the service statements, and performing priority ordering on the service parameters according to a preset rule.
Optionally, the log statements may further include parameter evaluation statements, where triggering of the parameter evaluation statements may be triggered after the processor executes the service statements in the first service environment, at this time, the processor obtains the service statements corresponding to the log threads in the second service environment and the service parameters corresponding to the service statements, at this time, priority ordering may be performed on the service parameters according to a preset rule, for example, in the field of online education over a network, the preset rule may be set according to the service types corresponding to the service parameters, the service types may be that a student enters a room, selects a subject, gives lessons, feeds back after lessons, and the like, the importance degrees of different service types are different, if a log corresponding to the feedback after lessons needs to be preferentially obtained at a certain time, the corresponding service parameters fed back after lessons may be set to have a high priority in the preset rule, all traffic parameters in the second traffic environment can be prioritized by a preset rule.
S306, acquiring the utilization rate of the processor, and if the utilization rate of the processor is smaller than a utilization rate threshold, acquiring the service parameter with high priority.
Alternatively, the utilization rate of the processor represents how busy the processor executes threads, and if too many threads are processed by the processor at the same time, the thread execution error of the processor may be caused, and the whole software system may be crashed. Therefore, the utilization rate of the processor can also be obtained, if the utilization rate of the processor is smaller than the utilization rate threshold value, the processor is in an idle state at the moment, and the log thread can be executed at the moment to realize the output of the log. The processor obtains the result of the priority ordering of all the service parameters and obtains the service parameters with high priority.
S307, an anonymous function corresponding to the service parameter with high priority is obtained, the anonymous function is called to execute an evaluation code to evaluate the service parameter, and an evaluation result is obtained.
Optionally, each log thread may correspond to an anonymous function, so that an anonymous function corresponding to a service parameter with a high priority may be obtained first to execute an evaluation code encapsulated by the anonymous function, and execute the evaluation code, and after the evaluation code runs, evaluation processing may be performed according to the service parameter with the high priority, and an evaluation result may be obtained.
And S308, saving the evaluation result.
Optionally, in order to facilitate later debugging or troubleshooting of errors, the evaluation result, that is, the output log, may also be stored in a designated local location or in a server.
Referring to fig. 4, fig. 4 is a schematic structural diagram of a log output device according to an embodiment of the present disclosure.
As shown in fig. 4, the log output apparatus 400 includes:
the service execution module 401 is configured to obtain a service statement and execute the service statement in the first service environment.
A service environment establishing module 402, configured to trigger a log output statement, establish a second service environment, and package an evaluation code for the service statement into the second service environment; the evaluation code is used to evaluate the business statement and log the output.
And a service continuing execution module 403, configured to return to the first service environment and continue to execute the service statement in the first service environment.
Referring to fig. 5, fig. 5 is a schematic structural diagram of a log output device according to another embodiment of the present application.
As shown in fig. 5, the log output device 500 includes:
the service execution module 501 is configured to obtain a service statement and execute the service statement in the first service environment.
A queue establishing module 502, configured to trigger a log output statement, and establish at least one asynchronous queue as a second service environment; the second service environment is different from the first service environment, and the operation priority of the second service environment is smaller than that of the first service environment.
An evaluation code obtaining module 503, configured to obtain a service type corresponding to the service statement, and obtain an evaluation code corresponding to the service type.
A first encapsulation module 504 for invoking an anonymous function to encapsulate the evaluation code into the second business environment.
And a service continuing execution module 505, configured to return to the first service environment, and continue to execute the service statement in the first service environment.
The first parameter obtaining module 506 is configured to trigger a parameter evaluation statement and obtain a service parameter corresponding to the service statement.
The first evaluation result obtaining module 507 is configured to call an anonymous function in the second service environment to execute an evaluation code to evaluate the service parameter, and obtain an evaluation result.
A first evaluation result saving module 508 for saving the evaluation result.
Referring to fig. 6, fig. 6 is a schematic structural diagram of a log output device according to another embodiment of the present application.
As shown in fig. 6, the log output device 600 includes:
the service execution module 601 is configured to obtain a service statement and execute the service statement in the first service environment.
A thread establishing module 602, configured to trigger a log output statement, and establish at least one log thread as a second service environment; wherein the second service environment is different from the first service environment.
Optionally, the second service environment includes a plurality of log threads, and each log thread in at least one log thread corresponds to an anonymous function; wherein the anonymity function is used to encapsulate evaluation code for the business statement into the second business context.
A second packaging module 603, configured to package the evaluation code for the business statement into a second business environment; the evaluation code is used to evaluate the business statement and log the output.
And a business continuing execution module 604, configured to return to the first business environment and continue to execute the business statement in the first business environment.
And the sorting module 605 is configured to trigger the parameter evaluation statements, obtain the service parameters corresponding to the service statements, and perform priority sorting on the service parameters according to a preset rule.
A second parameter obtaining module 606, configured to obtain a utilization rate of the processor, and if the utilization rate of the processor is smaller than a utilization rate threshold, obtain a service parameter with a high priority.
The second evaluation result obtaining module 607 is configured to obtain an anonymous function corresponding to the service parameter with the high priority, call the anonymous function to execute an evaluation code to evaluate the service parameter, and obtain an evaluation result.
And a second evaluation result saving module 608 for saving the evaluation result.
In an embodiment of the present application, a log output apparatus includes: the service execution module is used for acquiring service statements and executing the service statements in a first service environment; the service environment establishing module is used for triggering the log output statement, establishing a second service environment and packaging the evaluation code aiming at the service statement into the second service environment; the evaluation code is used for evaluating the business statement and outputting a log; and the business continuous execution module is used for returning to the first business environment and continuously executing the business statement in the first business environment. When the business statement is executed in the first business environment and the log related to the business statement needs to be output, a second business environment can be established, and the log output of the business statement is executed in the second business environment.
Embodiments of the present application also provide a computer storage medium storing a plurality of instructions adapted to be loaded by a processor and to perform the steps of the method according to any of the above embodiments.
Referring to fig. 7, fig. 7 is a schematic structural diagram of a terminal according to an embodiment of the present disclosure. As shown in fig. 7, the terminal 700 may include: at least one processor 701, at least one network interface 704, a user interface 703, memory 705, at least one communication bus 702.
Wherein a communication bus 702 is used to enable connective communication between these components.
The user interface 703 may include a Display screen (Display) and a Camera (Camera), and the optional user interface 703 may also include a standard wired interface and a standard wireless interface.
The network interface 704 may optionally include a standard wired interface, a wireless interface (e.g., WI-FI interface), among others.
Processor 701 may include one or more processing cores, among other things. The processor 701 connects various parts within the overall terminal 700 using various interfaces and lines, and performs various functions of the terminal 700 and processes data by executing or executing instructions, programs, code sets, or instruction sets stored in the memory 705, as well as calling data stored in the memory 705. Alternatively, the processor 701 may be implemented in hardware using at least one of Digital Signal Processing (DSP), Field-Programmable gate array (FPGA), and Programmable Logic Array (PLA). The processor 701 may integrate one or a combination of a Central Processing Unit (CPU), a Graphics Processing Unit (GPU), a modem, and the like. Wherein, the CPU mainly processes an operating system, a user interface, an application program and the like; the GPU is used for rendering and drawing the content required to be displayed by the display screen; the modem is used to handle wireless communications. It is understood that the modem may not be integrated into the processor 701, and may be implemented by a single chip.
The Memory 705 may include a Random Access Memory (RAM) or a Read-Only Memory (ROM). Optionally, the memory 705 includes a non-transitory computer-readable medium. The memory 705 may be used to store instructions, programs, code sets, or instruction sets. The memory 705 may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for at least one function (such as a touch function, a sound playing function, an image playing function, etc.), instructions for implementing the various method embodiments described above, and the like; the storage data area may store data and the like referred to in the above respective method embodiments. The memory 705 may optionally be at least one memory device located remotely from the processor 701. As shown in fig. 7, the memory 705, which is a kind of computer storage medium, may include therein an operating system, a network communication module, a user interface module, and a log output instruction.
In the terminal 700 shown in fig. 7, the user interface 703 is mainly used to provide an input interface for a user to obtain data input by the user; and the processor 701 may be configured to call the log output instruction stored in the memory 705, and specifically perform the following operations:
acquiring a business statement, and executing the business statement in a first business environment;
triggering a log output statement, establishing a second service environment, and packaging an evaluation code aiming at the service statement into the second service environment; the evaluation code is used for evaluating the business statement and outputting a log;
and returning to the first business environment, and continuing to execute the business statement in the first business environment.
In an embodiment, when the processor 701 executes the trigger log output statement and establishes the second service environment, the following operations are specifically performed:
triggering a log output statement, and establishing at least one asynchronous queue as a second service environment; the second service environment is different from the first service environment, and the operation priority of the second service environment is smaller than that of the first service environment.
In one embodiment, the processor 701 performs the following operations in particular when executing the encapsulation of the evaluation code for the business statement into the second business environment:
acquiring a service type corresponding to a service statement, and acquiring an evaluation code corresponding to the service type;
calling an anonymous function encapsulates the evaluation code into the second business environment.
In one embodiment, after the execution returns to the first service environment and continues to execute the service statement in the first service environment, the processor 701 further specifically performs the following operations:
triggering a parameter evaluation statement to acquire a service parameter corresponding to the service statement;
calling an anonymous function to execute an evaluation code in a second service environment to evaluate the service parameter and obtain an evaluation result;
and saving the evaluation result.
In one embodiment, the processor 701, when executing the trigger log output statement and establishing the second service environment, specifically performs the following operations:
triggering a log output statement, and establishing at least one log thread as a second service environment; wherein the second service environment is different from the first service environment.
Optionally, the second service environment includes a plurality of log threads, and each log thread in at least one log thread corresponds to an anonymous function; wherein the anonymity function is used to encapsulate evaluation code for the business statement into the second business context.
In one embodiment, after the processor 701 returns execution to the first service environment and continues to execute the service statement in the first service environment, the following operations are specifically performed:
triggering parameter evaluation statements, acquiring service parameters corresponding to all service statements, and performing priority ordering on all service parameters according to a preset rule;
acquiring the utilization rate of a processor, and acquiring a service parameter with high priority if the utilization rate of the processor is less than a utilization rate threshold value;
obtaining an anonymous function corresponding to a service parameter with a high priority, calling the anonymous function to execute an evaluation code to evaluate the service parameter, and obtaining an evaluation result;
and saving the evaluation result.
In the several embodiments provided in the present application, it should be understood that the disclosed apparatus and method may be implemented in other ways. For example, the above-described apparatus embodiments are merely illustrative, and for example, a division of modules is merely a division of logical functions, and an actual implementation may have another division, for example, a plurality of modules or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or modules, and may be in an electrical, mechanical or other form.
Modules described as separate parts may or may not be physically separate, and parts displayed as modules may or may not be physical modules, may be located in one place, or may be distributed on a plurality of network modules. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the present embodiment.
In addition, functional modules in the embodiments of the present application may be integrated into one processing module, or each of the modules may exist alone physically, or two or more modules are integrated into one module. The integrated module can be realized in a hardware mode, and can also be realized in a software functional module mode.
The integrated module, if implemented in the form of a software functional module and sold or used as a separate product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present application may be substantially implemented or contributed to by the prior art, or all or part of the technical solution may be embodied in 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 of 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 should be noted that, for the sake of simplicity, the above-mentioned method embodiments are described as a series of acts or combinations, but those skilled in the art should understand that the present application is not limited by the described order of acts, as some steps may be performed in other orders or simultaneously according to the present application. Further, those skilled in the art should also appreciate that the embodiments described in the specification are preferred embodiments and that the acts and modules referred to are not necessarily required in this application.
In the above embodiments, the descriptions of the respective embodiments have respective emphasis, and for parts that are not described in detail in a certain embodiment, reference may be made to related descriptions of other embodiments.
In view of the above description of the log output method, apparatus, storage medium and terminal provided by the present application, those skilled in the art will appreciate that there are variations in the specific implementation and application scope according to the concepts of the embodiments of the present application, and in summary, the content of the present specification should not be construed as a limitation to the present application.

Claims (10)

1. A method of log output, the method comprising:
acquiring a business statement, and executing the business statement in a first business environment;
triggering a log output statement, establishing a second service environment, and packaging an evaluation code aiming at the service statement into the second service environment; the evaluation code is used for evaluating the business statement and outputting a log;
and returning to the first business environment, and continuing to execute the business statement in the first business environment.
2. The method of claim 1, wherein the second business environment comprises at least one asynchronous queue; and the second service environment is different from the first service environment, and the running priority of the second service environment is smaller than that of the first service environment.
3. The method of claim 2, wherein encapsulating evaluation code for the business statement into the second business environment comprises:
acquiring a service type corresponding to the service statement, and acquiring an evaluation code corresponding to the service type;
calling an anonymous function to encapsulate the evaluation code into the second business environment.
4. The method of claim 3, wherein after returning to the first business environment and continuing to execute the business statement in the first business environment, further comprising:
triggering a parameter evaluation statement to acquire a service parameter corresponding to the service statement;
calling the anonymous function in the second service environment to execute the evaluation code to evaluate the service parameter and obtain an evaluation result;
and saving the evaluation result.
5. The method of claim 1, wherein the second business environment comprises at least one log thread; wherein the second business environment is different from the first business environment.
6. The method of claim 5, wherein each of the at least one log thread corresponds to an anonymity function; wherein the anonymity function is to encapsulate evaluation code for a business statement into the second business context.
7. The method of claim 6, wherein said returning to said first business environment and continuing to execute said business statement in said first business environment comprises:
triggering parameter evaluation statements, acquiring service parameters corresponding to all service statements, and performing priority ordering on all service parameters according to a preset rule;
acquiring the utilization rate of a processor, and if the utilization rate of the processor is smaller than a utilization rate threshold value, acquiring the service parameter with high priority;
obtaining the anonymous function corresponding to the service parameter with high priority, calling the anonymous function to execute the evaluation code to evaluate the service parameter, and obtaining an evaluation result;
and saving the evaluation result.
8. A log output apparatus, characterized in that the apparatus comprises:
the service execution module is used for acquiring a service statement and executing the service statement in a first service environment;
the service environment establishing module is used for triggering a log output statement, establishing a second service environment and packaging an evaluation code aiming at the service statement into the second service environment; the evaluation code is used for evaluating the business statement and outputting a log;
and the business continuous execution module is used for returning to the first business environment and continuously executing the business statement in the first business environment.
9. A computer storage medium storing a plurality of instructions adapted to be loaded by a processor and to perform the steps of the method according to any of claims 1 to 7.
10. A terminal comprising a memory, a processor and a computer program stored on the memory and executable on the processor, the processor when executing the program implementing the steps of the method according to any of claims 1 to 7.
CN201910913850.3A 2019-09-25 2019-09-25 Log output method and device, storage medium and terminal Pending CN110795303A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910913850.3A CN110795303A (en) 2019-09-25 2019-09-25 Log output method and device, storage medium and terminal

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910913850.3A CN110795303A (en) 2019-09-25 2019-09-25 Log output method and device, storage medium and terminal

Publications (1)

Publication Number Publication Date
CN110795303A true CN110795303A (en) 2020-02-14

Family

ID=69439779

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910913850.3A Pending CN110795303A (en) 2019-09-25 2019-09-25 Log output method and device, storage medium and terminal

Country Status (1)

Country Link
CN (1) CN110795303A (en)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107330034A (en) * 2017-06-26 2017-11-07 百度在线网络技术(北京)有限公司 A kind of log analysis method and device, computer equipment, storage medium
CN107491382A (en) * 2017-07-21 2017-12-19 北京京东尚科信息技术有限公司 Log-output method and device
CN108322350A (en) * 2018-02-27 2018-07-24 阿里巴巴集团控股有限公司 Business monitoring method and device and electronic equipment
CN108599973A (en) * 2018-01-05 2018-09-28 阿里巴巴集团控股有限公司 A kind of daily record correlating method, device and equipment

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107330034A (en) * 2017-06-26 2017-11-07 百度在线网络技术(北京)有限公司 A kind of log analysis method and device, computer equipment, storage medium
CN107491382A (en) * 2017-07-21 2017-12-19 北京京东尚科信息技术有限公司 Log-output method and device
CN108599973A (en) * 2018-01-05 2018-09-28 阿里巴巴集团控股有限公司 A kind of daily record correlating method, device and equipment
CN108322350A (en) * 2018-02-27 2018-07-24 阿里巴巴集团控股有限公司 Business monitoring method and device and electronic equipment

Similar Documents

Publication Publication Date Title
CN108512710B (en) Test method based on test tool and test tool
EP3848805A1 (en) Warm start technique for cloud-hosted functions
CN110750255B (en) Applet rendering method and device
CN107707986B (en) A kind of method and device for simulating barrage message in the exploitation of live streaming software
CN107526645A (en) A kind of communication optimization method and system
CN110781180B (en) Data screening method and data screening device
US20200073737A1 (en) Invoking enhanced plug-ins and creating workflows having a series of enhanced plug-ins
KR20210061984A (en) Method and apparatus for testing a dialogue platform, electronic device and storage medium
CN106842982A (en) One kind is based on many software collaboration analogue systems of VBA
CN116662039B (en) Industrial information parallel detection method, device and medium based on shared memory
CN110795303A (en) Log output method and device, storage medium and terminal
CN114748873B (en) Interface rendering method, device, equipment and storage medium
CN111506393A (en) ARM-based virtualization device and use method thereof
CN115858556A (en) Data processing method and device, storage medium and electronic equipment
CN115934378A (en) Service data processing method and device, electronic equipment and storage medium
CN114881235A (en) Inference service calling method and device, electronic equipment and storage medium
CN110412947A (en) Industrial equipment control method and its system, storage equipment
CN110825605B (en) Method, device, equipment and storage medium for simulating user operation
CN111552572A (en) Task processing method, readable storage medium and electronic device
CN112084099A (en) Method, device and equipment for obtaining alarm state value based on host and storage medium
US9800692B2 (en) Expression based declarative data service execution chaining
CN114860455B (en) Request processing method, device, equipment and storage medium
CN111813407A (en) Game development method, game running device and electronic equipment
CN114116095B (en) Input method, input device, electronic equipment, medium and product
CN113687870B (en) Terminal operation optimization method and device, storage medium and terminal

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination