Compare commits

...

6 Commits

Author SHA1 Message Date
027d0173bc logging: finish multi implementation 2020-11-11 21:15:02 -08:00
6f19b69bbd logging: add CREATE flag to file-based loggers. 2020-11-11 10:06:13 -08:00
7e118bfdb0 logging: add Multi 2020-11-11 09:52:07 -08:00
Kyle Isom
e0868841bf Merge pull request #7 from santosh653/master 2020-11-04 07:24:04 -08:00
santosh653
c558405d11 Update .travis.yml
Excluding go version 1.9 as only go version1.13 onwards are supported.
2020-11-04 05:22:10 -05:00
santosh653
a1eb035af7 Update .travis.yml
Adding Power support
2020-10-20 04:56:21 -04:00
5 changed files with 110 additions and 335 deletions

View File

@@ -1,8 +1,17 @@
arch:
- amd64
- ppc64le
sudo: false
language: go
go:
- tip
- 1.9
jobs:
exclude:
- go: 1.9
arch: amd64
- go: 1.9
arch: ppc64le
script:
- go get golang.org/x/lint/golint
- go get golang.org/x/tools/cmd/cover

View File

@@ -1,333 +0,0 @@
{
"summary": {
"title": "goutils threat model",
"owner": "K",
"description": "HTF COMPUTER DO WHAT COMPUTER DO"
},
"detail": {
"contributors": [],
"diagrams": [
{
"title": "COMPUTRONICS",
"thumbnail": "./public/content/images/thumbnail.jpg",
"id": 0,
"diagramJson": {
"cells": [
{
"type": "tm.Process",
"size": {
"width": 100,
"height": 100
},
"position": {
"x": 235,
"y": 346
},
"angle": 0,
"id": "44f457bb-4c3c-45a4-8c49-1556afb6fe2a",
"z": 1,
"hasOpenThreats": false,
"attrs": {
".element-shape": {
"class": "element-shape hasNoOpenThreats isInScope"
},
"text": {
"text": "DOING THE\nTHING"
},
".element-text": {
"class": "element-text hasNoOpenThreats isInScope"
}
}
},
{
"type": "tm.Actor",
"size": {
"width": 160,
"height": 80
},
"position": {
"x": 239,
"y": 31
},
"angle": 0,
"id": "f5cdeb80-8c89-4af1-8a5d-c23e9dda81dd",
"z": 2,
"hasOpenThreats": true,
"threats": [
{
"status": "Open",
"severity": "Medium",
"title": "Creepering",
"type": "Denial of service",
"description": "Creeping and what not.",
"mitigation": "Banishment."
}
],
"attrs": {
".element-shape": {
"class": "element-shape hasOpenThreats isInScope"
},
"text": {
"text": "the darkness"
},
".element-text": {
"class": "element-text hasOpenThreats isInScope"
}
}
},
{
"type": "tm.Store",
"size": {
"width": 160,
"height": 80
},
"position": {
"x": 413,
"y": 368
},
"angle": 0,
"id": "0132401e-9bca-497d-8a04-7bfa64f9b548",
"z": 3,
"hasOpenThreats": false,
"attrs": {
".element-shape": {
"class": "element-shape hasNoOpenThreats isInScope"
},
"text": {
"text": "crown jewels"
},
".element-text": {
"class": "element-text hasNoOpenThreats isInScope"
}
}
},
{
"type": "tm.Actor",
"size": {
"width": 160,
"height": 80
},
"position": {
"x": 384,
"y": 473
},
"angle": 0,
"id": "b2988659-754c-452d-9ef5-a2c766792a52",
"z": 4,
"hasOpenThreats": false,
"attrs": {
".element-shape": {
"class": "element-shape hasNoOpenThreats isInScope"
},
"text": {
"text": "civilians"
},
".element-text": {
"class": "element-text hasNoOpenThreats isInScope"
}
}
},
{
"type": "tm.Actor",
"size": {
"width": 160,
"height": 80
},
"position": {
"x": 390,
"y": 251
},
"angle": 0,
"id": "45ed7d67-2d9f-4a7b-a5d2-a222beb1ba02",
"z": 5,
"hasOpenThreats": false,
"attrs": {
".element-shape": {
"class": "element-shape hasNoOpenThreats isInScope"
},
"text": {
"text": "captain america"
},
".element-text": {
"class": "element-text hasNoOpenThreats isInScope"
}
}
},
{
"type": "tm.Boundary",
"smooth": true,
"source": {
"x": 70,
"y": 212
},
"target": {
"x": 773,
"y": 181
},
"vertices": [],
"id": "675f56fc-ec5a-48f1-83d8-e65bafee112c",
"z": 6,
"attrs": {}
},
{
"type": "tm.Flow",
"smooth": true,
"source": {
"id": "b2988659-754c-452d-9ef5-a2c766792a52"
},
"target": {
"id": "44f457bb-4c3c-45a4-8c49-1556afb6fe2a"
},
"vertices": [
{
"x": 389,
"y": 462
},
{
"x": 375,
"y": 459
},
{
"x": 359,
"y": 441
}
],
"id": "a841a516-7f81-41c5-a5d4-832655f5e219",
"labels": [
{
"position": 0.5,
"attrs": {
"text": {
"text": "request",
"font-weight": "400",
"font-size": "small"
}
}
}
],
"z": 7,
"hasOpenThreats": false,
"isPublicNetwork": true,
"isEncrypted": true,
"attrs": {
".marker-target": {
"class": "marker-target hasNoOpenThreats isInScope"
},
".connection": {
"class": "connection hasNoOpenThreats isInScope"
}
}
},
{
"type": "tm.Flow",
"smooth": true,
"source": {
"id": "44f457bb-4c3c-45a4-8c49-1556afb6fe2a"
},
"target": {
"id": "0132401e-9bca-497d-8a04-7bfa64f9b548"
},
"vertices": [],
"id": "f4181dae-fcad-44c7-ad98-19b5bb1b9c84",
"labels": [
{
"position": 0.5,
"attrs": {
"text": {
"text": "cogitate",
"font-weight": "400",
"font-size": "small"
}
}
}
],
"z": 8,
"hasOpenThreats": false,
"attrs": {
".marker-target": {
"class": "marker-target hasNoOpenThreats isInScope"
},
".connection": {
"class": "connection hasNoOpenThreats isInScope"
}
}
},
{
"type": "tm.Flow",
"smooth": true,
"source": {
"id": "45ed7d67-2d9f-4a7b-a5d2-a222beb1ba02"
},
"target": {
"id": "0132401e-9bca-497d-8a04-7bfa64f9b548"
},
"vertices": [],
"id": "01353067-ce16-4a19-abb7-ce47edc7e309",
"labels": [
{
"position": 0.5,
"attrs": {
"text": {
"text": "adjudicate",
"font-weight": "400",
"font-size": "small"
}
}
}
],
"z": 9,
"hasOpenThreats": false,
"attrs": {
".marker-target": {
"class": "marker-target hasNoOpenThreats isInScope"
},
".connection": {
"class": "connection hasNoOpenThreats isInScope"
}
}
},
{
"type": "tm.Flow",
"smooth": true,
"source": {
"id": "45ed7d67-2d9f-4a7b-a5d2-a222beb1ba02"
},
"target": {
"id": "44f457bb-4c3c-45a4-8c49-1556afb6fe2a"
},
"vertices": [],
"id": "5298f767-1675-4ba3-b450-e2a5aad62452",
"labels": [
{
"position": 0.5,
"attrs": {
"text": {
"text": "assimilate",
"font-weight": "400",
"font-size": "small"
}
}
}
],
"z": 10,
"hasOpenThreats": false,
"attrs": {
".marker-target": {
"class": "marker-target hasNoOpenThreats isInScope"
},
".connection": {
"class": "connection hasNoOpenThreats isInScope"
}
}
}
]
},
"size": {
"height": 590,
"width": 948.910888671875
}
}
],
"reviewer": "K"
}
}

View File

@@ -59,7 +59,7 @@ func NewSplitFile(outpath, errpath string, overwrite bool) (*File, error) {
if overwrite {
fl.fo, err = os.Create(outpath)
} else {
fl.fo, err = os.OpenFile(outpath, os.O_WRONLY|os.O_APPEND, 0644)
fl.fo, err = os.OpenFile(outpath, os.O_WRONLY|os.O_APPEND|os.O_CREATE, 0644)
}
if err != nil {
@@ -69,7 +69,7 @@ func NewSplitFile(outpath, errpath string, overwrite bool) (*File, error) {
if overwrite {
fl.fe, err = os.Create(errpath)
} else {
fl.fe, err = os.OpenFile(errpath, os.O_WRONLY|os.O_APPEND, 0644)
fl.fe, err = os.OpenFile(errpath, os.O_WRONLY|os.O_APPEND|os.O_CREATE, 0644)
}
if err != nil {

View File

@@ -277,3 +277,93 @@ func (lw *LogWriter) SetLevel(l Level) {
// Close is a no-op that satisfies the Logger interface.
func (lw *LogWriter) Close() error { return nil }
// Multi allows combining of loggers.
type Multi struct {
loggers []Logger
}
func NewMulti(loggers ...Logger) *Multi {
return &Multi{loggers: loggers}
}
func (m *Multi) SetLevel(level Level) {
for _, l := range m.loggers {
l.SetLevel(level)
}
}
func (m *Multi) Good() bool {
good := true
for _, l := range m.loggers {
good = good && l.Good()
}
return good
}
func (m *Multi) Status() error {
for _, l := range m.loggers {
if err := l.Status(); err != nil {
return err
}
}
return nil
}
func (m *Multi) Close() error {
for _, l := range m.loggers {
l.Close()
}
return nil
}
func (m *Multi) Debug(actor, event string, attrs map[string]string) {
for _, l := range m.loggers {
l.Debug(actor, event, attrs)
}
}
func (m *Multi) Info(actor, event string, attrs map[string]string) {
for _, l := range m.loggers {
l.Info(actor, event, attrs)
}
}
func (m *Multi) Warn(actor, event string, attrs map[string]string) {
for _, l := range m.loggers {
l.Warn(actor, event, attrs)
}
}
func (m *Multi) Error(actor, event string, attrs map[string]string) {
for _, l := range m.loggers {
l.Error(actor, event, attrs)
}
}
func (m *Multi) Critical(actor, event string, attrs map[string]string) {
for _, l := range m.loggers {
l.Critical(actor, event, attrs)
}
}
func (m *Multi) Fatal(actor, event string, attrs map[string]string) {
for _, l := range m.loggers {
l.Fatal(actor, event, attrs)
}
}
func (m *Multi) FatalCode(exitcode int, actor, event string, attrs map[string]string) {
for _, l := range m.loggers {
l.FatalCode(exitcode, actor, event, attrs)
}
}
func (m *Multi) FatalNoDie(actor, event string, attrs map[string]string) {
for _, l := range m.loggers {
l.FatalNoDie(actor, event, attrs)
}
}

View File

@@ -53,3 +53,12 @@ func TestDestroyLogFiles(t *testing.T) {
os.Remove("fw2.log")
os.Remove("fw2.err")
}
func TestMulti(t *testing.T) {
c1 := NewConsole()
c2 := NewConsole()
m := NewMulti(c1, c2)
if !m.Good() {
t.Fatal("failed to set up multi logger")
}
}