zoukankan      html  css  js  c++  java
  • 第四十二篇、自定义Log打印

    1.在Xcode 8出来之后,需要我们去关闭多余的日志信息打印

    2.在开发的过程中,打印调试日志是一项比不可少的工程,但是在iOS 10中NSLog打印日志被屏蔽了,就不得不使用自定义Log

    3.去掉xcode8的日志打印:Edit->Run->ENvironment variables -->添加OS_ACTIVITY_MODE 设置值为disable

      common 加 = 让图片大小按尺寸适应 (快捷键)

      sudo /usr/libexec/xpccachectl  + 重启电脑     因为xcode8的注释不可以用了

      @objc private 修饰的方法(为了保留OC的特性,方法能正常的响应)

    这是用系统NSLog打印的做法

    #ifdef DEBUG
    #define LRString [NSString stringWithFormat:@"%s",__FILE__].lastPathComponent
    #define LRLog(...) NSLog(@"%@ 第%d行 
    %@
    
    ",LRString,__LINE__,[NSString stringWithFormat:__VA_ARGS__])
    #else
    #define LRLog(...)
    #endif

    这是用Pritf() C语言的打印方式,需要UTF8String转码

    // 第一种
    #ifdef
    DEBUG #define LRString [NSString stringWithFormat:@"%s", __FILE__].lastPathComponent #define LRLog(...) printf("%s 第%d行: %s ", [LRString UTF8String] ,__LINE__, [[NSString stringWithFormat:__VA_ARGS__] UTF8String]); #else #define LRLog(...) #endif

    // 第二种:还是用原来的NSLog
    #ifdef DEBUG #define NSLog(format, ...) printf(" [%s] %s [第%d行] %s ", __TIME__, __FUNCTION__, __LINE__, [[NSString stringWithFormat:format, ## __VA_ARGS__] UTF8String]); #else #define NSLog(format, ...) #endif
     
  • 相关阅读:
    mysql事务
    mysql函数
    mysql自连接
    MYSQL添加外键关联
    SQL多表查询
    SQL数据完整性
    SQL limit
    SQL分组查询
    升级GCC 6.2编译LLVM的问题
    Quartz时SLF4J错误
  • 原文地址:https://www.cnblogs.com/HJQ2016/p/5925532.html
Copyright © 2011-2022 走看看