| 83 | } |
| 84 | |
| 85 | func (m *LogManager) checkMatchLocked(key sourceKey) { |
| 86 | sub, ok := m.subscribers[key] |
| 87 | if !ok { |
| 88 | return |
| 89 | } |
| 90 | |
| 91 | history := m.histories[key] |
| 92 | for i, event := range history { |
| 93 | matched := false |
| 94 | if sub.Regex != nil { |
| 95 | if sub.Regex.MatchString(event.Content) { |
| 96 | matched = true |
| 97 | } |
| 98 | } else if sub.Pattern != "" { |
| 99 | if strings.Contains(event.Content, sub.Pattern) { |
| 100 | matched = true |
| 101 | } |
| 102 | } |
| 103 | |
| 104 | if matched { |
| 105 | m.histories[key] = history[i+1:] |
| 106 | select { |
| 107 | case sub.MatchCh <- struct{}{}: |
| 108 | default: |
| 109 | } |
| 110 | return |
| 111 | } |
| 112 | } |
| 113 | } |
| 114 | |
| 115 | func (m *LogManager) Subscribe(node string, source LogSource, pattern string, isRegex bool) (*LogSubscription, error) { |
| 116 | m.mu.Lock() |