traffic-chromelogger: Index | Files | Directories

package chromelogger

import ""

Package chromemiddleware implements a Chrome Logger middleware for Traffic.

This is a Middleware for traffic ( It allows to send logs to the Chrome console if you have the Chrome Logger extension ( installed.


package main

import (

func rootHandler(w traffic.ResponseWriter, r *http.Request) {
  logger := w.GetVar("chromelogger").(*chromelogger.Logger)

    "foo": "bar",

  fmt.Fprint(w, "Hello, check your Chrome console after activating the Chrome Logger extension.\n")

func main() {
  router := traffic.New()
  router.Get("/", rootHandler)

  http.Handle("/", router)
  err := http.ListenAndServe(":7000", nil)

  if err != nil {


Package Files

data.go doc.go logger.go middleware.go responsewriter.go


const LOG_TYPE_ERROR = "error"
const LOG_TYPE_INFO = "info"
const LOG_TYPE_LOG = "log"
const LOG_TYPE_WARN = "warn"
const VERSION = "0.1.0"

type ChromeLoggerMiddleware

type ChromeLoggerMiddleware struct{}

func New

func New() *ChromeLoggerMiddleware

func (ChromeLoggerMiddleware) ServeHTTP

func (middleware ChromeLoggerMiddleware) ServeHTTP(w traffic.ResponseWriter, r *traffic.Request, next traffic.NextMiddlewareFunc)

type Data

type Data struct {
    Version string    `json:"version"`
    Columns []string  `json:"columns"`
    Rows    []*LogRow `json:"rows"`

func NewData

func NewData() *Data

func (*Data) AddRow

func (data *Data) AddRow(item interface{}, backtrace, logType string)

type LogData

type LogData []interface{}

func (*LogData) Add

func (data *LogData) Add(item interface{})

type LogRow

type LogRow []interface{}

func NewLogRow

func NewLogRow(logData *LogData, backtrace, logType string) *LogRow

type Logger

type Logger struct {
    // contains filtered or unexported fields

func (*Logger) Error

func (logger *Logger) Error(item interface{})

func (Logger) Export

func (logger Logger) Export() string

func (*Logger) Info

func (logger *Logger) Info(item interface{})

func (*Logger) Log

func (logger *Logger) Log(item interface{})

func (*Logger) Warn

func (logger *Logger) Warn(item interface{})



Package chromelogger imports 6 packages (graph) and is imported by 1 packages. Updated 2013-12-10. Refresh now. Tools for package owners.