Skip to content

Class JoggerDebug

hxs edited this page Dec 1, 2019 · 10 revisions

JoggerDebug

Extends Jogger

Package jogger
File JoggerDebug.java

JoggerDebug is the class to manage the debug logs of an application.
This class is an extension of Jogger class.

For other methods check the class parent Jogger.


Constructs

JoggerDebug()

This is a simple construct.

Example:

JoggerDebug j = new JoggerDebug();

JoggerDebug(String logName)

This construct set the log name.

Parameters:

  • logName, name for log file

Example:

JoggerDebug j = new JoggerDebug("log_name");

JoggerDebug(String logName, Integer maxSizeBytes)

This construct set the log name and the max size of log file.

Parameters:

  • logName, name for log file
  • maxSizeBytes, maximum size of log file, in bytes

Example:

JoggerDebug j = new JoggerDebug("log_name", 1024000);

Methods

Get and Set

boolean isDebug()

This method check if the application is on debug mode.

Default false

Return:
Return true if the application is on debug mode, false otherwise.

Example:

JoggerDebug joggerDebug = new JoggerDebug();
if (joggerDebug.isDebug()) {
  // your code
}

void setDebug(boolean debug)

This method active or disable the debug mode.

Parameters:

  • debug, true for active it, false otherwise

Example:

JoggerDebug joggerDebug = new JoggerDebug();
joggerDebug.setDebug(true);

boolean isPrintStackTrace()

This method check if the print of stack trace on log is active.

Default true

Return:
Return true if the print of stack trace is active, false otherwise.

Example:

JoggerDebug joggerDebug = new JoggerDebug();
if (joggerDebug.isPrintStackTrace()) {
  // your code
}

void setPrintStackTrace(boolean printStackTrace)

This method active or disable the print of stack trace on log.

Parameters:

  • printStackTrace, true for active it, false otherwise

Example:

JoggerDebug joggerDebug = new JoggerDebug();
joggerDebug.setDebug(true);
joggerDebug.setPrintStackTrace(false);

Log

void writeLog(String write)

Override void writeLog(String write) of Jogger

This method write, the string passed in input, on the debug log only if the debug mode is enable.
If the printStackTrace mode is active, then it print the datetime with the stacktrace and at end append your message. Otherwise if printStackTrace is diasbled, then print only the datetime with your message. Implement Jogger-Lock. For more info Jogger-Lock.

Parameters:

  • write, string to be writer on debug log file

Example:

JoggerDebug joggerDebug = new JoggerDebug();
joggerDebug.setDebug(true);
joggerDebug.writeLog("DEBUG ENABLED");

void writeStart()

This method write 'STARTING', through the writLog(String write) method.

Example:

JoggerDebug joggerDebug = new JoggerDebug();
joggerDebug.setDebug(true);
joggerDebug.writeStart();

void writeStart(String write)

This method write 'STARTING' with your message, through the writLog(String write) method.

Output format: STARTING -- {0}

Parameters:

  • write, message to be writer on debug log file

Example:

JoggerDebug joggerDebug = new JoggerDebug();
joggerDebug.setDebug(true);
joggerDebug.writeStart("JOGGER IS COOL!!!");

void writeEnd()

This method write 'END', through the writLog(String write) method.

Example:

JoggerDebug joggerDebug = new JoggerDebug();
joggerDebug.setDebug(true);
joggerDebug.writeEnd();

void writeEnd(String write)

This method write 'END' with your message, through the writLog(String write) method.

Output format: END -- {0}

Parameters:

  • write, message to be writer on debug log file

Example:

JoggerDebug joggerDebug = new JoggerDebug();
joggerDebug.setDebug(true);
joggerDebug.writeEnd("420 TIME");

void writeSuccess()

This method write 'SUCCESS', through the writLog(String write) method.

Example:

JoggerDebug joggerDebug = new JoggerDebug();
joggerDebug.setDebug(true);
joggerDebug.writeSuccess();

void writeSuccess(String write)

This method write 'SUCCESS' with your message, through the writLog(String write) method.

Output format: SUCCESS -- {0}

Parameters:

  • write, message to be writer on debug log file

Example:

JoggerDebug joggerDebug = new JoggerDebug();
joggerDebug.setDebug(true);
joggerDebug.writeSuccess("OH YES BABY!!!");

void writeFail()

This method write 'FAIL', through the writLog(String write) method.

Example:

JoggerDebug joggerDebug = new JoggerDebug();
joggerDebug.setDebug(true);
joggerDebug.writeFail();

void writeFail(String write)

This method write 'FAIL' with your message, through the writLog(String write) method.

Output format: FAIL -- {0}

Parameters:

  • write, message to be writer on debug log file

Example:

JoggerDebug joggerDebug = new JoggerDebug();
joggerDebug.setDebug(true);
joggerDebug.writeFail("DAMN!!!");

void writeError()

This method write 'FAIL', through the writLog(String write) method.

Example:

JoggerDebug joggerDebug = new JoggerDebug();
joggerDebug.setDebug(true);
joggerDebug.writeError();

void writeError(String write)

This method write 'FAIL' with your message, through the writLog(String write) method.

Output format: FAIL -- {0}

Parameters:

  • write, message to be writer on debug log file

Example:

JoggerDebug joggerDebug = new JoggerDebug();
joggerDebug.setDebug(true);
joggerDebug.writeError("AZZ!!!");