CN110597696A - Log information display method - Google Patents

Log information display method Download PDF

Info

Publication number
CN110597696A
CN110597696A CN201910833074.6A CN201910833074A CN110597696A CN 110597696 A CN110597696 A CN 110597696A CN 201910833074 A CN201910833074 A CN 201910833074A CN 110597696 A CN110597696 A CN 110597696A
Authority
CN
China
Prior art keywords
log
log information
function
variable
target
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.)
Granted
Application number
CN201910833074.6A
Other languages
Chinese (zh)
Other versions
CN110597696B (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.)
Changzhou New Way Software Co Ltd
Original Assignee
Changzhou New Way Software 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 Changzhou New Way Software Co Ltd filed Critical Changzhou New Way Software Co Ltd
Priority to CN201910833074.6A priority Critical patent/CN110597696B/en
Publication of CN110597696A publication Critical patent/CN110597696A/en
Application granted granted Critical
Publication of CN110597696B publication Critical patent/CN110597696B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/32Monitoring with visual or acoustical indication of the functioning of the machine
    • G06F11/323Visualisation of programs or trace data
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/34Recording or statistical evaluation of computer activity, e.g. of down time, of input/output operation ; Recording or statistical evaluation of user activity, e.g. usability assessment
    • G06F11/3466Performance evaluation by tracing or monitoring
    • G06F11/3476Data logging

Landscapes

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

Abstract

The invention provides a log information display method, which comprises the following steps: s1, starting a log service process of the log system; s2, adding a header file of the log system, a macro TREETRACE and a macro TRELEOG according to external input; s3, the target program runs to the target function adding macro TREETRACE, the log system generates first log information and updates the numerical value of a shrinkage variable, and the log service process acquires the numerical value of the shrinkage variable; s4, when the target program runs to the target function and macro TRELEOG is added, the log system generates second log information according to the amount of reduction; s5, when the target program exits the target function, the second function subtracts T from the amount of the retraction volume; and S6, outputting function log information by the log service process. The log information display method prints the log information by controlling the retraction mode, so that the output log information is more organized, and developers can intuitively and clearly observe details such as the calling sequence, the calling depth and the like of the function.

Description

Log information display method
Technical Field
The invention relates to the technical field of computers, in particular to a log information display method.
Background
The Log system is a tool commonly used by developers in the development process for recording the module running process, and when a problem occurs in the module running process, the developers can often find out the problem from Log information generated by the Log system. However, the log information generated by the existing log system cannot clearly view the calling condition of each thread or each function, and particularly when a project with a large code amount is encountered, the condition is particularly obvious, so that a developer cannot clearly and accurately find the problem when a module runs and has a problem, and the development efficiency is influenced.
Disclosure of Invention
The technical problem to be solved by the invention is as follows: in order to solve the problem that log information generated by the existing log system cannot be used for developers to accurately check thread and program calling conditions, the invention provides a log information display method to solve the problem.
The technical scheme adopted by the invention for solving the technical problems is as follows: a log information display method includes the following steps:
s1, starting a log service process of the log system;
s2, adding a header file of the log system in the target program according to external input, adding a macro TREETRACE provided by the log system at the beginning of the target function, and adding a macro TRELEOG in the target function;
s3, the target program runs to the target function adding macro TREETRACE, the log system generates first log information related to the target function, and the macro TREETRACE constructs a class which comprises a first function and a second function;
the first function judges whether the thread where the target function is located is provided with a retraction variable for controlling retraction;
if the thread where the target function is located does not set the over-retraction variable, the first function creates a retraction variable for the thread where the target function is located and assigns an initial value of the retraction variable to 0;
if the thread where the target function is located has set a variable of the amount of shrinkage, the first function obtains the variable of the amount of shrinkage and adds T to the value of the variable of the amount of shrinkage;
taking out a shrinkage variable by the log service process;
s4, when the target program runs to the target function adding macro TRELEOG, the log system generates second log information related to the target function;
s5, when the target program exits the target function, the second function subtracts T from the indentation amount of the thread where the target function is located;
and S6, the log service process integrates the first log information and the second log information into function log information according to the extracted reduction variable and outputs the function log information.
Preferably, step S1 further includes obtaining operation parameters according to the external input, where the operation parameters include an output mode and an output file size;
after the log service process acquires the first log information and the second log information, outputting the first log information and the second log information according to an output mode;
if the output mode is terminal output, the log service process prints the first log information and the second log information to a terminal for display;
and if the output mode is file output, the log service process prints the first log information and the second log information into a log file according to the size of the output file and stores the log file.
Preferably, a step S11 is further included between the steps S1 and S2, in which the log service process sets a storage address of the log file according to an external input.
Preferably, the function log information further includes a header, and the header includes a time and a thread ID.
The log information display method has the advantages that log information is printed by controlling the retraction mode, so that the output log information is more organized, and developers can intuitively and clearly observe details such as the calling sequence, the calling depth and the like of functions.
Drawings
The invention is further illustrated with reference to the following figures and examples.
FIG. 1 is a flow chart of a preferred embodiment of a log information display method of the present invention.
Detailed Description
Reference will now be made in detail to embodiments of the present invention, examples of which are illustrated in the accompanying drawings, wherein like or similar reference numerals refer to the same or similar elements or elements having the same or similar function throughout. The embodiments described below with reference to the accompanying drawings are illustrative only for the purpose of explaining the present invention, and are not to be construed as limiting the present invention.
In the description of the present invention, it is to be understood that the terms "center", "longitudinal", "lateral", "length", "width", "thickness", "upper", "lower", "front", "rear", "left", "right", "vertical", "horizontal", "top", "bottom", "inner", "outer", "axial", "radial", "circumferential", and the like, indicate orientations and positional relationships based on the orientations and positional relationships shown in the drawings, and are used merely for convenience of description and for simplicity of description, and do not indicate or imply that the device or element being referred to must have a particular orientation, be constructed and operated in a particular orientation, and therefore, should not be considered as limiting the present invention.
Furthermore, the terms "first," "second," and the like are used for descriptive purposes only and are not to be construed as indicating or implying relative importance. In the description of the present invention, it is to be noted that, unless otherwise explicitly specified or limited, the terms "connected" and "connected" are to be interpreted broadly, e.g., as being fixed or detachable or integrally connected; can be mechanically or electrically connected; may be directly connected or indirectly connected through an intermediate. The specific meanings of the above terms in the present invention can be understood in specific cases to those skilled in the art. In addition, in the description of the present invention, "a plurality" means two or more unless otherwise specified.
Any process or method descriptions in flow charts or otherwise described herein may be understood as representing modules, segments, or portions of code which include one or more executable instructions for implementing specific logical functions or steps of the process, and alternate implementations are included within the scope of the preferred embodiment of the present invention in which functions may be executed out of order from that shown or discussed, including substantially concurrently or in reverse order, depending on the functionality involved, as would be understood by those reasonably skilled in the art of the present invention.
As shown in fig. 1, the present invention provides a log information display method, which is characterized by comprising the following steps:
s1, the developer starts log service process tlcat of log system, which starts uddp monitor, the local IP and port number monitored by log service process is 2000;
s2, a developer adds a header file 'treelog.h' of a log system in a target program, then determines one or more target functions according to specific requirements, adds a macro TREETRACE provided by the log system at the beginning of the target function, and adds a macro TRELEOG provided by the log system in the target function;
s3, the object program runs, when the object program runs to the macro TREETRACE point when entering the object function, the macro TREETRACE constructs a special class, and the construction process of the class is described by the following program:
wherein, the function TreeTrace (const char tag, const char func); is a first function, function TreeTrace (); the first function is a constructor in class, and the constructor is described by the following procedure:
wherein:
the function get _ spaces _ num () is used for judging whether the amount of the reduction of the thread where the target function is located exists and obtaining the value of the variable of the reduction, and if the thread where the target function is located does not set the variable of the excess reduction, the macro TREETRACE creates a variable of the reduction with an initial value of 0 for the thread where the target function is located;
if the thread where the target function is located sets the over-scaling variable, the value of the function get _ spaces _ num () is the value of the scaling variable;
the function set _ spaces _ num () is used to set the value of the carry-down variable, and the function set _ spaces _ num () adds T to the value of the function get _ spaces _ num () as the value of the carry-down variable, where T is 4 in the present embodiment;
after determining the numerical value of the shrinkage variable, the log service process acquires the numerical value of the current shrinkage variable;
and S4, the target program runs to a macro TRELEOG added to the target function, a log system generates second log information through an interface function of the log system according to the reduction quantity, and the interface function of the log system is described by the following functions:
TREELOG("INFO","MUSIC","this is log info,idx:%d",idx);
wherein, the INFO is log grade, and the MUSIC is a function module to which the second log information belongs;
s5, when the target program exits the target function, the second function subtracts T from the amount of reduction of the thread in which the target function is located, where the second function is a destructor in class, and the destructor is described by the following procedure:
TreeTrace::~TreeTrace()
{
set_spaces_num(get_spaces_num()-4);
}
the function set _ spaces _ num () subtracts T from the value of the function get _ spaces _ num () as the value of the amount of the carry-down variable, in this example, the value of T is 4;
s6, the log service process integrates the first log information and the second log information into function log information according to the value of the amount of the indented variable acquired in step S3 and outputs it. For example, the second log information is displayed at the leftmost side of a line, and then the first log information is displayed after 4 characters are indented.
In this embodiment, after the log system is started, a developer inputs an instruction on a terminal interface to set an operating parameter of a log service process, and inputs a storage position of a log file in the case that log information is stored in the form of the log file on the terminal interface;
the operation parameters comprise a parameter representing whether to output the file and a parameter representing the size of the output file, and the storage position of the log file is described by the following instructions:
"-o/tmp/tlcat.log";
log information is stored in a file of/tmp/tlcat.log;
after obtaining the first log information and the second log information, the log service process judges how the log information is output according to the operation parameters;
the output mode is terminal output, and the log service process integrates the first log information and the second log information into function log information to be printed to the terminal for display;
the output mode is file output, the log service process integrates the first log information and the second log information into function log information, the function log information is printed into a log file named tlcat.
In a particular embodiment, the function log information further includes a header that includes a time and a thread ID.
In the description herein, references to the description of the term "one embodiment," "some embodiments," "an example," "a specific example," or "some examples," etc., mean that a particular feature, structure, material, or characteristic described in connection with the embodiment or example is included in at least one embodiment or example of the invention. In this specification, a schematic representation of the term does not necessarily refer to the same embodiment or example. Furthermore, the particular features, structures, materials, or characteristics described may be combined in any suitable manner in any one or more embodiments or examples.
In light of the foregoing description of the preferred embodiment of the present invention, many modifications and variations will be apparent to those skilled in the art without departing from the spirit and scope of the invention. The technical scope of the present invention is not limited to the content of the specification, and must be determined according to the scope of the claims.

Claims (4)

1. A log information display method is characterized by comprising the following steps:
s1, starting a log service process of the log system;
s2, adding a header file of the log system in the target program according to external input, adding a macro TREETRACE provided by the log system at the beginning of the target function, and adding a macro TRELEOG in the target function;
s3, the target program operates to the target function adding macro TREETRACE, and the log system generates first log information related to the target function; macro TREETRACE constructs a class that contains a first function and a second function;
the first function judges whether the thread where the target function is located is provided with a retraction variable for controlling retraction;
if the thread where the target function is located does not set the over-retraction variable, the first function creates a retraction variable for the thread where the target function is located and assigns an initial value of the retraction variable to 0;
if the thread where the target function is located has set a variable of the amount of shrinkage, the first function obtains the variable of the amount of shrinkage and adds T to the value of the variable of the amount of shrinkage;
taking out a shrinkage variable by the log service process;
s4, when the target program runs to the target function adding macro TRELEOG, the log system generates second log information related to the target function;
s5, when the target program exits the target function, the second function subtracts T from the indentation amount of the thread where the target function is located;
and S6, the log service process integrates the first log information and the second log information into function log information according to the extracted reduction variable and outputs the function log information.
2. The log information display method of claim 1, wherein:
step S1 further comprises obtaining operation parameters according to external input, wherein the operation parameters comprise an output mode and an output file size;
after the log service process acquires the first log information and the second log information, outputting the first log information and the second log information according to an output mode;
if the output mode is terminal output, the log service process prints the first log information and the second log information to a terminal for display;
and if the output mode is file output, the log service process prints the first log information and the second log information into a log file according to the size of the output file and stores the log file.
3. The log information display method of claim 2, wherein:
between steps S1 and S2, there is further included step S11 of the log service process setting a storage address of the log file according to an external input.
4. A log information display method as claimed in claim 3, characterized by:
the function log information further includes a header including a time and a thread ID.
CN201910833074.6A 2019-09-04 2019-09-04 Log information display method Active CN110597696B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910833074.6A CN110597696B (en) 2019-09-04 2019-09-04 Log information display method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910833074.6A CN110597696B (en) 2019-09-04 2019-09-04 Log information display method

Publications (2)

Publication Number Publication Date
CN110597696A true CN110597696A (en) 2019-12-20
CN110597696B CN110597696B (en) 2022-12-20

Family

ID=68857533

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910833074.6A Active CN110597696B (en) 2019-09-04 2019-09-04 Log information display method

Country Status (1)

Country Link
CN (1) CN110597696B (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114722050A (en) * 2022-06-10 2022-07-08 辰星(天津)自动化设备有限公司 Data synchronization method of robot system and robot system

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105260315A (en) * 2015-11-13 2016-01-20 上海斐讯数据通信技术有限公司 Method for debugging log in embedded system process
CN105260293A (en) * 2015-11-06 2016-01-20 Tcl集团股份有限公司 Output method, output device and terminal equipment of log information
CN109783330A (en) * 2018-12-10 2019-05-21 北京京东金融科技控股有限公司 Log processing method, display methods and relevant apparatus, system

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105260293A (en) * 2015-11-06 2016-01-20 Tcl集团股份有限公司 Output method, output device and terminal equipment of log information
CN105260315A (en) * 2015-11-13 2016-01-20 上海斐讯数据通信技术有限公司 Method for debugging log in embedded system process
CN109783330A (en) * 2018-12-10 2019-05-21 北京京东金融科技控股有限公司 Log processing method, display methods and relevant apparatus, system

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114722050A (en) * 2022-06-10 2022-07-08 辰星(天津)自动化设备有限公司 Data synchronization method of robot system and robot system
CN114722050B (en) * 2022-06-10 2022-09-30 辰星(天津)自动化设备有限公司 Data synchronization method of robot system and robot system

Also Published As

Publication number Publication date
CN110597696B (en) 2022-12-20

Similar Documents

Publication Publication Date Title
CN110597696B (en) Log information display method
JP2008234213A (en) Information processor, information processing method, information processing program and recording medium with same program recorded
JP2009181291A (en) Information processor, information processing method, and program
CN102902758A (en) Wallpaper setting method and device for obtaining network pictures by using search engine
CN103324684A (en) Control method and device for browser kernel in mobile terminal and mobile terminal
US7480592B2 (en) Remote diagnosis device, remote diagnosis system and program product
EP3598299A2 (en) Method, apparatus, and device for processing driver on terminal device side
US9203990B2 (en) Priority ordered user interface screens for controlling a device
CN105204981A (en) Application performance test method and device
CN109656567B (en) Dynamic method and system for heterogeneous service data processing logic
JP2009122936A (en) Sequence program monitor device equipped with display function for abnormality research and programmable controller
US10656938B2 (en) External comment storage and organization
JP2009048485A (en) Information processor, information processing method, information processing program and storage medium recording the information processing program
CN112818937A (en) Excel file identification method and device, electronic equipment and readable storage medium
CN116303589A (en) Workflow construction method, device, equipment and readable storage medium
CN111078326A (en) Method, device and equipment for calling functional module
CN106648700A (en) Display method and device compatible with different resolution ratios
CN109840113B (en) Application data processing method and equipment, storage medium and terminal thereof
CN105335657B (en) A kind of program bug detection method and device
CN113688343B (en) Page authority control method, device, equipment and readable storage medium
CN110058865A (en) A kind of program burn writing and operation method of single-chip microcontroller
CN115510820A (en) Dynamic data editing method, device, equipment and medium
JP2013009067A (en) Image processing apparatus, macro name determination method, and macro name determination program
CN113535160B (en) Method, device, system, electronic device and storage medium for multiplexing application modules
CN105468356A (en) Notification message control method and device

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