|
1 | 1 | # EzyLogger-Android |
2 | 2 | Simple Logger for Android |
| 3 | + |
| 4 | + |
| 5 | +### Gradle |
| 6 | + |
| 7 | + |
| 8 | + |
| 9 | +### How to use: |
| 10 | + |
| 11 | +Init Logger |
| 12 | + |
| 13 | +Use in Activity |
| 14 | +```java |
| 15 | + |
| 16 | +public class BaseActivtiy extends AppCompatActivity { |
| 17 | + @Override |
| 18 | + protected void onCreate(Bundle savedInstanceState) { |
| 19 | + super.onCreate(savedInstanceState); |
| 20 | + //inline initialize |
| 21 | + new Logger.Builder(this).setTag("testing").enableLog(true).create(); |
| 22 | + |
| 23 | + //short initialize |
| 24 | + Logger.init(this); // Optional if you dont use Logger Toast |
| 25 | + Logger.initTag(this,"testing"); // default is 'EzyLogger' |
| 26 | + Logger.initTag("testing"); // default is 'EzyLogger' |
| 27 | + Logger.canShowLog(true); // default is True |
| 28 | + } |
| 29 | +} |
| 30 | + |
| 31 | +``` |
| 32 | + |
| 33 | + |
| 34 | +Logger use |
| 35 | +```java |
| 36 | + |
| 37 | +//info log |
| 38 | +Logger.info("message"); |
| 39 | +Logger.info(Object); |
| 40 | +Logger.info(Object,Format); // JSON, XML,LIST, MAP, BUNDLE, STRING, INTENT, ARRAY |
| 41 | + |
| 42 | +Logger.debug(...); |
| 43 | +Logger.warn(...); |
| 44 | +Logger.error(...); |
| 45 | +Logger.verbose(...); |
| 46 | +Logger.wtf(...); |
| 47 | + |
| 48 | +//EXAMPLE OF USE |
| 49 | + |
| 50 | +List<?> users = new ArrayList<>(); |
| 51 | +Bundle bundle = new Bundle(); |
| 52 | +Map<String,?> map = new LinkedHashMap<>(); |
| 53 | +Intent intent = new Intent(); |
| 54 | + |
| 55 | +Logger.info("message"); |
| 56 | +Logger.info(0); |
| 57 | +Logger.info(new String[]{"test","world","hello"}); |
| 58 | +Logger.info(new int[]{0,1,2,3,4}); |
| 59 | +Logger.info(true); |
| 60 | + |
| 61 | +Logger.info(users); |
| 62 | +Logger.info(bundle); |
| 63 | +Logger.info(map); |
| 64 | +Logger.info(intent); |
| 65 | + |
| 66 | +Logger.info(JSON_STRING,Format.JSON); |
| 67 | +Logger.info(XML_STRING,Format.XML); |
| 68 | +Logger.info(users,Format.LIST); |
| 69 | +Logger.info(bundle,Format.BUNDLE); |
| 70 | +Logger.info(map,Format.MAP); |
| 71 | +Logger.info(intent,Format.INTENT); |
| 72 | +Logger.info("message",Format.STRING); |
| 73 | +Logger.info(new String[]{"array","1","2"},Format.ARRAY); |
| 74 | +``` |
| 75 | + |
| 76 | + |
| 77 | +Use Logger for showing Toast |
| 78 | + |
| 79 | +``` java |
| 80 | +// Logger.init(this) is needed |
| 81 | +Logger.shortToast(MESSAGE); |
| 82 | +Logger.longToast(MESSAGE); |
| 83 | +``` |
| 84 | + |
| 85 | + |
| 86 | +Extra Logger |
| 87 | +if you need to list all the values in SharedPreferences |
| 88 | +```java |
| 89 | + |
| 90 | +//init |
| 91 | +Logger.init(this) //needed if not init yet |
| 92 | + |
| 93 | +//will log all the prefs in the default Prefs |
| 94 | +new Logger.Preference().printAllSharedPref(); |
| 95 | + |
| 96 | +//log all the prefs in the selected Prefs |
| 97 | +new Logger.Preference().whichPrefDBName(PREF_NAME).printAllSharedPref(); |
| 98 | + |
| 99 | +//log the value by the key |
| 100 | +new Logger.Preference().printSharedPrefByKey(KEY); |
| 101 | + |
| 102 | + |
| 103 | + |
| 104 | +//OR can do like this |
| 105 | +Logger.Preference pref = new Logger.Preference(); |
| 106 | +pref.whichPrefDBName(PREF_NAME); |
| 107 | +pref.printAllSharedPref(); |
| 108 | +pref.printSharedPrefByKey(KEY); |
| 109 | + |
| 110 | +``` |
| 111 | + |
| 112 | + |
| 113 | + |
| 114 | + |
| 115 | +###License |
| 116 | +<pre> |
| 117 | +Copyright 2017 HAFIQ IQMAL |
| 118 | + |
| 119 | +Licensed under the Apache License, Version 2.0 (the "License"); |
| 120 | +you may not use this file except in compliance with the License. |
| 121 | +You may obtain a copy of the License at |
| 122 | + |
| 123 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 124 | + |
| 125 | +Unless required by applicable law or agreed to in writing, software |
| 126 | +distributed under the License is distributed on an "AS IS" BASIS, |
| 127 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 128 | +See the License for the specific language governing permissions and |
| 129 | +limitations under the License. |
| 130 | +</pre> |
0 commit comments