hipchat

package
v6.3.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2018 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package hipchat allows for log messages to be sent to a hipchat room.

Example

NOTE: "/notification" is added to the host url automatically.

package main

import (
	"github.com/go-playground/log"
	"github.com/go-playground/log/handlers/http/hipchat"
)

func main() {

	// NOTE: ROOM TOKEN must have view permissions for room
	hc, err := hipchat.New(hipchat.APIv2, "https://api.hipchat.com/v2/room/{ROOM ID or NAME}", "application/json", "{ROOM TOKEN}")
	if err != nil {
		log.Error(err)
	}
	hc.SetFilenameDisplay(log.Llongfile)

	log.RegisterHandler(hc, log.WarnLevel, log.AlertLevel, log.PanicLevel)

	log.WithFields(log.F("error", "something went wrong")).StackTrace().Alert("ALERT!")
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIVersion

type APIVersion uint8

APIVersion specifies the HipChat API version to use

const (
	APIv2 APIVersion = iota
)

Supported API Versions

type Activity

type Activity struct {
	HTML string `json:"html"`           // 1 - unlimited, Html for the activity to show in one line a summary of the action that happened
	Icon *Icon  `json:"icon,omitempty"` // icon to display
}

Activity is a HipChat activity object

type Attribute

type Attribute struct {
	Value Value  `json:"value"`           // attribute value
	Label string `json:"label,omitempty"` // min 1 max 50
}

Attribute is a HipChat attribute object

type Body

type Body struct {
	From          string `json:"from,omitempty"`           // min 0 max 64
	MessageFormat string `json:"message_format,omitempty"` // html or text
	Color         string `json:"color,omitempty"`          // yellow, green, red, purple, gray, random
	AttachTo      string `json:"attach_to,omitempty"`      // min 0 max 36
	Notify        bool   `json:"notify,omitempty"`         // Default false
	Message       string `json:"message"`                  // min 0 max 10,000
	Card          *Card  `json:"card,omitempty"`
}

Body encompases the structure needed to post data to a specific room

type Card

type Card struct {
	Style            string       `json:"style"`                 // min 1 max 16
	Description      *Description `json:"description,omitempty"` // description object
	Format           string       `json:"format,omitempty"`      // compact or medium
	URL              string       `json:"url,omitempty"`         // 1 - unlimited
	Title            string       `json:"title"`                 // min 1 max 500
	HipChatThumbnail *Thumbnail   `json:"thumbnail,omitempty"`   // thumbnail object
	Attributes       []Attribute  `json:"attributes,omitempty"`  // List of attributes to show below the card. Sample {label}:{value.icon} {value.label}
	ID               string       `json:"id"`                    // min 1 max unlimited, An id that will help HipChat recognise the same card when it is sent multiple times
	Icon             *Icon        `json:"icon,omitempty"`        // icon to display
}

Card is a custom Hipchat

type Description

type Description struct {
	Value  string `json:"value"`  // min 1 max 1000
	Format string `json:"format"` // html or text
}

Description is a HipChat description object

type HipChat

type HipChat struct {
	*http.HTTP
	// contains filtered or unexported fields
}

HipChat object

func New

func New(api APIVersion, remoteHost string, contentType string, authToken string, application string) (*HipChat, error)

New returns a new instance of the HipChat logger

func (*HipChat) SetTemplate

func (hc *HipChat) SetTemplate(htmlTemplate string)

SetTemplate sets Hipchats html template to be used for email body

type Icon

type Icon struct {
	URL       string `json:"url"`    // min 1 max unlimited
	URLRetina string `json:"url@2x"` // min 1 max unlimited, the icon url in retina
}

Icon is a HipChat icon object

type Thumbnail

type Thumbnail struct {
	URL       string `json:"url"`               // min 1 max 250
	URLRetina string `json:"url@2x"`            // min 1 max 250, the thumbnail url in retina
	Width     uint   `json:"width,omitempty"`   // width of image
	Height    uint   `json:"height, omitempty"` // height of image
}

Thumbnail is a HipChat thumbnail object

type Value

type Value struct {
	URL   string `json:"url,omitempty"`   // min 1 max unlimited, Url to be opened when a user clicks on the label
	Style string `json:"style,omitempty"` // AUI Integrations for now supporting only lozenges, lozenge-success, lozenge-error, lozenge-current, lozenge-complete, lozenge-moved, lozenge.
	Label string `json:"label"`           // min 1 max unlimited
	Icon  *Icon  `json:"icon,omitempty"`  // icon to display
}

Value is a HipChat value object

Jump to

Keyboard shortcuts

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