l14107cb 发表于 2024-10-3 09:04:19

Android开源项目举荐之「最好用的Log」


    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">阅读本文大概需要 4 分钟。</span>
      &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">有读者问我说「张哥,我<span style="color: black;">此刻</span>在<span style="color: black;">机构</span>做项目,一<span style="color: black;">起始</span>都是自己写,做起来很累,后来接触了开源社区才<span style="color: black;">晓得</span>原来有<span style="color: black;">那样</span>多好用的开源项目,大大的<span style="color: black;">提高</span>了我的工作效率,能<span style="color: black;">不可</span><span style="color: black;">举荐</span><span style="color: black;">有些</span>实用的开源项目给我?」</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">我觉得这个问题<span style="color: black;">尤其</span>好,如今的软件<span style="color: black;">研发</span>追求快速,尤其互联网<span style="color: black;">行业</span>的创业<span style="color: black;">机构</span>,比别人慢半拍很可能就错失了巨大的机会,<span style="color: black;">况且</span><span style="color: black;">亦</span><span style="color: black;">无</span>额外的资源去面面俱到,需要把所有的资源聚焦在核心的业务上,<span style="color: black;">因此</span><span style="color: black;">此刻</span>越来越多的<span style="color: black;">机构</span>专注<span style="color: black;">供给</span>单一<span style="color: black;">行业</span>的<span style="color: black;">处理</span><span style="color: black;">方法</span>,如推送、分享、登录、支付、客服等功能都有专门的<span style="color: black;">机构</span><span style="color: black;">供给</span>服务,<span style="color: black;">乃至</span>主机都不需要自己买,直接租用云主机就<span style="color: black;">能够</span>了。</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">针对</span><span style="color: black;">机构</span><span style="color: black;">研发</span>内部<span style="color: black;">来讲</span>,<span style="color: black;">运用</span>开源库能<span style="color: black;">极重</span>的<span style="color: black;">加强</span>自己的开发效率,不重复发明轮子,<span style="color: black;">况且</span>在各个技术<span style="color: black;">行业</span><span style="color: black;">亦</span>都<span style="color: black;">已然</span>有<span style="color: black;">有些</span>成熟的轮子了,只是开源项目确实太多,<span style="color: black;">针对</span><span style="color: black;">有些</span>经验不是<span style="color: black;">尤其</span>丰富的<span style="color: black;">研发</span>人员<span style="color: black;">来讲</span>很难分辨该用哪个,<span style="color: black;">那样</span>从今天<span style="color: black;">起始</span>我将不<span style="color: black;">定时</span>的来给<span style="color: black;">大众</span><span style="color: black;">举荐</span><span style="color: black;">有些</span>实用的开源项目,让你<span style="color: black;">能够</span><span style="color: black;">安心</span>的直接在工作中采用,<span style="color: black;">提高</span>你们工作效率的<span style="color: black;">同期</span><span style="color: black;">亦</span><span style="color: black;">能够</span>抽时间学习下这些项目的优秀设计,这<span style="color: black;">亦</span>是<span style="color: black;">提高</span>你们技能的一个有效的手段!</span></p><span style="color: black;">1</span>&nbsp;<span style="color: black;">&nbsp;Android Log</span>
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">咱们</span>在学习<span style="color: black;">研发</span>的<span style="color: black;">第1</span>件事应该就接触了 Log ,<span style="color: black;">亦</span><span style="color: black;">便是</span> Android <span style="color: black;">研发</span>中用来调试的日志,<span style="color: black;">咱们</span><span style="color: black;">通常</span>是<span style="color: black;">这般</span><span style="color: black;">运用</span>:</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;"><span style="color: black;">Log.d(TAG,"hello");</span></strong></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">效果<span style="color: black;">通常</span>如下:</p>

    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><img src="http://mmbiz.qpic.cn/mmbiz/159icnNTXChPPzLQGDMn2QV2LC7kfvZqEUFJpKmdbKnHZ9dKbQibth2os9DlymZXct23dSEgj8UnPH0hicMXWYAEg/640?wx_fmt=jpeg&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" style="width: 50%; margin-bottom: 20px;"></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">能够</span>看到很乱,<span style="color: black;">况且</span>输出 json 格式的话<span style="color: black;">亦</span><span style="color: black;">无</span>格式化,<span style="color: black;">亦</span>没法快速定位到 Log 的位置,<span style="color: black;">那样</span>今天就给<span style="color: black;">大众</span><span style="color: black;">举荐</span>一款非常好用的 Log 工具,<span style="color: black;">亦</span>是<span style="color: black;">咱们</span>团队在用的。</span></p><span style="color: black;">2</span>&nbsp;<span style="color: black;">&nbsp;Logger</span>
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">用 GitHub 的原话介绍<span style="color: black;">便是</span>:「Simple, pretty and powerful logger for android」。</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">废话不多说,<span style="color: black;">咱们</span>直接看下它的示例截图:</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><img src="http://mmbiz.qpic.cn/mmbiz/159icnNTXChPPzLQGDMn2QV2LC7kfvZqE761woAicQbe0ibE0TchOBh95cI7JffaPbJJtLuDOHAALQCv1rfaODkeg/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" style="width: 50%; margin-bottom: 20px;"></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">是不是很酷炫?<span style="color: black;">那样</span>下面稍微说下他的<span style="color: black;">详细</span>用法。</span></p><span style="color: black;">3</span>&nbsp;<span style="color: black;">&nbsp;依赖</span>
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><img src="http://mmbiz.qpic.cn/mmbiz/159icnNTXChPPzLQGDMn2QV2LC7kfvZqEDsSCNF47nC1zQU86TfgstpYzZ7hgxEhnSvI4DueW9L1QjNibGC7BoWg/640?wx_fmt=jpeg&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" style="width: 50%; margin-bottom: 20px;"></p><span style="color: black;">4</span>&nbsp;&nbsp;<span style="color: black;">&nbsp;基本用法</span>
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">运用</span>起来很简单,以下是最基本的用法:</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;"><span style="color: black;">Logger.d("test");</span></strong></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;"><span style="color: black;">Logger.d("test%d", "3"); &nbsp;</span></strong><span style="color: black;"> // String.format</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">效果如下:</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><img src="http://mmbiz.qpic.cn/mmbiz/159icnNTXChPPzLQGDMn2QV2LC7kfvZqEIMrg1VMDIdh8M5j4IAPiaxiavQHcByXmCu4WZxGSRcJGic6Vz1iawcDKkA/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" style="width: 50%; margin-bottom: 20px;"></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">能够</span>看到<span style="color: black;">包括</span>了三个<span style="color: black;">重点</span>部分,默认直接<span style="color: black;">表示</span>了当前所在的线程,所在的类,调用<span style="color: black;">办法</span>,<span style="color: black;">乃至</span>直接给你指明调用位置的行数,而且直接点击<span style="color: black;">转</span>到日志<span style="color: black;">详细</span>位置,最后是该日志的输出。</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">输出json格式的日志:</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;"><span style="color: black;">Logger.json(YOUR_JSON_DATA);</span></strong></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><img src="http://mmbiz.qpic.cn/mmbiz/159icnNTXChPPzLQGDMn2QV2LC7kfvZqECKcMDqMx1axd4Vbk9T6aaBzOUBCDa1AJCf3cXUcYT1PiaZsZicwXMSEg/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" style="width: 50%; margin-bottom: 20px;"></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">对应的输出xml格式:</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;"><span style="color: black;">Logger.xml(YOUR_XML_DATA);</span></strong></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">以上<span style="color: black;">咱们</span>所有用法<span style="color: black;">咱们</span><span style="color: black;">能够</span>看到其实<span style="color: black;">无</span>给 Log 加 TAG, 那是<span style="color: black;">由于</span><span style="color: black;">能够</span>统一给所有日志打上标签:</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;"><span style="color: black;">Logger.init(YOUR_TAG);</span></strong></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">倘若</span>想单独为某个日志打上不<span style="color: black;">同样</span>的标签:</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;"><span style="color: black;">Logger.t("mytag").d("hello");</span></strong></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">当然还有<span style="color: black;">更加多</span>的用法与配置,<span style="color: black;">例如</span>外层<span style="color: black;">办法</span>数量,自定义Log Tool,<span style="color: black;">表示</span>/<span style="color: black;">隐匿</span>线程信息等,<span style="color: black;">详细</span><span style="color: black;">大众</span><span style="color: black;">能够</span><span style="color: black;">自动</span>实践<span style="color: black;">科研</span>下。</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">GitHub<span style="color: black;">位置</span>:<span style="color: black;">https://github.com/orhanobut/logger</span></span></p><span style="color: black;">5</span>&nbsp;<span style="color: black;">&nbsp;<span style="color: black;">更加多</span></span>
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">除了基本用法之外,你还<span style="color: black;">能够</span>结合你们自己的业务做些封装,使你们的调试更方便些。<span style="color: black;">例如</span>为了调试网络方便,我就<span style="color: black;">运用</span>了 Logger 在<span style="color: black;">咱们</span>的网络层做了一点封装,大大<span style="color: black;">提高</span>了<span style="color: black;">咱们</span>调试网络的效率,调试网络再<span style="color: black;">亦</span><span style="color: black;">不消</span>走代理了,直接在 LogCat 上就<span style="color: black;">能够</span>看到<span style="color: black;">详细</span>的api、header、params、response等信息,上张图你们感受下:</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><img src="http://mmbiz.qpic.cn/mmbiz/159icnNTXChPPzLQGDMn2QV2LC7kfvZqEGuwvDshDa2lJv9N4IAFic1VuYn3NBHbyeudFjognjTHhAsYfMpuxNhw/640?wx_fmt=jpeg&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" style="width: 50%; margin-bottom: 20px;"></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">看完别犹豫了,赶紧在项目中立即<span style="color: black;">运用</span>起来吧!</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">最终</span>,有眼光独到的合作商肯找我了,简直感动的快哭了,从本周<span style="color: black;">起始</span>以后<span style="color: black;">文案</span>底部会固定放野狗的 banner ,这名字霸气吧?<span style="color: black;">近期</span>野狗举办了一个技术沙龙,感兴趣的不妨点击阅读原文报名活动。</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><img src="http://mmbiz.qpic.cn/mmbiz/159icnNTXChPnich4PsExLkkL7JOibS57b1SiahIENmnCSEfIb8cB51fbRCkAyBP9LM19U0iblWRGdtnW3I2RjG0MTw/640?wx_fmt=jpeg&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" style="width: 50%; margin-bottom: 20px;"></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">举荐</span>阅读:</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><a style="color: black;"><span style="color: black;">我面试到底问什么?</span></a></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><a style="color: black;"><span style="color: black;">从0<span style="color: black;">起始</span>学习 GitHub 系列之「向GitHub 提交代码」</span></a></p>




m5k1umn 发表于 2024-10-7 17:53:01

软文发布论坛开幕式圆满成功。 http://www.fok120.com

b1gc8v 发表于 2024-10-13 13:45:23

楼主继续加油啊!外链论坛加油!
页: [1]
查看完整版本: Android开源项目举荐之「最好用的Log」