Skip to content

Commit f5cd1dd

Browse files
committed
Change syslog to filelog.
1 parent 3130663 commit f5cd1dd

File tree

9 files changed

+29
-29
lines changed

9 files changed

+29
-29
lines changed

config/docker-monitor-filelog.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"plugin": "syslog",
2+
"plugin": "filelog",
33
"pluginConfig": {
44
"timestamp": "^time=\"(\\S*)\"",
55
"message": "msg=\"([^\n]*)\"",

config/kernel-monitor-filelog.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"plugin": "syslog",
2+
"plugin": "filelog",
33
"pluginConfig": {
44
"timestamp": "^.{15}",
55
"message": "kernel: \\[.*\\] (.*)",

pkg/logmonitor/logwatchers/syslog/log_watcher.go renamed to pkg/logmonitor/logwatchers/filelog/log_watcher.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
package syslog
17+
package filelog
1818

1919
import (
2020
"bufio"
@@ -35,7 +35,7 @@ import (
3535
"k8s.io/node-problem-detector/pkg/logmonitor/util"
3636
)
3737

38-
type syslogWatcher struct {
38+
type filelogWatcher struct {
3939
cfg types.WatcherConfig
4040
reader *bufio.Reader
4141
closer io.Closer
@@ -53,7 +53,7 @@ func NewSyslogWatcherOrDie(cfg types.WatcherConfig) types.LogWatcher {
5353
if err := syscall.Sysinfo(&info); err != nil {
5454
glog.Fatalf("Failed to get system info: %v", err)
5555
}
56-
return &syslogWatcher{
56+
return &filelogWatcher{
5757
cfg: cfg,
5858
translator: newTranslatorOrDie(cfg.PluginConfig),
5959
uptime: time.Now().Add(time.Duration(-info.Uptime * int64(time.Second))),
@@ -67,30 +67,30 @@ func NewSyslogWatcherOrDie(cfg types.WatcherConfig) types.LogWatcher {
6767
// Make sure NewSyslogWathcer is types.WatcherCreateFunc.
6868
var _ types.WatcherCreateFunc = NewSyslogWatcherOrDie
6969

70-
// Watch starts the syslog watcher.
71-
func (s *syslogWatcher) Watch() (<-chan *logtypes.Log, error) {
70+
// Watch starts the filelog watcher.
71+
func (s *filelogWatcher) Watch() (<-chan *logtypes.Log, error) {
7272
r, err := getLogReader(s.cfg.LogPath)
7373
if err != nil {
7474
return nil, err
7575
}
7676
s.reader = bufio.NewReader(r)
7777
s.closer = r
78-
glog.Info("Start watching syslog")
78+
glog.Info("Start watching filelog")
7979
go s.watchLoop()
8080
return s.logCh, nil
8181
}
8282

83-
// Stop stops the syslog watcher.
84-
func (s *syslogWatcher) Stop() {
83+
// Stop stops the filelog watcher.
84+
func (s *filelogWatcher) Stop() {
8585
s.tomb.Stop()
8686
}
8787

88-
// watchPollInterval is the interval syslog log watcher will
88+
// watchPollInterval is the interval filelog log watcher will
8989
// poll for pod change after reading to the end.
9090
const watchPollInterval = 500 * time.Millisecond
9191

92-
// watchLoop is the main watch loop of syslog watcher.
93-
func (s *syslogWatcher) watchLoop() {
92+
// watchLoop is the main watch loop of filelog watcher.
93+
func (s *filelogWatcher) watchLoop() {
9494
defer func() {
9595
s.closer.Close()
9696
close(s.logCh)
@@ -105,14 +105,14 @@ func (s *syslogWatcher) watchLoop() {
105105
for {
106106
select {
107107
case <-s.tomb.Stopping():
108-
glog.Infof("Stop watching syslog")
108+
glog.Infof("Stop watching filelog")
109109
return
110110
default:
111111
}
112112

113113
line, err := s.reader.ReadString('\n')
114114
if err != nil && err != io.EOF {
115-
glog.Errorf("Exiting syslog watch with error: %v", err)
115+
glog.Errorf("Exiting filelog watch with error: %v", err)
116116
return
117117
}
118118
buffer.WriteString(line)
@@ -135,7 +135,7 @@ func (s *syslogWatcher) watchLoop() {
135135
}
136136
}
137137

138-
// getLogReader returns log reader for syslog log. Note that getLogReader doesn't look back
138+
// getLogReader returns log reader for filelog log. Note that getLogReader doesn't look back
139139
// to the rolled out logs.
140140
func getLogReader(path string) (io.ReadCloser, error) {
141141
if path == "" {

pkg/logmonitor/logwatchers/syslog/log_watcher_test.go renamed to pkg/logmonitor/logwatchers/filelog/log_watcher_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
package syslog
17+
package filelog
1818

1919
import (
2020
"io/ioutil"
@@ -140,15 +140,15 @@ Jan 2 03:04:05 kernel: [2.000000] 3
140140
assert.NoError(t, err)
141141

142142
w := NewSyslogWatcherOrDie(types.WatcherConfig{
143-
Plugin: "syslog",
143+
Plugin: "filelog",
144144
PluginConfig: getTestPluginConfig(),
145145
LogPath: f.Name(),
146146
Lookback: test.lookback,
147147
})
148148
// Set the uptime.
149-
w.(*syslogWatcher).uptime = test.uptime
149+
w.(*filelogWatcher).uptime = test.uptime
150150
// Set the fake clock.
151-
w.(*syslogWatcher).clock = fakeClock
151+
w.(*filelogWatcher).clock = fakeClock
152152
logCh, err := w.Watch()
153153
assert.NoError(t, err)
154154
defer w.Stop()

pkg/logmonitor/logwatchers/syslog/translator.go renamed to pkg/logmonitor/logwatchers/filelog/translator.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1313
See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
16-
package syslog
16+
package filelog
1717

1818
import (
1919
"fmt"
@@ -95,7 +95,7 @@ func validatePluginConfig(cfg map[string]string) error {
9595
}
9696

9797
// formalizeTimestamp formalizes the timestamp. We need this because some log doesn't contain full
98-
// timestamp, e.g. syslog.
98+
// timestamp, e.g. filelog.
9999
func formalizeTimestamp(t time.Time) time.Time {
100100
if t.Year() == 0 {
101101
t = t.AddDate(time.Now().Year(), 0, 0)

pkg/logmonitor/logwatchers/syslog/translator_test.go renamed to pkg/logmonitor/logwatchers/filelog/translator_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
package syslog
17+
package filelog
1818

1919
import (
2020
"testing"

pkg/logmonitor/logwatchers/register_syslog.go renamed to pkg/logmonitor/logwatchers/register_filelog.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ limitations under the License.
1717
package logwatchers
1818

1919
import (
20-
"k8s.io/node-problem-detector/pkg/logmonitor/logwatchers/syslog"
20+
"k8s.io/node-problem-detector/pkg/logmonitor/logwatchers/filelog"
2121
)
2222

23-
const syslogPluginName = "syslog"
23+
const filelogPluginName = "filelog"
2424

2525
func init() {
26-
// Register the syslog plugin.
27-
registerLogWatcher(syslogPluginName, syslog.NewSyslogWatcherOrDie)
26+
// Register the filelog plugin.
27+
registerLogWatcher(filelogPluginName, filelog.NewSyslogWatcherOrDie)
2828
}

pkg/logmonitor/logwatchers/register_journald.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@ import (
2525
const journaldPluginName = "journald"
2626

2727
func init() {
28-
// Register the syslog plugin.
28+
// Register the journald plugin.
2929
registerLogWatcher(journaldPluginName, journald.NewJournaldWatcher)
3030
}

pkg/logmonitor/logwatchers/types/log_watcher.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ type LogWatcher interface {
3131
// WatcherConfig is the configuration of the log watcher.
3232
type WatcherConfig struct {
3333
// Plugin is the name of plugin which is currently used.
34-
// Currently supported: syslog, journald.
34+
// Currently supported: filelog, journald.
3535
Plugin string `json:"plugin, omitempty"`
3636
// PluginConfig is a key/value configuration of a plugin. Valid configurations
3737
// are defined in different log watcher plugin.

0 commit comments

Comments
 (0)