summaryrefslogtreecommitdiffstats
path: root/logging
diff options
context:
space:
mode:
authorSean E. Russell <ser@ser1.net>2020-06-07 16:40:03 -0500
committerSean E. Russell <ser@ser1.net>2020-06-07 16:56:19 -0500
commitb20f47738953c9f2a1c3e483976104bc3cbfcbba (patch)
tree192ea9d205d8e3c041c8b31d865e8364cb0a4b6f /logging
parentb13fd2833c081d6d187b80d7d43f358e9e7d2009 (diff)
linting & documentationv4.0.0
Updated versioning and dates for release.
Diffstat (limited to 'logging')
-rw-r--r--logging/logging.go4
-rw-r--r--logging/logging_test.go15
2 files changed, 11 insertions, 8 deletions
diff --git a/logging/logging.go b/logging/logging.go
index 7bc1f9e..5195b82 100644
--- a/logging/logging.go
+++ b/logging/logging.go
@@ -15,6 +15,10 @@ const (
LOGFILE = "errors.log"
)
+// New creates a new logger in the default cache directory; the returned
+// WriteCloser should be closed when the program exits. If an error is
+// encountered during file creation, a nil WriteCloser and appropriate
+// error are returned.
func New(c gotop.Config) (io.WriteCloser, error) {
// create the log directory
cache := c.ConfigDir.QueryCacheFolder()
diff --git a/logging/logging_test.go b/logging/logging_test.go
index 1ea7484..902028a 100644
--- a/logging/logging_test.go
+++ b/logging/logging_test.go
@@ -2,22 +2,21 @@ package logging
import (
"io/ioutil"
- //"log"
"os"
- "path/filepath"
"testing"
+ "github.com/shibukawa/configdir"
"github.com/stretchr/testify/assert"
- "github.com/xxxserxxx/gotop/v4"
+ gotop "github.com/xxxserxxx/gotop/v4"
)
func TestLogging(t *testing.T) {
- tdn := "testdir"
- path, err := filepath.Abs(tdn)
+ c := gotop.NewConfig()
+ c.ConfigDir = configdir.New("", "gotoptest")
+ c.MaxLogSize = 300
+ path := c.ConfigDir.QueryCacheFolder().Path
+ var err error
defer os.RemoveAll(path)
- c := gotop.Config{
- MaxLogSize: 300,
- }
wc, err := New(c)
assert.NoError(t, err)
if err != nil {