Ejemplo n.º 1
0
// Example
func main() {
	// Token
	cloudpelican.SetToken("YOUR_TOKEN_HERE")

	// More verbose
	cloudpelican.SetDebugMode(true)

	// Basic message
	var msg string = "This is a log message %d"

	// Write message and validate
	for i := 0; i < 10; i++ {
		// Basic message with a sequence number for esting purposes
		parsedMsg := fmt.Sprintf(msg, i)
		res := cloudpelican.LogMessage(parsedMsg)
		//time.Sleep(1000 * time.Millisecond)
		// Validate the writing
		if !res {
			log.Println("Something went wrong")
		} else {
			log.Printf("Written %d bytes of data '%s' to backend.\n", len(parsedMsg), parsedMsg)
		}
	}

	// Sleep
	cloudpelican.Drain()
}
// Test log message
func TestLogMessage(t *testing.T) {
	const in string = "Hello World"
	const out bool = true
	if x := cloudpelican.LogMessage(in); x != out {
		t.Errorf("cloudpelican.LogMessage(%v) = %v, want %v", in, x, out)
	}
}