# Logger **Repository Path**: baijuncheng-open-source/logger ## Basic Information - **Project Name**: Logger - **Description**: No description available - **Primary Language**: Java - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-10-31 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Logger #### 介绍 Simple, pretty and powerful logger for Z #### 使用说明 1,test for AndroidLogAdapter with default FormatStrategy Logger.addLogAdapter(new AndroidLogAdapter()); Logger.d("message"); Logger.clearLogAdapters(); 2,test for AndroidLogAdapter with customized PrettyFormatStrategy FormatStrategy formatStrategy = PrettyFormatStrategy.newBuilder() .showThreadInfo(false) // (Optional) Whether to show thread info or not. Default true .methodCount(0) // (Optional) How many method line to show. Default 2 .methodOffset(3) // (Optional) Skips some method invokes in stack trace. Default 5 // .logStrategy(customLog) // (Optional) Changes the log strategy to print out. Default LogCat .tag("My custom tag") // (Optional) Custom tag for each log. Default PRETTY_LOGGER .build(); Logger.addLogAdapter(new AndroidLogAdapter(formatStrategy)); 3,test for AndroidLogAdapter with default FormatStrategy who has rewritten isLoggable Logger.addLogAdapter(new AndroidLogAdapter() { @Override public boolean isLoggable(int priority, String tag) { return true; } }); 4, test for DiskLogAdapter Logger.addLogAdapter(new DiskLogAdapter(this)); //test for warn priority Logger.w("no thread info and only 1 method"); Logger.clearLogAdapters(); formatStrategy = PrettyFormatStrategy.newBuilder() .showThreadInfo(false) .methodCount(0) .build(); //test for AndroidLogAdapter with customized PrettyFormatStrategy Logger.addLogAdapter(new AndroidLogAdapter(formatStrategy)); //test for info priority Logger.i("no thread info and method info for INFO"); //test for error priority Logger.e("no thread info and method info for ERROR"); //test for customized tag with error priority Logger.t("tag").e("Custom tag for only one use"); 5,test for json Logger.json("{ \"key\": 3, \"value\": something}"); //test for List Logger.d(Arrays.asList("foo", "bar")); Map map = new HashMap<>(); map.put("key", "value"); map.put("key1", "value2"); //test for HashMap Logger.d(map); Logger.clearLogAdapters(); formatStrategy = PrettyFormatStrategy.newBuilder() .showThreadInfo(false) .methodCount(0) .tag("MyTag") .build(); Logger.addLogAdapter(new AndroidLogAdapter(formatStrategy)); //test for AndroidLogAdapter with customized PrettyFormatStrategy Logger.w("my log message with my tag");