CN109218407B - Code management and control method based on log monitoring technology and terminal equipment - Google Patents

Code management and control method based on log monitoring technology and terminal equipment Download PDF

Info

Publication number
CN109218407B
CN109218407B CN201810920817.9A CN201810920817A CN109218407B CN 109218407 B CN109218407 B CN 109218407B CN 201810920817 A CN201810920817 A CN 201810920817A CN 109218407 B CN109218407 B CN 109218407B
Authority
CN
China
Prior art keywords
log
terminal
point
application program
monitored
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.)
Active
Application number
CN201810920817.9A
Other languages
Chinese (zh)
Other versions
CN109218407A (en
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.)
Ping An Puhui Enterprise Management Co Ltd
Original Assignee
Ping An Puhui Enterprise Management 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 Ping An Puhui Enterprise Management Co Ltd filed Critical Ping An Puhui Enterprise Management Co Ltd
Priority to CN201810920817.9A priority Critical patent/CN109218407B/en
Publication of CN109218407A publication Critical patent/CN109218407A/en
Application granted granted Critical
Publication of CN109218407B publication Critical patent/CN109218407B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/02Protocols based on web technology, e.g. hypertext transfer protocol [HTTP]
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/362Software debugging
    • G06F11/3644Software debugging by instrumenting at runtime
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/50Network services
    • H04L67/56Provisioning of proxy services

Abstract

The invention is suitable for the technical field of data processing, and provides a code control method based on a log monitoring technology, a terminal device and a computer readable storage medium, wherein the code control method comprises the following steps: the method comprises the steps of building a hypertext transfer protocol (HTTP) server and a log service in the HTTP server, obtaining a server address and a port number in the built HTTP server, and obtaining a log identifier in the built log service; configuring a server address and a port number, and taking an HTTP server as a proxy server of a terminal; starting the log service, determining the log position of an application program on the terminal through the log identifier, and setting a log point at the log position; and when the terminal runs the application program, obtaining the running log of the application program at the log point through the log service, and outputting the running log. The method and the device realize the management and control of the appointed codes of the application program based on the log monitoring technology, and improve the pertinence of the code management and control.

Description

Code management and control method based on log monitoring technology and terminal equipment
Technical Field
The invention belongs to the technical field of data processing, and particularly relates to a code management and control method based on a log monitoring technology, a terminal device and a computer readable storage medium.
Background
With the development of science and technology, mobile terminals and fixed terminals applying terminal technology have gradually become popular among thousands of households, and become necessities in daily life of people. The terminal is often installed with an application program to implement a specific function, and in the early development of the application program, developers often need to monitor the running process of the application program and locate and solve problems when problems occur in the running process.
In the prior art, the running log of the application program in the running process is mainly obtained through a log tool so as to monitor the application program, but different log tools are required to be used for different operating systems of a terminal where the application program is located. Such as for IOS systems, charles tools are used; for the android system, a Fidder tool is used. Moreover, the log tool can only capture information related to the data request, and cannot acquire the running log of the designated code of the application program according to the requirement of a developer. In summary, the conventional code management method cannot be generally applied to various operating systems, and cannot manage the specified code in the application program.
Disclosure of Invention
In view of this, embodiments of the present invention provide a code management and control method based on a log monitoring technology, a terminal device, and a computer-readable storage medium, so as to solve the problem in the prior art that code management and control is low in applicability to an operating system and cannot manage and control a specified code.
A first aspect of an embodiment of the present invention provides a code management and control method based on a log monitoring technology, including:
the method comprises the steps of building a hypertext transfer protocol (HTTP) server and a log service in the HTTP server, obtaining a server address and a port number in the built HTTP server, and obtaining a log identifier in the built log service, wherein the log identifier is used for determining a log position to be monitored by a log to be set;
configuring the server address and the port number, and taking the HTTP server as a proxy server of the terminal;
starting the log service, determining the log position of an application program on the terminal through the log identifier, and setting a log point at the log position;
and when the terminal runs the application program, obtaining the running log of the application program at the log point through the log service, and outputting the running log.
A second aspect of the embodiments of the present invention provides a terminal device, where the terminal device includes a memory, a processor, and a computer program stored in the memory and executable on the processor, and the processor implements the following steps when executing the computer program:
the method comprises the steps of building a hypertext transfer protocol (HTTP) server and a log service in the HTTP server, obtaining a server address and a port number in the built HTTP server, and obtaining a log identifier in the built log service, wherein the log identifier is used for determining a log position to be monitored by a log to be set;
configuring the server address and the port number, and taking the HTTP server as a proxy server of the terminal;
starting the log service, determining the log position of an application program on the terminal through the log identifier, and setting a log point at the log position;
and when the terminal runs the application program, obtaining the running log of the application program at the log point through the log service, and outputting the running log.
A third aspect of embodiments of the present invention provides a computer-readable storage medium storing a computer program, which is executed by a processor to perform the following steps.
The method comprises the steps of building a hypertext transfer protocol (HTTP) server and a log service in the HTTP server, obtaining a server address and a port number in the built HTTP server, and obtaining a log identifier in the built log service, wherein the log identifier is used for determining a log position to be monitored by a log to be set;
configuring the server address and the port number, and taking the HTTP server as a proxy server of the terminal;
starting the log service, determining the log position of an application program on the terminal through the log identifier, and setting a log point at the log position;
and when the terminal runs the application program, obtaining the running log of the application program at the log point through the log service, and outputting the running log.
Compared with the prior art, the embodiment of the invention has the following beneficial effects:
according to the method and the device, the HTTP server and the log service are set up on the terminal equipment for monitoring, such as a computer, the HTTP server is set as the proxy server of the terminal to be monitored, the log service is started in the HTTP server, the log point setting in the application program of the terminal to be monitored is achieved, and when the application program is executed, the HTTP server can obtain the running log of the application program at the log point through the log service.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings needed to be used in the embodiments or the prior art descriptions will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without inventive exercise.
Fig. 1 is a flowchart illustrating an implementation of a code management and control method based on a log monitoring technology according to an embodiment of the present invention;
fig. 2 is a flowchart of an implementation of a code management and control method based on a log monitoring technology according to a second embodiment of the present invention;
fig. 3 is a flowchart of an implementation of a code management and control method based on a log monitoring technology according to a third embodiment of the present invention;
fig. 4 is a flowchart of an implementation of a code management and control method based on a log monitoring technology according to a fourth embodiment of the present invention;
fig. 5 is a flowchart of an implementation of a code management and control method based on a log monitoring technology according to a fifth embodiment of the present invention;
FIG. 6 is a diagram of a log point record table according to a sixth embodiment of the present invention;
fig. 7 is a block diagram of a terminal device according to a seventh embodiment of the present invention;
fig. 8 is a schematic diagram of a terminal device according to an eighth embodiment of the present invention.
Detailed Description
In the following description, for purposes of explanation and not limitation, specific details are set forth, such as particular system structures, techniques, etc. in order to provide a thorough understanding of the embodiments of the invention. It will be apparent, however, to one skilled in the art that the present invention may be practiced in other embodiments that depart from these specific details. In other instances, detailed descriptions of well-known systems, devices, circuits, and methods are omitted so as not to obscure the description of the present invention with unnecessary detail.
The method comprises the steps of building a hypertext transfer protocol (HTTP) server and a log service in the HTTP server, obtaining a server address and a port number in the built HTTP server, obtaining a log identifier in the built log service, wherein the log identifier is used for determining a log position to be monitored by a log to be set, configuring the server address and the port number, using the HTTP server as a proxy server of a terminal, starting the log service, determining the log position of an application program on the terminal through the log identifier in the log service, setting a log point at the log position, obtaining an operation log of the application program at the log point through the log service when the terminal operates the application program, and outputting the operation log.
In order to explain the technical means of the present invention, the following description will be given by way of specific examples.
Fig. 1 shows an implementation flow of a code management and control method based on a log monitoring technology according to an embodiment of the present invention, which is detailed as follows:
in S101, a hypertext transfer protocol (HTTP) server and a log service in the HTTP server are built, a server address and a port number in the built HTTP server are obtained, a log identifier in the built log service is obtained, and the log identifier is used for determining a log position to be monitored by a log to be set.
Compared with the traditional method such as a Fidder tool, which can only capture information (namely a data packet related to a request) related to a HyperText Transfer Protocol (HTTP) request in an application program of a terminal and cannot capture running information of underlying codes in the application program, such as JS (JavaScript) functions, native functions and the like, in the embodiment of the invention, an HTTP server is firstly built on a terminal device for monitoring, and the server address and the port number of the built HTTP server are obtained, wherein the terminal device can be a computer operated by a user. Optionally, the HTTP server is built based on node. Js is a lightweight Javascript operating environment, and because the node is based on an event-driven, non-blocking I/O model, the node has the characteristics of lightweight and high efficiency.
In the embodiment of the invention, a log service is also built in the HTTP server, wherein the log service refers to program logic for log monitoring, when the log service is started, the operation of log monitoring is started, and when the log service is closed, the log monitoring is interrupted. The log service establishment mainly comprises two aspects, wherein the first aspect is to configure a log identifier, the log identifier is used for determining the log position of a breakpoint required to be set in an application program of a terminal to be monitored, and the log identifier can be specifically configured according to actual requirements; the second aspect is to configure an output mode of the operation log, and after the operation log on the terminal application is acquired, the operation log needs to be output, the output mode includes, but is not limited to, output at a console (console) of the HTTP server and file output, and the file output refers to adding the operation log to a specific log file for output, which will be described in detail later. In order to distinguish the terminal device from the terminal to be monitored, hereinafter, the terminal device to be monitored is named as a user equipment, and the terminal is specifically indicated as the monitored terminal, and may be a mobile terminal or a fixed terminal, etc.
In S102, the server address and the port number are configured, and the HTTP server is used as a proxy server of the terminal.
The established HTTP server and the log service therein are the main bodies for acquiring the logs, and the terminal is the main body for outputting the logs. After the configuration is completed, the HTTP server becomes a proxy server of the terminal, and when the terminal issues a network request to the outside, the HTTP server must issue the network request to the outside by proxy of the HTTP server, and send a result returned by the outside according to the network request to the terminal. It should be noted that the number of the terminals is not limited in the embodiment of the present invention, that is, one or more terminals may be provided.
In S103, the log service is started, the log location of the application program on the terminal is determined by the log identifier, and a log point is set at the log location.
In a conventional method for managing and controlling codes of a terminal, different log tools are generally used for monitoring according to an operating system used by the terminal, for example, if the terminal is an IOS system, a charles log tool is used for monitoring logs; for example, if the terminal is an android system, a folder log tool is used for monitoring. On this basis, if the charles logging tool is used to monitor the android system, monitoring may fail because the logging tool is incompatible with the operating system. Therefore, in the embodiment of the present invention, after configuring the HTTP server as a proxy server of the terminal, the log service in the HTTP is started to determine the log position in the engineering code of the application program according to the log identifier in the log service, and the execution of the log service is not limited to the operating system of the terminal, where the engineering code refers to all the underlying codes of the application program. For example, if the log is identified by a function name onCreate (), all onCreate () functions are looked up in the code of the application and the line of code where the onCreate () function occurs (e.g., line 33) is taken as the log location. And after the log position is determined, setting a log point at the log position, wherein the set log point has a log output function. The log point is similar to the breakpoint in the Android Studio development platform, but in the embodiment of the invention, the log point is automatically set by log service, and the log point is not manually searched and set in the log position as in the Android Studio. In addition, the log identifier may be a specific function name, a variable name, a specific code line, and the like, which is not limited in the embodiment of the present invention. It should be noted that, in order to improve security, there may be a verification process for the interface domain name address in the application program, so that the log service of the HTTP server may be added to the white list of the application program in advance, thereby preventing the execution of log monitoring from being affected by verification.
In S104, when the terminal runs the application program, the log service obtains the running log of the application program at the log point, and outputs the running log.
After the log point setting is completed, the application program is operated on the terminal, and in the operation process, the log service captures the operation log generated by the log point in real time and outputs the operation log, wherein the output mode can be directly output to a console of the HTTP server or can be output by integrating the operation log into a log file.
Optionally, a log cache is set, the running logs generated in real time are stored in the log cache, and when the capacity of the log cache reaches a preset threshold, the running logs in the log cache are output. In some scenes with low real-time requirements, the running logs generated by the application program at the log point can be stored in a pre-log cache, and when the capacity of the log cache reaches a threshold (such as 8000 bytes), the running logs in the log cache are output to a console or added to a log file for output, so that the monitoring pressure of the HTTP server is reduced.
Alternatively, if a plurality of functions are loaded on the application program, the plurality of functions are executed, and an execution log corresponding to each function is acquired and output. In an actual application scenario, multiple functions generally exist on an application, for example, the application for network communication includes functions of adding a buddy, initiating a session, and joining a group. Therefore, in the embodiment of the invention, the plurality of functions are sequentially operated, the operation log corresponding to each function is obtained and finally output, and the applicability of log monitoring in a test scene is improved.
As can be seen from the embodiment shown in fig. 1, in the embodiment of the present invention, an HTTP server and a log service in the HTTP server are established, a server address and a port number of the HTTP server are configured at a terminal that needs to be monitored, the HTTP server is used as a proxy server of the terminal, then the log service in the HTTP server is started, a log position of an application program on the terminal is determined by a log identifier in the log service, and a log point is set at the log position.
Fig. 2 is a diagram illustrating an implementation method obtained by refining a process of configuring a server address and a port number based on the first embodiment of the present invention. An embodiment of the present invention provides an implementation flowchart of a code management and control method based on a log monitoring technology, and as shown in fig. 2, the code management and control method based on the log monitoring technology may include the following steps:
in S201, a wireless network is created and the terminal is connected to the wireless network.
Since the HTTP server is configured as a proxy server of the terminal on the premise that the HTTP server and the terminal belong to the same network, in the embodiment of the present invention, a wireless network (on the premise that the user equipment has a wireless network card) can be created by the user equipment where the HTTP server is located, and the terminal is connected to the wireless network. The wireless network is preferably a WiFi network.
In S202, connection information including the server address and the port number is generated, and the connection information is sent to the terminal through the wireless network at preset time intervals, so that the terminal performs proxy setting based on the connection information.
When a connected terminal appears in a wireless network created by user equipment, the user equipment generates connection information including a server address and a port number of an HTTP server, and sets the connection information to be sent to the terminal connected to the wireless network through the wireless network at preset time intervals (such as 1 minute). In the embodiment of the invention, the first script file can be preset in the user equipment, and the connection information is sent to the terminal in the wireless network once at every preset time interval by executing the first script file. By executing the preset first script file, the operation of configuring the sending process when the terminal connected with the wireless network appears is omitted. Similarly, configuring a second script file at the terminal, and executing the second script file to open an HTTP proxy option of a wireless network connected on the terminal after the terminal receives the connection information, and configuring a server address and a port number in the connection information in the HTTP proxy option to complete proxy server setting.
As can be seen from the embodiment shown in fig. 2, in the embodiment of the present invention, a wireless network is created in the user equipment, the terminal is added to the wireless network of the user equipment, connection information including a server address and a port number is generated in the user equipment, and the connection information is sent to the terminal through the wireless network at preset time intervals, so that the terminal performs proxy setting based on the connection information, thereby reducing complexity of operation and improving convenience of proxy server configuration.
Fig. 3 is a diagram showing an implementation method obtained by refining a process of sending the connection information to the terminal through the wireless network at preset time intervals on the basis of the second embodiment of the present invention and on the basis of the existence of a plurality of terminals. An embodiment of the present invention provides an implementation flowchart of a code management and control method based on a log monitoring technology, and as shown in fig. 3, the code management and control method based on the log monitoring technology may include the following steps:
in S301, a preset identifier to be monitored is obtained, where the identifier to be monitored is used to indicate the terminal to be monitored.
In an actual application scenario, there may be a case where log monitoring is performed on multiple terminals at the same time, for example, log monitoring is performed on an application program on a terminal equipped with an IOS system and an application program on a terminal equipped with an android system at the same time. Moreover, there may be a case where a plurality of terminals connected to a wireless network created by a user equipment need log monitoring, and another part of terminals do not need log monitoring. Therefore, in the embodiment of the invention, the identifier to be monitored is obtained, and the terminal which needs log monitoring in the wireless network is determined according to the identifier to be monitored, wherein the identifier to be monitored can be pre-stored in a local or remote database of the user equipment, and when the wireless network is detected to be started, the identifier to be monitored is automatically obtained. The format of the identifier to be monitored can be the name of the terminal, or a machine identification code or other forms of the terminal, and is determined according to the actual application scenario.
In S302, the terminal corresponding to the identifier to be monitored is determined among the plurality of terminals connected to the wireless network, and the terminal corresponding to the identifier to be monitored is added to a terminal set to be monitored.
The user equipment identifies a plurality of terminals connected with a wireless network one by one, and if the identifier to be monitored is the name of the terminal, the terminal with the name matched with the identifier to be monitored is added to a terminal set to be monitored; and if the identifier to be monitored is a machine identification code, acquiring the machine identification codes of the plurality of terminals one by one, and adding the terminal corresponding to the machine identification code matched with the identifier to be monitored to the terminal set to be monitored. It is worth mentioning that the terminal set to be monitored is only used for indicating a classification relationship, and not a specific storage structure. In addition, the process in step S302 may also be configured to be executed once every preset second interval (e.g., 5 minutes), so as to facilitate identification of a terminal newly joining the wireless network.
In S303, the connection information is sent to the terminals in the terminal set to be monitored at intervals, and the to-be-monitored identifier corresponding to the terminal that has received the connection information is updated to the proxied identifier.
After determining the terminal needing log monitoring, sending the connection information including the server address and the port number to the terminal in the terminal set to be monitored at intervals. On the basis, because the wireless network may fluctuate or be limited by the performance of the terminal, the connection information may be passively interrupted in the transmission process, so whether the connection information is successfully sent to the terminal is checked, and if the connection information is not successfully sent, the connection information is automatically sent again or a user is prompted to manually send the connection information; if the connection information is successfully sent, the identifier to be monitored, corresponding to the terminal receiving the connection information, in the user equipment is updated to be a proxy identifier, the proxy identifier indicates that the corresponding terminal has completed proxy server setting, and when the connection information is sent next time, if the user equipment detects that the terminal corresponding to the proxy identifier exists, the connection information is not sent to the terminal, so that resources are saved.
As can be seen from the embodiment shown in fig. 3, in the embodiment of the present invention, by obtaining a preset identifier to be monitored, which is used for indicating the terminal to be monitored, determining a terminal corresponding to the identifier to be monitored among a plurality of terminals connected to a wireless network, adding the determined terminal to a terminal set to be tested, then sending connection information to the terminals in the terminal set to be tested at intervals, and updating the identifier to be tested corresponding to the terminal that has received the connection information to an agent identifier, accuracy of determining the terminal that needs to perform code management and control is improved, and resource waste caused by missending of the connection information is prevented.
Fig. 4 is a diagram showing an implementation method obtained by refining a process of determining a log location of an application program on a terminal through a log identifier and setting a log point at the log location based on the first embodiment of the present invention. As shown in fig. 4, the implementation flowchart of the code management and control method based on the log monitoring technology provided in the embodiment of the present invention may include the following steps:
in S401, a log point record table is obtained, where the log point record table includes a plurality of log identifiers and a log point level corresponding to each log identifier.
In an actual application scenario, there are often situations in which log monitoring needs to be performed on multiple functions or multiple variables in the engineering code of an application. In this embodiment, a log point record table is obtained, which can be set by a user, and a schematic diagram of the log point record table is shown in fig. 6, a log point level corresponding to a log identifier OnCreate is WARN, a log point level corresponding to a log identifier OnStart is ERROR, and a log point level corresponding to a log identifier OnResume is ERROR. The log point record table comprises a plurality of log identifications and log point grades corresponding to the log identifications, wherein each row of the log point record table comprises one log identification and the log point grade corresponding to the log identification, and the log identifications and the log point grades are distinguished in a field (column) mode. For convenience of explanation, the log levels are exemplified based on log4j, and in log4j, the log levels are, in order from low to high in severity, DEBUG, INFO, WARN, ERROR, and false, where DEBUG indicates information related to debugging, INFO is used to feed back a current state, WARN indicates a situation with potential harm, similar to a warning, ERROR indicates an erroneous event but still can support the application program to run, false indicates a severe event that may cause the application program to stop, and the log point level may be any one of the log levels and is determined according to an actual application scenario. It should be noted that the logpoint record table only indicates that the log id and the logpoint level are stored in a table structure, and the format of the logpoint record table may be an EXCEL table, a database table, or a Comma-Separated Values (CSV) file.
Optionally, if there are a plurality of identical log identifiers in the log point record table, unifying, as the log point level of the plurality of identical log identifiers, the log point level with the lowest severity level among the plurality of log point levels corresponding to the plurality of identical log identifiers. For example, the log point record table may be divided by time periods, and alarms are performed according to different log point levels in different time periods, assuming that the application has an a function, a B function, and a C function, and when the a function, the B function, and the C function are all executed, log monitoring needs to be performed on a certain function, but the importance degrees of the function to the a function, the B function, and the C function are inconsistent, so that when the log point record table is set, there may be a plurality of same log identifiers, but the log point levels corresponding to the same log identifiers are inconsistent, so as to alarm the running log according to different log point levels in different running time periods, where the log point record table is as follows:
onCreate()ERROR
onCreate()WARN
onCreate()WARN
in the above example, the a function of the application program is started in the first operation time period (e.g. 1 point to 2 points), and the operation log is alarmed according to the ERROR level; starting the function B of the application program in a second operation time period (such as 2 to 3 points), and alarming the operation log according to the WARN level; and starting the C function of the application program in a third running time period (such as 3-4 points), and alarming the running log according to the WARN level. However, in actual operation, it is likely that the corresponding function is not strictly started according to the operation time period, for example, the B function of the application program is started from 1 point to 2 points, the B function should perform an alarm at the WARN level, but the log service performs an alarm at the ERROR level in the time period, so that the operation log at the WARN level generated by the log point does not trigger an alarm. Therefore, in the embodiment of the invention, the log point grade with the lowest severity degree in the log point grades corresponding to the same log identifications is determined, the log point grades are uniformly used as the log point grades of the same log identifications, the difference of the log point grades corresponding to the same log identifications in the log point recording list is shielded, and the safety of log alarm operation is improved. In the above example, the severity of WARN is lower than ERROR, so WARN is unified as the log point level of onCreate () log identification as follows:
onCreate()WARN
onCreate()WARN
onCreate()WARN
and after the setting is finished, when any one of the A function, the B function and the C function of the application program is executed, alarming according to the WARN level.
In S402, the log service is executed to set the log point at the log position in the application program corresponding to the plurality of log identifications in the log point record table.
And after the log point record table is acquired, executing log service so as to set log points at log positions corresponding to a plurality of log identifications in the log point record table in the engineering code of the terminal application program. And moreover, the log point grades corresponding to the log points are stored in the local HTTP server of the user equipment, so that subsequent warning is facilitated.
In S403, comparing the log level of the running log with the log point level corresponding to the log point, and giving an alarm according to the comparison result.
In the embodiment of the invention, the user equipment compares the acquired log grade of the running log with the log point grade which is stored locally in the user equipment and corresponds to the log point according to the importance degree, and gives an alarm according to the compared result. Because the application program is provided with a plurality of log points, the log grade of the running log corresponding to each log point is compared with the log point grade corresponding to the log point respectively so as to independently judge the alarm mode adopted by the running log corresponding to each log point. According to the difference of the comparison result, the specific alarm manner is also different, for example, the alarm manner may be by outputting an alarm prompt, and the specific content is described later.
As can be seen from the embodiment shown in fig. 4, in the embodiment of the present invention, a log point record table is obtained, where the log point record table includes a plurality of log identifiers and a log point level corresponding to each log identifier, a log service is executed in a user equipment, so as to set a log point at a log position in an application program corresponding to the plurality of log identifiers in the log point record table, after the setting of the log point is completed, after the application program is run at a terminal, an operation log of the application program at the log point is obtained through the log service of the user equipment, the log level of the operation log is compared with the log point level corresponding to the log point, and an alarm is given according to a comparison result.
Fig. 5 is a diagram illustrating an implementation method obtained by refining the process of alarming according to the comparison result based on the fourth embodiment of the present invention. As shown in fig. 5, the implementation flowchart of the code management and control method based on the log monitoring technology provided in the embodiment of the present invention may include the following steps:
in S501, if the log level of the operation log is higher than or equal to the log point level, the operation log is output to the console of the HTTP server, and an alarm prompt is output.
After the operation logs of the application program at the log points are obtained, if the severity of the log levels of the operation logs is higher than or equal to the log point levels, for example, the log levels of the operation logs are WARN, the log point levels are WARN, or the log levels of the operation logs are ERROR and the log point levels are WARN, the severity of the operation conditions of the log points in the application program is proved to exceed the expectation, the operation logs are output to a control console of an HTTP server, and the user can conveniently and quickly check the operation logs. In addition, an alarm prompt can be generated based on the operation log and output, wherein the alarm prompt can be output to a front-end page of the user equipment or output in a mail, short message and other modes.
In S502, if the log level of the operation log is lower than the log point level, the operation log is stored in a preset address.
If the log level of the running log is lower than the log point level, the running condition of the log point is proved to be in a controllable range, no alarm is given, and the running log is stored to a preset address in the form of a log file, so that the checking of a user on an abnormal running log is not influenced while the running log in a normal state is stored.
As can be seen from the embodiment shown in fig. 5, in the embodiment of the present invention, the log level of the operation log is obtained, the log level is compared with the log point level, which is stored in the user equipment and corresponds to the log point, if the log level is higher than or equal to the log point level, the operation log is output to the console of the HTTP server, and an alarm prompt is output, and if the log level is lower than the log point level, the operation log is stored to the preset address.
It should be understood that, the sequence numbers of the steps in the foregoing embodiments do not imply an execution sequence, and the execution sequence of each process should be determined by its function and inherent logic, and should not constitute any limitation to the implementation process of the embodiments of the present invention.
Fig. 7 shows a block diagram of a terminal device according to an embodiment of the present invention, where the terminal device includes units for executing steps in the embodiment corresponding to fig. 1. Please refer to fig. 1 and fig. 1 for the corresponding description of the embodiment. For convenience of explanation, only the portions related to the present embodiment are shown.
Referring to fig. 7, the terminal device includes:
the building unit 71 is configured to build a hypertext transfer protocol (HTTP) server and a log service in the HTTP server, acquire a server address and a port number in the built HTTP server, and acquire a log identifier in the built log service, where the log identifier is used to determine a log position to be monitored by a log to be set;
a configuration unit 72, configured to configure the server address and the port number, and use the HTTP server as a proxy server of the terminal;
a starting unit 73, configured to start the log service, determine the log position of the application program on the terminal according to the log identifier, and set a log point at the log position;
and the output unit 74 is configured to, when the terminal runs the application program, obtain an operation log of the application program at the log point through the log service, and output the operation log.
Optionally, the configuration unit 72 includes:
a creating unit configured to create a wireless network and connect the terminal to the wireless network;
and the sending unit is used for generating connection information comprising the server address and the port number, and sending the connection information to the terminal through the wireless network at intervals of preset time so as to enable the terminal to perform proxy setting based on the connection information.
Optionally, there are a plurality of terminals, and the sending unit includes:
the system comprises an acquisition unit, a monitoring unit and a monitoring unit, wherein the acquisition unit is used for acquiring a preset identifier to be monitored, and the identifier to be monitored is used for indicating the terminal to be monitored;
an adding unit, configured to determine the terminal corresponding to the identifier to be monitored among the multiple terminals connected to the wireless network, and add the terminal corresponding to the identifier to be monitored to a terminal set to be monitored;
and the updating unit is used for sending the connection information to the terminals in the terminal set to be monitored at intervals, and updating the identifiers to be monitored corresponding to the terminals which have received the connection information into the proxied identifiers.
Optionally, the starting unit 73 includes:
a log point record table acquiring unit, configured to acquire a log point record table, where the log point record table includes a plurality of log identifiers and a log point level corresponding to each log identifier;
the execution unit is used for executing the log service so as to set the log points at the log positions corresponding to a plurality of log identifications in the log point record table in an application program;
the output unit 74 further includes:
and the alarm unit is used for comparing the log grade of the running log with the log point grade corresponding to the log point and giving an alarm according to the comparison result.
Optionally, the alarm unit includes:
the alarm subunit is configured to output the operation log to a console of the HTTP server and output an alarm prompt if the log level of the operation log is higher than or equal to the log point level;
and the storage unit is used for storing the running log to a preset address if the log grade of the running log is lower than the log point grade.
Therefore, the terminal device provided by the embodiment of the invention builds the HTTP server and the log service, and dotting is performed in the application program of the terminal through the log service, so that the pertinence and the applicability of code management and control are improved.
Fig. 8 is a schematic diagram of a terminal device according to an embodiment of the present invention. As shown in fig. 8, the terminal device 8 of this embodiment includes: a processor 80, a memory 81 and a computer program 82, such as a code management program based on log monitoring technology, stored in said memory 81 and executable on said processor 80. The processor 80 executes the computer program 82 to implement the steps in each of the above-mentioned code management and control method embodiments based on the log monitoring technology, such as the steps S101 to S104 shown in fig. 1. Alternatively, the processor 80, when executing the computer program 82, implements the functions of the units in the terminal device embodiments described above, such as the functions of the units 71 to 74 shown in fig. 7.
Illustratively, the computer program 82 may be divided into one or more units, which are stored in the memory 81 and executed by the processor 80 to accomplish the present invention. The one or more units may be a series of computer program instruction segments capable of performing specific functions, which are used to describe the execution of the computer program 82 in the terminal device 8. For example, the computer program 82 may be divided into a building unit, a configuration unit, a starting unit and an output unit, and the specific functions of each unit are as follows:
the device comprises a building unit, a monitoring unit and a processing unit, wherein the building unit is used for building a hypertext transfer protocol (HTTP) server and a log service in the HTTP server, acquiring a server address and a port number in the built HTTP server, and acquiring a log identifier in the built log service, and the log identifier is used for determining a log position to be monitored by a log to be set;
the configuration unit is used for configuring the server address and the port number and taking the HTTP server as a proxy server of the terminal;
the starting unit is used for starting the log service, determining the log position of an application program on the terminal through the log identifier and setting a log point at the log position;
and the output unit is used for acquiring the running log of the application program at the log point through the log service and outputting the running log when the terminal runs the application program.
The terminal device 8 may be a desktop computer, a notebook, a palm computer, a cloud server, or other computing devices. The terminal device may include, but is not limited to, a processor 80, a memory 81. Those skilled in the art will appreciate that fig. 8 is merely an example of a terminal device 8 and does not constitute a limitation of terminal device 8 and may include more or fewer components than shown, or some components may be combined, or different components, e.g., the terminal device may also include input-output devices, network access devices, buses, etc.
The Processor 80 may be a Central Processing Unit (CPU), other general purpose Processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field-Programmable Gate Array (FPGA) or other Programmable logic device, discrete Gate or transistor logic device, discrete hardware component, or the like. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
The storage 81 may be an internal storage unit of the terminal device 8, such as a hard disk or a memory of the terminal device 8. The memory 81 may also be an external storage device of the terminal device 8, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), and the like, which are provided on the terminal device 8. Further, the memory 81 may also include both an internal storage unit and an external storage device of the terminal device 8. The memory 81 is used for storing the computer program and other programs and data required by the terminal device. The memory 81 may also be used to temporarily store data that has been output or is to be output.
It is obvious to those skilled in the art that, for convenience and simplicity of description, the above division of each functional unit is only used for illustration, and in practical applications, the above function distribution may be performed by different functional units according to needs, that is, the internal structure of the terminal device is divided into different functional units to perform all or part of the above described functions. Each functional unit in the embodiments may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit, and the integrated unit may be implemented in a form of hardware, or in a form of software functional unit. In addition, specific names of the functional units are only used for distinguishing one functional unit from another, and are not used for limiting the protection scope of the application. The specific working process of the units in the system may refer to the corresponding process in the foregoing method embodiment, and is not described herein again.
In the above embodiments, the descriptions of the respective embodiments have respective emphasis, and reference may be made to the related descriptions of other embodiments for parts that are not described or illustrated in a certain embodiment.
Those of ordinary skill in the art will appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware or combinations of computer software and electronic hardware. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present invention.
In the embodiments provided in the present invention, it should be understood that the disclosed terminal device and method may be implemented in other ways. For example, the above-described terminal device embodiments are merely illustrative, and for example, the division of the units is only one logical function division, and there may be other divisions when actually implementing, for example, a plurality of units or components may be combined or may be integrated into another system, or some features may be omitted, or not implemented. 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 units, and may be in an electrical, mechanical or other form.
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 units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit may be implemented in the form of hardware, or may also be implemented in the form of a software functional unit.
The integrated unit, if implemented in the form of a software functional unit and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, all or part of the flow of the method according to the embodiments of the present invention may also be implemented by a computer program, which may be stored in a computer-readable storage medium, and when the computer program is executed by a processor, the steps of the method embodiments described above may be implemented. Wherein the computer program comprises computer program code, which may be in the form of source code, object code, an executable file or some intermediate form, etc. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, usb disk, removable hard disk, magnetic disk, optical disk, computer Memory, read-Only Memory (ROM), random Access Memory (RAM), electrical carrier wave signals, telecommunications signals, software distribution medium, and the like. It should be noted that the computer readable medium may contain content that is subject to appropriate increase or decrease as required by legislation and patent practice in jurisdictions, for example, in some jurisdictions, computer readable media does not include electrical carrier signals and telecommunications signals as is required by legislation and patent practice.
The above-mentioned embodiments are only used for illustrating the technical solutions of the present invention, and not for limiting the same; 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; such modifications and substitutions do not substantially depart from the spirit and scope of the embodiments of the present invention, and are intended to be included within the scope of the present invention.

Claims (8)

1. A code management and control method based on a log monitoring technology is characterized by comprising the following steps:
the method comprises the steps of building a hypertext transfer protocol (HTTP) server and a log service in the HTTP server, obtaining a server address and a port number in the built HTTP server, and obtaining a log identifier in the built log service, wherein the log identifier is used for determining a log position to be set for log monitoring in an application program of a terminal to be monitored; the log identification comprises a specific function name, a variable name and a specific code line;
configuring the server address and the port number, and taking the HTTP server as a proxy server of the terminal;
starting the log service, searching all the log marks in codes of an application program, taking a code line with the log marks as a log position, and setting a log point at the log position;
when the terminal runs the application program, obtaining the running log of the application program at the log point through the log service, and outputting the running log;
the determining the log position of the application program on the terminal through the log identifier and setting a log point at the log position includes:
acquiring a log point record table, wherein the log point record table comprises a plurality of log identifications and log point grades corresponding to the log identifications;
executing the log service to set the log points at the log positions in an application program corresponding to the plurality of log identifications in the log point record table;
when the terminal runs the application program, the log service acquires the running log of the application program at the log point, and the method further comprises the following steps:
comparing the log grade of the running log with the log point grade corresponding to the log point, and giving an alarm according to the comparison result.
2. The code management method of claim 1, wherein the configuring the server address and the port number comprises:
creating a wireless network and connecting the terminal to the wireless network;
and generating connection information comprising the server address and the port number, and sending the connection information to the terminal through the wireless network at preset time intervals so that the terminal performs proxy setting based on the connection information.
3. The code management and control method according to claim 2, wherein if there are a plurality of the terminals, the sending the connection information to the terminal through the wireless network at every predetermined time interval includes:
acquiring a preset identifier to be monitored, wherein the identifier to be monitored is used for indicating the terminal to be monitored;
determining the terminal corresponding to the identifier to be monitored in a plurality of terminals connected with the wireless network, and adding the terminal corresponding to the identifier to be monitored to a terminal set to be monitored;
and sending the connection information to the terminals in the terminal set to be monitored at intervals, and updating the identifiers to be monitored corresponding to the terminals which have received the connection information into the proxied identifiers.
4. The code management and control method according to claim 1, wherein the alarming according to the comparison result includes:
if the log level of the running log is higher than or equal to the log point level, outputting the running log to a console of the HTTP server, and outputting an alarm prompt;
and if the log grade of the running log is lower than the log point grade, storing the running log to a preset address.
5. A terminal device, characterized in that the terminal device comprises a memory, a processor and a computer program stored in the memory and executable on the processor, the processor implementing the following steps when executing the computer program:
the method comprises the steps of building a hypertext transfer protocol (HTTP) server and a log service in the HTTP server, obtaining a server address and a port number in the built HTTP server, and obtaining a log identifier in the built log service, wherein the log identifier is used for determining a log position to be set for log monitoring in an application program of a terminal to be monitored; the log identification comprises a specific function name, a variable name and a specific code line;
configuring the server address and the port number, and taking the HTTP server as a proxy server of the terminal;
starting the log service, searching all the log marks in codes of an application program, taking a code line with the log marks as a log position, and setting a log point at the log position;
when the terminal runs the application program, obtaining the running log of the application program at the log point through the log service, and outputting the running log;
the determining the log position of the application program on the terminal through the log identifier and setting a log point at the log position includes:
acquiring a log point record table, wherein the log point record table comprises a plurality of log identifications and log point grades corresponding to the log identifications;
executing the log service to set the log point at the log position corresponding to a plurality of log identifications in the log point record table in an application program;
when the terminal runs the application program, the log service acquires the running log of the application program at the log point, and the method further comprises the following steps:
comparing the log grade of the running log with the log point grade corresponding to the log point, and giving an alarm according to the comparison result.
6. The terminal device of claim 5, wherein the configuring the server address and the port number comprises:
creating a wireless network and connecting the terminal to the wireless network;
and generating connection information comprising the server address and the port number, and sending the connection information to the terminal through the wireless network at preset time intervals so that the terminal performs proxy setting based on the connection information.
7. The terminal device of claim 6, wherein if there are a plurality of terminals, the sending the connection information to the terminal through the wireless network at preset time intervals comprises:
acquiring a preset identifier to be monitored, wherein the identifier to be monitored is used for indicating the terminal to be monitored;
determining the terminal corresponding to the identifier to be monitored in a plurality of terminals connected with the wireless network, and adding the terminal corresponding to the identifier to be monitored to a terminal set to be monitored;
and sending the connection information to the terminals in the terminal set to be monitored at intervals, and updating the identifiers to be monitored corresponding to the terminals which have received the connection information into the proxied identifiers.
8. A computer-readable storage medium, in which a computer program is stored, which, when being executed by a processor, carries out the steps of a code management method according to any one of claims 1 to 4.
CN201810920817.9A 2018-08-14 2018-08-14 Code management and control method based on log monitoring technology and terminal equipment Active CN109218407B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810920817.9A CN109218407B (en) 2018-08-14 2018-08-14 Code management and control method based on log monitoring technology and terminal equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810920817.9A CN109218407B (en) 2018-08-14 2018-08-14 Code management and control method based on log monitoring technology and terminal equipment

Publications (2)

Publication Number Publication Date
CN109218407A CN109218407A (en) 2019-01-15
CN109218407B true CN109218407B (en) 2022-10-25

Family

ID=64988528

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810920817.9A Active CN109218407B (en) 2018-08-14 2018-08-14 Code management and control method based on log monitoring technology and terminal equipment

Country Status (1)

Country Link
CN (1) CN109218407B (en)

Families Citing this family (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109947630B (en) * 2019-03-14 2020-08-04 腾讯科技(深圳)有限公司 Fault notification method, device and storage medium
CN112770408B (en) * 2021-01-15 2023-01-06 广州虎牙科技有限公司 Log transmission method and device, computer equipment and storage medium
CN113076296A (en) * 2021-03-30 2021-07-06 咪咕文化科技有限公司 Log generation method and device, electronic equipment and storage medium
CN115174544A (en) * 2021-04-02 2022-10-11 京东科技控股股份有限公司 Log obtaining method, device, equipment and medium
CN114564348B (en) * 2021-12-16 2023-04-04 深圳开源互联网安全技术有限公司 Js third-party application monitoring method and system for code layer

Citations (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2001039012A2 (en) * 1999-11-22 2001-05-31 Avenue, A, Inc. Efficient web server log processing
CN101651707A (en) * 2009-09-22 2010-02-17 西安交通大学 Method for automatically acquiring user behavior log of network
CN103401937A (en) * 2013-08-07 2013-11-20 中国科学院信息工程研究所 Log data processing method and system
CN104572411A (en) * 2013-10-10 2015-04-29 腾讯科技(深圳)有限公司 Log data processing method and device
CN105187241A (en) * 2015-08-19 2015-12-23 浪潮(北京)电子信息产业有限公司 Log recording method and system based on linux kernel
CN106096034A (en) * 2016-06-27 2016-11-09 乐视控股(北京)有限公司 application log management method and device
CN106201844A (en) * 2016-06-29 2016-12-07 北京智能管家科技有限公司 A kind of log collecting method and device
CN106776093A (en) * 2016-12-12 2017-05-31 Tcl集团股份有限公司 A kind of application exception log processing method and system
CN107122290A (en) * 2016-02-25 2017-09-01 阿里巴巴集团控股有限公司 The recording method of log information and device
CN107678938A (en) * 2017-08-24 2018-02-09 阿里巴巴集团控股有限公司 The adjustment method and equipment of a kind of application program
CN108038049A (en) * 2017-12-13 2018-05-15 西安电子科技大学 Real-time logs control system and control method, cloud computing system and server
CN108124252A (en) * 2017-12-29 2018-06-05 深圳市金立通信设备有限公司 A kind of method, terminal and computer readable storage medium for obtaining information

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US10614085B2 (en) * 2016-05-26 2020-04-07 International Business Machines Corporation System impact based logging with enhanced event context

Patent Citations (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2001039012A2 (en) * 1999-11-22 2001-05-31 Avenue, A, Inc. Efficient web server log processing
CN101651707A (en) * 2009-09-22 2010-02-17 西安交通大学 Method for automatically acquiring user behavior log of network
CN103401937A (en) * 2013-08-07 2013-11-20 中国科学院信息工程研究所 Log data processing method and system
CN104572411A (en) * 2013-10-10 2015-04-29 腾讯科技(深圳)有限公司 Log data processing method and device
CN105187241A (en) * 2015-08-19 2015-12-23 浪潮(北京)电子信息产业有限公司 Log recording method and system based on linux kernel
CN107122290A (en) * 2016-02-25 2017-09-01 阿里巴巴集团控股有限公司 The recording method of log information and device
CN106096034A (en) * 2016-06-27 2016-11-09 乐视控股(北京)有限公司 application log management method and device
CN106201844A (en) * 2016-06-29 2016-12-07 北京智能管家科技有限公司 A kind of log collecting method and device
CN106776093A (en) * 2016-12-12 2017-05-31 Tcl集团股份有限公司 A kind of application exception log processing method and system
CN107678938A (en) * 2017-08-24 2018-02-09 阿里巴巴集团控股有限公司 The adjustment method and equipment of a kind of application program
CN108038049A (en) * 2017-12-13 2018-05-15 西安电子科技大学 Real-time logs control system and control method, cloud computing system and server
CN108124252A (en) * 2017-12-29 2018-06-05 深圳市金立通信设备有限公司 A kind of method, terminal and computer readable storage medium for obtaining information

Also Published As

Publication number Publication date
CN109218407A (en) 2019-01-15

Similar Documents

Publication Publication Date Title
CN109218407B (en) Code management and control method based on log monitoring technology and terminal equipment
CN110489391B (en) Data processing method and related equipment
CN109634258B (en) Bus message checking method, device and system for hardware-in-loop test
CN110719199B (en) Network automatic testing and fault positioning method and device
CN111045921A (en) Automatic interface testing method and device, computer equipment and storage medium
CN110119350B (en) Software development kit testing method, device and equipment and computer storage medium
CN110088744B (en) Database maintenance method and system
CN111506047B (en) Vehicle diagnosis method, device and storage medium
CN111045893B (en) Method, device and system for executing monitoring task, storage medium and electronic device
CN112988485A (en) Simulation test method and device for power Internet of things equipment
CN110928770B (en) Software testing method, device, system, storage medium and electronic equipment
CN108306787B (en) Application monitoring method and related equipment
CN110958161B (en) Block chain link point monitoring method and device and storage medium
US9935867B2 (en) Diagnostic service for devices that employ a device agent
CN113791792A (en) Application calling information acquisition method and device and storage medium
CN107872363B (en) Data packet loss processing method and system, readable storage medium and electronic device
CN111190761B (en) Log output method and device, storage medium and electronic equipment
CN110930110B (en) Distributed flow monitoring method and device, storage medium and electronic equipment
CN110940874B (en) Calibration method, server and medium for nuclear power station transformer protection device
CN111506641A (en) Data management method, data acquisition platform, data management system and storage medium
CN106940647B (en) Code management method and device
CN115454860A (en) Automatic testing method and device, storage medium and electronic equipment
CN114327981A (en) Safety verification system, method and device of function safety mechanism
US11570189B2 (en) Simultaneously testing whether a plurality of electronic devices connected via a communication network correctly handle exceptions
CN113965447B (en) Online cloud diagnosis method, device, system, equipment and storage medium

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
GR01 Patent grant
GR01 Patent grant