2019年3月28日星期四

The log system for unity3d


In a project, program information output is essential. However, the ordinary output is not easy to control, and a large number of outputs will not only affect the performance, but also make the output chaotic, it is difficult to find effective information.
Therefore, the LogDog plug-in has been developed to effectively filter the output type and category, help locate the location of the information, and effectively handle the frame-down rate caused by a large number of simultaneous outputs.

This article describes the basic usage of the high-performance "Log Dog" and its applications.

Quick Start

First, let's look at the content format of an output.


The output is divided into three types, INFO, WARN, ERROR.
The green arrow is the output title.
The red arrow is the output serial number.
The blue arrow is the output content.
The orange arrow is the output module logo.
The second line is the file where the output is located and the line it is in.

Output with parameters:

LogDog supports output with multiple parameters, which can be a string, can be an object, and can be a combination of multiple types.





Filter output function:

LogDog can filter the output of the specified model flags. This way, you can focus on only the key log information without deleting or commenting the code.



In Start, the two module flags BAG and CHAT are filtered.
Then call the event method



The output of the log is as follows


Obviously, the output of lines 69 and 70 is not output and is filtered.

Output without file positioning:

Sometimes, most of the logic code for program engineering is developed in other lightweight languages as needed. Compare Lua, js, etc. . .
At this time, the output without file positioning can be called, and the specific log positioning is written in the corresponding language.




Demo operation instructions :
LogDog can also do custom output processing, like writing a file, sending the specified output data to the background or server, or there is no output panel on the phone, you need to redefine the output to the display screen. . .

In this case, do a demo to redefine the output to the display screen.


Mount the startup script and add the Content of the ScrollView and ScrollView in the UI. TextPrefab is just a normal prefab. In the AJ_LogDog/Prefab directory.




Also add a Button, just to set whether to display the ScrollView.



Set the callback processing method for the log.


The effect of opening the log panel is as follows:



API description:
JOLog.Ins.SetTitle("LOG_TITLE");
//Set the output title.
JOLog.Ins.SetEnable(true);
//Set the output switch. If it is false, all logs will not be processed.
JOLog.Ins.SetLogLevel(1);
// Error:3>Warn:2>Info:1
//Set the output level, and the output is greater than or equal to Info.
//If the parameter is 2, only the output levels of Warn and Error are output.
JOLog.Ins.SetRunInTick(true);
// Whether to frame processing when setting the output, it is recommended to set to true.
// In this way, the program will not cause large fluctuations in the frame rate due to multiple outputs at the same time.
// When set to true, you need to call JOLog.Ins.Tick() in the started Update method;


JOLog.Ins.AddIgnoreTag("Ignore Tag");
// Set filter flag
// All logs with some flags are not output. (except for error output)
JOLog.Ins.SetCall(this._LogCall);
void _LogCall(short logLv, string msg);
// Set the output callback, you can customize the output if needed
// In addition, due to some abnormally captured output of the program, it is also the object of our attention.
// If you need to redefine the output processing, you can add LogExceptionCatch to supplement
LogExceptionCatch.Ins.SetDebug(true);
LogExceptionCatch.Ins.SetDrawCall(this._LogCall);


Future Content
1. Further optimize performance
2. Provide more convenient calls
3. Increase specified output

Welcome to contact us

Unity Asset Store URL: https://assetstore.unity.com/packages/slug/142605


没有评论:

发表评论