Simple Logging for Android & iPhone
来源:互联网 发布:知乎 日本手工皮具 编辑:程序博客网 时间:2024/06/06 14:28
Simple Logging for Android & iPhone
http://codingincircles.com/2010/12/simple-logging-for-android-iphone/
Logging is one of those things I don’t want to implement until I get an error somewhere and I’d rather not try to track it down with a debugger. This happens very quickly when dealing with XCode’s included and rather lacking debugger, or on Android’s command-line-only native code debugger.
So, for my and public domain usage: A simple logging macro
Source code
#ifndef REMOVE_LOGGING
#ifdef ANDROID
#define LOG_DEBUG(message, ...) \
do { __android_log_print(ANDROID_LOG_DEBUG, "Terrasweeper", "[%s:%d] " message, __FILE__, __LINE__, ##__VA_ARGS__); } while (0)
#else
#define LOG_DEBUG(message, ...) \
do { std::printf("[%s:%d] " message "\n", __FILE__, __LINE__, ##__VA_ARGS__); } while(0)
#endif
#else
#define LOG_DEBUG(message, ...) do { LOG_UNUSED(message); } while (0)
#endif
As you can see, it supports Windows, Unix and iPhone through stdout, and android through the custom logging that you can retrieve with the LogCat tool
Posted by Tatham | Categories: Blog |
Log to logcat.
1) To invoke the logger in native code include the header and call _android_log_write(..).
#include <android/log.h>__android_log_write(ANDROID_LOG_INFO, "tag here", "message here");
2) In your Android.mk file include the log lib like this.
LOCAL_LDLIBS := -L$(SYSROOT)/usr/lib -llog
0 0
- Simple Logging for Android & iPhone
- slf4j, Simple Logging Facade for Java 的包使用说明
- slf4j, Simple Logging Facade for Java 的包使用说明
- SLF4J(Simple logging facade for Java)【整理】
- A Simple Localization Example for the iPhone
- iPhone Tabs for Android!
- Java日志学习四:Simple Logging Facade for Java (SLF4J)源码浅析
- Simple Guide for Porting Android Kernel
- [转]Simple Guide for Porting Android Kernel
- Simple Guide for Porting Android Kernel
- Simple Guide for Porting Android Kernel (portingNote)
- Simple Guide for Porting Android Kernel
- simple guide for porting android kernel
- iPhone Like Toolbar for Android
- C++ Logging and building Boost for iPhone/iPad 3.2 and MacOSX
- Simple iPhone Keychain Access
- Simple iPhone Keychain Access
- Simple iPhone Keychain Access
- Load Balancing
- Java I/O之FilenameFilter类列举出指定路径下某个扩展名的文件
- python爬虫实践之网页抓取
- 条款:07 为多态基类声明virtual析构函数
- spring mvc 接收json 异常 Unsupported Media Type
- Simple Logging for Android & iPhone
- 重构31式之封装集合
- MFC之CStdioFile(文件存在就追加写 + 文件读取一行)
- DOS下切换目录方法CD命令
- 在Linux下sqlplus 登录时显示SID 和用户名
- "二十进制数加法"
- 手机root权限
- xhost +
- Leetcode Best Time to Buy and Sell Stock III