github.com/franc20/ayesa_sap@v7.0.0-beta.28.0.20200124003224-302d4d52fa6c+incompatible/actor/v2action/logging.go (about) 1 package v2action 2 3 import ( 4 "context" 5 6 "code.cloudfoundry.org/cli/actor/sharedaction" 7 ) 8 9 func (actor Actor) GetStreamingLogs(appGUID string, client sharedaction.LogCacheClient) (<-chan sharedaction.LogMessage, <-chan error, context.CancelFunc) { 10 return sharedaction.GetStreamingLogs(appGUID, client) 11 } 12 13 func (actor Actor) GetRecentLogsForApplicationByNameAndSpace(appName string, spaceGUID string, client sharedaction.LogCacheClient) ([]sharedaction.LogMessage, Warnings, error) { 14 app, allWarnings, err := actor.GetApplicationByNameAndSpace(appName, spaceGUID) 15 if err != nil { 16 return nil, allWarnings, err 17 } 18 19 logCacheMessages, err := sharedaction.GetRecentLogs(app.GUID, client) 20 if err != nil { 21 return nil, allWarnings, err 22 } 23 24 var logMessages []sharedaction.LogMessage 25 26 for _, message := range logCacheMessages { 27 logMessages = append(logMessages, *sharedaction.NewLogMessage( 28 message.Message(), 29 message.Type(), 30 message.Timestamp(), 31 message.SourceType(), 32 message.SourceInstance(), 33 )) 34 } 35 36 return logMessages, allWarnings, nil 37 } 38 39 func (actor Actor) GetStreamingLogsForApplicationByNameAndSpace(appName string, spaceGUID string, client sharedaction.LogCacheClient) (<-chan sharedaction.LogMessage, <-chan error, context.CancelFunc, Warnings, error) { 40 app, allWarnings, err := actor.GetApplicationByNameAndSpace(appName, spaceGUID) 41 if err != nil { 42 return nil, nil, func() {}, allWarnings, err 43 } 44 45 messages, logErrs, stopStreaming := actor.GetStreamingLogs(app.GUID, client) 46 47 return messages, logErrs, stopStreaming, allWarnings, err 48 }