console

package module
v0.0.0-...-105276c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 19, 2015 License: MIT Imports: 2 Imported by: 18

README

js/console

Package console provides GopherJS wrappers for the JavaScript console.

Install

go get honnef.co/go/js/console

Documentation

Overview

Package console provides GopherJS wrappers for the JavaScript console.

Some functions support format specifiers. The following specifiers are supported:

%s – Formats the value as a string
%d – Formats the value as an integer
%i – Same as %d
%f – Formats the value as a floating point value.
%o – Formats the value as an expandable DOM element (as in the Elements panel).
%O – Formats the value as an expandable JavaScript object.
%c – Formats the output string according to CSS styles you provide.

This package does not provide functions for the aliases console.debug and console.info – use Log instead.

For a more detailed explanation of the APIs, see for example Google's documentation at https://developers.google.com/chrome-developer-tools/docs/console-api.

Portions of this documentation are modifications based on work created and shared by Google and used according to terms described in the Creative Commons 3.0 Attribution License.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Assert

func Assert(b bool, msg interface{})

Assert writes msg to the console if b is false.

func Clear

func Clear()

Clear clears the console.

func Count

func Count(label string)

Count writes the number of times that it has been invoked at the same line and with the same label.

func Dir

func Dir(obj interface{})

Dir prints a JavaScript representation of the specified object. If the object being logged is an HTML element, then the properties of its DOM representation are displayed.

func DirXML

func DirXML(obj interface{})

DirXML Prints an XML representation of the specified object. For HTML elements, calling this method is equivalent to calling Log.

func Error

func Error(objs ...interface{})

Error is like Log but also includes a stack trace.

func Group

func Group(objs ...interface{})

Group starts a new logging group with an optional title.

All console output that occurs after calling this function appears in the same visual group. Groups can be nested.

The title will be generated according to the rules of the Log function.

func GroupCollapsed

func GroupCollapsed(objs ...interface{})

GroupCollapsed is like Group, except that the newly created group starts collapsed instead of open.

func GroupEnd

func GroupEnd()

GroupEnd closes the currently active logging group.

func Log

func Log(objs ...interface{})

Log displays a message in the console. You pass one or more objects to this method, each of which are evaluated and concatenated into a space-delimited string. The first parameter you pass to Log may contain format specifiers.

func Profile

func Profile(label interface{})

Profile starts a new CPU profile with an optional label.

func ProfileEnd

func ProfileEnd()

ProfileEnd stops the currently running CPU profile, if any.

func Time

func Time(label interface{})

Time starts a new timer with an associated label. Calling TimeEnd with the same label will stop the timer and print the elapsed time.

func TimeEnd

func TimeEnd(label interface{})

TimeEnd ends a timer that was started with Time and prints the elapsed time.

func Timestamp

func Timestamp(label interface{})

Timestamp adds an event to the timeline during a recording session.

func Trace

func Trace()

Trace prints a stack trace, starting from the point where Trace was called.

func Warn

func Warn(objs ...interface{})

Warn is like Log but displays a different icon alongside the message.

Types

type Writer

type Writer struct {
	// contains filtered or unexported fields
}

Writer implements an io.Writer on top of the JavaScript console. Writes will be buffered until a newline is encountered, which will cause flushing up to the newline.

func New

func New() *Writer

func (*Writer) Flush

func (w *Writer) Flush()

Flush will flush the current line to the console.

func (*Writer) Write

func (w *Writer) Write(buf []byte) (n int, err error)

func (*Writer) WriteString

func (w *Writer) WriteString(s string) (n int, err error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL