首页 文章 精选 留言 我的

精选列表

搜索[logging],共2638篇文章
优秀的个人博客,低调大师

Android Logging

Here is HauteLook’s logger class from our Android Code Library. It displays class name, method name and line number per line of log message. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 package com.hautelook.android.lib.logger; /** * @authorjimmy@hautelook.com * @copyright 2011 HauteLook * * Description: * Simple logger that displays: class name, method name and line number * * * Usage: * * Use this class directly or customize it by extending it. * * HLlog.i(""); * HLLog.i("called"); * HLLog.i("called","tag"); * * L.i(); * L.i("called"); * L.i("called","tag"); * * Sub-classing example: * * // C.DEBUG = boolean true/false (project specific constant class) * * public class L extends HLLog { * * public static String DEFAULT_TAG = "HauteLook"; * * public static void i() { * if(C.DEBUG) callLogger("i", DEFAULT_TAG, ""); * } * * public static void i(String message) { * if(C.DEBUG) callLogger("i", DEFAULT_TAG, message); * } * * public static void i(String message, String tag) { * if(C.DEBUG) callLogger("i", tag, message); * } * * } * */ import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import android.util.Log; @SuppressWarnings ( "unused" ) publicclass HLLog { publicstatic String DEFAULT_TAG = "HauteLookLib" ; finalstaticintdepth = 4 ; publicstaticvoid i(String message) { callLogger( "i" , DEFAULT_TAG, message); } publicstaticvoid i(String message, String tag) { callLogger( "i" , tag, message); } publicstaticvoid d(String message) { callLogger( "d" , DEFAULT_TAG, message); } publicstaticvoid d(String message, String tag) { callLogger( "d" , tag, message); } publicstaticvoid e(String message) { callLogger( "e" , DEFAULT_TAG, message); } publicstaticvoid e(String message, String tag) { callLogger( "e" , tag, message); } publicstaticvoid w(String message) { callLogger( "w" , DEFAULT_TAG, message); } publicstaticvoid w(String message, String tag) { callLogger( "w" , tag, message); } publicstaticvoid v(String message) { callLogger( "v" , DEFAULT_TAG, message); } publicstaticvoid v(String message, String tag) { callLogger( "v" , tag, message); } @SuppressWarnings ( "rawtypes" ) publicstaticvoid callLogger(String methodName, String tag, String message) { final StackTraceElement[] ste = Thread.currentThread().getStackTrace(); try { Class cls = Class.forName( "android.util.Log" ); Method method = cls.getMethod(methodName, String. class , String. class ); method.invoke( null , tag, getTrace(ste) + message); } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (SecurityException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } catch (NoSuchMethodException e) { e.printStackTrace(); } } publicstatic String getTrace(StackTraceElement[] ste) { return "[" + getClassName(ste) + "][" + getMethodName(ste) + "][" + getLineNumber(ste) + "] " ; } publicstatic String getClassPackage(StackTraceElement[] ste) { return ste[depth].getClassName(); } publicstatic String getClassName(StackTraceElement[] ste) { String[] temp = ste[depth].getClassName().split( "\\." ); return temp[temp.length - 1 ]; } publicstatic String getMethodName(StackTraceElement[] ste) { return ste[depth].getMethodName(); } publicstaticint getLineNumber(StackTraceElement[] ste) { return ste[depth].getLineNumber(); } } 欢迎加群互相学习,共同进步。QQ群:iOS: 58099570 | Android: 572064792 | Nodejs:329118122 做人要厚道,转载请注明出处! 本文转自张昺华-sky博客园博客,原文链接:http://www.cnblogs.com/sunshine-anycall/p/3479070.html ,如需转载请自行联系原作者

优秀的个人博客,低调大师

Python的日志把我坑惨了,原来logging和print的区别这么大

本地跑的时候,这些print都输出在终端里,一目了然。但线上服务是用nohup后台启动的,标准输出被重定向到了一个文件。出问题那天,他打开那个文件,发现里面混着几十个模块的输出,print的内容和框架自己的输出搅在一起,没有时间戳,没有日志级别,没有模块名。他想搜“订单12345”的处理记录,结果搜出来几百行,根本分不清哪行是开始、哪行是结束、哪行出了错。

资源下载

更多资源
腾讯云软件源

腾讯云软件源

为解决软件依赖安装时官方源访问速度慢的问题,腾讯云为一些软件搭建了缓存服务。您可以通过使用腾讯云软件源站来提升依赖包的安装速度。为了方便用户自由搭建服务架构,目前腾讯云软件源站支持公网访问和内网访问。

Nacos

Nacos

Nacos /nɑ:kəʊs/ 是 Dynamic Naming and Configuration Service 的首字母简称,一个易于构建 AI Agent 应用的动态服务发现、配置管理和AI智能体管理平台。Nacos 致力于帮助您发现、配置和管理微服务及AI智能体应用。Nacos 提供了一组简单易用的特性集,帮助您快速实现动态服务发现、服务配置、服务元数据、流量管理。Nacos 帮助您更敏捷和容易地构建、交付和管理微服务平台。

Spring

Spring

Spring框架(Spring Framework)是由Rod Johnson于2002年提出的开源Java企业级应用框架,旨在通过使用JavaBean替代传统EJB实现方式降低企业级编程开发的复杂性。该框架基于简单性、可测试性和松耦合性设计理念,提供核心容器、应用上下文、数据访问集成等模块,支持整合Hibernate、Struts等第三方框架,其适用范围不仅限于服务器端开发,绝大多数Java应用均可从中受益。

优质分享App

优质分享App

近一个月的开发和优化,本站点的第一个app全新上线。该app采用极致压缩,本体才4.36MB。系统里面做了大量数据访问、缓存优化。方便用户在手机上查看文章。后续会推出HarmonyOS的适配版本。

用户登录
用户注册