Package com.wowza.util
Class DebugUtils
Object
com.wowza.util.DebugUtils
DebugUtils: Debugging utilties.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic File
byteArrayToFile
(byte[] data, String filePath) Dump a buffer of bytes to a file.static boolean
doesStackContainMethod
(String methodName) Examine current stack trace to determine if the specified method name in the the trace.static String
formatBytes
(byte[] data) Format byte array for printing.static String
formatBytes
(byte[] data, boolean showIndex) Format byte array for printing.static String
formatBytes
(byte[] data, int offset, int len) Format byte array for printing.static String
formatBytes
(byte[] data, int offset, int len, boolean showIndex) Format byte array for printing.static String
formatBytesInSingleRow
(byte[] data, int offset, int len) Format byte array for printing.static String
formatBytesShort
(byte[] data) Format byte array for printing.static String
formatBytesShort
(byte[] data, int offset, int len) Format byte array for printing.static String
formatBytesStruct
(byte[] data) static String
formatBytesStruct
(byte[] data, int offset, int len) Format byte array for printing.static String
formatMilliseconds
(long ms) Give a time in seconds, return a String representing the time in hh:mm:ss.mmm.static String
formatSeconds
(long t) Give a time in seconds, return a String representing the time in hh:mm:ss.static String
formatUtcTime
(long utcTime) static String
stackTraceToSingleLineString
(Throwable e, int maxLines) Given an exception, return single line String representation.static String
Given an exception, return String representation.static String
stackTraceToString
(Throwable e, int maxLines, String seperator) Given an exception, return single line String representation.static String
toHex
(byte value) Format a byte value to a 0xff formatstatic String
toHex
(int value) Format a byte value to a 0xffffffff formatstatic String
toLong
(long value) Format a long value to a 0xffffffffffffffff format
-
Constructor Details
-
DebugUtils
public DebugUtils()
-
-
Method Details
-
formatBytesShort
Format byte array for printing. Simple format as rows of hex values (16 values per row)- Parameters:
data
- byte array- Returns:
- formatted string
-
formatBytesShort
Format byte array for printing. Simple format as rows of hex values (16 values per row)- Parameters:
data
- byte arrayoffset
- offset in arraylen
- data len- Returns:
- formatted string
-
formatBytes
Format byte array for printing. Format as rows of hex values (16 values per row) along with text representation of data.- Parameters:
data
- byte array- Returns:
- formatted string
-
formatBytes
Format byte array for printing. Format as rows of hex values (16 values per row) along with text representation of data.- Parameters:
data
- byte array- Returns:
- formatted string
-
formatBytes
Format byte array for printing. Format as rows of hex values (16 values per row) along with text representation of data.- Parameters:
data
- byte arrayoffset
- start index in arraylen
- length to format- Returns:
- formatted string
-
formatBytes
Format byte array for printing. Format as rows of hex values (16 values per row) along with text representation of data.- Parameters:
data
- byte arrayoffset
- start index in arraylen
- length to format- Returns:
- formatted string
-
formatBytesInSingleRow
Format byte array for printing. Format as rows of hex values al in one row along with text representation of data.- Parameters:
data
- byte arrayoffset
- start index in arraylen
- length to format- Returns:
- formatted string
-
formatBytesStruct
-
formatBytesStruct
Format byte array for printing. Format as Java primitive byte values (8 per row).- Parameters:
data
- byte array- Returns:
- formatted string
-
toHex
Format a byte value to a 0xff format- Parameters:
value
- byte value- Returns:
- return string
-
toHex
Format a byte value to a 0xffffffff format- Parameters:
value
- int value- Returns:
- return string
-
toLong
Format a long value to a 0xffffffffffffffff format- Parameters:
value
- long value- Returns:
- return string
-
byteArrayToFile
Dump a buffer of bytes to a file. Useful for debugging.- Parameters:
data
- a buffer of bytesfilePath
- The path and filename
-
formatSeconds
Give a time in seconds, return a String representing the time in hh:mm:ss.123 s --> 00:02:03
- Parameters:
t
-- Returns:
- time representation
-
formatMilliseconds
Give a time in seconds, return a String representing the time in hh:mm:ss.mmm.123456 ms --> 00:02:03.456
- Parameters:
ms
-- Returns:
- time representation
-
formatUtcTime
-
stackTraceToString
Given an exception, return String representation. Note: this is the entire raw stack trace including tabs and line endings- Parameters:
e
- throwable- Returns:
- stack trace representation
-
stackTraceToSingleLineString
Given an exception, return single line String representation. Note: line endings are replaced with "|" character. Tabs are removed.- Parameters:
e
- throwablemaxLines
- If greater than zero, returns only first maxLines of trace- Returns:
- stack trace info
-
stackTraceToString
Given an exception, return single line String representation. Note: line endings are replaced with "|" character. Tabs are removed.- Parameters:
e
- throwablemaxLines
- If greater than zero, returns only first maxLines of traceseperator
- character to replace line endings with- Returns:
- stack trace info
-
doesStackContainMethod
Examine current stack trace to determine if the specified method name in the the trace.Could be enhanced quite a bit by also checking for Class and method. But simple for now.
- Parameters:
methodName
-- Returns:
- true if in trace, else false
-