# Namespace goog.debug

code »

## Interfaces

goog.debug.EntryPointMonitor No Description.

## Classes

goog.debug.Error Base class for custom error objects. goog.debug.LogBuffer Creates the log buffer. goog.debug.LogRecord LogRecord objects are used to pass logging requests between the logging framework and individual log Handlers. goog.debug.Logger The Logger is an object used for logging debug messages.

Show:Public Protected Private

## Type Definitions

code »goog.debug.Loggable : `(string|function(): string)`
A message value that can be handled by a Logger. Functions are treated like callbacks, but are only called when the event's log level is enabled. This is useful for logging messages that are expensive to construct.

## Global Functions

code »goog.debug.catchErrors ( logFunc, opt_cancel, opt_target )

Catches onerror events fired by windows and similar objects.

Parameters
logFunc: `function(Object)` The function to call with the error information. opt_cancel: `boolean=` Whether to stop the error from reaching the browser. opt_target: `Object=` Object that fires onerror events.

code »goog.debug.deepExpose ( obj, opt_showFn ) ⇒ `string`

Creates a string representing a given primitive or object, and for an object, all its properties and nested objects. WARNING: If an object is given, it and all its nested objects will be modified. To detect reference cycles, this method identifies objects using goog.getUid() which mutates the object.

Parameters
obj: `*` Object to expose. opt_showFn: `boolean=` Also show properties that are functions (by default, functions are omitted).
Returns
A string representation of `obj`.

code »goog.debug.enhanceError ( err, opt_message ) ⇒ `!Error`

Converts an object to an Error if it's a String, adds a stacktrace if there isn't one, and optionally adds an extra message.

Parameters
err: `(Error|string)` the original thrown object or string. opt_message: `string=` optional additional message to add to the error.
Returns
If err is a string, it is used to create a new Error, which is enhanced and returned. Otherwise err itself is enhanced and returned.

code »goog.debug.expose ( obj, opt_showFn ) ⇒ `string`

Creates a string representing an object and all its properties.

Parameters
obj: `(Object|null|undefined)` Object to expose. opt_showFn: `boolean=` Show the functions as well as the properties, default is false.
Returns
The string representation of `obj`.

code »goog.debug.exposeArray ( arr ) ⇒ `string`

Recursively outputs a nested array as a string.

Parameters
arr: `Array` The array.
Returns
String representing nested array.

code »goog.debug.exposeException ( err, opt_fn ) ⇒ `string`

Exposes an exception that has been caught by a try...catch and outputs the error with a stack trace.

Parameters
err: `Object` Error object or string. opt_fn: `Function=` Optional function to start stack trace from.
Returns
Details of exception.

code »goog.debug.fnNameResolver_ ( ) ⇒ `string`

Resolves functions to their names. Resolved function names will be cached.

code »goog.debug.getFunctionName ( fn ) ⇒ `string`

Gets a function name

Parameters
fn: `Function` Function to get name of.
Returns
Function's name.

code »goog.debug.getNativeStackTrace_ ( fn ) ⇒ `?string`

Parameters
fn: `Function` The function to start getting the trace from.

code »goog.debug.getStacktrace ( opt_fn ) ⇒ `string`

Gets the current stack trace, either starting from the caller or starting from a specified function that's currently on the call stack.

Parameters
opt_fn: `Function=` Optional function to start getting the trace from. If not provided, defaults to the function that called this.
Returns
Stack trace.

code »goog.debug.getStacktraceHelper_ ( fn, visited ) ⇒ `string`

Private helper for getStacktrace().

Parameters
fn: `Function` Function to start getting the trace from. visited: `Array` List of functions visited so far.
Returns
Stack trace starting from function fn.

code »goog.debug.getStacktraceSimple ( opt_depth ) ⇒ `string`

Gets the current stack trace. Simple and iterative - doesn't worry about catching circular references or getting the args.

Parameters
opt_depth: `number=` Optional maximum depth to trace back to.
Returns
A string with the function names of all functions in the stack, separated by \n.

code »goog.debug.makeWhitespaceVisible ( string ) ⇒ `string`

Makes whitespace visible by replacing it with printable characters. This is useful in finding diffrences between the expected and the actual output strings of a testcase.

Parameters
string: `string` whose whitespace needs to be made visible.
Returns
string whose whitespace is made visible.

code »goog.debug.normalizeErrorObject ( err ) ⇒ `!Object`

Normalizes the error/exception object between browsers.

Parameters
err: `Object` Raw error object.
Returns
Normalized error object.

code »goog.debug.setFunctionResolver ( resolver )

Set a custom function name resolver.

Parameters
resolver: `function(Function): string` Resolves functions to their names.

## Global Properties

code »goog.debug.MAX_STACK_DEPTH : `number`

Max length of stack to try and output

code »goog.debug.fnNameCache_ : `Object`

Hash map for storing function names that have already been looked up.

## Compiler Constants

code »goog.debug.LOGGING_ENABLED : `boolean`