com.stericson.RootTools
Class RootTools

java.lang.Object
  extended by com.stericson.RootTools.RootTools

public final class RootTools
extends java.lang.Object


Field Summary
static boolean debugMode
           
static int default_Command_Timeout
          Setting this will change the default command timeout.
static boolean handlerEnabled
          Setting this to false will disable the handler that is used by default for the 3 callback methods for Command.
static java.util.List<java.lang.String> lastFoundBinaryPaths
           
static java.lang.String utilPath
           
 
Constructor Summary
RootTools()
           
 
Method Summary
static boolean checkUtil(java.lang.String util)
          This will check a given binary, determine if it exists and determine that it has either the permissions 755, 775, or 777.
static void closeAllShells()
          This will close all open shells.
static void closeCustomShell()
          This will close the custom shell that you opened.
static void closeShell(boolean root)
          This will close either the root shell or the standard shell depending on what you specify.
static boolean copyFile(java.lang.String source, java.lang.String destination, boolean remountAsRw, boolean preserveFileAttributes)
          Copys a file to a destination.
static boolean deleteFileOrDirectory(java.lang.String target, boolean remountAsRw)
          Deletes a file or directory
static boolean exists(java.lang.String file)
          Use this to check whether or not a file exists on the filesystem.
static boolean findBinary(java.lang.String binaryName)
           
static void fixUtil(java.lang.String util, java.lang.String utilPath)
          This will try and fix a given binary.
static boolean fixUtils(java.lang.String[] utils)
          This will check an array of binaries, determine if they exist and determine that it has either the permissions 755, 775, or 777.
static java.util.List<java.lang.String> getBusyBoxApplets()
          This will return an List of Strings.
static java.util.List<java.lang.String> getBusyBoxApplets(java.lang.String path)
          This will return an List of Strings.
static java.lang.String getBusyBoxVersion()
           
static java.lang.String getBusyBoxVersion(java.lang.String path)
           
static Shell getCustomShell(java.lang.String shellPath)
          This will open or return, if one is already open, a custom shell, you are responsible for managing the shell, reading the output and for closing the shell when you are done using it.
static Shell getCustomShell(java.lang.String shellPath, int timeout)
          This will open or return, if one is already open, a custom shell, you are responsible for managing the shell, reading the output and for closing the shell when you are done using it.
static Permissions getFilePermissionsSymlinks(java.lang.String file)
           
static java.lang.String getInode(java.lang.String file)
          This method will return the inode number of a file.
static java.lang.String getMountedAs(java.lang.String path)
          This will tell you how the specified mount is mounted.
static java.util.ArrayList<Mount> getMounts()
          This will return an ArrayList of the class Mount.
static java.util.Set<java.lang.String> getPath()
          This will return the environment variable $PATH
static Shell getShell(boolean root)
          This will open or return, if one is already open, a shell, you are responsible for managing the shell, reading the output and for closing the shell when you are done using it.
static Shell getShell(boolean root, int timeout)
          This will open or return, if one is already open, a shell, you are responsible for managing the shell, reading the output and for closing the shell when you are done using it.
static Shell getShell(boolean root, int timeout, int retry)
          This will open or return, if one is already open, a shell, you are responsible for managing the shell, reading the output and for closing the shell when you are done using it.
static long getSpace(java.lang.String path)
          Get the space for a desired partition.
static java.lang.String getSymlink(java.lang.String file)
          This will return a String that represent the symlink for a specified file.
static java.util.ArrayList<Symlink> getSymlinks(java.lang.String path)
          This will return an ArrayList of the class Symlink.
static java.lang.String getWorkingToolbox()
          This will return to you a string to be used in your shell commands which will represent the valid working toolbox with correct permissions.
static boolean hasBinary(android.content.Context context, java.lang.String binaryName)
          This method checks whether a binary is installed.
static boolean hasEnoughSpaceOnSdCard(long updateSize)
          Checks if there is enough Space on SDCard
static boolean hasUtil(java.lang.String util, java.lang.String box)
          Checks whether the toolbox or busybox binary contains a specific util
static boolean installBinary(android.content.Context context, int sourceId, java.lang.String binaryName)
          This method can be used to unpack a binary from the raw resources folder and store it in /data/data/app.package/files/ This is typically useful if you provide your own C- or C++-based binary.
static boolean installBinary(android.content.Context context, int sourceId, java.lang.String destName, java.lang.String mode)
          This method can be used to unpack a binary from the raw resources folder and store it in /data/data/app.package/files/ This is typically useful if you provide your own C- or C++-based binary.
static boolean isAccessGiven()
           
static boolean isAppletAvailable(java.lang.String applet)
          This will let you know if an applet is available from BusyBox

static boolean isAppletAvailable(java.lang.String applet, java.lang.String path)
          This will let you know if an applet is available from BusyBox

static boolean isBusyboxAvailable()
           
static boolean islog()
          This method allows you to check whether logging is enabled.
static boolean isNativeToolsReady(int nativeToolsId, android.content.Context context)
           
static boolean isProcessRunning(java.lang.String processName)
          This method can be used to to check if a process is running
static boolean isRootAvailable()
           
static boolean killProcess(java.lang.String processName)
          This method can be used to kill a running process
static void log(java.lang.String msg)
          This method allows you to output debug messages only when debugging is on.
static void log(java.lang.String msg, int type, java.lang.Exception e)
          This method allows you to output debug messages only when debugging is on.
static void log(java.lang.String TAG, java.lang.String msg)
          This method allows you to output debug messages only when debugging is on.
static void log(java.lang.String TAG, java.lang.String msg, int type, java.lang.Exception e)
          This method allows you to output debug messages only when debugging is on.
static void offerBusyBox(android.app.Activity activity)
          This will launch the Android market looking for BusyBox
static android.content.Intent offerBusyBox(android.app.Activity activity, int requestCode)
          This will launch the Android market looking for BusyBox, but will return the intent fired and starts the activity with startActivityForResult
static void offerSuperUser(android.app.Activity activity)
          This will launch the Android market looking for SuperUser
static android.content.Intent offerSuperUser(android.app.Activity activity, int requestCode)
          This will launch the Android market looking for SuperUser, but will return the intent fired and starts the activity with startActivityForResult
static boolean remount(java.lang.String file, java.lang.String mountType)
          This will take a path, which can contain the file name as well, and attempt to remount the underlying partition.
static void restartAndroid()
          This restarts only Android OS without rebooting the whole device.
static void runBinary(android.content.Context context, java.lang.String binaryName, java.lang.String parameter)
          Executes binary in a separated process.
static void runShellCommand(Shell shell, Command command)
          Executes a given command with root access or without depending on the value of the boolean passed.
static void setRim(RootToolsInternalMethods rim)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

debugMode

public static boolean debugMode

lastFoundBinaryPaths

public static java.util.List<java.lang.String> lastFoundBinaryPaths

utilPath

public static java.lang.String utilPath

handlerEnabled

public static boolean handlerEnabled
Setting this to false will disable the handler that is used by default for the 3 callback methods for Command. By disabling this all callbacks will be called from a thread other than the main UI thread.


default_Command_Timeout

public static int default_Command_Timeout
Setting this will change the default command timeout. The default is 20000ms

Constructor Detail

RootTools

public RootTools()
Method Detail

setRim

public static void setRim(RootToolsInternalMethods rim)

checkUtil

public static boolean checkUtil(java.lang.String util)
This will check a given binary, determine if it exists and determine that it has either the permissions 755, 775, or 777.

Parameters:
util - Name of the utility to check.
Returns:
boolean to indicate whether the binary is installed and has appropriate permissions.

closeAllShells

public static void closeAllShells()
                           throws java.io.IOException
This will close all open shells.

Throws:
java.io.IOException

closeCustomShell

public static void closeCustomShell()
                             throws java.io.IOException
This will close the custom shell that you opened.

Throws:
java.io.IOException

closeShell

public static void closeShell(boolean root)
                       throws java.io.IOException
This will close either the root shell or the standard shell depending on what you specify.

Parameters:
root - a boolean to specify whether to close the root shell or the standard shell.
Throws:
java.io.IOException

copyFile

public static boolean copyFile(java.lang.String source,
                               java.lang.String destination,
                               boolean remountAsRw,
                               boolean preserveFileAttributes)
Copys a file to a destination. Because cp is not available on all android devices, we have a fallback on the cat command

Parameters:
source - example: /data/data/org.adaway/files/hosts
destination - example: /system/etc/hosts
remountAsRw - remounts the destination as read/write before writing to it
preserveFileAttributes - tries to copy file attributes from source to destination, if only cat is available only permissions are preserved
Returns:
true if it was successfully copied

deleteFileOrDirectory

public static boolean deleteFileOrDirectory(java.lang.String target,
                                            boolean remountAsRw)
Deletes a file or directory

Parameters:
target - example: /data/data/org.adaway/files/hosts
remountAsRw - remounts the destination as read/write before writing to it
Returns:
true if it was successfully deleted

exists

public static boolean exists(java.lang.String file)
Use this to check whether or not a file exists on the filesystem.

Parameters:
file - String that represent the file, including the full path to the file and its name.
Returns:
a boolean that will indicate whether or not the file exists.

fixUtil

public static void fixUtil(java.lang.String util,
                           java.lang.String utilPath)
This will try and fix a given binary. (This is for Busybox applets or Toolbox applets) By "fix", I mean it will try and symlink the binary from either toolbox or Busybox and fix the permissions if the permissions are not correct.

Parameters:
util - Name of the utility to fix.
utilPath - path to the toolbox that provides ln, rm, and chmod. This can be a blank string, a path to a binary that will provide these, or you can use RootTools.getWorkingToolbox()

fixUtils

public static boolean fixUtils(java.lang.String[] utils)
                        throws java.lang.Exception
This will check an array of binaries, determine if they exist and determine that it has either the permissions 755, 775, or 777. If an applet is not setup correctly it will try and fix it. (This is for Busybox applets or Toolbox applets)

Parameters:
utils - Name of the utility to check.
Returns:
boolean to indicate whether the operation completed. Note that this is not indicative of whether the problem was fixed, just that the method did not encounter any exceptions.
Throws:
java.lang.Exception - if the operation cannot be completed.

findBinary

public static boolean findBinary(java.lang.String binaryName)
Parameters:
binaryName - String that represent the binary to find.
Returns:
true if the specified binary was found. Also, the path the binary was found at can be retrieved via the variable lastFoundBinaryPath, if the binary was found in more than one location this will contain all of these locations.

getBusyBoxVersion

public static java.lang.String getBusyBoxVersion(java.lang.String path)
Parameters:
path - String that represents the path to the Busybox binary you want to retrieve the version of.
Returns:
BusyBox version is found, "" if not found.

getBusyBoxVersion

public static java.lang.String getBusyBoxVersion()
Returns:
BusyBox version is found, "" if not found.

getBusyBoxApplets

public static java.util.List<java.lang.String> getBusyBoxApplets()
                                                          throws java.lang.Exception
This will return an List of Strings. Each string represents an applet available from BusyBox.

Returns:
null If we cannot return the list of applets.
Throws:
java.lang.Exception

getBusyBoxApplets

public static java.util.List<java.lang.String> getBusyBoxApplets(java.lang.String path)
                                                          throws java.lang.Exception
This will return an List of Strings. Each string represents an applet available from BusyBox.

Parameters:
path - Path to the busybox binary that you want the list of applets from.
Returns:
null If we cannot return the list of applets.
Throws:
java.lang.Exception

getCustomShell

public static Shell getCustomShell(java.lang.String shellPath,
                                   int timeout)
                            throws java.io.IOException,
                                   java.util.concurrent.TimeoutException,
                                   RootDeniedException
This will open or return, if one is already open, a custom shell, you are responsible for managing the shell, reading the output and for closing the shell when you are done using it.

Parameters:
shellPath - a String to Indicate the path to the shell that you want to open.
timeout - an int to Indicate the length of time before giving up on opening a shell.
Throws:
java.util.concurrent.TimeoutException
RootDeniedException
java.io.IOException

getCustomShell

public static Shell getCustomShell(java.lang.String shellPath)
                            throws java.io.IOException,
                                   java.util.concurrent.TimeoutException,
                                   RootDeniedException
This will open or return, if one is already open, a custom shell, you are responsible for managing the shell, reading the output and for closing the shell when you are done using it.

Parameters:
shellPath - a String to Indicate the path to the shell that you want to open.
Throws:
java.util.concurrent.TimeoutException
RootDeniedException
java.io.IOException

getFilePermissionsSymlinks

public static Permissions getFilePermissionsSymlinks(java.lang.String file)
Parameters:
file - String that represent the file, including the full path to the file and its name.
Returns:
An instance of the class permissions from which you can get the permissions of the file or if the file could not be found or permissions couldn't be determined then permissions will be null.

getInode

public static java.lang.String getInode(java.lang.String file)
This method will return the inode number of a file. This method is dependent on having a version of ls that supports the -i parameter.

Parameters:
file - path to the file that you wish to return the inode number
Returns:
String The inode number for this file or "" if the inode number could not be found.

getMounts

public static java.util.ArrayList<Mount> getMounts()
                                            throws java.lang.Exception
This will return an ArrayList of the class Mount. The class mount contains the following property's: device mountPoint type flags

These will provide you with any information you need to work with the mount points.

Returns:
ArrayList an ArrayList of the class Mount.
Throws:
java.lang.Exception - if we cannot return the mount points.

getMountedAs

public static java.lang.String getMountedAs(java.lang.String path)
                                     throws java.lang.Exception
This will tell you how the specified mount is mounted. rw, ro, etc...

Parameters:
path - The mount you want to check
Returns:
String What the mount is mounted as.
Throws:
java.lang.Exception - if we cannot determine how the mount is mounted.

getPath

public static java.util.Set<java.lang.String> getPath()
                                               throws java.lang.Exception
This will return the environment variable $PATH

Returns:
Set A Set of Strings representing the environment variable $PATH
Throws:
java.lang.Exception - if we cannot return the $PATH variable

getShell

public static Shell getShell(boolean root,
                             int timeout,
                             int retry)
                      throws java.io.IOException,
                             java.util.concurrent.TimeoutException,
                             RootDeniedException
This will open or return, if one is already open, a shell, you are responsible for managing the shell, reading the output and for closing the shell when you are done using it.

Parameters:
retry - a int to indicate how many times the ROOT shell should try to open with root priviliges...
root - a boolean to Indicate whether or not you want to open a root shell or a standard shell
timeout - an int to Indicate the length of time to wait before giving up on opening a shell.
Throws:
java.util.concurrent.TimeoutException
RootDeniedException
java.io.IOException

getShell

public static Shell getShell(boolean root,
                             int timeout)
                      throws java.io.IOException,
                             java.util.concurrent.TimeoutException,
                             RootDeniedException
This will open or return, if one is already open, a shell, you are responsible for managing the shell, reading the output and for closing the shell when you are done using it.

Parameters:
root - a boolean to Indicate whether or not you want to open a root shell or a standard shell
timeout - an int to Indicate the length of time to wait before giving up on opening a shell.
Throws:
java.util.concurrent.TimeoutException
RootDeniedException
java.io.IOException

getShell

public static Shell getShell(boolean root)
                      throws java.io.IOException,
                             java.util.concurrent.TimeoutException,
                             RootDeniedException
This will open or return, if one is already open, a shell, you are responsible for managing the shell, reading the output and for closing the shell when you are done using it.

Parameters:
root - a boolean to Indicate whether or not you want to open a root shell or a standard shell
Throws:
java.util.concurrent.TimeoutException
RootDeniedException
java.io.IOException

getSpace

public static long getSpace(java.lang.String path)
Get the space for a desired partition.

Parameters:
path - The partition to find the space for.
Returns:
the amount if space found within the desired partition. If the space was not found then the value is -1
Throws:
java.util.concurrent.TimeoutException

getSymlink

public static java.lang.String getSymlink(java.lang.String file)
This will return a String that represent the symlink for a specified file.

Parameters:
file - path to the file to get the Symlink for. (must have absolute path)
Returns:
String a String that represent the symlink for a specified file or an empty string if no symlink exists.

getSymlinks

public static java.util.ArrayList<Symlink> getSymlinks(java.lang.String path)
                                                throws java.lang.Exception
This will return an ArrayList of the class Symlink. The class Symlink contains the following property's: path SymplinkPath

These will provide you with any Symlinks in the given path.

Parameters:
path - path to search for Symlinks.
Returns:
ArrayList an ArrayList of the class Symlink.
Throws:
java.lang.Exception - if we cannot return the Symlinks.

getWorkingToolbox

public static java.lang.String getWorkingToolbox()
This will return to you a string to be used in your shell commands which will represent the valid working toolbox with correct permissions. For instance, if Busybox is available it will return "busybox", if busybox is not available but toolbox is then it will return "toolbox"

Returns:
String that indicates the available toolbox to use for accessing applets.

hasEnoughSpaceOnSdCard

public static boolean hasEnoughSpaceOnSdCard(long updateSize)
Checks if there is enough Space on SDCard

Parameters:
updateSize - size to Check (long)
Returns:
true if the Update will fit on SDCard, false if not enough space on SDCard. Will also return false, if the SDCard is not mounted as read/write

hasUtil

public static boolean hasUtil(java.lang.String util,
                              java.lang.String box)
Checks whether the toolbox or busybox binary contains a specific util

Parameters:
util -
box - Should contain "toolbox" or "busybox"
Returns:
true if it contains this util

installBinary

public static boolean installBinary(android.content.Context context,
                                    int sourceId,
                                    java.lang.String destName,
                                    java.lang.String mode)
This method can be used to unpack a binary from the raw resources folder and store it in /data/data/app.package/files/ This is typically useful if you provide your own C- or C++-based binary. This binary can then be executed using sendShell() and its full path.

Parameters:
context - the current activity's Context
sourceId - resource id; typically R.raw.id
destName - destination file name; appended to /data/data/app.package/files/
mode - chmod value for this file
Returns:
a boolean which indicates whether or not we were able to create the new file.

installBinary

public static boolean installBinary(android.content.Context context,
                                    int sourceId,
                                    java.lang.String binaryName)
This method can be used to unpack a binary from the raw resources folder and store it in /data/data/app.package/files/ This is typically useful if you provide your own C- or C++-based binary. This binary can then be executed using sendShell() and its full path.

Parameters:
context - the current activity's Context
sourceId - resource id; typically R.raw.id
binaryName - destination file name; appended to /data/data/app.package/files/
Returns:
a boolean which indicates whether or not we were able to create the new file.

hasBinary

public static boolean hasBinary(android.content.Context context,
                                java.lang.String binaryName)
This method checks whether a binary is installed.

Parameters:
context - the current activity's Context
binaryName - binary file name; appended to /data/data/app.package/files/
Returns:
a boolean which indicates whether or not the binary already exists.

isAppletAvailable

public static boolean isAppletAvailable(java.lang.String applet,
                                        java.lang.String path)
This will let you know if an applet is available from BusyBox

Parameters:
applet - The applet to check for.
path - Path to the busybox binary that you want to check. (do not include binary name)
Returns:
true if applet is available, false otherwise.

isAppletAvailable

public static boolean isAppletAvailable(java.lang.String applet)
This will let you know if an applet is available from BusyBox

Parameters:
applet - The applet to check for.
Returns:
true if applet is available, false otherwise.

isAccessGiven

public static boolean isAccessGiven()
Returns:
true if your app has been given root access.
Throws:
java.util.concurrent.TimeoutException - if this operation times out. (cannot determine if access is given)

isBusyboxAvailable

public static boolean isBusyboxAvailable()
Returns:
true if BusyBox was found.

isNativeToolsReady

public static boolean isNativeToolsReady(int nativeToolsId,
                                         android.content.Context context)

isProcessRunning

public static boolean isProcessRunning(java.lang.String processName)
This method can be used to to check if a process is running

Parameters:
processName - name of process to check
Returns:
true if process was found
Throws:
java.util.concurrent.TimeoutException - (Could not determine if the process is running)

isRootAvailable

public static boolean isRootAvailable()
Returns:
true if su was found.

killProcess

public static boolean killProcess(java.lang.String processName)
This method can be used to kill a running process

Parameters:
processName - name of process to kill
Returns:
true if process was found and killed successfully

offerBusyBox

public static void offerBusyBox(android.app.Activity activity)
This will launch the Android market looking for BusyBox

Parameters:
activity - pass in your Activity

offerBusyBox

public static android.content.Intent offerBusyBox(android.app.Activity activity,
                                                  int requestCode)
This will launch the Android market looking for BusyBox, but will return the intent fired and starts the activity with startActivityForResult

Parameters:
activity - pass in your Activity
requestCode - pass in the request code
Returns:
intent fired

offerSuperUser

public static void offerSuperUser(android.app.Activity activity)
This will launch the Android market looking for SuperUser

Parameters:
activity - pass in your Activity

offerSuperUser

public static android.content.Intent offerSuperUser(android.app.Activity activity,
                                                    int requestCode)
This will launch the Android market looking for SuperUser, but will return the intent fired and starts the activity with startActivityForResult

Parameters:
activity - pass in your Activity
requestCode - pass in the request code
Returns:
intent fired

remount

public static boolean remount(java.lang.String file,
                              java.lang.String mountType)
This will take a path, which can contain the file name as well, and attempt to remount the underlying partition.

For example, passing in the following string: "/system/bin/some/directory/that/really/would/never/exist" will result in /system ultimately being remounted. However, keep in mind that the longer the path you supply, the more work this has to do, and the slower it will run.

Parameters:
file - file path
mountType - mount type: pass in RO (Read only) or RW (Read Write)
Returns:
a boolean which indicates whether or not the partition has been remounted as specified.

restartAndroid

public static void restartAndroid()
This restarts only Android OS without rebooting the whole device. This does NOT work on all devices. This is done by killing the main init process named zygote. Zygote is restarted automatically by Android after killing it.

Throws:
java.util.concurrent.TimeoutException

runBinary

public static void runBinary(android.content.Context context,
                             java.lang.String binaryName,
                             java.lang.String parameter)
Executes binary in a separated process. Before using this method, the binary has to be installed in /data/data/app.package/files/ using the installBinary method.

Parameters:
context - the current activity's Context
binaryName - name of installed binary
parameter - parameter to append to binary like "-vxf"

runShellCommand

public static void runShellCommand(Shell shell,
                                   Command command)
                            throws java.io.IOException
Executes a given command with root access or without depending on the value of the boolean passed. This will also start a root shell or a standard shell without you having to open it specifically.

You will still need to close the shell after you are done using the shell.

Parameters:
shell - The shell to execute the command on, this can be a root shell or a standard shell.
command - The command to execute in the shell
Throws:
java.io.IOException

log

public static void log(java.lang.String msg)
This method allows you to output debug messages only when debugging is on. This will allow you to add a debug option to your app, which by default can be left off for performance. However, when you need debugging information, a simple switch can enable it and provide you with detailed logging.

This method handles whether or not to log the information you pass it depending whether or not RootTools.debugMode is on. So you can use this and not have to worry about handling it yourself.

Parameters:
msg - The message to output.

log

public static void log(java.lang.String TAG,
                       java.lang.String msg)
This method allows you to output debug messages only when debugging is on. This will allow you to add a debug option to your app, which by default can be left off for performance. However, when you need debugging information, a simple switch can enable it and provide you with detailed logging.

This method handles whether or not to log the information you pass it depending whether or not RootTools.debugMode is on. So you can use this and not have to worry about handling it yourself.

Parameters:
TAG - Optional parameter to define the tag that the Log will use.
msg - The message to output.

log

public static void log(java.lang.String msg,
                       int type,
                       java.lang.Exception e)
This method allows you to output debug messages only when debugging is on. This will allow you to add a debug option to your app, which by default can be left off for performance. However, when you need debugging information, a simple switch can enable it and provide you with detailed logging.

This method handles whether or not to log the information you pass it depending whether or not RootTools.debugMode is on. So you can use this and not have to worry about handling it yourself.

Parameters:
msg - The message to output.
type - The type of log, 1 for verbose, 2 for error, 3 for debug
e - The exception that was thrown (Needed for errors)

islog

public static boolean islog()
This method allows you to check whether logging is enabled. Yes, it has a goofy name, but that's to keep it as short as possible. After all writing logging calls should be painless. This method exists to save Android going through the various Java layers that are traversed any time a string is created (i.e. what you are logging) Example usage: if(islog) { StrinbBuilder sb = new StringBuilder(); // ... // build string // ... log(sb.toString()); }

Returns:
true if logging is enabled

log

public static void log(java.lang.String TAG,
                       java.lang.String msg,
                       int type,
                       java.lang.Exception e)
This method allows you to output debug messages only when debugging is on. This will allow you to add a debug option to your app, which by default can be left off for performance. However, when you need debugging information, a simple switch can enable it and provide you with detailed logging.

This method handles whether or not to log the information you pass it depending whether or not RootTools.debugMode is on. So you can use this and not have to worry about handling it yourself.

Parameters:
TAG - Optional parameter to define the tag that the Log will use.
msg - The message to output.
type - The type of log, 1 for verbose, 2 for error, 3 for debug
e - The exception that was thrown (Needed for errors)