├── .gitignore
├── ILog
├── .classpath
├── .project
├── AndroidManifest.xml
├── proguard-project.txt
├── project.properties
└── src
│ └── com
│ └── moshx
│ └── ilog
│ ├── ILog.java
│ ├── Settings.java
│ ├── console
│ ├── AndroidConsole.java
│ ├── ConsoleFactory.java
│ ├── ILogConsole.java
│ └── JVMConsole.java
│ ├── filelogger
│ ├── FileLogger.java
│ ├── HtmlFileLogger.java
│ └── TextFileLogger.java
│ └── utils
│ └── Utility.java
├── ILogJVMSample
├── .classpath
├── .project
├── .settings
│ └── org.eclipse.jdt.core.prefs
└── src
│ └── com
│ └── moshx
│ └── jvmsample
│ └── LoggingTest.java
├── ILogSample
├── .classpath
├── .project
├── AndroidManifest.xml
├── ic_launcher-web.png
├── libs
│ └── android-support-v4.jar
├── proguard-project.txt
├── project.properties
├── res
│ ├── drawable-hdpi
│ │ └── ic_launcher.png
│ ├── drawable-mdpi
│ │ └── ic_launcher.png
│ ├── drawable-xhdpi
│ │ └── ic_launcher.png
│ ├── drawable-xxhdpi
│ │ └── ic_launcher.png
│ ├── layout
│ │ ├── activity_main.xml
│ │ └── fragment_main.xml
│ ├── menu
│ │ └── main.xml
│ ├── values-v11
│ │ └── styles.xml
│ ├── values-v14
│ │ └── styles.xml
│ ├── values-w820dp
│ │ └── dimens.xml
│ └── values
│ │ ├── dimens.xml
│ │ ├── strings.xml
│ │ └── styles.xml
└── src
│ └── com
│ └── moshx
│ └── ilogsample
│ └── MainActivity.java
├── LICENSE
└── README.md
/.gitignore:
--------------------------------------------------------------------------------
1 | # Built application files
2 | *.apk
3 | *.ap_
4 |
5 | # Files for the Dalvik VM
6 | *.dex
7 |
8 | # Java class files
9 | *.class
10 |
11 | # Generated files
12 | bin/
13 | gen/
14 |
15 | # Gradle files
16 | .gradle/
17 | build/
18 |
19 | # Local configuration file (sdk path, etc)
20 | local.properties
21 |
22 | # Proguard folder generated by Eclipse
23 | proguard/
24 |
--------------------------------------------------------------------------------
/ILog/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/ILog/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | ILog
4 |
5 |
6 |
7 |
8 |
9 | com.android.ide.eclipse.adt.ResourceManagerBuilder
10 |
11 |
12 |
13 |
14 | com.android.ide.eclipse.adt.PreCompilerBuilder
15 |
16 |
17 |
18 |
19 | org.eclipse.jdt.core.javabuilder
20 |
21 |
22 |
23 |
24 | com.android.ide.eclipse.adt.ApkBuilder
25 |
26 |
27 |
28 |
29 |
30 | com.android.ide.eclipse.adt.AndroidNature
31 | org.eclipse.jdt.core.javanature
32 |
33 |
34 |
--------------------------------------------------------------------------------
/ILog/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/ILog/proguard-project.txt:
--------------------------------------------------------------------------------
1 | # To enable ProGuard in your project, edit project.properties
2 | # to define the proguard.config property as described in that file.
3 | #
4 | # Add project specific ProGuard rules here.
5 | # By default, the flags in this file are appended to flags specified
6 | # in ${sdk.dir}/tools/proguard/proguard-android.txt
7 | # You can edit the include path and order by changing the ProGuard
8 | # include property in project.properties.
9 | #
10 | # For more details, see
11 | # http://developer.android.com/guide/developing/tools/proguard.html
12 |
13 | # Add any project specific keep options here:
14 |
15 | # If your project uses WebView with JS, uncomment the following
16 | # and specify the fully qualified class name to the JavaScript interface
17 | # class:
18 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
19 | # public *;
20 | #}
21 |
--------------------------------------------------------------------------------
/ILog/project.properties:
--------------------------------------------------------------------------------
1 | # This file is automatically generated by Android Tools.
2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3 | #
4 | # This file must be checked in Version Control Systems.
5 | #
6 | # To customize properties used by the Ant build system edit
7 | # "ant.properties", and override values to adapt the script to your
8 | # project structure.
9 | #
10 | # To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
11 | #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
12 |
13 | # Project target.
14 | target=android-19
15 | android.library=true
16 |
--------------------------------------------------------------------------------
/ILog/src/com/moshx/ilog/ILog.java:
--------------------------------------------------------------------------------
1 | package com.moshx.ilog;
2 |
3 | import java.util.Locale;
4 |
5 | import com.moshx.ilog.Settings.Level;
6 | import com.moshx.ilog.console.ILogConsole;
7 | import com.moshx.ilog.console.ConsoleFactory;
8 | import com.moshx.ilog.filelogger.FileLogger;
9 | import com.moshx.ilog.filelogger.TextFileLogger;
10 |
11 | public class ILog {
12 |
13 | private final Settings mSettings = new Settings();
14 | private ILogConsole mLogger = ConsoleFactory.getNewLogger(mSettings);
15 | private FileLogger mFileLogger = new TextFileLogger();
16 |
17 | public static final ILog o = new ILog("ILog");
18 |
19 | private String mTag;
20 |
21 | /**
22 | * Simple constructor to use, the tag value will be the name of the Class
23 | * this constructor called from.
24 | */
25 | public ILog() {
26 | this(getCurrentClassName());
27 | }
28 |
29 | /**
30 | * Constructor to create {@link ILog} instance with specific tag.
31 | *
32 | * @param tag
33 | * the tag value
34 | */
35 | public ILog(String tag) {
36 | mTag = tag;
37 | }
38 |
39 | /**
40 | * Set the enabled state logging.
41 | *
42 | * @param enabled
43 | * True if logging is enabled, false otherwise.
44 | */
45 | public ILog enableLogging(boolean enabled) {
46 | mSettings.enableLogging(enabled);
47 | return this;
48 | }
49 |
50 | /**
51 | * Sets the tag value to the name of the Class of this method called from.
52 | */
53 | public ILog setTag() {
54 | mTag = getCurrentClassName();
55 | return this;
56 | }
57 |
58 | /**
59 | * Set the value of tag
60 | *
61 | * @param tag
62 | */
63 | public ILog setTag(String tag) {
64 | mTag = tag;
65 | return this;
66 | }
67 |
68 | /**
69 | * Returns the {@link Settings} of this {@link ILog} instance
70 | *
71 | * @return Settings
72 | */
73 | public Settings getSettings() {
74 | return mSettings;
75 | }
76 |
77 | /**
78 | * Logging
79 | */
80 |
81 | /**
82 | * Send a {@link #DEBUG} log message, the message will be created from
83 | * current class and current method
84 | */
85 | public ILog d() {
86 | return d(mTag, getCurrentStackLine(), null);
87 | }
88 |
89 | /**
90 | * Send a {@link #DEBUG} log message.
91 | *
92 | * @param msg
93 | * The object you would like logged.
94 | */
95 | public ILog d(Object msg) {
96 | return d(mTag, msg, null);
97 | }
98 |
99 | /**
100 | * Send a {@link #DEBUG} log message.
101 | *
102 | * @param tag
103 | * Used to identify the source of a log message. It usually
104 | * identifies the class or activity where the log call occurs.
105 | * @param msg
106 | * The object you would like logged.
107 | */
108 | public ILog d(String tag, Object msg) {
109 | return d(tag, msg, null);
110 | }
111 |
112 | /**
113 | * Send a {@link #DEBUG} log exception.
114 | *
115 | * @param err
116 | * An exception to log
117 | */
118 | public ILog d(Throwable err) {
119 | return d(mTag, null, err);
120 | }
121 |
122 | /**
123 | * Send a {@link #DEBUG} log message and log the exception.
124 | *
125 | * @param msg
126 | * The Object you would like logged.
127 | * @param err
128 | * An exception to log
129 | */
130 | public ILog d(Object msg, Throwable err) {
131 | return d(mTag, msg, err);
132 | }
133 |
134 | /**
135 | * Send a {@link #DEBUG} log message and log the exception.
136 | *
137 | * @param tag
138 | * Used to identify the source of a log message. It usually
139 | * identifies the class or activity where the log call occurs.
140 | * @param msg
141 | * The Object you would like logged.
142 | * @param err
143 | * An exception to log
144 | */
145 | public ILog d(String tag, Object msg, Throwable err) {
146 | if (mSettings.enabled && mSettings.isDebugEnabled) {
147 | mLogger.d(tag, msg, err);
148 | if (mSettings.isFileLoggingEnabled) {
149 | mFileLogger.log(Level.DEBUG, tag, msg, err);
150 | }
151 | }
152 | return this;
153 | }
154 |
155 | /**
156 | * Send a {@link #INFO} log message, the message will be created from
157 | * current class and current method
158 | */
159 | public ILog i() {
160 | return i(mTag, getCurrentStackLine(), null);
161 | }
162 |
163 | /**
164 | * Send a {@link #INFO} log message.
165 | *
166 | * @param msg
167 | * The Object you would like logged.
168 | */
169 | public ILog i(String msg) {
170 | return i(mTag, msg, null);
171 | }
172 |
173 | /**
174 | * Send a {@link #INFO} log message.
175 | *
176 | * @param tag
177 | * Used to identify the source of a log message. It usually
178 | * identifies the class or activity where the log call occurs.
179 | * @param msg
180 | * The Object you would like logged.
181 | */
182 | public ILog i(String tag, String msg) {
183 | return i(tag, msg, null);
184 | }
185 |
186 | /**
187 | * Send a {@link #INFO} log exception.
188 | *
189 | * @param err
190 | * An exception to log
191 | */
192 | public ILog i(Throwable err) {
193 | return i(mTag, null, err);
194 | }
195 |
196 | /**
197 | * Send a {@link #INFO} log message and log the exception.
198 | *
199 | * @param msg
200 | * The Object you would like logged.
201 | * @param err
202 | * An exception to log
203 | */
204 | public ILog i(String msg, Throwable err) {
205 | return i(mTag, msg, err);
206 | }
207 |
208 | /**
209 | * Send a {@link #INFO} log message and log the exception.
210 | *
211 | * @param tag
212 | * Used to identify the source of a log message. It usually
213 | * identifies the class or activity where the log call occurs.
214 | * @param msg
215 | * The Object you would like logged.
216 | * @param err
217 | * An exception to log
218 | */
219 | public ILog i(String tag, String msg, Throwable err) {
220 | if (mSettings.enabled && mSettings.isInfoEnabled) {
221 | mLogger.i(tag, msg, err);
222 | if (mSettings.isFileLoggingEnabled) {
223 | mFileLogger.log(Level.INFO, tag, msg, err);
224 | }
225 | }
226 | return this;
227 | }
228 |
229 | // Verbose
230 |
231 | /**
232 | * Send a {@link #VERBOSE} log message, the message will be created from
233 | * current class and current method.
234 | */
235 | public ILog v() {
236 | return v(mTag, getCurrentStackLine(), null);
237 | }
238 |
239 | /**
240 | * Send a {@link #VERBOSE} log message.
241 | *
242 | * @param msg
243 | * The Object you would like logged.
244 | */
245 | public ILog v(String msg) {
246 | return v(mTag, msg, null);
247 | }
248 |
249 | /**
250 | * Send a {@link #VERBOSE} log message.
251 | *
252 | * @param tag
253 | * Used to identify the source of a log message. It usually
254 | * identifies the class or activity where the log call occurs.
255 | * @param msg
256 | * The Object you would like logged.
257 | */
258 | public ILog v(String tag, String msg) {
259 | return v(tag, msg, null);
260 | }
261 |
262 | /**
263 | * Send a {@link #VERBOSE} log the exception.
264 | *
265 | * @param err
266 | * An exception to log
267 | */
268 | public ILog v(Throwable err) {
269 | return v(mTag, null, err);
270 | }
271 |
272 | /**
273 | * Send a {@link #VERBOSE} log message and log the exception.
274 | *
275 | * @param msg
276 | * The Object you would like logged.
277 | * @param err
278 | * An exception to log
279 | */
280 | public ILog v(String msg, Throwable err) {
281 | return v(mTag, msg, err);
282 | }
283 |
284 | /**
285 | * Send a {@link #VERBOSE} log message and log the exception.
286 | *
287 | * @param tag
288 | * Used to identify the source of a log message. It usually
289 | * identifies the class or activity where the log call occurs.
290 | * @param msg
291 | * The Object you would like logged.
292 | * @param err
293 | * An exception to log
294 | */
295 | public ILog v(String tag, String msg, Throwable err) {
296 | if (mSettings.enabled && mSettings.isVerboseEnabled) {
297 | mLogger.v(tag, msg, err);
298 | if (mSettings.isFileLoggingEnabled) {
299 | mFileLogger.log(Level.VERBOSE, tag, msg, err);
300 | }
301 | }
302 | return this;
303 | }
304 |
305 | // Error
306 |
307 | /**
308 | * Send a {@link #ERROR} log message, the message will be created from
309 | * current class and current method.
310 | */
311 | public ILog e() {
312 | return e(mTag, getCurrentStackLine(), null);
313 | }
314 |
315 | /**
316 | * Send a {@link #ERROR} log message.
317 | *
318 | * @param msg
319 | * The Object you would like logged.
320 | */
321 | public ILog e(Object msg) {
322 | return e(mTag, msg, null);
323 | }
324 |
325 | /**
326 | * Send a {@link #ERROR} log message.
327 | *
328 | * @param tag
329 | * Used to identify the source of a log message. It usually
330 | * identifies the class or activity where the log call occurs.
331 | * @param msg
332 | * The message you would like logged.
333 | */
334 | public ILog e(String tag, Object msg) {
335 | return e(tag, msg, null);
336 | }
337 |
338 | /**
339 | * Send a {@link #ERROR} log exception.
340 | *
341 | * @param err
342 | * An exception to log
343 | */
344 | public ILog e(Throwable err) {
345 | return e(mTag, null, err);
346 | }
347 |
348 | /**
349 | * Send a {@link #ERROR} log message and log the exception.
350 | *
351 | * @param msg
352 | * The message you would like logged.
353 | * @param err
354 | * An exception to log
355 | */
356 | public ILog e(Object msg, Throwable err) {
357 | return e(mTag, msg, err);
358 | }
359 |
360 | /**
361 | * Send a {@link #ERROR} log message and log the exception.
362 | *
363 | * @param tag
364 | * Used to identify the source of a log message. It usually
365 | * identifies the class or activity where the log call occurs.
366 | * @param msg
367 | * The object you would like logged.
368 | * @param err
369 | * An exception to log
370 | */
371 | public ILog e(String tag, Object msg, Throwable err) {
372 | if (mSettings.enabled && mSettings.isErrorEnabled) {
373 | mLogger.e(tag, msg, err);
374 | if (mSettings.isFileLoggingEnabled) {
375 | mFileLogger.log(Level.ERROR, tag, msg, err);
376 | }
377 | }
378 | return this;
379 | }
380 |
381 | // Warn
382 | /**
383 | * Send a {@link #WARN} log message, the message will be created from
384 | * current class and current method.
385 | */
386 | public ILog w() {
387 | return w(mTag, getCurrentStackLine(), null);
388 | }
389 |
390 | /**
391 | * Send a {@link #WARN} log message.
392 | *
393 | * @param msg
394 | * The object you would like logged.
395 | */
396 | public ILog w(Object msg) {
397 | return w(mTag, msg, null);
398 | }
399 |
400 | /**
401 | * Send a {@link #WARN} log message.
402 | *
403 | * @param tag
404 | * Used to identify the source of a log message. It usually
405 | * identifies the class or activity where the log call occurs.
406 | * @param msg
407 | * The message you would like logged.
408 | */
409 | public ILog w(String tag, Object msg) {
410 | return w(tag, msg, null);
411 | }
412 |
413 | /**
414 | * Send a {@link #WARN} log exception.
415 | *
416 | * @param err
417 | * An exception to log
418 | */
419 | public ILog w(Throwable err) {
420 | return w(mTag, null, err);
421 | }
422 |
423 | /**
424 | * Send a {@link #WARN} log message and log the exception.
425 | *
426 | * @param msg
427 | * The message you would like logged.
428 | * @param err
429 | * An exception to log
430 | */
431 | public ILog w(Object msg, Throwable err) {
432 | return w(mTag, msg, err);
433 | }
434 |
435 | /**
436 | * Send a {@link #WARN} log message and log the exception.
437 | *
438 | * @param tag
439 | * Used to identify the source of a log message. It usually
440 | * identifies the class or activity where the log call occurs.
441 | * @param msg
442 | * The message you would like logged.
443 | * @param err
444 | * An exception to log
445 | */
446 | public ILog w(String tag, Object msg, Throwable err) {
447 | if (mSettings.enabled && mSettings.isWarnEnabled) {
448 | mLogger.w(tag, msg, err);
449 | if (mSettings.isFileLoggingEnabled) {
450 | mFileLogger.log(Level.WARN, tag, msg, err);
451 | }
452 | }
453 | return this;
454 | }
455 |
456 | private String getCurrentStackLine() {
457 |
458 | StackTraceElement target = new Exception().getStackTrace()[2];
459 |
460 | String msg = String.format(Locale.US, "[%d:%s] %s()",
461 | target.getLineNumber(), target.getClassName(),
462 | target.getMethodName());
463 | return msg;
464 |
465 | }
466 |
467 | /**
468 | *
469 | * @return current instance of {@link FileLogger}, the default value is
470 | * instance of {@link TextFileLogger}
471 | */
472 | public FileLogger getFileLogger() {
473 | return mFileLogger;
474 | }
475 |
476 | /**
477 | * associate an instance of {@link FileLogger}, if the instance is not
478 | * null
, file logging will be enabled
479 | *
480 | * @param fileLogger
481 | * the instance of {@link FileLogger}
482 | */
483 | public ILog setFileLogger(FileLogger fileLogger) {
484 | mSettings.setFileLogging(fileLogger != null);
485 | mFileLogger = fileLogger;
486 | return this;
487 | }
488 |
489 | /**
490 | * Set the enabled state of the instance of {@link FileLogger} associated
491 | * with current instance of {@link ILog}.
492 | *
493 | * @param enabled
494 | * True if file logging is enabled, false otherwise.
495 | */
496 | public ILog setFileLogging(boolean enabled) {
497 | mSettings.setFileLogging(enabled);
498 | return this;
499 | }
500 |
501 | private static String getCurrentClassName() {
502 | String className = new Exception().getStackTrace()[2].getClassName();
503 | if (className.contains(".")) {
504 | className = className.substring(className.lastIndexOf(".") + 1);
505 | }
506 | return className;
507 | }
508 | }
509 |
--------------------------------------------------------------------------------
/ILog/src/com/moshx/ilog/Settings.java:
--------------------------------------------------------------------------------
1 | package com.moshx.ilog;
2 |
3 | import com.moshx.ilog.filelogger.FileLogger;
4 |
5 | public class Settings {
6 |
7 | public enum Level {
8 |
9 | DEBUG(0x01), INFO(0x02), WARN(0x04), ERROR(0x08), VERBOSE(0x16);
10 |
11 | public final int value;
12 |
13 | Level(int value) {
14 | this.value = value;
15 |
16 | }
17 | }
18 |
19 | boolean enabled = true;
20 | /**
21 | * Levels
22 | */
23 | boolean isDebugEnabled = true;
24 | boolean isInfoEnabled = true;
25 | boolean isWarnEnabled = true;
26 | boolean isErrorEnabled = true;
27 | boolean isVerboseEnabled = true;
28 | boolean isFileLoggingEnabled = false;
29 | private boolean isWrapText = true;
30 |
31 | /**
32 | * Sets the {@link Level}s that would be logged, only passed levels would be
33 | * logged.
34 | *
35 | * @param levels
36 | * to be logged
37 | */
38 | public void setLevels(int levels) {
39 |
40 | isDebugEnabled = ((levels & Level.DEBUG.value) == Level.DEBUG.value);
41 | isInfoEnabled = ((levels & Level.INFO.value) == Level.INFO.value);
42 | isWarnEnabled = ((levels & Level.WARN.value) == Level.WARN.value);
43 | isErrorEnabled = ((levels & Level.ERROR.value) == Level.ERROR.value);
44 | isVerboseEnabled = ((levels & Level.VERBOSE.value) == Level.VERBOSE.value);
45 | }
46 |
47 | /**
48 | * Sets the {@link Level}s that would be logged, only passed levels would be
49 | * logged.
50 | *
51 | * @param levels
52 | * to be logged
53 | */
54 | public void setLevels(Level... levels) {
55 | int vals = 0;
56 | if (levels != null) {
57 | for (Level l : levels) {
58 | vals |= l.value;
59 | }
60 | setLevels(vals);
61 | }
62 | }
63 |
64 | /**
65 | * Set the enabled state logging.
66 | *
67 | * @param enabled
68 | * True if logging is enabled, false otherwise.
69 | */
70 | public void enableLogging(boolean enabled) {
71 | this.enabled = enabled;
72 | }
73 |
74 | public boolean isLoggingEnabled() {
75 | return enabled;
76 | }
77 |
78 | /**
79 | * Set the enabled state of the instance of {@link FileLogger} associated
80 | * with current instance of {@link ILog}.
81 | *
82 | * @param enabled
83 | * True if file logging is enabled, false otherwise.
84 | */
85 | public void setFileLogging(boolean enabled) {
86 | isFileLoggingEnabled = enabled;
87 | }
88 |
89 | public boolean isFileLogging() {
90 | return isFileLoggingEnabled;
91 | }
92 |
93 | /**
94 | * formations
95 | */
96 |
97 | private String outFormat = "%s -%s %s %s";
98 |
99 | public void setOutFormat(String format) {
100 | outFormat = format;
101 | }
102 |
103 | public String formatOut(Object... in) {
104 | return String.format(outFormat, in);
105 | }
106 |
107 | public boolean isWrapText() {
108 | return isWrapText;
109 | }
110 |
111 | /**
112 | * enabled text wrapping in Android LogCat, if the length of the message
113 | * will be more than 4000 characters, it will be split into lines
114 | *
115 | * @param isWrapText
116 | * if true text wrapping will be enabled, false otherwise
117 | * (default value is enabled)
118 | */
119 | public void setWrapText(boolean isWrapText) {
120 | this.isWrapText = isWrapText;
121 | }
122 | }
123 |
--------------------------------------------------------------------------------
/ILog/src/com/moshx/ilog/console/AndroidConsole.java:
--------------------------------------------------------------------------------
1 | package com.moshx.ilog.console;
2 |
3 | import android.util.Log;
4 |
5 | import com.moshx.ilog.Settings;
6 |
7 | class AndroidConsole extends ILogConsole {
8 |
9 | private Settings mSettings;
10 |
11 | public AndroidConsole(Settings sts) {
12 | mSettings = sts;
13 | }
14 |
15 | @Override
16 | public void d(String tag, Object msg, Throwable err) {
17 |
18 | String msgStr = msg != null ? msg.toString() : "";
19 |
20 | if (msgStr.length() > 4000 && mSettings.isWrapText()) {
21 | String[] arrs = splitStringByLimit(msgStr, 4000);
22 | for (String s : arrs) {
23 | Log.d(tag, s);
24 | }
25 | if (err != null) {
26 | Log.d(tag, "", err);
27 | }
28 | } else {
29 | Log.d(tag, msgStr, err);
30 | }
31 | }
32 |
33 | @Override
34 | public void e(String tag, Object msg, Throwable err) {
35 | String msgStr = msg != null ? msg.toString() : "";
36 |
37 | if (msgStr.length() > 4000 && mSettings.isWrapText()) {
38 | String[] arrs = splitStringByLimit(msgStr, 4000);
39 | for (String s : arrs) {
40 | Log.e(tag, s);
41 | }
42 | if (err != null) {
43 | Log.e(tag, "", err);
44 | }
45 | } else {
46 | Log.e(tag, msgStr, err);
47 | }
48 | }
49 |
50 | @Override
51 | public void i(String tag, Object msg, Throwable err) {
52 |
53 | String msgStr = msg != null ? msg.toString() : "";
54 |
55 | if (msgStr.length() > 4000 && mSettings.isWrapText()) {
56 | String[] arrs = splitStringByLimit(msgStr, 4000);
57 | for (String s : arrs) {
58 | Log.i(tag, s);
59 | }
60 | if (err != null) {
61 | Log.i(tag, "", err);
62 | }
63 | } else {
64 | Log.i(tag, msgStr, err);
65 | }
66 | }
67 |
68 | @Override
69 | public void v(String tag, Object msg, Throwable err) {
70 |
71 | String msgStr = msg != null ? msg.toString() : "";
72 |
73 | if (msgStr.length() > 4000 && mSettings.isWrapText()) {
74 | String[] arrs = splitStringByLimit(msgStr, 4000);
75 | for (String s : arrs) {
76 | Log.v(tag, s);
77 | }
78 | if (err != null) {
79 | Log.v(tag, "", err);
80 | }
81 | } else {
82 | Log.v(tag, msgStr, err);
83 | }
84 | }
85 |
86 | @Override
87 | public void w(String tag, Object msg, Throwable err) {
88 |
89 | String msgStr = msg != null ? msg.toString() : "";
90 |
91 | if (msgStr.length() > 4000 && mSettings.isWrapText()) {
92 | String[] arrs = splitStringByLimit(msgStr, 4000);
93 | for (String s : arrs) {
94 | Log.w(tag, s);
95 | }
96 | if (err != null) {
97 | Log.w(tag, "", err);
98 | }
99 | } else {
100 | Log.w(tag, msgStr, err);
101 | }
102 | }
103 |
104 | }
105 |
--------------------------------------------------------------------------------
/ILog/src/com/moshx/ilog/console/ConsoleFactory.java:
--------------------------------------------------------------------------------
1 | package com.moshx.ilog.console;
2 |
3 | import java.util.Locale;
4 |
5 | import com.moshx.ilog.Settings;
6 |
7 | public class ConsoleFactory {
8 |
9 | static boolean isAndroidVM = false;
10 | static {
11 | String vendor = System.getProperty("java.vm.vendor");
12 | isAndroidVM = (vendor.toLowerCase(Locale.US).contains("android"));
13 | }
14 |
15 | public static ILogConsole getNewLogger(Settings sts) {
16 | if (isAndroidVM) {
17 | return new AndroidConsole(sts);
18 | } else {
19 | return new JVMConsole(sts);
20 | }
21 | }
22 |
23 | }
24 |
--------------------------------------------------------------------------------
/ILog/src/com/moshx/ilog/console/ILogConsole.java:
--------------------------------------------------------------------------------
1 | package com.moshx.ilog.console;
2 |
3 | public abstract class ILogConsole {
4 |
5 | public abstract void d(String tag, Object msg, Throwable err);
6 |
7 | public abstract void e(String tag, Object msg, Throwable err);
8 |
9 | public abstract void i(String tag, Object msg, Throwable err);
10 |
11 | public abstract void v(String tag, Object msg, Throwable err);
12 |
13 | public abstract void w(String tag, Object msg, Throwable err);
14 |
15 | protected static boolean isEmpty(Object s) {
16 | return s == null || s.toString().length() == 0;
17 | }
18 |
19 | protected static String[] splitStringByLimit(String s, int limit) {
20 | int length = s.length();
21 | int count = length / 4000 + (length % 4000 > 0 ? 1 : 0);
22 | String[] msgs = new String[count];
23 | int index = 0;
24 | for (int i = 0; i < msgs.length; i++) {
25 | int r = index + 4000;
26 | if (r > length) {
27 | r = length;
28 | }
29 | msgs[i] = s.substring(index, r);
30 | index += 4000;
31 | }
32 |
33 | return msgs;
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/ILog/src/com/moshx/ilog/console/JVMConsole.java:
--------------------------------------------------------------------------------
1 | package com.moshx.ilog.console;
2 |
3 | import java.io.PrintStream;
4 |
5 | import com.moshx.ilog.Settings;
6 | import com.moshx.ilog.utils.Utility;
7 |
8 | class JVMConsole extends ILogConsole {
9 |
10 | private static final String DEBUG_STR = "Debug ";
11 | private static final String ERROR_STR = "Error ";
12 | private static final String INFO_STR = "Info ";
13 | private static final String VERBOSE_STR = "Verbose";
14 | private static final String WARN_STR = "Warning";
15 |
16 | private Settings mSettings;
17 |
18 | public JVMConsole(Settings sts) {
19 | mSettings = sts;
20 | }
21 |
22 | @Override
23 | public void d(String tag, Object msg, Throwable err) {
24 | System.out.println(mSettings.formatOut(Utility.getFormattedDate(),
25 | DEBUG_STR, tag, msg != null ? msg : ""));
26 | printThrowable(err, System.out);
27 | }
28 |
29 | @Override
30 | public void e(String tag, Object msg, Throwable err) {
31 | System.err.println(mSettings.formatOut(Utility.getFormattedDate(),
32 | ERROR_STR, tag, msg != null ? msg : ""));
33 | printThrowable(err, System.err);
34 |
35 | }
36 |
37 | @Override
38 | public void i(String tag, Object msg, Throwable err) {
39 | System.out.println(mSettings.formatOut(Utility.getFormattedDate(),
40 | INFO_STR, tag, msg != null ? msg : ""));
41 | printThrowable(err, System.out);
42 | }
43 |
44 | @Override
45 | public void v(String tag, Object msg, Throwable err) {
46 | System.out.println(mSettings.formatOut(Utility.getFormattedDate(),
47 | VERBOSE_STR, tag, msg != null ? msg : ""));
48 | printThrowable(err, System.out);
49 | }
50 |
51 | @Override
52 | public void w(String tag, Object msg, Throwable err) {
53 | System.out.println(mSettings.formatOut(Utility.getFormattedDate(),
54 | WARN_STR, tag, msg != null ? msg : ""));
55 | printThrowable(err, System.out);
56 | }
57 |
58 | private void printThrowable(Throwable err, PrintStream out) {
59 | if (err != null && out != null) {
60 | err.printStackTrace(out);
61 | }
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/ILog/src/com/moshx/ilog/filelogger/FileLogger.java:
--------------------------------------------------------------------------------
1 | package com.moshx.ilog.filelogger;
2 |
3 | import java.io.File;
4 | import java.io.FileNotFoundException;
5 | import java.io.FileOutputStream;
6 | import java.io.PrintStream;
7 |
8 | import com.moshx.ilog.Settings.Level;
9 | import com.moshx.ilog.utils.Utility;
10 |
11 | public abstract class FileLogger {
12 |
13 | protected PrintStream printStream;
14 |
15 | public void setLogStream(PrintStream printStream) {
16 | this.printStream = printStream;
17 | onStart();
18 | }
19 |
20 | public FileLogger setLogFile(String path) {
21 | setLogFile(new File(path));
22 | return this;
23 | }
24 |
25 | public File createLogFile(String path) {
26 |
27 | try {
28 | File f = new File(path);
29 | f.getParentFile().mkdirs();
30 | f.createNewFile();
31 | setLogFile(f);
32 | return f;
33 | } catch (Exception e) {
34 | e.printStackTrace();
35 | setLogStream(null);
36 | }
37 | return null;
38 | }
39 |
40 | public File createLogFile(String parent, String fileName) {
41 | try {
42 | File f = new File(parent, fileName);
43 | f.getParentFile().mkdirs();
44 | f.createNewFile();
45 | setLogFile(f);
46 | return f;
47 |
48 | } catch (Exception e) {
49 | e.printStackTrace();
50 | setLogStream(null);
51 | }
52 | return null;
53 | }
54 |
55 | public File createLogFile(File parentFile, String fileName) {
56 | return createLogFile(parentFile.getAbsolutePath(), fileName);
57 | }
58 |
59 | public File createLogFile(File parentFile) {
60 | try {
61 | File f = new File(parentFile, generateLogFileName()
62 | + getFileExtension());
63 | f.getParentFile().mkdirs();
64 | f.createNewFile();
65 | setLogFile(f);
66 | return f;
67 | } catch (Exception e) {
68 | e.printStackTrace();
69 | setLogStream(null);
70 | }
71 |
72 | return null;
73 | }
74 |
75 | public File setLogFile(File file) {
76 | if (file != null && file.exists() && file.canWrite()) {
77 | try {
78 | PrintStream stream = new PrintStream(
79 | new FileOutputStream(file), true);
80 | setLogStream(stream);
81 | return file;
82 |
83 | } catch (FileNotFoundException e) {
84 | e.printStackTrace();
85 | setLogStream(null);
86 | }
87 |
88 | } else {
89 | setLogStream(null);
90 | }
91 |
92 | return null;
93 | }
94 |
95 | public void onStart() {
96 | if (printStream == null) {
97 | return;
98 | }
99 | printStream.append("Logging Started on "
100 | + Utility.getFormattedDate().concat("\n\n"));
101 | }
102 |
103 | public abstract boolean log(Level level, String tag, Object msg,
104 | Throwable err);
105 |
106 | public void onEnd() {
107 | if (printStream == null) {
108 | return;
109 | }
110 | printStream.append("\nLogging Ended on "
111 | + Utility.getFormattedDate().concat("\n"));
112 | }
113 |
114 | public static String generateLogFileName() {
115 | return "ILog_" + Utility.getFormattedFileDate();
116 | }
117 |
118 | protected String getFileExtension() {
119 | return ".log";
120 | }
121 |
122 | }
123 |
--------------------------------------------------------------------------------
/ILog/src/com/moshx/ilog/filelogger/HtmlFileLogger.java:
--------------------------------------------------------------------------------
1 | package com.moshx.ilog.filelogger;
2 |
3 | import java.io.PrintWriter;
4 | import java.io.StringWriter;
5 | import java.net.UnknownHostException;
6 |
7 | import com.moshx.ilog.Settings.Level;
8 | import com.moshx.ilog.utils.Utility;
9 |
10 | public class HtmlFileLogger extends FileLogger {
11 |
12 | private String htmlStart1 = "
" + "%s";
13 | private String htmlStart2 = ""
14 | + ""
15 | + ""
16 | + ""
17 | + ""
18 | + "Level | "
19 | + "Time | "
20 | + "Tag | "
21 | + "Message | "
22 | + "Error | " + "
";
23 |
24 | private String tableRow = ""
25 | + "%s | "
26 | + "%s | "
27 | + "%s | "
28 | + "%s | "
29 | + "%s | " + "
";
30 |
31 | private String htmlEnd = "
" + "";
32 |
33 | @Override
34 | public void onStart() {
35 | if (printStream != null) {
36 |
37 | printStream.format(htmlStart1,
38 | "Logging Started on:" + Utility.getFormattedDate());
39 | printStream.append(htmlStart2);
40 |
41 | }
42 | }
43 |
44 | @Override
45 | public boolean log(Level level, String tag, Object msg, Throwable err) {
46 | if (printStream != null) {
47 | String row = String
48 | .format(tableRow, level.name().charAt(0),
49 | Utility.getFormattedDate(), tag,
50 | msg != null ? msg.toString() : "",
51 | getStackTraceString(err));
52 | switch (level) {
53 | case DEBUG:
54 | row = row.replaceAll("#color", "#39379B");
55 | break;
56 | case ERROR:
57 | row = row.replaceAll("#color", "#FA1100");
58 | break;
59 | case WARN:
60 | row = row.replaceAll("#color", "#FB9700");
61 | break;
62 | case INFO:
63 | row = row.replaceAll("#color", "#1B8000");
64 | break;
65 | case VERBOSE:
66 | row = row.replaceAll("#color", "#000000");
67 | break;
68 | default:
69 | break;
70 | }
71 | printStream.append(row);
72 |
73 | }
74 | return false;
75 | }
76 |
77 | @Override
78 | public void onEnd() {
79 | printStream.append(htmlEnd);
80 |
81 | }
82 |
83 | private String getStackTraceString(Throwable tr) {
84 | if (tr == null) {
85 | return "";
86 | }
87 |
88 | // This is to reduce the amount of log spew that apps do in the
89 | // non-error
90 | // condition of the network being unavailable.
91 | Throwable t = tr;
92 | while (t != null) {
93 | if (t instanceof UnknownHostException) {
94 | return "";
95 | }
96 | t = t.getCause();
97 | }
98 |
99 | StringWriter sw = new StringWriter();
100 | PrintWriter pw = new PrintWriter(sw, false);
101 | tr.printStackTrace(pw);
102 | pw.flush();
103 | return sw.toString().replaceAll("\n", "");
104 | }
105 |
106 | @Override
107 | protected String getFileExtension() {
108 | return ".html";
109 | }
110 | }
111 |
--------------------------------------------------------------------------------
/ILog/src/com/moshx/ilog/filelogger/TextFileLogger.java:
--------------------------------------------------------------------------------
1 | package com.moshx.ilog.filelogger;
2 |
3 | import java.util.Locale;
4 |
5 | import com.moshx.ilog.Settings.Level;
6 | import com.moshx.ilog.utils.Utility;
7 |
8 | public class TextFileLogger extends FileLogger {
9 |
10 | String logFormat = "[%s] -%s %s %s\n";
11 |
12 | @Override
13 | public boolean log(Level level, String tag, Object msg, Throwable err) {
14 | if (printStream == null) {
15 | return false;
16 | }
17 |
18 | String result = String.format(Locale.US, logFormat, Utility
19 | .getFormattedDate(), level.toString(), tag,
20 | msg != null ? msg.toString() : "");
21 | printStream.append(result);
22 | if (err != null) {
23 | err.printStackTrace(printStream);
24 | }
25 | return true;
26 | }
27 |
28 | }
29 |
--------------------------------------------------------------------------------
/ILog/src/com/moshx/ilog/utils/Utility.java:
--------------------------------------------------------------------------------
1 | package com.moshx.ilog.utils;
2 |
3 | import java.text.SimpleDateFormat;
4 | import java.util.Date;
5 | import java.util.Locale;
6 |
7 | public class Utility {
8 |
9 | private static final SimpleDateFormat FILE_DATE_FORMATTER = new SimpleDateFormat(
10 | "yyyy_MM_dd__HH_mm_ss_SSS", Locale.US);
11 |
12 | protected static final SimpleDateFormat TIME_FORMATTER = new SimpleDateFormat(
13 | "yyyy-MM-dd HH:mm:ss", Locale.US);
14 |
15 | public static String getFormattedDate() {
16 | return TIME_FORMATTER.format(new Date());
17 | }
18 |
19 | public static String getFormattedFileDate() {
20 | return FILE_DATE_FORMATTER.format(new Date());
21 | }
22 |
23 | }
24 |
--------------------------------------------------------------------------------
/ILogJVMSample/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/ILogJVMSample/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | ILogJVMSample
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.jdt.core.javabuilder
10 |
11 |
12 |
13 |
14 |
15 | org.eclipse.jdt.core.javanature
16 |
17 |
18 |
--------------------------------------------------------------------------------
/ILogJVMSample/.settings/org.eclipse.jdt.core.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
4 | org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
5 | org.eclipse.jdt.core.compiler.compliance=1.7
6 | org.eclipse.jdt.core.compiler.debug.lineNumber=generate
7 | org.eclipse.jdt.core.compiler.debug.localVariable=generate
8 | org.eclipse.jdt.core.compiler.debug.sourceFile=generate
9 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
10 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
11 | org.eclipse.jdt.core.compiler.source=1.7
12 |
--------------------------------------------------------------------------------
/ILogJVMSample/src/com/moshx/jvmsample/LoggingTest.java:
--------------------------------------------------------------------------------
1 | package com.moshx.jvmsample;
2 |
3 | import java.io.File;
4 | import java.net.URL;
5 |
6 | import com.moshx.ilog.ILog;
7 | import com.moshx.ilog.filelogger.HtmlFileLogger;
8 |
9 | public class LoggingTest {
10 |
11 | public static void main(String[] args) {
12 |
13 | ILog log = new ILog();
14 | log.d(); // will print current class + method
15 | log.i("am here"); // will print passed message
16 | log.e("erro :O");
17 | log.v();
18 |
19 | log.setFileLogger(new HtmlFileLogger()).getFileLogger()
20 | .createLogFile(getLoggingFile());
21 | log.d();
22 | log.d(1000);
23 | log.getFileLogger().onEnd();
24 |
25 | new AnotherTestClass().test();
26 |
27 | }
28 |
29 | private static File getLoggingFile() {
30 | URL location = LoggingTest.class.getProtectionDomain().getCodeSource()
31 | .getLocation();
32 | return new File(location.getFile()).getParentFile();
33 | }
34 |
35 | public static class AnotherTestClass {
36 | ILog log = new ILog();
37 |
38 | public void test() {
39 |
40 | log.d();
41 | log.d("here i'am");
42 | }
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/ILogSample/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/ILogSample/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | ILogAndroidSample
4 |
5 |
6 |
7 |
8 |
9 | com.android.ide.eclipse.adt.ResourceManagerBuilder
10 |
11 |
12 |
13 |
14 | com.android.ide.eclipse.adt.PreCompilerBuilder
15 |
16 |
17 |
18 |
19 | org.eclipse.jdt.core.javabuilder
20 |
21 |
22 |
23 |
24 | com.android.ide.eclipse.adt.ApkBuilder
25 |
26 |
27 |
28 |
29 |
30 | com.android.ide.eclipse.adt.AndroidNature
31 | org.eclipse.jdt.core.javanature
32 |
33 |
34 |
--------------------------------------------------------------------------------
/ILogSample/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
10 |
11 |
16 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/ILogSample/ic_launcher-web.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MoshDev/ILog/6d6ab17ae2395208d36cddcfc5212c5678a1297d/ILogSample/ic_launcher-web.png
--------------------------------------------------------------------------------
/ILogSample/libs/android-support-v4.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MoshDev/ILog/6d6ab17ae2395208d36cddcfc5212c5678a1297d/ILogSample/libs/android-support-v4.jar
--------------------------------------------------------------------------------
/ILogSample/proguard-project.txt:
--------------------------------------------------------------------------------
1 | # To enable ProGuard in your project, edit project.properties
2 | # to define the proguard.config property as described in that file.
3 | #
4 | # Add project specific ProGuard rules here.
5 | # By default, the flags in this file are appended to flags specified
6 | # in ${sdk.dir}/tools/proguard/proguard-android.txt
7 | # You can edit the include path and order by changing the ProGuard
8 | # include property in project.properties.
9 | #
10 | # For more details, see
11 | # http://developer.android.com/guide/developing/tools/proguard.html
12 |
13 | # Add any project specific keep options here:
14 |
15 | # If your project uses WebView with JS, uncomment the following
16 | # and specify the fully qualified class name to the JavaScript interface
17 | # class:
18 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
19 | # public *;
20 | #}
21 |
--------------------------------------------------------------------------------
/ILogSample/project.properties:
--------------------------------------------------------------------------------
1 | # This file is automatically generated by Android Tools.
2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3 | #
4 | # This file must be checked in Version Control Systems.
5 | #
6 | # To customize properties used by the Ant build system edit
7 | # "ant.properties", and override values to adapt the script to your
8 | # project structure.
9 | #
10 | # To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
11 | #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
12 |
13 | # Project target.
14 | target=android-19
15 | android.library.reference.1=../../../Workspaces/Utils/appcompat_v7
16 | android.library.reference.2=../ILog
17 |
--------------------------------------------------------------------------------
/ILogSample/res/drawable-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MoshDev/ILog/6d6ab17ae2395208d36cddcfc5212c5678a1297d/ILogSample/res/drawable-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/ILogSample/res/drawable-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MoshDev/ILog/6d6ab17ae2395208d36cddcfc5212c5678a1297d/ILogSample/res/drawable-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/ILogSample/res/drawable-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MoshDev/ILog/6d6ab17ae2395208d36cddcfc5212c5678a1297d/ILogSample/res/drawable-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/ILogSample/res/drawable-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MoshDev/ILog/6d6ab17ae2395208d36cddcfc5212c5678a1297d/ILogSample/res/drawable-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/ILogSample/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
8 |
--------------------------------------------------------------------------------
/ILogSample/res/layout/fragment_main.xml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/ILogSample/res/menu/main.xml:
--------------------------------------------------------------------------------
1 |
13 |
--------------------------------------------------------------------------------
/ILogSample/res/values-v11/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/ILogSample/res/values-v14/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/ILogSample/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 | 64dp
9 |
10 |
11 |
--------------------------------------------------------------------------------
/ILogSample/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 16dp
5 | 16dp
6 |
7 |
8 |
--------------------------------------------------------------------------------
/ILogSample/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | ILogSample
5 | Hello world!
6 | Settings
7 |
8 |
9 |
--------------------------------------------------------------------------------
/ILogSample/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
14 |
15 |
16 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/ILogSample/src/com/moshx/ilogsample/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.moshx.ilogsample;
2 |
3 | import android.os.Bundle;
4 | import android.support.v4.app.Fragment;
5 | import android.support.v7.app.ActionBarActivity;
6 | import android.view.LayoutInflater;
7 | import android.view.Menu;
8 | import android.view.MenuItem;
9 | import android.view.View;
10 | import android.view.ViewGroup;
11 |
12 | import com.moshx.ilog.ILog;
13 |
14 | public class MainActivity extends ActionBarActivity {
15 |
16 | private ILog log = new ILog();
17 |
18 | @Override
19 | protected void onCreate(Bundle savedInstanceState) {
20 | super.onCreate(savedInstanceState);
21 | setContentView(R.layout.activity_main);
22 |
23 | if (savedInstanceState == null) {
24 | getSupportFragmentManager().beginTransaction()
25 | .add(R.id.container, new PlaceholderFragment()).commit();
26 | }
27 |
28 | log.d();// check logcat
29 | }
30 |
31 | @Override
32 | public boolean onCreateOptionsMenu(Menu menu) {
33 |
34 | // Inflate the menu; this adds items to the action bar if it is present.
35 | getMenuInflater().inflate(R.menu.main, menu);
36 | return true;
37 | }
38 |
39 | @Override
40 | public boolean onOptionsItemSelected(MenuItem item) {
41 | // Handle action bar item clicks here. The action bar will
42 | // automatically handle clicks on the Home/Up button, so long
43 | // as you specify a parent activity in AndroidManifest.xml.
44 | int id = item.getItemId();
45 | if (id == R.id.action_settings) {
46 | return true;
47 | }
48 | return super.onOptionsItemSelected(item);
49 | }
50 |
51 | /**
52 | * A placeholder fragment containing a simple view.
53 | */
54 | public static class PlaceholderFragment extends Fragment {
55 |
56 | public PlaceholderFragment() {
57 | }
58 |
59 | @Override
60 | public View onCreateView(LayoutInflater inflater, ViewGroup container,
61 | Bundle savedInstanceState) {
62 | View rootView = inflater.inflate(R.layout.fragment_main, container,
63 | false);
64 | return rootView;
65 | }
66 | }
67 |
68 | }
69 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 2, June 1991
3 |
4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
6 | Everyone is permitted to copy and distribute verbatim copies
7 | of this license document, but changing it is not allowed.
8 |
9 | Preamble
10 |
11 | The licenses for most software are designed to take away your
12 | freedom to share and change it. By contrast, the GNU General Public
13 | License is intended to guarantee your freedom to share and change free
14 | software--to make sure the software is free for all its users. This
15 | General Public License applies to most of the Free Software
16 | Foundation's software and to any other program whose authors commit to
17 | using it. (Some other Free Software Foundation software is covered by
18 | the GNU Lesser General Public License instead.) You can apply it to
19 | your programs, too.
20 |
21 | When we speak of free software, we are referring to freedom, not
22 | price. Our General Public Licenses are designed to make sure that you
23 | have the freedom to distribute copies of free software (and charge for
24 | this service if you wish), that you receive source code or can get it
25 | if you want it, that you can change the software or use pieces of it
26 | in new free programs; and that you know you can do these things.
27 |
28 | To protect your rights, we need to make restrictions that forbid
29 | anyone to deny you these rights or to ask you to surrender the rights.
30 | These restrictions translate to certain responsibilities for you if you
31 | distribute copies of the software, or if you modify it.
32 |
33 | For example, if you distribute copies of such a program, whether
34 | gratis or for a fee, you must give the recipients all the rights that
35 | you have. You must make sure that they, too, receive or can get the
36 | source code. And you must show them these terms so they know their
37 | rights.
38 |
39 | We protect your rights with two steps: (1) copyright the software, and
40 | (2) offer you this license which gives you legal permission to copy,
41 | distribute and/or modify the software.
42 |
43 | Also, for each author's protection and ours, we want to make certain
44 | that everyone understands that there is no warranty for this free
45 | software. If the software is modified by someone else and passed on, we
46 | want its recipients to know that what they have is not the original, so
47 | that any problems introduced by others will not reflect on the original
48 | authors' reputations.
49 |
50 | Finally, any free program is threatened constantly by software
51 | patents. We wish to avoid the danger that redistributors of a free
52 | program will individually obtain patent licenses, in effect making the
53 | program proprietary. To prevent this, we have made it clear that any
54 | patent must be licensed for everyone's free use or not licensed at all.
55 |
56 | The precise terms and conditions for copying, distribution and
57 | modification follow.
58 |
59 | GNU GENERAL PUBLIC LICENSE
60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
61 |
62 | 0. This License applies to any program or other work which contains
63 | a notice placed by the copyright holder saying it may be distributed
64 | under the terms of this General Public License. The "Program", below,
65 | refers to any such program or work, and a "work based on the Program"
66 | means either the Program or any derivative work under copyright law:
67 | that is to say, a work containing the Program or a portion of it,
68 | either verbatim or with modifications and/or translated into another
69 | language. (Hereinafter, translation is included without limitation in
70 | the term "modification".) Each licensee is addressed as "you".
71 |
72 | Activities other than copying, distribution and modification are not
73 | covered by this License; they are outside its scope. The act of
74 | running the Program is not restricted, and the output from the Program
75 | is covered only if its contents constitute a work based on the
76 | Program (independent of having been made by running the Program).
77 | Whether that is true depends on what the Program does.
78 |
79 | 1. You may copy and distribute verbatim copies of the Program's
80 | source code as you receive it, in any medium, provided that you
81 | conspicuously and appropriately publish on each copy an appropriate
82 | copyright notice and disclaimer of warranty; keep intact all the
83 | notices that refer to this License and to the absence of any warranty;
84 | and give any other recipients of the Program a copy of this License
85 | along with the Program.
86 |
87 | You may charge a fee for the physical act of transferring a copy, and
88 | you may at your option offer warranty protection in exchange for a fee.
89 |
90 | 2. You may modify your copy or copies of the Program or any portion
91 | of it, thus forming a work based on the Program, and copy and
92 | distribute such modifications or work under the terms of Section 1
93 | above, provided that you also meet all of these conditions:
94 |
95 | a) You must cause the modified files to carry prominent notices
96 | stating that you changed the files and the date of any change.
97 |
98 | b) You must cause any work that you distribute or publish, that in
99 | whole or in part contains or is derived from the Program or any
100 | part thereof, to be licensed as a whole at no charge to all third
101 | parties under the terms of this License.
102 |
103 | c) If the modified program normally reads commands interactively
104 | when run, you must cause it, when started running for such
105 | interactive use in the most ordinary way, to print or display an
106 | announcement including an appropriate copyright notice and a
107 | notice that there is no warranty (or else, saying that you provide
108 | a warranty) and that users may redistribute the program under
109 | these conditions, and telling the user how to view a copy of this
110 | License. (Exception: if the Program itself is interactive but
111 | does not normally print such an announcement, your work based on
112 | the Program is not required to print an announcement.)
113 |
114 | These requirements apply to the modified work as a whole. If
115 | identifiable sections of that work are not derived from the Program,
116 | and can be reasonably considered independent and separate works in
117 | themselves, then this License, and its terms, do not apply to those
118 | sections when you distribute them as separate works. But when you
119 | distribute the same sections as part of a whole which is a work based
120 | on the Program, the distribution of the whole must be on the terms of
121 | this License, whose permissions for other licensees extend to the
122 | entire whole, and thus to each and every part regardless of who wrote it.
123 |
124 | Thus, it is not the intent of this section to claim rights or contest
125 | your rights to work written entirely by you; rather, the intent is to
126 | exercise the right to control the distribution of derivative or
127 | collective works based on the Program.
128 |
129 | In addition, mere aggregation of another work not based on the Program
130 | with the Program (or with a work based on the Program) on a volume of
131 | a storage or distribution medium does not bring the other work under
132 | the scope of this License.
133 |
134 | 3. You may copy and distribute the Program (or a work based on it,
135 | under Section 2) in object code or executable form under the terms of
136 | Sections 1 and 2 above provided that you also do one of the following:
137 |
138 | a) Accompany it with the complete corresponding machine-readable
139 | source code, which must be distributed under the terms of Sections
140 | 1 and 2 above on a medium customarily used for software interchange; or,
141 |
142 | b) Accompany it with a written offer, valid for at least three
143 | years, to give any third party, for a charge no more than your
144 | cost of physically performing source distribution, a complete
145 | machine-readable copy of the corresponding source code, to be
146 | distributed under the terms of Sections 1 and 2 above on a medium
147 | customarily used for software interchange; or,
148 |
149 | c) Accompany it with the information you received as to the offer
150 | to distribute corresponding source code. (This alternative is
151 | allowed only for noncommercial distribution and only if you
152 | received the program in object code or executable form with such
153 | an offer, in accord with Subsection b above.)
154 |
155 | The source code for a work means the preferred form of the work for
156 | making modifications to it. For an executable work, complete source
157 | code means all the source code for all modules it contains, plus any
158 | associated interface definition files, plus the scripts used to
159 | control compilation and installation of the executable. However, as a
160 | special exception, the source code distributed need not include
161 | anything that is normally distributed (in either source or binary
162 | form) with the major components (compiler, kernel, and so on) of the
163 | operating system on which the executable runs, unless that component
164 | itself accompanies the executable.
165 |
166 | If distribution of executable or object code is made by offering
167 | access to copy from a designated place, then offering equivalent
168 | access to copy the source code from the same place counts as
169 | distribution of the source code, even though third parties are not
170 | compelled to copy the source along with the object code.
171 |
172 | 4. You may not copy, modify, sublicense, or distribute the Program
173 | except as expressly provided under this License. Any attempt
174 | otherwise to copy, modify, sublicense or distribute the Program is
175 | void, and will automatically terminate your rights under this License.
176 | However, parties who have received copies, or rights, from you under
177 | this License will not have their licenses terminated so long as such
178 | parties remain in full compliance.
179 |
180 | 5. You are not required to accept this License, since you have not
181 | signed it. However, nothing else grants you permission to modify or
182 | distribute the Program or its derivative works. These actions are
183 | prohibited by law if you do not accept this License. Therefore, by
184 | modifying or distributing the Program (or any work based on the
185 | Program), you indicate your acceptance of this License to do so, and
186 | all its terms and conditions for copying, distributing or modifying
187 | the Program or works based on it.
188 |
189 | 6. Each time you redistribute the Program (or any work based on the
190 | Program), the recipient automatically receives a license from the
191 | original licensor to copy, distribute or modify the Program subject to
192 | these terms and conditions. You may not impose any further
193 | restrictions on the recipients' exercise of the rights granted herein.
194 | You are not responsible for enforcing compliance by third parties to
195 | this License.
196 |
197 | 7. If, as a consequence of a court judgment or allegation of patent
198 | infringement or for any other reason (not limited to patent issues),
199 | conditions are imposed on you (whether by court order, agreement or
200 | otherwise) that contradict the conditions of this License, they do not
201 | excuse you from the conditions of this License. If you cannot
202 | distribute so as to satisfy simultaneously your obligations under this
203 | License and any other pertinent obligations, then as a consequence you
204 | may not distribute the Program at all. For example, if a patent
205 | license would not permit royalty-free redistribution of the Program by
206 | all those who receive copies directly or indirectly through you, then
207 | the only way you could satisfy both it and this License would be to
208 | refrain entirely from distribution of the Program.
209 |
210 | If any portion of this section is held invalid or unenforceable under
211 | any particular circumstance, the balance of the section is intended to
212 | apply and the section as a whole is intended to apply in other
213 | circumstances.
214 |
215 | It is not the purpose of this section to induce you to infringe any
216 | patents or other property right claims or to contest validity of any
217 | such claims; this section has the sole purpose of protecting the
218 | integrity of the free software distribution system, which is
219 | implemented by public license practices. Many people have made
220 | generous contributions to the wide range of software distributed
221 | through that system in reliance on consistent application of that
222 | system; it is up to the author/donor to decide if he or she is willing
223 | to distribute software through any other system and a licensee cannot
224 | impose that choice.
225 |
226 | This section is intended to make thoroughly clear what is believed to
227 | be a consequence of the rest of this License.
228 |
229 | 8. If the distribution and/or use of the Program is restricted in
230 | certain countries either by patents or by copyrighted interfaces, the
231 | original copyright holder who places the Program under this License
232 | may add an explicit geographical distribution limitation excluding
233 | those countries, so that distribution is permitted only in or among
234 | countries not thus excluded. In such case, this License incorporates
235 | the limitation as if written in the body of this License.
236 |
237 | 9. The Free Software Foundation may publish revised and/or new versions
238 | of the General Public License from time to time. Such new versions will
239 | be similar in spirit to the present version, but may differ in detail to
240 | address new problems or concerns.
241 |
242 | Each version is given a distinguishing version number. If the Program
243 | specifies a version number of this License which applies to it and "any
244 | later version", you have the option of following the terms and conditions
245 | either of that version or of any later version published by the Free
246 | Software Foundation. If the Program does not specify a version number of
247 | this License, you may choose any version ever published by the Free Software
248 | Foundation.
249 |
250 | 10. If you wish to incorporate parts of the Program into other free
251 | programs whose distribution conditions are different, write to the author
252 | to ask for permission. For software which is copyrighted by the Free
253 | Software Foundation, write to the Free Software Foundation; we sometimes
254 | make exceptions for this. Our decision will be guided by the two goals
255 | of preserving the free status of all derivatives of our free software and
256 | of promoting the sharing and reuse of software generally.
257 |
258 | NO WARRANTY
259 |
260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
268 | REPAIR OR CORRECTION.
269 |
270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
278 | POSSIBILITY OF SUCH DAMAGES.
279 |
280 | END OF TERMS AND CONDITIONS
281 |
282 | How to Apply These Terms to Your New Programs
283 |
284 | If you develop a new program, and you want it to be of the greatest
285 | possible use to the public, the best way to achieve this is to make it
286 | free software which everyone can redistribute and change under these terms.
287 |
288 | To do so, attach the following notices to the program. It is safest
289 | to attach them to the start of each source file to most effectively
290 | convey the exclusion of warranty; and each file should have at least
291 | the "copyright" line and a pointer to where the full notice is found.
292 |
293 | {description}
294 | Copyright (C) {year} {fullname}
295 |
296 | This program is free software; you can redistribute it and/or modify
297 | it under the terms of the GNU General Public License as published by
298 | the Free Software Foundation; either version 2 of the License, or
299 | (at your option) any later version.
300 |
301 | This program is distributed in the hope that it will be useful,
302 | but WITHOUT ANY WARRANTY; without even the implied warranty of
303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
304 | GNU General Public License for more details.
305 |
306 | You should have received a copy of the GNU General Public License along
307 | with this program; if not, write to the Free Software Foundation, Inc.,
308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
309 |
310 | Also add information on how to contact you by electronic and paper mail.
311 |
312 | If the program is interactive, make it output a short notice like this
313 | when it starts in an interactive mode:
314 |
315 | Gnomovision version 69, Copyright (C) year name of author
316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
317 | This is free software, and you are welcome to redistribute it
318 | under certain conditions; type `show c' for details.
319 |
320 | The hypothetical commands `show w' and `show c' should show the appropriate
321 | parts of the General Public License. Of course, the commands you use may
322 | be called something other than `show w' and `show c'; they could even be
323 | mouse-clicks or menu items--whatever suits your program.
324 |
325 | You should also get your employer (if you work as a programmer) or your
326 | school, if any, to sign a "copyright disclaimer" for the program, if
327 | necessary. Here is a sample; alter the names:
328 |
329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program
330 | `Gnomovision' (which makes passes at compilers) written by James Hacker.
331 |
332 | {signature of Ty Coon}, 1 April 1989
333 | Ty Coon, President of Vice
334 |
335 | This General Public License does not permit incorporating your program into
336 | proprietary programs. If your program is a subroutine library, you may
337 | consider it more useful to permit linking proprietary applications with the
338 | library. If this is what you want to do, use the GNU Lesser General
339 | Public License instead of this License.
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ILog
2 | ====
3 |
4 | Simple Logging Tool for Android and Java Platforms
5 |
6 | Download
7 | ========
8 | Jar file download https://github.com/MoshDev/ILog/releases/tag/Version_0.1
9 |
10 | Samples and documentation
11 | =========================
12 |
13 | new ILog().d(); // as simple as that
14 |
15 | Refer to http://moshx.com/?p=57 for more details
16 |
--------------------------------------------------------------------------------