ue4 打个log难如狗
注意:
把log相关两个宏写到类中,并编译后,在输出日志的位置的Categories关键字过滤的位置看不到自己的标签是因为需要先运行一次,输出一些这个标签的log后,这个自定义的标签才会显示在这
原文 https://wiki.unrealengine.com/Logs,_Printing_Messages_To_Yourself_During_Runtime#Log_an_FString
http://www.cnblogs.com/blueroses/p/6037981.html
说明:本文为Wiki上的RAMA大神文章的大致翻译
游戏模式:
在游戏模式下,你需要在游戏的快捷方式后面加 -Log,才会在游戏中显示。
编辑器模式(Play In Editor):
你可以在Output窗口中看到log信息。
如果想在游戏中看到,需要到Engin.ini中修改参数添加"GameCommandLine=-log,如果没有,则需要按~,输入-Log命令开启。
快速使用:
UE_LOG(LogTemp, Warning, TEXT("Your message"));
不用设置标签,简单快速。
设置拥有自己标签的Log:
在你的游戏头文件中加入:

//General Log
DECLARE_LOG_CATEGORY_EXTERN(YourLog, Log, All); //Logging during game startup
DECLARE_LOG_CATEGORY_EXTERN(YourInit, Log, All); //Logging for your AI system
DECLARE_LOG_CATEGORY_EXTERN(YourAI, Log, All); //Logging for Critical Errors that must always be addressed
DECLARE_LOG_CATEGORY_EXTERN(YourCriticalErrors, Log, All);

这样输出的Log你就可以知道是哪个部分的,这也是UE_Log很有用的原因。
在你的游戏Cpp文件中:

//General Log
DEFINE_LOG_CATEGORY(YourLog); //Logging during game startup
DEFINE_LOG_CATEGORY(YourInit); //Logging for your AI system
DEFINE_LOG_CATEGORY(YourAI); //Logging for Critical Errors that must always be addressed
DEFINE_LOG_CATEGORY(YourCriticalErrors);

Log格式:
Log Message
//"This is a message to yourself during runtime!"
UE_LOG(YourLog,Warning,TEXT("This is a message to yourself during runtime!"));
Log an FString
%s strings are wanted as TCHAR* by Log, so use *FString()
//"MyCharacter's Name is %s"
UE_LOG(YourLog,Warning,TEXT("MyCharacter's Name is %s"), *MyCharacter->GetName() );
Log an Int
//"MyCharacter's Health is %d"
UE_LOG(YourLog,Warning,TEXT("MyCharacter's Health is %d"), MyCharacter->Health );
Log a Float
//"MyCharacter's Health is %f"
UE_LOG(YourLog,Warning,TEXT("MyCharacter's Health is %f"), MyCharacter->Health );
Log an FVector
//"MyCharacter's Location is %s"
UE_LOG(YourLog,Warning,TEXT("MyCharacter's Location is %s"),
*MyCharacter->GetActorLocation().ToString());
Log an FName
//"MyCharacter's FName is %s"
UE_LOG(YourLog,Warning,TEXT("MyCharacter's FName is %s"),
*MyCharacter->GetFName().ToString());
Log an FString,Int,Float
//"%s has health %d, which is %f percent of total health"
UE_LOG(YourLog,Warning,TEXT("%s has health %d, which is %f percent of total health"),
*MyCharacter->GetName(), MyCharacter->Health, MyCharacter->HealthPercent);
Log的颜色设置:
//"this is Grey Text"
UE_LOG(YourLog,Log,TEXT("This is grey text!"));
//"this is Yellow Text"
UE_LOG(YourLog,Warning,TEXT("This is yellow text!"));
//"This is Red Text"
UE_LOG(YourLog,Error,TEXT("This is red text!"));
可以看得出第二个参数是是用来控制颜色的。
传递客户端信息(网络模式):
PlayerController->ClientMessage("Your Message");
命令行命令以及Engine.ini配置:
Log conventions (in the console, ini files, or environment variables)
[cat] = a category for the command to operate on, or 'global' for all categories.
标签,没有设置就显示所有的Log
[level] = verbosity level, one of: none, error, warning, display, log, verbose, all, default
关卡,显示某某关卡的Log
At boot time, compiled in default is overridden by ini files setting, which is overridden by command line
Log console command usage

Log list - list all log categories
Log list [string] - list all log categories containing a substring
Log reset - reset all log categories to their boot-time default
Log [cat] - toggle the display of the category [cat]
Log [cat] off - disable display of the category [cat]
Log [cat] on - resume display of the category [cat]
Log [cat] [level] - set the verbosity level of the category [cat]
Log [cat] break - toggle the debug break on display of the category [cat]

Log command line
-LogCmds=\"[arguments],[arguments]...\" - applies a list of console commands at boot time
-LogCmds=\"foo verbose, bar off\" - turns on the foo category and turns off the bar category
Environment variables
Any command line option can be set via the environment variable UE-CmdLineArgs
set UE-CmdLineArgs=\"-LogCmds=foo verbose breakon, bar off\"
Config file
In DefaultEngine.ini or Engine.ini:
[Core.Log]
global=[default verbosity for things not listed later]
[cat]=[level]
foo=verbose break
Rama后面的一篇文章提供了显示代码行号、函数名称、类名等功能:
https://wiki.unrealengine.com/Logs,_Printing_the_Class_Name,_Function_Name,_Line_Number_of_your_Calling_Code!
ue4 打个log难如狗的更多相关文章
- JavaScript面向对象轻松入门之多态(demo by ES5、ES6、TypeScript)
多态(Polymorphism)按字面的意思就是"多种状态",同样的行为(方法)在不同对象上有不同的状态. 在OOP中很多地方都要用到多态的特性,比如同样是点击鼠标右键,点击快捷方 ...
- javascript重修之书(一):如何判断变量的数据类型
javascript重修之书(一):如何判断变量的数据类型 一:检测值类型 基本类型:(Undefined.Null.Boolean.Number和String) javascript之所以被称为一门 ...
- js各种继承方式汇总
js中的各种继承实现汇总 首先定义一个父类: function Animal(name) { this.name = name || '动物' this.sleep = function () { c ...
- 前端综合学习笔记---异步、ES6/7、Module、Promise同步 vs 异步
同步 vs 异步 先看下面的 demo,根据程序阅读起来表达的意思,应该是先打印100,1秒钟之后打印200,最后打印300.但是实际运行根本不是那么回事 console.log(100) setTi ...
- Vuex、axios、跨域请求处理和import/export的注意问题
一.Vuex 1.介绍 vuex是一个专门为Vue.js设计的集中式状态管理架构. 对于状态,我们把它理解为在data中需要共享给其他组件使用的部分数据. Vuex和单纯的全局对象有以下不同: 1. ...
- web笔试
类型判断用到哪些方法? typeof和instanceof 值类型和引用类型的区别? 根据 JavaScript中的变量类型传递方式,又分为值类型和引用类型,在参数传递方式上,值类型是按值传递,引用类 ...
- 潭州课堂25班:Ph201805201 WEB 之 JS 第五课 (课堂笔记)
算数运算符 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF ...
- Javascript MVC 学习笔记(一) 模型和数据
写在前面 近期在看<MVC的Javascript富应用开发>一书.本来是抱着一口气读完的想法去看的.结果才看了一点就傻眼了:太多不懂的地方了. 仅仅好看一点查一点,一点一点往下看吧,进度虽 ...
- 《前端JavaScript面试技巧》笔记一
思考: 拿到一个面试题,你第一时间看到的是什么 -> 考点 又如何看待网上搜出来的永远也看不完的题海 -> 不变应万变 如何对待接下来遇到的面试题 -> 题目到知识再到题目 知识体系 ...
随机推荐
- java基础之容器、集合、集合常用方法
一.容器(Collection):数组是一种容器,集合也是一种容器 java编程中,装其他各种各样的对象(引用类型)的一种东西,叫容器 注意: 1.数组的长度是固定的 2.集合:长度不固定, 可以随时 ...
- angularJs-未加载完成的页面显示混乱ng-bind
ng-bind 未初始化完成不加载数据,避免产生{{}}导致页面混乱 还是上边的例子,当前页面没有加载完成的时候,页面显示是不完整的会频繁的出现{{}}这样子的表达式语句,给用户的感觉很不和谐,所以使 ...
- windows下安装Qt
1.Linux下安装Qt与MySQL相对来说比较容易,在这里我就不多加介绍. 接下来主要介绍windows下安装Qt与MySQL. 2.在windows,我安装QtCreator, 使用的是qt-wi ...
- Vue:实践学习笔记(5)——Vue-Cli脚手架的使用
Vue:实践学习笔记(5)——Vue-Cli脚手架的使用 快速开始 项目配置 可视化配置 vue ui 命令配置 vue init webpack vue-demo(项目名) 运行测试 进入vue-d ...
- 第13届景驰-埃森哲杯广东工业大学ACM程序设计大赛 G 旋转矩阵 【模拟】
链接:https://www.nowcoder.com/acm/contest/90/G 来源:牛客网 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 32768K,其他语言65536 ...
- Laravel5.5执行表迁移命令出现表为空的解决方案
今天在使用一个第三方包 laravel-admin 时,出现了这样的错误:SQLSTATE[42000]: Syntax error or access violation: 1103 Incorre ...
- 20145239杜文超 《Java程序设计》第2周学习总结
20145239 <Java程序设计>第2周学习总结 教材学习内容总结 第三章主要介绍了Java语言的基础语法. 要求我们认识类型与变量,学习运算符的基本使用以及了解类型转换.运用基本流程 ...
- 编译debian内核
玩腻了开发板,在pc上编译linux内核. debian 官方的内核文档见http://kernel-handbook.alioth.debian.org 我选择编译与当前内核版本对应的linux内核 ...
- android 内存泄漏问题【转】
本文转载自:http://www.voidcn.com/article/p-hbnuyfwz-ee.html 内存泄露问题在一些压力测试的场景很容易暴露,例如一些常用应用场景反复操作(eg:反复切换前 ...
- web tools for sublime
Your code editor is your main development tool; you use it to write and save lines of code. Write be ...