|
1 | 1 | --- |
| 2 | + |
2 | 3 | title: Android Clog |
| 4 | + |
3 | 5 | --- |
4 | 6 |
|
5 | | -<section class="bs-docs-section"> |
6 | | - <h1 id="overview" class="page-header">Using Clog with Android</h1> |
| 7 | +# Using Clog with Android |
| 8 | +{ #overview .page-header } |
| 9 | + |
| 10 | +> Clog is a replacement of the standard Android Log. Featuring multiple logging profiles, removal of annoying tags, and |
| 11 | +> the powerful Parselmouth formatting language, you'll wonder how you ever got by without it. |
7 | 12 | |
8 | | - <blockquote> |
9 | | - Clog is a drop-in replacement of the standard Android Log. Featuing multiple logging profiles and the powerful Parselmouth formatting language, you'll wonder how you ever got by without it. |
10 | | - </blockquote> |
| 13 | +### Features |
11 | 14 |
|
12 | | - <h3 id="features">Features</h3> |
| 15 | +- All features of the base Clog library |
| 16 | +- Android-specific logging profiles for both development and production |
13 | 17 |
|
14 | | - <ul> |
15 | | - <li>All features of the base Clog library</li> |
16 | | - <li>Android-specific logging profiles for both development and production</li> |
17 | | - </ul> |
| 18 | + |
| 19 | +# Get It |
| 20 | +{ #download .page-header } |
18 | 21 |
|
19 | | -</section> |
| 22 | +### Include In Your Project |
20 | 23 |
|
21 | | -<section class="bs-docs-section"> |
22 | | - <h1 id="download" class="page-header">Get It</h1> |
| 24 | +Android Clog can be added to your project from Jitpack through Gradle. |
23 | 25 |
|
24 | | - <h3 id="download-include">Include In Your Project</h3> |
25 | | - <p> |
26 | | - Android Clog can be added to your project from Jitpack through Gradle. |
27 | | - </p> |
| 26 | +Add this to your project-level build.gradle: |
28 | 27 |
|
29 | | - <p> |
30 | | - Add this to your project-level build.gradle: |
31 | | - </p> |
32 | | - <pre> |
| 28 | +```groovy |
33 | 29 | allprojects { |
34 | 30 | repositories { |
35 | 31 | ... |
36 | 32 | maven { url "https://jitpack.io" } |
37 | 33 | } |
38 | | -}</pre> |
| 34 | +} |
| 35 | +``` |
| 36 | + |
| 37 | +Add this to your module's dependencies: |
39 | 38 |
|
40 | | - <p> |
41 | | - Add this to your module's dependencies: |
42 | | - </p> |
43 | | - <pre> |
| 39 | +```groovy |
44 | 40 | dependencies { |
45 | 41 | ... |
46 | | - compile('com.github.cjbrooks12:Android-Clog:v{{site.version}}@aar') { |
47 | | - transitive = true; |
48 | | - } |
49 | | -}</pre> |
| 42 | + api 'com.github.cjbrooks12:Android-Clog:v{{site.version}}' |
| 43 | +} |
| 44 | +``` |
| 45 | + |
50 | 46 |
|
51 | | - <h3 id="download-github">Github</h3> |
52 | | - <p> |
53 | | - Full source can be viewed on Github. Feel free to send me a PR. |
54 | | - </p> |
55 | | - <div> |
56 | | - <a href="https://github.com/cjbrooks12/Android-Clog">Github Repo</a> |
57 | | - </div> |
| 47 | +### Github |
58 | 48 |
|
59 | | - <h3 id="download-jitpack">Jitpack</h3> |
60 | | - <p> |
61 | | - Download the most recent commits, or see instructions for installing with Maven, at Jitpack. |
62 | | - </p> |
63 | | - <div> |
64 | | - <a href="https://jitpack.io/#cjbrooks12/Android-Clog"><img src="https://camo.githubusercontent.com/86295ad9ade648308e2328e7b2aba032fed9cc0c/68747470733a2f2f6a69747061636b2e696f2f762f636a62726f6f6b7331322f416e64726f69642d436c6f672e737667" alt="" data-canonical-src="https://jitpack.io/v/cjbrooks12/Android-Clog.svg" style="max-width:100%;"></a> |
65 | | - </div> |
| 49 | +Full source can be viewed on [Github](https://github.com/cjbrooks12/Android-Clog). Feel free to send me a PR. |
66 | 50 |
|
67 | | - <h3 id="download-javadoc">View Javadoc</h3> |
68 | | - <p> |
69 | | - View javadoc, hosted by Jitpack. |
70 | | - </p> |
71 | | - <div> |
72 | | - <a href="https://jitpack.io/com/github/cjbrooks12/Clog/v{{site.version}}/javadoc/"><img src="https://camo.githubusercontent.com/e987e48872f10d633fc044d7e20e7b82f99df591/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f7461672f636a62726f6f6b7331322f436c6f672e7376673f6d61784167653d32353932303030266c6162656c3d6a617661646f63" alt="JitPack Javadoc" data-canonical-src="https://img.shields.io/github/tag/cjbrooks12/Clog.svg?maxAge=2592000&label=javadoc" style="max-width:100%;"></a> |
73 | | - </div> |
74 | | -</section> |
| 51 | +### Jitpack |
75 | 52 |
|
76 | | -<section class="bs-docs-section"> |
77 | | - <h1 id="use" class="page-header">Use in your apps</h1> |
| 53 | +Download the most recent commits, or see instructions for installing with Maven, at Jitpack. |
| 54 | + |
| 55 | +[](https://jitpack.io/#JavaEden/Clog) |
| 56 | + |
| 57 | +### Javadoc |
78 | 58 |
|
79 | | - <h3 id="use-implementation">Clog implementation</h3> |
| 59 | +View javadoc, hosted by Jitpack. |
80 | 60 |
|
81 | | - <p>See <a href="https://github.com/cjbrooks12/Clog">https://github.com/cjbrooks12/Clog</a> for information on Clog.</p> |
| 61 | +[](https://jitpack.io/com/github/cjbrooks12/Clog/v{{site.version}}/javadoc/) |
82 | 62 |
|
83 | | - <p>Android Clog provides simple Android Log implementations for Clog. The mapping between Clog levels and Android Clog levels is one-to-one, as the Clog API was designed to directly replace Log:</p> |
| 63 | +# Use In Your Apps |
| 64 | +{ #download .page-header } |
84 | 65 |
|
85 | | - <p><code>Clog.d(...) --> Log.d(...)</code></p> |
| 66 | +### Clog implementation |
86 | 67 |
|
87 | | - <p><code>Clog.e(...) --> Log.e(...)</code></p> |
| 68 | +See [{{site.baseUrl}}]({{site.baseUrl}}) for information on Clog. |
88 | 69 |
|
89 | | - <p><code>Clog.i(...) --> Log.i(...)</code></p> |
| 70 | +Android Clog provides simple Android Log implementations for Clog. The mapping between Clog levels and Android Clog |
| 71 | +levels is one-to-one, as the Clog API was designed to replace Log, but be more flexible and not require tags with the |
| 72 | +logging calls. |
90 | 73 |
|
91 | | - <p><code>Clog.v(...) --> Log.v(...)</code></p> |
| 74 | +`Clog.v(...) ->> Log.v(...)` |
92 | 75 |
|
93 | | - <p><code>Clog.w(...) --> Log.w(...)</code></p> |
| 76 | +`Clog.d(...) ->> Log.d(...)` |
94 | 77 |
|
95 | | - <p><code>Clog.wtf(...) --> Log.wtf(...)</code></p> |
| 78 | +`Clog.i(...) ->> Log.i(...)` |
96 | 79 |
|
97 | | - <p>In addition, Clog tags work exactly like Android Log tags, like so:</p> |
| 80 | +`Clog.w(...) ->> Log.w(...)` |
98 | 81 |
|
99 | | - <pre> |
100 | | -d(String tag, String message) { |
101 | | - Log.d(tag, message); |
102 | | -}</pre> |
| 82 | +`Clog.e(...) ->> Log.e(...)` |
103 | 83 |
|
104 | | - <p>Getting Android Clog integrated into your project is easy. Add the following to your Activity's <code>onCreate()</code>:</p> |
| 84 | +`Clog.wtf(...) ->> Log.wtf(...)` |
105 | 85 |
|
106 | | - <pre> |
| 86 | +In addition, Clog gets rid of the annoying Android Log tags. By default, the Tag passed to the Android logger is the |
| 87 | +simple classname of the calling class: |
| 88 | + |
| 89 | +``` |
| 90 | +Clog.d(String message) ->> Log.d(callerClassName, message) |
| 91 | +``` |
| 92 | + |
| 93 | +If, for some reason, you need to set the Tag to something other than the caller class's name, you can push a Tag into |
| 94 | +Clog before logging: |
| 95 | + |
| 96 | +``` |
| 97 | +Clog.pushTag(customTag); |
| 98 | +Clog.d(message); ->> Log.d(customTag, message) |
| 99 | +``` |
| 100 | + |
| 101 | +Just make sure to pop it back off when you're done, otherwise other places will be logged with that tag as well. |
| 102 | + |
| 103 | +``` |
| 104 | +Clog.popTag(); |
| 105 | +``` |
| 106 | + |
| 107 | +Getting Android Clog integrated into your project is easy. Add the following to your Activity's or Application's |
| 108 | +`onCreate()` method: |
| 109 | + |
| 110 | +```java |
107 | 111 | if(BuildConfig.DEBUG) { |
108 | 112 | Clog.setCurrentProfile("dev", AndroidClog.getDevelopmentClog()); |
109 | 113 | } |
110 | 114 | else { |
111 | 115 | Clog.setCurrentProfile("prod", AndroidClog.getProductionClog()); |
112 | | -}</pre> |
113 | | - |
114 | | - <p>In development, all logs will be directed to the standard Log implementations shown above, but in production, all logs will be discarded. You can replace the production log profile with implementations that write to file or send to Crashlytics if you need that instead.</p> |
115 | | - |
| 116 | +} |
| 117 | +``` |
116 | 118 |
|
117 | | -</section> |
| 119 | +In development, all logs will be directed to the standard Log implementations shown above, but in production, all logs |
| 120 | +will be discarded. You can replace the production log profile with implementations that write to file or send to |
| 121 | +Crashlytics if you need that instead. |
0 commit comments