From af19d2dfff063cae7e64f6fd4e60aaaa2a807606 Mon Sep 17 00:00:00 2001 From: Ronnie Lazar Date: Thu, 8 Feb 2018 11:09:11 +0200 Subject: [PATCH 1/5] Added '-y' arg to apt install in Dockerfile --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index cfa1c4c..8c43d6b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,7 +14,7 @@ RUN yarn RUN npm run build FROM ubuntu:16.04 -RUN apt update && apt install libsystemd-dev +RUN apt update && apt install -y libsystemd-dev COPY --from=server /logserver /usr/bin/logserver COPY --from=client /client/dist /client/dist ENTRYPOINT ["logserver"] From c0663ed7671cfceaf72b8b01952c32ab65fa5cc0 Mon Sep 17 00:00:00 2001 From: Ronnie Lazar Date: Thu, 8 Feb 2018 14:42:05 +0200 Subject: [PATCH 2/5] Added optional thread name column Added pathname and lineno --- Makefile | 2 +- client/app/components/file-view/file-view.js | 10 +- client/app/components/file-view/lines-view.js | 17 +++- client/app/components/selectors.js | 9 +- example/logserver.json | 5 +- main_test.go | 96 +++++++++++-------- parse/log.go | 17 ++-- parse/parse.go | 34 ++++++- parse/parse_test.go | 26 +++++ 9 files changed, 159 insertions(+), 57 deletions(-) diff --git a/Makefile b/Makefile index 66ea310..4c2f083 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ .PHONY: test run-example run-example-dynamic client test: - go test -race ./... -timeout 30s + go test ./... -timeout 30s run-example: go run ./main.go -debug -config ./example/logserver.json diff --git a/client/app/components/file-view/file-view.js b/client/app/components/file-view/file-view.js index 0e4a6b3..e12bcb1 100644 --- a/client/app/components/file-view/file-view.js +++ b/client/app/components/file-view/file-view.js @@ -36,6 +36,7 @@ class FileView extends Component { activeFs: [], showTimestamp: true, showLinenumbers: true, + showThreadName: false, } componentWillMount() { @@ -134,6 +135,7 @@ class FileView extends Component { showLevels={levels} showLinenumbers={this.state.showLinenumbers} showTimestamp={this.state.showTimestamp} + showThreadName={this.state.showThreadName} /> } else { contentComponent =
File is empty
@@ -172,6 +174,12 @@ class FileView extends Component { }) }}>Timestamps + { + this.setState({ + showThreadName: checked, + }) + }}>Thread Name + {contentComponent} @@ -180,4 +188,4 @@ class FileView extends Component { } } -export default FileView \ No newline at end of file +export default FileView diff --git a/client/app/components/file-view/lines-view.js b/client/app/components/file-view/lines-view.js index 769a4f1..09aa106 100644 --- a/client/app/components/file-view/lines-view.js +++ b/client/app/components/file-view/lines-view.js @@ -43,6 +43,7 @@ class LinesView extends Component { } static propTypes = { + showThreadName: PropTypes.bool, showFilename: PropTypes.bool, showTimestamp: PropTypes.bool, showLinenumbers: PropTypes.bool, @@ -51,6 +52,7 @@ class LinesView extends Component { } static defaultProps = { + showThreadName: false, showFilename: false, showTimestamp: false, showLinenumbers: false, @@ -74,7 +76,7 @@ class LinesView extends Component { _getColumns = () => { const {maxLengths} = this.state - const {showFilename, showTimestamp, showLinenumbers} = this.props + const {showThreadName, showFilename, showTimestamp, showLinenumbers} = this.props if (showFilename) { return [ @@ -95,6 +97,12 @@ class LinesView extends Component { }, ] + if (showThreadName) { + columns.unshift({ + width: 100, + name: 'threadName', + }) + } if (showTimestamp) { columns.unshift({ width: 135, @@ -191,6 +199,11 @@ class LinesView extends Component { {line.get('level')} : null break } + case 'threadName': { + content = line.get('threadName') ? + {line.get('threadName')} : null + break + } case 'timestamp': { if (line.get('time')) { const timestamp = moment(line.get('time')) @@ -247,4 +260,4 @@ class LinesView extends Component { } } -export {LinesView} \ No newline at end of file +export {LinesView} diff --git a/client/app/components/selectors.js b/client/app/components/selectors.js index a3b9e68..463498b 100644 --- a/client/app/components/selectors.js +++ b/client/app/components/selectors.js @@ -53,7 +53,12 @@ export const levelsSelector = createSelector( export const contentSelector = createSelector( appStateSelector, levelsSelector, - (app = Map(), levels = Set()) => app.get('content', List()).filter(line => !line.get('level') || levels.includes(line.get('level', '').toLowerCase())) + (app = Map(), levels = Set()) => app.get('content', List()).filter(line => !line.get('level') || levels.includes(line.get('level', '').toLowerCase())).map(line => { + if (line.get('pathname')) { + return line.set('msg', `${line.get('msg')} (${line.get('pathname')}:${line.get('lineno')})`) + } + return line + }) ) const findMatches = (content = List(), query) => { @@ -110,4 +115,4 @@ export const searchResultsSelector = createSelector( (app = Map()) => app.get('search_results') ) -export const locationSelect = (state = Map()) => state.get('router').location || {} \ No newline at end of file +export const locationSelect = (state = Map()) => state.get('router').location || {} diff --git a/example/logserver.json b/example/logserver.json index ebbe932..ff8fe3d 100644 --- a/example/logserver.json +++ b/example/logserver.json @@ -31,7 +31,10 @@ "msg": "msg", "level": "levelname", "time": "created", - "args": "args" + "args": "args", + "threadName": "threadName", + "pathname": "pathname", + "lineno": "lineno" }, "time_formats": [ "unix_float" diff --git a/main_test.go b/main_test.go index 5b97e64..2ca27a6 100644 --- a/main_test.go +++ b/main_test.go @@ -55,31 +55,40 @@ func TestHandler(t *testing.T) { Meta: engine.Meta{ID: 1, Action: "get-content", FS: "node1", Path: engine.Path{"mancala.stratolog"}}, Lines: []parse.Log{ { - Msg: "data disk was found in distributionID:0 table version:1, setting inTable=True", - Level: "INFO", - Time: mustParseTime("2017-12-25T16:23:05+02:00"), - FS: "node1", - FileName: "mancala.stratolog", - Line: 1, - Offset: 0, + Msg: "data disk was found in distributionID:0 table version:1, setting inTable=True", + Level: "INFO", + Time: mustParseTime("2017-12-25T16:23:05+02:00"), + FS: "node1", + FileName: "mancala.stratolog", + Line: 1, + Offset: 0, + ThreadName: "DistributorThread", + LineNo: 162, + PathName: "/usr/share/stratostorage/mancala_management_service.egg/mancala/management/distributor/distributor.py", }, { - Msg: "data disk was found in distributionID:0 table version:1, setting inTable=True", - Level: "INFO", - Time: mustParseTime("2017-12-25T16:23:05+02:00"), - FS: "node1", - FileName: "mancala.stratolog", - Line: 2, - Offset: 699, + Msg: "data disk was found in distributionID:0 table version:1, setting inTable=True", + Level: "INFO", + Time: mustParseTime("2017-12-25T16:23:05+02:00"), + FS: "node1", + FileName: "mancala.stratolog", + Line: 2, + Offset: 699, + ThreadName: "DistributorThread", + LineNo: 162, + PathName: "/usr/share/stratostorage/mancala_management_service.egg/mancala/management/distributor/distributor.py", }, { - Msg: "data disk was found in distributionID:0 table version:1, setting inTable=True", - Level: "INFO", - Time: mustParseTime("2017-12-25T16:23:05+02:00"), - FS: "node1", - FileName: "mancala.stratolog", - Line: 3, - Offset: 1398, + Msg: "data disk was found in distributionID:0 table version:1, setting inTable=True", + Level: "INFO", + Time: mustParseTime("2017-12-25T16:23:05+02:00"), + FS: "node1", + FileName: "mancala.stratolog", + Line: 3, + Offset: 1398, + ThreadName: "DistributorThread", + LineNo: 162, + PathName: "/usr/share/stratostorage/mancala_management_service.egg/mancala/management/distributor/distributor.py", }, }, }, @@ -135,12 +144,15 @@ func TestHandler(t *testing.T) { Meta: engine.Meta{ID: 4, Action: "search", FS: "node1", Path: engine.Path{"mancala.stratolog"}}, Lines: []parse.Log{ {Msg: "data disk was found in distributionID:0 table version:1, setting inTable=True", - Level: "INFO", - Time: mustParseTime("2017-12-25T16:23:05+02:00"), - FS: "node1", - FileName: "mancala.stratolog", - Line: 2, - Offset: 699, + Level: "INFO", + Time: mustParseTime("2017-12-25T16:23:05+02:00"), + FS: "node1", + FileName: "mancala.stratolog", + Line: 2, + Offset: 699, + ThreadName: "DistributorThread", + LineNo: 162, + PathName: "/usr/share/stratostorage/mancala_management_service.egg/mancala/management/distributor/distributor.py", }, }, }, @@ -180,12 +192,15 @@ func TestHandler(t *testing.T) { Meta: engine.Meta{ID: 6, Action: "search", FS: "node1", Path: engine.Path{"mancala.stratolog"}}, Lines: []parse.Log{ {Msg: "data disk was found in distributionID:0 table version:1, setting inTable=True", - Level: "INFO", - Time: mustParseTime("2017-12-25T16:23:05+02:00"), - FS: "node1", - FileName: "mancala.stratolog", - Line: 2, - Offset: 699, + Level: "INFO", + Time: mustParseTime("2017-12-25T16:23:05+02:00"), + FS: "node1", + FileName: "mancala.stratolog", + Line: 2, + Offset: 699, + ThreadName: "DistributorThread", + LineNo: 162, + PathName: "/usr/share/stratostorage/mancala_management_service.egg/mancala/management/distributor/distributor.py", }, }, }, @@ -203,12 +218,15 @@ func TestHandler(t *testing.T) { Meta: engine.Meta{ID: 7, Action: "search", FS: "node1", Path: engine.Path{"mancala.stratolog"}}, Lines: []parse.Log{ {Msg: "data disk was found in distributionID:0 table version:1, setting inTable=True", - Level: "INFO", - Time: mustParseTime("2017-12-25T16:23:05+02:00"), - FS: "node1", - FileName: "mancala.stratolog", - Line: 2, - Offset: 699, + Level: "INFO", + Time: mustParseTime("2017-12-25T16:23:05+02:00"), + FS: "node1", + FileName: "mancala.stratolog", + Line: 2, + Offset: 699, + ThreadName: "DistributorThread", + LineNo: 162, + PathName: "/usr/share/stratostorage/mancala_management_service.egg/mancala/management/distributor/distributor.py", }, }, }, diff --git a/parse/log.go b/parse/log.go index d3aba85..21df460 100644 --- a/parse/log.go +++ b/parse/log.go @@ -10,13 +10,16 @@ import ( ) type Log struct { - Msg string `json:"msg"` - Level string `json:"level"` - Time *time.Time `json:"time,omitempty"` - FS string `json:"fs"` - FileName string `json:"file_name"` - Line int `json:"line"` - Offset int `json:"offset"` + Msg string `json:"msg"` + Level string `json:"level"` + Time *time.Time `json:"time,omitempty"` + FS string `json:"fs"` + FileName string `json:"file_name"` + Line int `json:"line"` + Offset int `json:"offset"` + ThreadName string `json:"threadName,omitempty"` + PathName string `json:"pathname,omitempty"` + LineNo int `json:"lineno"` } func (l *Log) parseTime(timeFormats []string, timeString string) { diff --git a/parse/parse.go b/parse/parse.go index 1544fa3..f02e686 100644 --- a/parse/parse.go +++ b/parse/parse.go @@ -13,10 +13,13 @@ import ( type Type string const ( - KeyTime = "time" - KeyLevel = "level" - KeyMsg = "msg" - KeyArgs = "args" + KeyTime = "time" + KeyLevel = "level" + KeyMsg = "msg" + KeyArgs = "args" + KeyThreadName = "threadName" + KeyPathName = "pathname" + KeyLineNo = "lineno" ) // noParserAfter determines how many line should be parsed before choosing a no-parser @@ -163,6 +166,29 @@ func (p *parser) parseJson(line []byte) *Log { log.Msg += argsToMessage(j) } + if jsonKey, ok := p.JsonMapping[KeyThreadName]; ok { + if log.ThreadName, ok = j[jsonKey].(string); !ok { + return nil + } + delete(j, jsonKey) + } + + if jsonKey, ok := p.JsonMapping[KeyPathName]; ok { + if log.PathName, ok = j[jsonKey].(string); !ok { + return nil + } + delete(j, jsonKey) + } + + if jsonKey, ok := p.JsonMapping[KeyLineNo]; ok { + var floatLineNo float64 + if floatLineNo, ok = j[jsonKey].(float64); !ok { + return nil + } + log.LineNo = int(floatLineNo) + delete(j, jsonKey) + } + return log } diff --git a/parse/parse_test.go b/parse/parse_test.go index a1a27cc..d8ad198 100644 --- a/parse/parse_test.go +++ b/parse/parse_test.go @@ -18,6 +18,19 @@ func TestParser(t *testing.T) { require.Nil(t, err) parsers, err := New([]Config{ + { + Glob: "*.stratolog", + JsonMapping: map[string]string{ + "msg": "msg", + "level": "levelname", + "time": "created", + "args": "args", + "threadName": "threadName", + "pathname": "pathname", + "lineno": "lineno", + }, + TimeFormats: []string{"unix_float"}, + }, { Glob: "*.jsonlog", JsonMapping: map[string]string{ @@ -51,6 +64,19 @@ func TestParser(t *testing.T) { line string want *Log }{ + { + name: "stratolog/basic", + logName: "file.stratolog", + line: `{"process": 36154, "args": ["val1", 0, true], "module": "distributor", "funcName": "_updateDisksInTableStates", "exc_text": null, "name": "my-name", "thread": 140189066323712, "created": 1514211785.448693, "threadName": "DistributorThread", "filename": "distributor.py", "levelno": 20, "processName": "MainProcess", "pathname": "/var/lib/file.py", "lineno": 162, "msg": "hello %s you got:%s yes? %s, sure", "levelname": "INFO"}`, + want: &Log{ + Msg: `hello val1 you got:0 yes? true, sure`, + Time: &time1, + Level: "INFO", + ThreadName: "DistributorThread", + PathName: "/var/lib/file.py", + LineNo: 162, + }, + }, { name: "jsonlog/list args", logName: "file.jsonlog", From e956fc0dc0180c6c2f6cb4afd50216050d6bd86b Mon Sep 17 00:00:00 2001 From: Eyal Date: Mon, 12 Feb 2018 12:54:18 +0200 Subject: [PATCH 3/5] Makefile: restore race flag for test --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 4c2f083..b00fd22 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ .PHONY: test run-example run-example-dynamic client test: - go test ./... -timeout 30s + go test -race ./... -timeout 30s run-example: go run ./main.go -debug -config ./example/logserver.json From 959685fde350c7dbf044d74644e75e191ebb4dbe Mon Sep 17 00:00:00 2001 From: Eyal Date: Mon, 12 Feb 2018 13:03:17 +0200 Subject: [PATCH 4/5] rename thread name and path name --- client/app/components/file-view/lines-view.js | 8 +- client/app/components/selectors.js | 4 +- main_test.go | 114 +++++++++--------- parse/log.go | 20 +-- parse/parse.go | 8 +- parse/parse_test.go | 26 ++-- 6 files changed, 90 insertions(+), 90 deletions(-) diff --git a/client/app/components/file-view/lines-view.js b/client/app/components/file-view/lines-view.js index 09aa106..3cf39f2 100644 --- a/client/app/components/file-view/lines-view.js +++ b/client/app/components/file-view/lines-view.js @@ -100,7 +100,7 @@ class LinesView extends Component { if (showThreadName) { columns.unshift({ width: 100, - name: 'threadName', + name: 'thread', }) } if (showTimestamp) { @@ -199,9 +199,9 @@ class LinesView extends Component { {line.get('level')} : null break } - case 'threadName': { - content = line.get('threadName') ? - {line.get('threadName')} : null + case 'thread': { + content = line.get('thread') ? + {line.get('thread')} : null break } case 'timestamp': { diff --git a/client/app/components/selectors.js b/client/app/components/selectors.js index 463498b..caa35bb 100644 --- a/client/app/components/selectors.js +++ b/client/app/components/selectors.js @@ -54,8 +54,8 @@ export const contentSelector = createSelector( appStateSelector, levelsSelector, (app = Map(), levels = Set()) => app.get('content', List()).filter(line => !line.get('level') || levels.includes(line.get('level', '').toLowerCase())).map(line => { - if (line.get('pathname')) { - return line.set('msg', `${line.get('msg')} (${line.get('pathname')}:${line.get('lineno')})`) + if (line.get('path')) { + return line.set('msg', `${line.get('msg')} (${line.get('path')}:${line.get('lineno')})`) } return line }) diff --git a/main_test.go b/main_test.go index 2ca27a6..8841893 100644 --- a/main_test.go +++ b/main_test.go @@ -55,40 +55,40 @@ func TestHandler(t *testing.T) { Meta: engine.Meta{ID: 1, Action: "get-content", FS: "node1", Path: engine.Path{"mancala.stratolog"}}, Lines: []parse.Log{ { - Msg: "data disk was found in distributionID:0 table version:1, setting inTable=True", - Level: "INFO", - Time: mustParseTime("2017-12-25T16:23:05+02:00"), - FS: "node1", - FileName: "mancala.stratolog", - Line: 1, - Offset: 0, - ThreadName: "DistributorThread", - LineNo: 162, - PathName: "/usr/share/stratostorage/mancala_management_service.egg/mancala/management/distributor/distributor.py", + Msg: "data disk was found in distributionID:0 table version:1, setting inTable=True", + Level: "INFO", + Time: mustParseTime("2017-12-25T16:23:05+02:00"), + FS: "node1", + FileName: "mancala.stratolog", + Line: 1, + Offset: 0, + Thread: "DistributorThread", + LineNo: 162, + Path: "/usr/share/stratostorage/mancala_management_service.egg/mancala/management/distributor/distributor.py", }, { - Msg: "data disk was found in distributionID:0 table version:1, setting inTable=True", - Level: "INFO", - Time: mustParseTime("2017-12-25T16:23:05+02:00"), - FS: "node1", - FileName: "mancala.stratolog", - Line: 2, - Offset: 699, - ThreadName: "DistributorThread", - LineNo: 162, - PathName: "/usr/share/stratostorage/mancala_management_service.egg/mancala/management/distributor/distributor.py", + Msg: "data disk was found in distributionID:0 table version:1, setting inTable=True", + Level: "INFO", + Time: mustParseTime("2017-12-25T16:23:05+02:00"), + FS: "node1", + FileName: "mancala.stratolog", + Line: 2, + Offset: 699, + Thread: "DistributorThread", + LineNo: 162, + Path: "/usr/share/stratostorage/mancala_management_service.egg/mancala/management/distributor/distributor.py", }, { - Msg: "data disk was found in distributionID:0 table version:1, setting inTable=True", - Level: "INFO", - Time: mustParseTime("2017-12-25T16:23:05+02:00"), - FS: "node1", - FileName: "mancala.stratolog", - Line: 3, - Offset: 1398, - ThreadName: "DistributorThread", - LineNo: 162, - PathName: "/usr/share/stratostorage/mancala_management_service.egg/mancala/management/distributor/distributor.py", + Msg: "data disk was found in distributionID:0 table version:1, setting inTable=True", + Level: "INFO", + Time: mustParseTime("2017-12-25T16:23:05+02:00"), + FS: "node1", + FileName: "mancala.stratolog", + Line: 3, + Offset: 1398, + Thread: "DistributorThread", + LineNo: 162, + Path: "/usr/share/stratostorage/mancala_management_service.egg/mancala/management/distributor/distributor.py", }, }, }, @@ -144,15 +144,15 @@ func TestHandler(t *testing.T) { Meta: engine.Meta{ID: 4, Action: "search", FS: "node1", Path: engine.Path{"mancala.stratolog"}}, Lines: []parse.Log{ {Msg: "data disk was found in distributionID:0 table version:1, setting inTable=True", - Level: "INFO", - Time: mustParseTime("2017-12-25T16:23:05+02:00"), - FS: "node1", - FileName: "mancala.stratolog", - Line: 2, - Offset: 699, - ThreadName: "DistributorThread", - LineNo: 162, - PathName: "/usr/share/stratostorage/mancala_management_service.egg/mancala/management/distributor/distributor.py", + Level: "INFO", + Time: mustParseTime("2017-12-25T16:23:05+02:00"), + FS: "node1", + FileName: "mancala.stratolog", + Line: 2, + Offset: 699, + Thread: "DistributorThread", + LineNo: 162, + Path: "/usr/share/stratostorage/mancala_management_service.egg/mancala/management/distributor/distributor.py", }, }, }, @@ -192,15 +192,15 @@ func TestHandler(t *testing.T) { Meta: engine.Meta{ID: 6, Action: "search", FS: "node1", Path: engine.Path{"mancala.stratolog"}}, Lines: []parse.Log{ {Msg: "data disk was found in distributionID:0 table version:1, setting inTable=True", - Level: "INFO", - Time: mustParseTime("2017-12-25T16:23:05+02:00"), - FS: "node1", - FileName: "mancala.stratolog", - Line: 2, - Offset: 699, - ThreadName: "DistributorThread", - LineNo: 162, - PathName: "/usr/share/stratostorage/mancala_management_service.egg/mancala/management/distributor/distributor.py", + Level: "INFO", + Time: mustParseTime("2017-12-25T16:23:05+02:00"), + FS: "node1", + FileName: "mancala.stratolog", + Line: 2, + Offset: 699, + Thread: "DistributorThread", + LineNo: 162, + Path: "/usr/share/stratostorage/mancala_management_service.egg/mancala/management/distributor/distributor.py", }, }, }, @@ -218,15 +218,15 @@ func TestHandler(t *testing.T) { Meta: engine.Meta{ID: 7, Action: "search", FS: "node1", Path: engine.Path{"mancala.stratolog"}}, Lines: []parse.Log{ {Msg: "data disk was found in distributionID:0 table version:1, setting inTable=True", - Level: "INFO", - Time: mustParseTime("2017-12-25T16:23:05+02:00"), - FS: "node1", - FileName: "mancala.stratolog", - Line: 2, - Offset: 699, - ThreadName: "DistributorThread", - LineNo: 162, - PathName: "/usr/share/stratostorage/mancala_management_service.egg/mancala/management/distributor/distributor.py", + Level: "INFO", + Time: mustParseTime("2017-12-25T16:23:05+02:00"), + FS: "node1", + FileName: "mancala.stratolog", + Line: 2, + Offset: 699, + Thread: "DistributorThread", + LineNo: 162, + Path: "/usr/share/stratostorage/mancala_management_service.egg/mancala/management/distributor/distributor.py", }, }, }, diff --git a/parse/log.go b/parse/log.go index 21df460..3ef2539 100644 --- a/parse/log.go +++ b/parse/log.go @@ -10,16 +10,16 @@ import ( ) type Log struct { - Msg string `json:"msg"` - Level string `json:"level"` - Time *time.Time `json:"time,omitempty"` - FS string `json:"fs"` - FileName string `json:"file_name"` - Line int `json:"line"` - Offset int `json:"offset"` - ThreadName string `json:"threadName,omitempty"` - PathName string `json:"pathname,omitempty"` - LineNo int `json:"lineno"` + Msg string `json:"msg"` + Level string `json:"level"` + Time *time.Time `json:"time,omitempty"` + FS string `json:"fs"` + FileName string `json:"file_name"` + Line int `json:"line"` + Offset int `json:"offset"` + Thread string `json:"thread,omitempty"` + Path string `json:"path,omitempty"` + LineNo int `json:"lineno"` } func (l *Log) parseTime(timeFormats []string, timeString string) { diff --git a/parse/parse.go b/parse/parse.go index f02e686..be0bf09 100644 --- a/parse/parse.go +++ b/parse/parse.go @@ -17,8 +17,8 @@ const ( KeyLevel = "level" KeyMsg = "msg" KeyArgs = "args" - KeyThreadName = "threadName" - KeyPathName = "pathname" + KeyThreadName = "thread" + KeyPathName = "path" KeyLineNo = "lineno" ) @@ -167,14 +167,14 @@ func (p *parser) parseJson(line []byte) *Log { } if jsonKey, ok := p.JsonMapping[KeyThreadName]; ok { - if log.ThreadName, ok = j[jsonKey].(string); !ok { + if log.Thread, ok = j[jsonKey].(string); !ok { return nil } delete(j, jsonKey) } if jsonKey, ok := p.JsonMapping[KeyPathName]; ok { - if log.PathName, ok = j[jsonKey].(string); !ok { + if log.Path, ok = j[jsonKey].(string); !ok { return nil } delete(j, jsonKey) diff --git a/parse/parse_test.go b/parse/parse_test.go index d8ad198..5706e69 100644 --- a/parse/parse_test.go +++ b/parse/parse_test.go @@ -21,13 +21,13 @@ func TestParser(t *testing.T) { { Glob: "*.stratolog", JsonMapping: map[string]string{ - "msg": "msg", - "level": "levelname", - "time": "created", - "args": "args", - "threadName": "threadName", - "pathname": "pathname", - "lineno": "lineno", + "msg": "msg", + "level": "levelname", + "time": "created", + "args": "args", + "thread": "threadName", + "path": "pathname", + "lineno": "lineno", }, TimeFormats: []string{"unix_float"}, }, @@ -69,12 +69,12 @@ func TestParser(t *testing.T) { logName: "file.stratolog", line: `{"process": 36154, "args": ["val1", 0, true], "module": "distributor", "funcName": "_updateDisksInTableStates", "exc_text": null, "name": "my-name", "thread": 140189066323712, "created": 1514211785.448693, "threadName": "DistributorThread", "filename": "distributor.py", "levelno": 20, "processName": "MainProcess", "pathname": "/var/lib/file.py", "lineno": 162, "msg": "hello %s you got:%s yes? %s, sure", "levelname": "INFO"}`, want: &Log{ - Msg: `hello val1 you got:0 yes? true, sure`, - Time: &time1, - Level: "INFO", - ThreadName: "DistributorThread", - PathName: "/var/lib/file.py", - LineNo: 162, + Msg: `hello val1 you got:0 yes? true, sure`, + Time: &time1, + Level: "INFO", + Thread: "DistributorThread", + Path: "/var/lib/file.py", + LineNo: 162, }, }, { From 24b44daa6539b71e113cda7c930f4407c0a379ef Mon Sep 17 00:00:00 2001 From: Eyal Date: Mon, 12 Feb 2018 14:59:18 +0200 Subject: [PATCH 5/5] fix example logserver.json --- example/logserver.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/example/logserver.json b/example/logserver.json index ff8fe3d..b0c6201 100644 --- a/example/logserver.json +++ b/example/logserver.json @@ -32,9 +32,9 @@ "level": "levelname", "time": "created", "args": "args", - "threadName": "threadName", - "pathname": "pathname", - "lineno": "lineno" + "thread": "threadName", + "path": "pathname", + "lineno": "lineno" }, "time_formats": [ "unix_float"