Android/Linux大于1024Bytes打印
16lz
2021-01-23
1.Android.mkLOCAL_PATH := $(call my-dir)include $(CLEAR_VARS)#LOCAL_MULTILIB := 32LOCAL_SRC_FILES := print-log.cppLOCAL_MODULE := print-logLOCAL_MODULE_TAGS := optinalLOCAL_SHARED_LIBRARIES := liblog libutilsinclude $(BUILD_EXECUTABLE)2.print-log.cpp#include #include #include #undef NDEBUG#undef LOG_TAG#define LOG_TAG "print_log"#define LOG_MAX 1024static void print_str(std::string buffer, char *func, int line){ int len = buffer.length(); int start = 0; int end = LOG_MAX; ALOGE("xxx---starting------->%s(), line = %d, len = %d",func,line,len); for(int i = 0; i < 100; i++){ if(len > end){ //linux log //cout << buffer.substr(start, LOG_MAX) << endl; //android log ALOGE("%s(): data[%d] = %s",__FUNCTION__,i,buffer.substr(start, LOG_MAX).c_str()); start = end; end = end + LOG_MAX; }else{ //linux log //cout <%s(), line = %d, len = %d",func,line,len); }int main(){ char *parameters = "12345611111111111111111111111111111111111111111111111111111111111111122222222222222222222222222222222222222222222222222222222222222222222222222222222222222222233333333333333333333333333333333333333333333333333333333333333444444444444444444444444444444444444444444444444444444444444444412345611111111111111111111111111111111111111111111111111111111111111122222222222222222222222222222222222222222222222222222222222222222222222222222222222222222233333333333333333333333333333333333333333333333333333333333333444444444444444444444444444444444444444444444444444444444444444412345611111111111111111111111111111111111111111111111111111111111111122222222222222222222222222222222222222222222222222222222222222222222222222222222222222222233333333333333333333333333333333333333333333333333333333333333444444444444444444444444444444444444444444444444444444444444444412345611111111111111111111111111111111111111111111111111111111111111122222222222222222222222222222222222222222222222222222222222222222222222222222222222222222233333333333333333333333333333333333333333333333333333333333333444444444444444444444444444444444444444444444444444444444444444412345611111111111111111111111111111111111111"; //const char * ----> string:两种方式 //1. std::string buffer(parameters); //2. //buffer = parameters; print_str(buffer,"main",__FUNCTION__); ALOGE("xxx---------->%s(), line = %d",__FUNCTION__,__LINE__); return 0;}
更多相关文章
- Android更新UI的五种方式
- Android关于桌面快捷方式工具类!
- Android菜单实现两种方式
- 我今天的面试题,注册广播有几种方式,这些方式有何优缺点?请谈谈Andr
- Android 代码设置Color的几种方式
- Android控件隐藏方式 .
- Android客户端与服务端交互-客户端GET方式登录和客户端POST方式
- Android获取存储卡路径的方式