cols

package
v1.5.0-alpha6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 26, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TimeOnlyMilli = "15:04:05.000"
)

Variables

View Source
var (
	HistoryTime = output.TableColumn[*models.JobHistory]{
		ColumnConfig: table.ColumnConfig{Name: "Time", WidthMax: len(time.StampMilli), WidthMaxEnforcer: output.ShortenTime},
		Value:        func(j *models.JobHistory) string { return j.Occurred().Format(time.StampMilli) },
	}
	HistoryTimeOnly = output.TableColumn[*models.JobHistory]{
		ColumnConfig: table.ColumnConfig{Name: "Time", WidthMax: len(TimeOnlyMilli), WidthMaxEnforcer: text.Trim},
		Value:        func(j *models.JobHistory) string { return j.Occurred().Format(TimeOnlyMilli) },
	}
	HistoryDateTime = output.TableColumn[*models.JobHistory]{
		ColumnConfig: table.ColumnConfig{Name: "Time", WidthMax: 20, WidthMaxEnforcer: text.WrapText},
		Value:        func(j *models.JobHistory) string { return j.Occurred().Format(time.DateTime) },
	}
	HistoryLevel = output.TableColumn[*models.JobHistory]{
		ColumnConfig: table.ColumnConfig{Name: "Level", WidthMax: 15, WidthMaxEnforcer: text.WrapText},
		Value:        func(jwi *models.JobHistory) string { return jwi.Type.String() },
	}
	HistoryExecID = output.TableColumn[*models.JobHistory]{
		ColumnConfig: table.ColumnConfig{Name: "Exec. ID", WidthMax: 10, WidthMaxEnforcer: text.WrapText},
		Value: func(j *models.JobHistory) string {
			if j.ExecutionID == "" {
				return ""
			}
			return idgen.ShortUUID(j.ExecutionID)
		},
	}
	HistoryTopic = output.TableColumn[*models.JobHistory]{
		ColumnConfig: table.ColumnConfig{Name: "Topic", WidthMax: 15, WidthMaxEnforcer: text.WrapSoft},
		Value:        func(jh *models.JobHistory) string { return string(jh.Event.Topic) },
	}
	HistoryEvent = output.TableColumn[*models.JobHistory]{
		ColumnConfig: table.ColumnConfig{Name: "Event", WidthMax: 90, WidthMaxEnforcer: output.WrapSoftPreserveNewlines},
		Value: func(h *models.JobHistory) string {
			res := h.Event.Message

			if h.Event.Details != nil {
				if h.Event.Details[models.DetailsKeyIsError] == "true" {
					res = output.BoldStr(output.RedStr("Error: ")) + res
				}

				if h.Event.Details[models.DetailsKeyHint] != "" {
					res +=
						"\n" + output.BoldStr(output.GreenStr("Hint: ")) + h.Event.Details[models.DetailsKeyHint]
				}

				if system.IsDebugMode() {
					for k, v := range h.Event.Details {

						if k == models.DetailsKeyHint || k == models.DetailsKeyIsError {
							continue
						}
						res += "\n" + fmt.Sprintf("* %s %s", output.BoldStr(k+":"), v)
					}
				}
			}
			return res
		},
	}
)

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL