github.com/CyCoreSystems/ari@v4.8.4+incompatible/logging.go (about) 1 package ari 2 3 // Logging represents a communication path to an 4 // Asterisk server for working with logging resources 5 type Logging interface { 6 7 // Create creates a new log. The levels are a comma-separated list of 8 // logging levels on which this channel should operate. The name of the 9 // channel should be the key's ID. 10 Create(key *Key, levels string) (*LogHandle, error) 11 12 // Data retrives the data for a logging channel 13 Data(key *Key) (*LogData, error) 14 15 // Data retrives the data for a logging channel 16 Get(key *Key) *LogHandle 17 18 // List the logs 19 List(filter *Key) ([]*Key, error) 20 21 // Rotate rotates the log 22 Rotate(key *Key) error 23 24 // Delete deletes the log 25 Delete(key *Key) error 26 } 27 28 // LogData represents the log data 29 type LogData struct { 30 // Key is the cluster-unique identifier for this logging channel 31 Key *Key `json:"key"` 32 33 // Name is the name of the logging channel 34 Name string `json:"channel"` 35 36 // Levels is a comma-separated list of logging levels for this channel 37 Levels string `json:"levels"` 38 39 // Type indicates the type of logs for this channel 40 Types string `json:"types"` 41 42 // Status indicates whether this logging channel is enabled 43 Status string `json:"status"` 44 } 45 46 // NewLogHandle builds a new log handle given the `Key` and `Logging`` client 47 func NewLogHandle(key *Key, l Logging) *LogHandle { 48 return &LogHandle{ 49 key: key, 50 c: l, 51 } 52 } 53 54 // LogHandle provides an interface to manipulate a logging channel 55 type LogHandle struct { 56 key *Key 57 c Logging 58 } 59 60 // ID returns the ID (name) of the logging channel 61 func (l *LogHandle) ID() string { 62 return l.key.ID 63 } 64 65 // Key returns the Key of the logging channel 66 func (l *LogHandle) Key() *Key { 67 return l.key 68 } 69 70 // Data returns the data for the logging channel 71 func (l *LogHandle) Data() (*LogData, error) { 72 return l.c.Data(l.key) 73 } 74 75 // Rotate causes the logging channel's logfiles to be rotated 76 func (l *LogHandle) Rotate() error { 77 return l.c.Rotate(l.key) 78 } 79 80 // Delete removes the logging channel from Asterisk 81 func (l *LogHandle) Delete() error { 82 return l.c.Delete(l.key) 83 }