Пример #1
0
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
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)
		}
	}
}