Skip to content

Commit

Permalink
Added enable/disable for section headers
Browse files Browse the repository at this point in the history
  • Loading branch information
DarkGuardsman committed Apr 7, 2017
1 parent 5936eda commit b318d31
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
version_major=0
version_minor=2
version_revis=3
version_revis=4
archivebase=CodingLib
groupid=codinglib
org=builtbroken
28 changes: 25 additions & 3 deletions src/main/java/com/builtbroken/jlib/lang/DebugPrinter.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ public class DebugPrinter
protected String sectionName;
/** Is the logger enabled */
protected boolean enabled = true;
/** Used in start section and end section to restore enable status of previous nest */
protected boolean prev_enabled = true;

/**
* Creates a new debug printer
Expand Down Expand Up @@ -143,7 +145,8 @@ public void start(String msg)
/**
* Starts a new section, indents the section
*
* @param msg - message to output
* @param sectionName - name of a section
* @param msg - message to output
*/
public void start(String sectionName, String msg)
{
Expand All @@ -152,6 +155,20 @@ public void start(String sectionName, String msg)
nest();
}

/**
* Starts a new section, indents the section
*
* @param sectionName - name of a section
* @param msg - message to output
* @param enable - changes the enabled state, used for procedural logic
*/
public void start(String sectionName, String msg, boolean enable)
{
prev_enabled = this.enabled;
this.enabled = enable;
start(sectionName, msg);
}

/**
* Ends an existing section, always
* last section create and will
Expand All @@ -161,6 +178,7 @@ public void start(String sectionName, String msg)
*/
public void end(String msg)
{
enabled = prev_enabled;
unnest();
log(msg);
sectionName = null;
Expand All @@ -178,19 +196,23 @@ public void end()
}

/**
* Enables logging
* Enables logging globally,
* changes previous status as well
*/
public void enable()
{
enabled = true;
prev_enabled = true;
}

/**
* Disable logging
* Disable logging globally,
* changes previous status as well
*/
public void disable()
{
enabled = false;
prev_enabled = false;
}

/**
Expand Down

0 comments on commit b318d31

Please sign in to comment.