Skip to content

Logging & Utils

Samuel Grant edited this page Jun 22, 2020 · 3 revisions

Logging

The library has an optional built in logging function. The logging function is disabled by default but can be enabled or disabled at any time by using

ts3.LoggingEnabled(true) // or false

The following events are logged, each in their own console colour:

  • Notice - General message such as "Successfully established a TCP connection to ..."
  • Debug -
  • Error - Typically used if a function returns an error
  • CmcExec - Logs the date/time and string of every command that is sent to the server

If logging is disabled: errors will not be logged to the console. They should still be returned through either the *status or error variables see more

Utils

The following utility functions are provided for your convenience.

// Reverses the Encode function
func Decode(s string) string {
	return decoder.Replace(s)
}
// Replaces spaces with '+' - Query paramater values
// need their spaces replaced with '+'
func Encode(s string) string {
	return encoder.Replace(s)
}

// URL encodes ' ' and '='. 
// use this if you generate a URL query string
// this is done automatically if you call `get()
func WebEncode(s string) string {
	return webEncoder.Replace(s)
}

// Converts int64 to a string
func i64tostr(i int64) string {
	return strconv.FormatInt(i, 10)
}

Clone this wiki locally