Logging
Table of Contents
- Developer's Guide
- Introduction
- Goals & Features
- Community & Support
- Contributing
- Games Built with Libgdx
- Prerequisites
- Gradle Project Setup, Running, Debugging and Packaging
- Project Setup, Running & Debugging
- Third Party Services
- Working from Source
- Using libgdx with other JVM languages
- The Application Framework
- A Simple Game
- File Handling
- Networking
- Preferences
- Input Handling
- Memory Management
- Audio
- Graphics
- Configuration & Querying Graphics ??
- Fullscreen & VSync
- Continuous & Non-Continuous Rendering
- Clearing the Screen
- Take a Screenshot
- OpenGL ES Support
- Configuration & Querying OpenGL ??
- Direct Access ??
- Utility Classes
- 2D Graphics
- 3D Graphics
- Quick Start
- Models
- Material and environment
- 3D animations and skinning
- Importing Blender models in LibGDX
- Perspective Camera ??
- Picking ??
- Managing Your Assets
- Utilities
- Math Utilities
- Interpolation
- Vectors, Matrices, Quaternions
- Circles, Planes, Rays, etc.
- Path interface & Splines
- Bounding Volumes ??
- Intersection & Overlap Testing ??
- Physics
- Tools
- Extensions
- Deploying your Application
- Building Libgdx ??
- Known Issues
- Articles
- Deprecated (May be outdated)
The Application
interface provides simple logging facilities that give granular control.
A message can be a normal info message, an error message with an optional exception or a debug message:
Gdx.app.log("MyTag", "my informative message");
Gdx.app.error("MyTag", "my error message", exception);
Gdx.app.debug("MyTag", "my error message");
Depending on the platform, the messages are logged to the console (desktop), LogCat (Android) or a GWT TextArea
provided in the GwtApplicationConfiguration
or created automatically (html5).
Logging can be limited to a specific logging level:
Gdx.app.setLogLevel(logLevel);
where logLevel
can be one of the following values:
- Application.LOG_NONE: mutes all logging.
- Application.LOG_DEBUG: logs all messages.
- Application.LOG_ERROR: logs only error messages.
- Application.LOG_INFO: logs error and normal messages.
demo
package com.example.groupactiontest;
import com.badlogic.gdx.Application;
import com.badlogic.gdx.ApplicationListener;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.GL10;
public class MyGame implements ApplicationListener {
@Override
public void create() {
Gdx.app.setLogLevel(Application.LOG_ERROR);//这时候使用Gdx对应的log工具来打log的时候就只能看到error级别及以上的了
//使用libgdx提供的打日志的方法写日志。还是在logcat中查看
Gdx.app.log("MyTag", "my information message");
Gdx.app.error("MyTag", "my error message...");
Gdx.app.debug("MyTag", "my debug messgae");
}
@Override
public void dispose() {
// TODO Auto-generated method stub
}
@Override
public void pause() {
// TODO Auto-generated method stub
}
@Override
public void render() {
Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
}
@Override
public void resize(int arg0, int arg1) {
// TODO Auto-generated method stub
}
@Override
public void resume() {
// TODO Auto-generated method stub
}
}
源码下载链接:
http://download.csdn.net/detail/caihongshijie6/7036095