A method and device for obtaining environment variables
By updating and traversing the environment variable library to generate environment variable logs when receiving the target log generation request, the complex and time-consuming problem of environmental variable acquisition in the prior art is solved, and work efficiency is improved.
Patent Information
- Application Number
- CN202110467477.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-04-28
- Publication Date
- 2025-01-10
- Estimated Expiration
- 2041-04-28
AI Technical Summary
When troubleshooting application problems, developers need to obtain environment variables in the system running the application, but existing methods need to be filtered from a large amount of log code, which is time-consuming and labor-intensive and inefficient.
Provides a method for obtaining environment variables. By calling the dynamic environment variable acquisition thread when receiving the target log generation request, it obtains the current dynamic environment variable variable, updates the preset environment variable library, traversing the updated environment variable library to generate the environment variable log and Send to the backend, simplifying the process of obtaining environment variables.
Simplifies the process of obtaining environment variables, saves time and improves work efficiency. By building and managing environment variable libraries, external access ports are provided, and the process of obtaining static and dynamic environment variables is simplified.
Smart Images

Figure CN113110846B_ABST
Abstract
Description
Background Art
[0002] When developers troubleshoot application problems, they need to obtain the environment variables in the system where the application is running and understand some parameters of the application's running environment.
[0003] Currently, when troubleshooting application problems, developers obtain the corresponding logs based on the log information identifier, and then filter out the environment parameters from the tens of thousands of lines of code in the logs, which is time-consuming, labor-intensive, and inefficient. Summary of the invention
[0004] The embodiments of the present application provide a method and device for obtaining environment variables to solve the problem that the process of obtaining environment variables is complicated, time-consuming and labor-intensive.
[0005] In a first aspect, an embodiment of the present application provides a method for obtaining an environment variable, comprising:
[0006] When receiving a target log generation request, the dynamic environment variable acquisition thread is called to obtain the current dynamic environment variables;
[0007] According to the current dynamic environment variables, the dynamic environment variables of the previous round stored in the preset environment variable library are updated;
[0008] The static environment variables stored in the updated environment variable library and the dynamic environment variables of the current round are traversed to generate an environment variable log, and the environment variable log is sent to the back end.
[0009] Optionally, before receiving the target log generation request, the environment variable library is constructed in the following manner:
[0010] If an application program execution instruction is generated based on a user's trigger operation, a static environment variable acquisition thread is called to acquire the static environment variable, and the static environment variable is stored in the environment variable library;
[0011] If an initial log generation request is received, the dynamic environment variable acquisition thread is called to acquire initial dynamic environment variables, and the initial dynamic environment variables are used as dynamic environment variables of the current round and stored in the environment variable library.
[0012] Optionally, the calling of a static environment variable acquisition thread to acquire a static environment variable includes:
[0013] The static environment variable acquisition thread is called to acquire the static environment variable from the operating system according to preset static environment variable configuration information.
[0014] Optionally, storing the static environment variables in the environment variable library includes:
[0015] The static environment variable acquisition thread is called to access the variable reading interface of the environment variable library, and the static environment variable is sent to the environment variable library, so that the environment variable library stores the static environment variable.
[0016] Optionally, the calling of the dynamic environment variable acquisition thread to acquire the initial dynamic environment variable includes:
[0017] The dynamic environment variable thread is called to obtain the initial dynamic environment variable from the operating system according to preset dynamic environment variable configuration information.
[0018] Optionally, the storing the initial dynamic environment variables as the dynamic environment variables of the current round in an environment variable library includes:
[0019] The dynamic environment variable acquisition thread is called to access the variable reading interface of the environment variable library, and the initial dynamic environment variable is sent to the environment variable library, so that the environment variable library stores the initial dynamic environment variable as the dynamic environment variable of the current round.
[0020] In a second aspect, an embodiment of the present application further provides a device for obtaining an environment variable, including:
[0021] The acquisition unit is used to call the dynamic environment variable acquisition thread to acquire the current dynamic environment variable when receiving a target log generation request;
[0022] A processing unit, configured to update the dynamic environment variables of the previous round stored in a preset environment variable library according to the current dynamic environment variables;
[0023] The generation unit is used to traverse the static environment variables stored in the updated environment variable library and the dynamic environment variables of the current round, generate an environment variable log, and send the environment variable log to the back end.
[0024] Optionally, before receiving the target log generation request, the device further includes a construction unit, and the construction unit constructs the environment variable library in the following manner:
[0025] If an application program execution instruction is generated based on a user's trigger operation, a static environment variable acquisition thread is called to acquire the static environment variable, and the static environment variable is stored in the environment variable library;
[0026] If an initial log generation request is received, the dynamic environment variable acquisition thread is called to acquire initial dynamic environment variables, and the initial dynamic environment variables are used as dynamic environment variables of the current round and stored in the environment variable library.
[0027] Optionally, the construction unit is used to:
[0028] The static environment variable acquisition thread is called to acquire the static environment variable from the operating system according to preset static environment variable configuration information.
[0029] Optionally, the construction unit is used to:
[0030] The static environment variable acquisition thread is called to access the variable reading interface of the environment variable library, and the static environment variable is sent to the environment variable library, so that the environment variable library stores the static environment variable.
[0031] Optionally, the construction unit is used to:
[0032] The dynamic environment variable thread is called to obtain the initial dynamic environment variable from the operating system according to preset dynamic environment variable configuration information.
[0033] Optionally, the construction unit is used to:
[0034] The dynamic environment variable acquisition thread is called to access the variable reading interface of the environment variable library, and the initial dynamic environment variable is sent to the environment variable library, so that the environment variable library stores the initial dynamic environment variable as the dynamic environment variable of the current round.
[0035] In a third aspect, an embodiment of the present application further provides a computer device, comprising a processor and a memory, wherein the memory stores program code, and when the program code is executed by the processor, the processor executes the steps of any one of the above-mentioned methods for obtaining environment variables.
[0036] In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium, which includes a program code. When the program product is run on a computer device, the program code is used to enable the computer device to execute the steps of any one of the above-mentioned methods for obtaining environment variables.
[0037] The beneficial effects of this application are as follows:
[0038] The embodiment of the present application provides a method and device for obtaining an environment variable, the method comprising: upon receiving a target log generation request, calling a dynamic environment variable acquisition thread to obtain the current dynamic environment variable; then updating the dynamic environment variables of the previous round stored in the preset environment variable library according to the current dynamic environment variable, traversing the static environment variables stored in the updated environment variable library and the dynamic environment variables of the current round, generating an environment variable log, and sending the environment variable log to the back end. The method for obtaining an environment variable provided by the embodiment of the present application constructs an environment variable library for storing and managing environment variables, and also provides an access port for external access to the environment variable library, which can access the static environment variables stored in the updated environment variable library and the dynamic environment variables of the current round through the access port, generating an environment variable log, simplifying the process of obtaining environment variables, saving the time spent on obtaining environment variables, and improving work efficiency.
[0039] Other features and advantages of the present application will be described in the following description, and partly become apparent from the description, or be understood by practicing the present application. The purpose and other advantages of the present application can be realized and obtained by the structures specifically pointed out in the written description, claims, and drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0041] Figure 1a This is a flowchart for building an environment variable library;
[0042] Figure 1b A logical diagram for building an environment variable library;
[0043] Figure 2 A flowchart of a method for obtaining environmental variables provided in an embodiment of the present application;
[0044] Figure 3a A schematic diagram of a process for obtaining environment variables for a troubleshooting scenario in an embodiment of the present application;
[0045] Figure 3b A logical schematic diagram of obtaining environment variables for a troubleshooting scenario in an embodiment of the present application;
[0046] Figure 3c A logical diagram of obtaining environment variables for troubleshooting scenarios in related technologies;
[0047] Figure 4a A schematic diagram of a process for obtaining environment variables for a development scenario in an embodiment of the present application;
[0048] Figure 4b A logical schematic diagram of obtaining environment variables for a development scenario in an embodiment of the present application;
[0049] Figure 4c A logical diagram of obtaining environment variables for development scenarios in related technologies;
[0050] Figure 5 This is a schematic diagram of the structure of a device for acquiring environmental variables in an embodiment of the present application;
[0051] Figure 6 A schematic diagram of the structure of a computer device in an embodiment of the present application;
[0052] Figure 7 A schematic diagram of the hardware composition structure of a computing device using an embodiment of the present application. DETAILED DESCRIPTION
[0053] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the technical solution of the present application, rather than all of the embodiments. Based on the embodiments recorded in the application documents, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the technical solution of the present application.
[0054] When developers are troubleshooting application problems or developing applications, they need to obtain environment variables in the system where the application is running and understand some parameters of the application's running environment.
[0055] When troubleshooting application problems, developers obtain the corresponding logs based on the log information identifier, and then filter out the environment parameters from the tens of thousands of lines of code in the log, which is time-consuming, labor-intensive, and inefficient. When developing applications, for each business to be developed, developers use tool-based methods to continuously obtain the same environment variables from the system API layer, which is time-consuming and labor-intensive, occupies process resources, and reduces work efficiency.
[0056] Due to the adoption of the above method, the process of obtaining environment variables is complicated, time-consuming and laborious. In view of this, the present application provides a method and device for obtaining environment variables. The method includes: when the application running on the smart terminal receives a target log generation request, first update the dynamic environment variables of the previous round stored in the preset environment variable library according to the current dynamic environment variables obtained, then traverse the updated environment variable library to generate an environment variable log, and send the environment variable log to the back end.
[0057] Therefore, before introducing the method for obtaining the environment variables provided in the embodiment of the present application, refer to Figure 1a The flowchart and Figure 1b The logical schematic diagram shown first introduces the process of building an environment variable library.
[0058] The environment variable library includes two types of environment variables: static environment variables and dynamic environment variables. Among them, environment variables that remain unchanged during the life cycle are usually called static environment variables, and environment variables that change in real time during the life cycle are usually called dynamic environment variables. Due to the characteristics of the two types of environment variables, the methods of obtaining the two types of environment variables are also different. Among them, the static environment variable acquisition thread used to obtain static environment variables and the dynamic environment variable acquisition thread used to obtain dynamic environment variables are in a multi-threaded relationship running in parallel.
[0059] S101: If an application program execution instruction is generated based on a user's triggering operation, a static environment variable acquisition thread is called to acquire static environment variables, and the static environment variables are stored in an environment variable library.
[0060] Users can trigger operations such as touch operations (such as single-clicking the screen, double-clicking the screen, sliding the screen, etc.), voice control operations (such as sending a control instruction of "open music applications" to the voice assistant running on the smart terminal, so that the voice assistant can open the corresponding music applications based on the control instruction), gesture control (such as using fingers, knuckles or screen stylus to draw specific graphics on the screen; for example, pulling down the screen with three fingers to open a specific application, etc.), etc., to make the operating system running on the smart terminal generate application running instructions, so that the operating system can open the corresponding application based on the application running instructions. Among them, the smart terminal is an electronic device used by the user, and the electronic device can be a personal computer, mobile phone, tablet computer, notebook, e-book reader, smart home and other computer devices with certain computing capabilities.
[0061] When the operating system generates an application running instruction based on the user's trigger operation, the corresponding application is opened to provide application services for the user. The application can call the static environment variable acquisition thread, and obtain the static environment variables from the corresponding system API layer of the operating system according to the preset static environment variable configuration information. Specifically, the static environment variable configuration information includes at least the basic information of the application, the screen information of the smart terminal, the system information of the running application, and the custom static environment variable configuration information. The corresponding static environment variables include at least: the developer of the application, the version information of the opened application, the screen size of the smart terminal, the operating system version information of the smart terminal, and the attribute values of the custom static environment variables. Among them, the static environment variables include both the static environment variables of the application itself and the static environment variables in the operating system running the application, and the custom static environment configuration information is a type of static environment variable configuration information customized by the developer, including at least the attributes of the custom static environment variables, and the corresponding attribute values.
[0062] After obtaining the static environment variables, the application calls the static environment variable acquisition thread, accesses the variable reading interface of the environment variable library (i.e., the Add interface), and sends the static environment variables to the environment variable library so that the environment variable library stores the static environment variables. In order to facilitate query and management, each static environment variable is classified and stored in the environment variable library according to the static environment variable configuration information.
[0063] S102: If an initial log generation request is received, the dynamic environment variable acquisition thread is called to acquire initial dynamic environment variables, and the initial dynamic environment variables are used as dynamic environment variables of the current round and stored in the environment variable library.
[0064] The troubleshooter or developer sends an initial log generation request to the application running on the smart terminal through the operation at the back end. When the application receives the initial log generation request, it calls the dynamic environment variable acquisition thread, and obtains the initial dynamic environment variable from the corresponding system API layer of the operating system according to the preset dynamic environment variable configuration information. The dynamic environment variable configuration information at least includes: the running information of the application, the central processing unit (CPU) information, the patch information, and the custom dynamic environment variable configuration information, and the corresponding dynamic environment variables at least include: the information of the application running in the front end, the information of each application running in the background, the memory information (including the occupied memory and the unoccupied memory), the secure digital card (SD) storage information, the patch information of the operating system, the patch information of the application, and the attribute value of the custom dynamic environment variable. Among them, the dynamic environment variables include both the dynamic environment variables of the application itself and the dynamic environment variables in the operating system running the application, and the custom dynamic environment configuration information is a type of dynamic environment variable configuration information customized by the developer, at least including the attributes of the custom dynamic environment variable, and the corresponding attribute values.
[0065] After obtaining the initial dynamic environment variables, the application calls the dynamic environment variable acquisition thread, accesses the variable reading interface of the environment variable library (i.e., the Add interface), and sends the initial dynamic environment variables to the environment variable library so that the environment variable library stores the initial dynamic environment variables. In order to facilitate query and management, each initial dynamic environment variable is classified and stored in the environment variable library according to the dynamic environment variable configuration information.
[0066] See also Figure 2 The flow chart shown introduces the method for obtaining environment variables based on the constructed environment variable library provided in the embodiment of the present application.
[0067] S201: When a target log generation request is received, a dynamic environment variable acquisition thread is called to acquire current dynamic environment variables.
[0068] The troubleshooter or developer sends a target log generation request to the application running on the smart terminal through operations on the backend. Due to the real-time update characteristics of dynamic environment variables, when the application receives the target log generation request, it calls the dynamic environment variable acquisition thread and obtains the current dynamic environment variables according to the dynamic environment variable configuration information.
[0069] S202: According to the current dynamic environment variables, the dynamic environment variables of the previous round stored in the preset environment variable library are updated.
[0070] The application calls the dynamic environment variable acquisition thread, accesses the variable reading interface of the environment variable library (that is, the Add interface), sends the current dynamic environment variables to the environment variable library, updates and replaces the previous round of dynamic environment variables stored in the environment variable library, and ensures that the latest dynamic environment variables can be stored in the environment variable library before generating the environment variable log.
[0071] S203: Traverse the static environment variables stored in the updated environment variable library and the dynamic environment variables of the current round, generate an environment variable log, and send the environment variable log to the backend.
[0072] The application traverses the static environment variables stored in the updated environment variable library and the current round of dynamic environment variables in sequence. Each time an environment variable is traversed, the specific contents such as the attributes and attribute values of the environment variable are printed in the environment variable log until all environment variables stored in the environment variable library are traversed. An environment variable log is generated, compressed and uploaded to the server, and the server forwards the environment variable log to the device used by the troubleshooter or developer, and the device displays the generated environment variable log, so that the troubleshooter or developer can troubleshoot application problems or develop applications based on the environment variable log.
[0073] Specific implementation examples are given for different application scenarios to describe the use of the environment variable library in the application scenario.
[0074] Specific embodiment 1: Scenario for troubleshooting application problems.
[0075] See also Figure 3a The flowchart and Figure 3b The logical schematic diagram shown introduces the process of the specific embodiment 1.
[0076] S301: The problem troubleshooter sends a troubleshooting log generation request (eg, a target log generation request) to the application running on the smart terminal through operations at the backend;
[0077] S302: When receiving a troubleshooting log generation request sent by a troubleshooter, the application calls a dynamic environment variable acquisition thread to acquire current dynamic environment variables;
[0078] S303: the application updates the previous round of dynamic environment variables stored in the preset environment variable library according to the current dynamic environment variables;
[0079] S304: The application traverses the static environment variables stored in the updated environment variable library and the dynamic environment variables of the current round, generates an environment variable log, and sends the environment variable log to the backend, thereby sending it to the problem troubleshooter.
[0080] The related technology does not provide a method for managing environment variables. Therefore, the application developed by the developer can only write the environment variable identifier into the log, and then set a specific log information identifier for the log written with the environment variable identifier, so that the troubleshooter can quickly obtain the environment variable from thousands of lines of log code in the future.
[0081] See also Figure 3c As can be seen from the logical schematic diagram shown, in the method of obtaining environment variables provided by the relevant technology for troubleshooting scenarios, when the troubleshooter needs to obtain the environment variables, he or she either obtains the environment variables in the corresponding log based on the log information identifier and environment variable identifier provided by the developer, or, if the log information identifier and environment variable identifier are not obtained, the troubleshooter manually screens thousands of lines of log code to obtain the corresponding environment variables.
[0082] Compared with the method for obtaining environment variables provided by the related art for troubleshooting scenarios, the method for obtaining environment variables provided in the embodiment of the present application constructs an environment variable library for storing and managing environment variables, and also provides an access port for external access to the environment variable library. The static environment variables stored in the updated environment variable library and the dynamic environment variables of the current round can be accessed through the access port, and an environment variable log is generated, which simplifies the process of obtaining environment variables, saves the time spent on obtaining environment variables, and improves work efficiency.
[0083] Specific embodiment 2: for the development scenario of developing application programs.
[0084] See also Figure 4a The flowchart and Figure 4b The logical schematic diagram shown introduces the process of the second specific embodiment.
[0085] S401: The developer sends a development log generation request (eg, a target log generation request) to the application running on the smart terminal through operations at the backend;
[0086] S402: When receiving the development log generation request sent by the developer, the application calls the dynamic environment variable acquisition thread to acquire the current dynamic environment variable;
[0087] S403: The application updates the previous round of dynamic environment variables stored in the preset environment variable library according to the current dynamic environment variables;
[0088] S404: The application traverses the static environment variables stored in the updated environment variable library and the dynamic environment variables of the current round, generates an environment variable log, and sends the environment variable log to the backend, and then to the developer.
[0089] See also Figure 4c As can be seen from the logical schematic diagram shown, in the method of obtaining environment variables provided by the relevant technology for development scenarios, when the developer needs to obtain the environment variables for each business to be developed, he or she either looks for the corresponding tool class method himself or herself to continuously obtain the same environment variables from the system API layer, or asks other developers to obtain the corresponding tool class method to continuously obtain the same environment variables from the system API layer.
[0090] Compared with the method for obtaining environment variables provided by the related art for development scenarios, the method for obtaining environment variables provided in the embodiment of the present application constructs an environment variable library for storing and managing environment variables, and also provides an access port for external access to the environment variable library. The static environment variables stored in the updated environment variable library and the dynamic environment variables of the current round can be accessed through the access port to generate an environment variable log without repeatedly accessing the system API layer to obtain the same environment variables.
[0091] Based on the same inventive concept as the above method embodiment, the present application embodiment also provides a device for obtaining environmental variables, see Figure 5 As shown in the structural diagram, the device may include an acquisition unit 501, a processing unit 502, a generation unit 503 and a construction unit 504, wherein:
[0092] The acquisition unit 501 is used to call the dynamic environment variable acquisition thread to acquire the current dynamic environment variable when receiving a target log generation request;
[0093] The processing unit 502 is used to update the dynamic environment variables of the previous round stored in the preset environment variable library according to the current dynamic environment variables;
[0094] The generating unit 503 is used to traverse the static environment variables stored in the updated environment variable library and the dynamic environment variables of the current round, generate an environment variable log, and send the environment variable log to the back end.
[0095] Optionally, before receiving the target log generation request, the device further includes a construction unit 504, and the construction unit 504 constructs the environment variable library in the following manner:
[0096] If an application program execution instruction is generated based on a user's trigger operation, a static environment variable acquisition thread is called to acquire the static environment variable, and the static environment variable is stored in the environment variable library;
[0097] If an initial log generation request is received, the dynamic environment variable acquisition thread is called to acquire initial dynamic environment variables, and the initial dynamic environment variables are used as dynamic environment variables of the current round and stored in the environment variable library.
[0098] Optionally, the construction unit 504 is used to:
[0099] The static environment variable acquisition thread is called to acquire the static environment variable from the operating system according to preset static environment variable configuration information.
[0100] Optionally, the construction unit 504 is used to:
[0101] The static environment variable acquisition thread is called to access the variable reading interface of the environment variable library, and the static environment variable is sent to the environment variable library, so that the environment variable library stores the static environment variable.
[0102] Optionally, the construction unit 504 is used to:
[0103] The dynamic environment variable thread is called to obtain the initial dynamic environment variable from the operating system according to preset dynamic environment variable configuration information.
[0104] Optionally, the construction unit 504 is used to:
[0105] The dynamic environment variable acquisition thread is called to access the variable reading interface of the environment variable library, and the initial dynamic environment variable is sent to the environment variable library, so that the environment variable library stores the initial dynamic environment variable as the dynamic environment variable of the current round.
[0106] For the convenience of description, the above parts are divided into modules (or units) according to their functions and described separately. Of course, when implementing this application, the functions of each module (or unit) can be implemented in the same or multiple software or hardware.
[0107] After introducing the method and apparatus for acquiring environmental variables according to an exemplary embodiment of the present application, next, a computer device according to another exemplary embodiment of the present application is introduced.
[0108] Those skilled in the art will appreciate that various aspects of the present application may be implemented as a system, method or program product. Therefore, various aspects of the present application may be specifically implemented in the following forms, namely: a complete hardware implementation, a complete software implementation (including firmware, microcode, etc.), or a combination of hardware and software, which may be collectively referred to as "circuit", "module" or "system" herein.
[0109] Based on the same inventive concept as the above method embodiment, the present application embodiment also provides a computer device, see Figure 6 As shown, the environment variable acquisition device 600 may include at least a processor 601 and a memory 602. The memory 602 stores program codes, and when the program codes are executed by the processor 601, the processor 601 executes the steps of any one of the above-mentioned environment variable acquisition methods.
[0110] In some possible implementations, the computing device according to the present application may include at least one processor and at least one memory. The memory stores program code, and when the program code is executed by the processor, the processor executes the steps of the method for obtaining environmental variables according to various exemplary implementations of the present application described above in this specification. For example, the processor may execute the following steps: Figure 2 Follow the steps shown in .
[0111] Refer to the following Figure 7 hereinafter, a computing device 700 according to this embodiment of the present application is described. Figure 7 The computing device 700 is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.
[0112] like Figure 7 As shown, the computing device 700 is in the form of a general computing device. The components of the computing device 500 may include but are not limited to: at least one processing unit 701, at least one storage unit 702, and a bus 703 connecting different system components (including the storage unit 702 and the processing unit 701).
[0113] The bus 703 includes a data bus, an address bus, and a control bus.
[0114] The storage unit 702 may include a readable medium in the form of a volatile memory, such as a random access memory (RAM) 7021 and / or a cache memory unit 7022 , and may further include a read-only memory (ROM) 7023 .
[0115] The storage unit 702 may also include a program / utility 7025 having a set (at least one) of program modules 7024, such program modules 7024 including but not limited to: an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment.
[0116] The computing device 700 may also communicate with one or more external devices 704 (e.g., keyboards, pointing devices, etc.), which may be performed via input / output (I / O) interfaces 705. Furthermore, the computing device 700 may also communicate with one or more networks (e.g., local area networks (LANs), wide area networks (WANs), and / or public networks, such as the Internet) via network adapters 706. As shown, the network adapters 706 communicate with other modules for the computing device 700 via bus 703. It should be understood that, although not shown in the figure, other hardware and / or software modules may be used in conjunction with the computing device 700, including but not limited to: microcode, device drivers, redundant processors, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.
[0117] Based on the same inventive concept as the above method embodiment, various aspects of the method for obtaining environmental variables provided by the present application can also be implemented in the form of a program product, which includes program code. When the program product is run on a computer device, the program code is used to enable the computer device to execute the steps of the method for obtaining environmental variables according to various exemplary embodiments of the present application described above in this specification. For example, the computer device can execute the following steps: Figure 2 Follow the steps shown in .
[0118] The program product may use any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. The readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of readable storage media (a non-exhaustive list) include: an electrical connection with one or more wires, a portable disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above.
[0119] Although the preferred embodiments of the present application have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications falling within the scope of the present application.
[0120] Obviously, those skilled in the art can make various changes and modifications to the present application without departing from the spirit and scope of the present application. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to include these modifications and variations.
Claims
1. A method for obtaining an environment variable, characterized in that: include: When receiving an application running instruction generated based on a user's trigger operation, calling a static environment variable acquisition thread, acquiring static environment variables that remain unchanged during the life cycle, and storing the static environment variables in an environment variable library; When receiving an initial log generation request, calling a dynamic environment variable acquisition thread, acquiring initial dynamic environment variables that change in real time during a life cycle, and storing the initial dynamic environment variables in the environment variable library; Whenever a target log generation request is received, a dynamic environment variable acquisition thread is called to acquire the current dynamic environment variable, and the dynamic environment variable acquisition thread is called to access the variable reading interface of the environment variable library, and the dynamic environment variable stored in the environment variable library is updated to the current dynamic environment variable; The static environment variables stored in the updated environment variable library and the current dynamic environment variables are traversed in sequence. Each time an environment variable is traversed, the variable information of the environment variable is printed into the variable log template until all environment variables are traversed. The variable log template that prints the information of each variable is used as the environment variable log, and the environment variable log is sent to the back end.
2. The method according to claim 1, characterized in that The calling of the static environment variable acquisition thread to obtain the static environment variables that remain unchanged during the life cycle includes: The static environment variable acquisition thread is called to acquire the static environment variables that remain unchanged during the life cycle from the operating system according to preset static environment variable configuration information.
3. The method according to claim 2, characterized in that The storing of the static environment variables in the environment variable library comprises: The static environment variable acquisition thread is called to access the variable reading interface of the environment variable library, and the static environment variable is sent to the environment variable library, so that the environment variable library stores the static environment variable.
4. The method according to claim 1, characterized in that The calling of the dynamic environment variable acquisition thread to acquire the initial dynamic environment variables that change in real time during the life cycle includes: The dynamic environment variable acquisition thread is called to acquire the initial dynamic environment variables that change in real time during the life cycle from the operating system according to preset dynamic environment variable configuration information.
5. The method according to claim 4, characterized in that The storing of the initial dynamic environment variables in the environment variable library comprises: The dynamic environment variable acquisition thread is called to access the variable reading interface of the environment variable library, and the initial dynamic environment variable is sent to the environment variable library, so that the environment variable library stores the initial dynamic environment variable.
6. A device for obtaining environmental variables, characterized in that: include: A construction unit is used to call a static environment variable acquisition thread when receiving an application running instruction generated based on a user's trigger operation, acquire static environment variables that remain unchanged during a life cycle, and store the static environment variables in an environment variable library; When receiving an initial log generation request, calling a dynamic environment variable acquisition thread, acquiring initial dynamic environment variables that change in real time during a life cycle, and storing the initial dynamic environment variables in the environment variable library; The processing unit is configured to call a dynamic environment variable acquisition thread to acquire a current dynamic environment variable each time a target log generation request is received, and call the dynamic environment variable acquisition thread to access a variable reading interface of the environment variable library, and update the dynamic environment variable stored in the environment variable library to the current dynamic environment variable; A generation unit is used to sequentially traverse the static environment variables stored in the updated environment variable library and the current dynamic environment variables, and each time an environment variable is traversed, the variable information of the environment variable is printed into a variable log template until all environment variables are traversed. The variable log template that prints the information of each variable is used as an environment variable log, and the environment variable log is sent to the back end.
7. The device according to claim 6, characterized in that The building blocks are used to: The static environment variable acquisition thread is called to acquire the static environment variables that remain unchanged during the life cycle from the operating system according to preset static environment variable configuration information.
8. The device according to claim 7, characterized in that The building blocks are used to: The static environment variable acquisition thread is called to access the variable reading interface of the environment variable library, and the static environment variable is sent to the environment variable library, so that the environment variable library stores the static environment variable.
9. The device according to claim 8, characterized in that The building blocks are used to: The dynamic environment variable acquisition thread is called to acquire the initial dynamic environment variables that change in real time during the life cycle from the operating system according to preset dynamic environment variable configuration information.
10. The device according to claim 6 or 9, characterized in that The building blocks are used to: The dynamic environment variable acquisition thread is called to access the variable reading interface of the environment variable library, and the initial dynamic environment variable is sent to the environment variable library, so that the environment variable library stores the initial dynamic environment variable.
11. A computer device, characterized in that: It comprises a processor and a memory, wherein the memory stores program codes, and when the program codes are executed by the processor, the processor executes the steps of the method according to any one of claims 1 to 5.
12. A computer-readable storage medium, characterized in that: It includes program codes. When the program product is run on a computer device, the program codes are used to make the computer device execute the steps of the method according to any one of claims 1 to 5.
Citation Information
Patent Citations
Automatic deployment method for application system supporting multiple databases and multiple middleware types
CN106325951A
Running environment switching method and device and computer-readable storage medium
CN107861863A