コード例 #1
0
ファイル: download.go プロジェクト: chuckhendo/themekit
func handleError(filename string, err error, eventLog chan themekit.ThemeEvent) {
	if nonFatal, ok := err.(themekit.NonFatalNetworkError); ok {
		event := basicEvent{
			Title:     "Non-Fatal Network Error",
			EventType: nonFatal.Verb,
			Target:    filename,
			etype:     "fsevent",
			Formatter: func(b basicEvent) string {
				return fmt.Sprintf(
					"[%s] Could not complete %s for %s",
					themekit.RedText(fmt.Sprintf("%d", nonFatal.Code)),
					themekit.YellowText(b.EventType),
					themekit.BlueText(b.Target),
				)
			},
		}
		logEvent(event, eventLog)
	}
}
コード例 #2
0
ファイル: watch.go プロジェクト: chuckhendo/themekit
func spawnWorker(workerName string, queue chan themekit.AssetEvent, client themekit.ThemeClient, eventLog chan themekit.ThemeEvent) {
	logEvent(workerSpawnEvent(workerName), eventLog)
	for {
		asset := <-queue
		if asset.Asset().IsValid() {
			workerEvent := basicEvent{
				Title:     "FS Event",
				EventType: asset.Type().String(),
				Target:    asset.Asset().Key,
				etype:     "fsevent",
				Formatter: func(b basicEvent) string {
					return fmt.Sprintf(
						"Received %s event on %s",
						themekit.GreenText(b.EventType),
						themekit.BlueText(b.Target),
					)
				},
			}
			logEvent(workerEvent, eventLog)
			logEvent(client.Perform(asset), eventLog)
		}
	}
}