Skip to content

Commit

Permalink
0.0.3 release fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
hypersleep committed Jul 22, 2016
1 parent f09da04 commit bd8c3b5
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 53 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## 0.0.3 (unreleased)
## 0.0.3

- command and args should set as torch args #14
- add ability to filter output log by service name #16
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ Torch can use two types of formating: `regexp` and `json`

It writes additional fields `bytes`, `ip`, `icmp_seq`, `ttl` and `time` to elasticsearch.

JSON formating trying to unmarshal log line as JSON object:
2.`json` formating trying to unmarshal log line as JSON object:

```
{
Expand Down
63 changes: 12 additions & 51 deletions format.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import(
"regexp"
"errors"
"strings"
"encoding/json"
)

Expand All @@ -15,7 +16,7 @@ type(

Parser interface {
setup(options string) error
load(line []byte)
load(logLine []byte)
parse() error
clear()
addField(name string, value interface{})
Expand Down Expand Up @@ -61,21 +62,6 @@ func (regexpLine *RegexpLine) setup(options string) error {
return nil
}

func (nullLine *NullLine) load(line []byte) {
nullLine.line = line
nullLine.message["Message"] = string(line)
}

func (jsonLine *JsonLine) load(line []byte) {
jsonLine.line = line
jsonLine.message["Message"] = string(line)
}

func (regexpLine *RegexpLine) load(line []byte) {
regexpLine.line = line
regexpLine.message["Message"] = string(line)
}

func (nullLine *NullLine) parse() error {
return nil
}
Expand All @@ -90,7 +76,6 @@ func (jsonLine *JsonLine) parse() error {

func (regexpLine *RegexpLine) parse() error {
result := regexpLine.regexp.FindAllStringSubmatch(string(regexpLine.line), -1)

if len(result) > 0 {
cuttedResult := result[0]
names := regexpLine.regexp.SubexpNames()
Expand All @@ -100,48 +85,24 @@ func (regexpLine *RegexpLine) parse() error {
} else {
errors.New("Failed to parse line using regexp: " + string(regexpLine.line))
}

return nil
}

func (nullLine *NullLine) clear() {
for key, _ := range nullLine.message {
nullLine.message[key] = nil
}
}

func (jsonLine *JsonLine) clear() {
for key, _ := range jsonLine.message {
jsonLine.message[key] = nil
}
func (line *Line) load(logLine []byte) {
line.line = logLine
line.message["Message"] = strings.TrimSpace(string(logLine))
}

func (regexpLine *RegexpLine) clear() {
for key, _ := range regexpLine.message {
regexpLine.message[key] = nil
func (line *Line) clear() {
for key, _ := range line.message {
line.message[key] = nil
}
}

func (nullLine *NullLine) addField(name string, value interface{}) {
nullLine.message[name] = value
}

func (jsonLine *JsonLine) addField(name string, value interface{}) {
jsonLine.message[name] = value
}

func (regexpLine *RegexpLine) addField(name string, value interface{}) {
regexpLine.message[name] = value
}

func (nullLine *NullLine) getMessage() map[string]interface{} {
return nullLine.message
}

func (jsonLine *JsonLine) getMessage() map[string]interface{} {
return jsonLine.message
func (line *Line) addField(name string, value interface{}) {
line.message[name] = value
}

func (regexpLine *RegexpLine) getMessage() map[string]interface{} {
return regexpLine.message
func (line *Line) getMessage() map[string]interface{} {
return line.message
}

0 comments on commit bd8c3b5

Please sign in to comment.