| 81 | } |
| 82 | |
| 83 | func logHandler(session sockjs.Session) { |
| 84 | |
| 85 | var ( |
| 86 | buf string |
| 87 | err error |
| 88 | msg LogMessage |
| 89 | logSession LogSession |
| 90 | ) |
| 91 | if buf, err = session.Recv(); err != nil { |
| 92 | log.Printf("handleLogSession: can't Recv: %v", err) |
| 93 | return |
| 94 | } |
| 95 | if err = json.Unmarshal([]byte(buf), &msg); err != nil { |
| 96 | log.Printf("handleLogSession: can't UnMarshal (%v): %s", err, buf) |
| 97 | return |
| 98 | } |
| 99 | if logSession = LogSessions.Get(msg.SessionID); logSession.Id == "" { |
| 100 | log.Printf("handleLogSession: can't find session '%s'", msg.SessionID) |
| 101 | return |
| 102 | } |
| 103 | logSession.sockJSSession = session |
| 104 | LogSessions.Set(msg.SessionID, logSession) |
| 105 | logSession.Bound <- nil |
| 106 | } |
| 107 | |
| 108 | func WaitForLoggingStream(k8sClient kubernetes.Interface, namespace string, pod string, container string, tailLines int, follow bool, previous bool , timestamps bool,sessionId string) { |
| 109 | select { |