(app models.Application)
| 99 | } |
| 100 | |
| 101 | func (cmd *Logs) tailLogsFor(app models.Application) error { |
| 102 | onConnect := func() { |
| 103 | cmd.ui.Say(T("Connected, tailing logs for app {{.AppName}} in org {{.OrgName}} / space {{.SpaceName}} as {{.Username}}...\n", |
| 104 | map[string]interface{}{ |
| 105 | "AppName": terminal.EntityNameColor(app.Name), |
| 106 | "OrgName": terminal.EntityNameColor(cmd.config.OrganizationFields().Name), |
| 107 | "SpaceName": terminal.EntityNameColor(cmd.config.SpaceFields().Name), |
| 108 | "Username": terminal.EntityNameColor(cmd.config.Username())})) |
| 109 | } |
| 110 | |
| 111 | c := make(chan logs.Loggable) |
| 112 | e := make(chan error) |
| 113 | |
| 114 | go cmd.logsRepo.TailLogsFor(app.GUID, onConnect, c, e) |
| 115 | |
| 116 | for { |
| 117 | select { |
| 118 | case msg, ok := <-c: |
| 119 | if !ok { |
| 120 | return nil |
| 121 | } |
| 122 | cmd.ui.Say("%s", msg.ToLog(time.Local)) |
| 123 | case err := <-e: |
| 124 | return cmd.handleError(err) |
| 125 | } |
| 126 | } |
| 127 | } |
| 128 | |
| 129 | func (cmd *Logs) handleError(err error) error { |
| 130 | switch err.(type) { |
no test coverage detected