]> gitweb.fperrin.net Git - Dictionary.git/blob - jars/gss-lib-2.2/src/com/pras/Log.java
Added gss-lib-2.2.
[Dictionary.git] / jars / gss-lib-2.2 / src / com / pras / Log.java
1 /*\r
2  * Copyright (C) 2010 Prasanta Paul, http://prasanta-paul.blogspot.com\r
3  *\r
4  * Licensed under the Apache License, Version 2.0 (the "License");\r
5  * you may not use this file except in compliance with the License.\r
6  * You may obtain a copy of the License at\r
7  *\r
8  *      http://www.apache.org/licenses/LICENSE-2.0\r
9  *\r
10  * Unless required by applicable law or agreed to in writing, software\r
11  * distributed under the License is distributed on an "AS IS" BASIS,\r
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
13  * See the License for the specific language governing permissions and\r
14  * limitations under the License.\r
15  */\r
16 \r
17 package com.pras;\r
18 \r
19 /**\r
20  * Based on your target platform- edit this file and add appropriate Log console\r
21  * e.g. \r
22  * for Android, android.util.Log\r
23  * for J2ME, Desktop File based logging.\r
24  * </br>\r
25  * By default Logging will be enabled\r
26  * \r
27  * @author Prasanta Paul\r
28  *\r
29  */\r
30 public class Log {\r
31 \r
32         /**\r
33          * Set to false if you don't need Log output\r
34          */\r
35         private static boolean isLogEnabled = true;\r
36         \r
37         \r
38         /**\r
39          * Enable logging\r
40          */\r
41         public static void enableLog(){\r
42                 isLogEnabled = true;\r
43         }\r
44         /**\r
45          * Disable logging. Good for production release.\r
46          */\r
47         public static void disableLog(){\r
48                 isLogEnabled = false;\r
49         }\r
50         /**\r
51          * Pring Log message\r
52          * @param tag Log TAG\r
53          * @param msg Log Message\r
54          */\r
55         public static void p(String tag, String msg){\r
56                 \r
57                 if(!isLogEnabled)\r
58                         return;\r
59                 \r
60                 if(tag != null)\r
61                         print("["+ tag +"] ");\r
62                 if(msg != null)\r
63                         print(msg);\r
64                 print("\n");\r
65         }\r
66         \r
67         private static void print(String s){\r
68                 // TODO: Add appropriate stream based on your platform\r
69                 System.out.print(s);\r
70         }\r
71 }\r