Skip to content
This repository has been archived by the owner on Nov 21, 2024. It is now read-only.

Commit

Permalink
datarithms2 -> datarithms, logging2 -> logging
Browse files Browse the repository at this point in the history
  • Loading branch information
Alextopher committed Jan 19, 2024
1 parent 23a5c49 commit f475640
Show file tree
Hide file tree
Showing 16 changed files with 108 additions and 108 deletions.
22 changes: 11 additions & 11 deletions aggregator/aggregator_nginx.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
"strings"
"time"

"github.com/COSI-Lab/Mirror/logging2"
"github.com/COSI-Lab/Mirror/logging"
"github.com/COSI-Lab/geoip"
"github.com/IncSW/geoip2"
influxdb2 "github.com/influxdata/influxdb-client-go/v2"
Expand Down Expand Up @@ -95,7 +95,7 @@ func (aggregator *NGINXProjectAggregator) Init(reader api.QueryAPI) (lastUpdated

for result.Next() {
if result.Err() != nil {
logging2.Warn("QueryProjectStatistics Flux Query Error", result.Err())
logging.Warn("QueryProjectStatistics Flux Query Error", result.Err())
continue
}

Expand All @@ -105,7 +105,7 @@ func (aggregator *NGINXProjectAggregator) Init(reader api.QueryAPI) (lastUpdated
// Get the Project short name
Project, ok := dp.ValueByKey("Project").(string)
if !ok {
logging2.Warn("Error getting Project short name")
logging.Warn("Error getting Project short name")
fmt.Printf("%T %v\n", Project, Project)
continue
}
Expand All @@ -117,7 +117,7 @@ func (aggregator *NGINXProjectAggregator) Init(reader api.QueryAPI) (lastUpdated

field, ok := dp.ValueByKey("_field").(string)
if !ok {
logging2.Warn("Error getting field")
logging.Warn("Error getting field")
fmt.Printf("%T %v\n", field, field)
continue
}
Expand All @@ -126,23 +126,23 @@ func (aggregator *NGINXProjectAggregator) Init(reader api.QueryAPI) (lastUpdated
case "bytes_sent":
sent, ok := dp.ValueByKey("_value").(int64)
if !ok {
logging2.Warn("Error getting bytes sent")
logging.Warn("Error getting bytes sent")
fmt.Printf("%T %v\n", dp.ValueByKey("_value"), dp.ValueByKey("_value"))
continue
}
stats[Project].BytesSent = sent
case "bytes_recv":
received, ok := dp.ValueByKey("_value").(int64)
if !ok {
logging2.Warn("Error getting bytes recv")
logging.Warn("Error getting bytes recv")
fmt.Printf("%T %v\n", dp.ValueByKey("_value"), dp.ValueByKey("_value"))
continue
}
stats[Project].BytesRecv = received
case "requests":
requests, ok := dp.ValueByKey("_value").(int64)
if !ok {
logging2.Warn("Error getting requests")
logging.Warn("Error getting requests")
fmt.Printf("%T %v\n", dp.ValueByKey("_value"), dp.ValueByKey("_value"))
continue
}
Expand Down Expand Up @@ -230,7 +230,7 @@ func TailNGINXLogFile(logFile string, lastUpdated time.Time, channels []chan<- N

f, err := os.Open(logFile)
if err != nil {
logging2.Error(err)
logging.Error(err)
return
}

Expand All @@ -244,7 +244,7 @@ func TailNGINXLogFile(logFile string, lastUpdated time.Time, channels []chan<- N
}
offset += int64(len(s.Text()) + 1)
}
logging2.Info("Found nginx log offset in", time.Since(start))
logging.Info("Found nginx log offset in", time.Since(start))

// Tail the log file `tail -F` starting at the offset
seek := tail.SeekInfo{
Expand All @@ -253,11 +253,11 @@ func TailNGINXLogFile(logFile string, lastUpdated time.Time, channels []chan<- N
}
tail, err := tail.TailFile(logFile, tail.Config{Follow: true, ReOpen: true, MustExist: true, Location: &seek})
if err != nil {
logging2.Error("Failed to start tailing `nginx.log`:", err)
logging.Error("Failed to start tailing `nginx.log`:", err)
return
}

logging2.Success("Tailing nginx log file")
logging.Success("Tailing nginx log file")

// Parse each line as we receive it
for line := range tail.Lines {
Expand Down
20 changes: 10 additions & 10 deletions aggregator/aggregator_rsyncd.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"strings"
"time"

"github.com/COSI-Lab/Mirror/logging2"
"github.com/COSI-Lab/Mirror/logging"
influxdb2 "github.com/influxdata/influxdb-client-go/v2"
"github.com/influxdata/influxdb-client-go/v2/api"
"github.com/nxadm/tail"
Expand Down Expand Up @@ -64,7 +64,7 @@ func (a *RSYNCDAggregator) Init(reader api.QueryAPI) (lastUpdated time.Time, err
// Get the field
field, ok := dp.ValueByKey("_field").(string)
if !ok {
logging2.Warn("Error getting field")
logging.Warn("Error getting field")
fmt.Printf("%T %v\n", field, field)
continue
}
Expand All @@ -74,30 +74,30 @@ func (a *RSYNCDAggregator) Init(reader api.QueryAPI) (lastUpdated time.Time, err
case "bytes_sent":
sent, ok := dp.ValueByKey("_value").(int64)
if !ok {
logging2.Warn("Error getting bytes sent")
logging.Warn("Error getting bytes sent")
fmt.Printf("%T %v\n", dp.ValueByKey("_value"), dp.ValueByKey("_value"))
continue
}
a.stat.BytesSent = sent
case "bytes_recv":
received, ok := dp.ValueByKey("_value").(int64)
if !ok {
logging2.Warn("Error getting bytes recv")
logging.Warn("Error getting bytes recv")
fmt.Printf("%T %v\n", dp.ValueByKey("_value"), dp.ValueByKey("_value"))
continue
}
a.stat.BytesRecv = received
case "requests":
requests, ok := dp.ValueByKey("_value").(int64)
if !ok {
logging2.Warn("Error getting requests")
logging.Warn("Error getting requests")
fmt.Printf("%T %v\n", dp.ValueByKey("_value"), dp.ValueByKey("_value"))
continue
}
a.stat.Requests = requests
}
} else {
logging2.Warn("Error querying influxdb for rsyncd stat", result.Err())
logging.Warn("Error querying influxdb for rsyncd stat", result.Err())
}
}

Expand Down Expand Up @@ -137,7 +137,7 @@ func TailRSYNCLogFile(logFile string, lastUpdated time.Time, channels []chan<- R

f, err := os.Open(logFile)
if err != nil {
logging2.Error(err)
logging.Error(err)
return
}

Expand All @@ -151,7 +151,7 @@ func TailRSYNCLogFile(logFile string, lastUpdated time.Time, channels []chan<- R
}
offset += int64(len(s.Text()) + 1)
}
logging2.Info("Found rsyncd log offset in", time.Since(start))
logging.Info("Found rsyncd log offset in", time.Since(start))

// Tail the log file `tail -F` starting at the offset
seek := tail.SeekInfo{
Expand All @@ -160,11 +160,11 @@ func TailRSYNCLogFile(logFile string, lastUpdated time.Time, channels []chan<- R
}
tail, err := tail.TailFile(logFile, tail.Config{Follow: true, ReOpen: true, MustExist: true, Location: &seek})
if err != nil {
logging2.Error("Failed to start tailing `rsyncd.log`:", err)
logging.Error("Failed to start tailing `rsyncd.log`:", err)
return
}

logging2.Success("Tailing rsyncd log file")
logging.Success("Tailing rsyncd log file")

// Parse each line as we receive it
for line := range tail.Lines {
Expand Down
8 changes: 4 additions & 4 deletions aggregators.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (

"github.com/COSI-Lab/Mirror/aggregator"
"github.com/COSI-Lab/Mirror/config"
"github.com/COSI-Lab/Mirror/logging2"
"github.com/COSI-Lab/Mirror/logging"
"github.com/influxdata/influxdb-client-go/v2/api"
)

Expand All @@ -23,14 +23,14 @@ func StartNGINXAggregator(reader api.QueryAPI, writer api.WriteAPI, config *conf
for _, subnetString := range subnetStrings {
_, subnet, err := net.ParseCIDR(subnetString)
if err != nil {
logging2.Warnf("Failed to parse subnet %q for %q", subnetString, name)
logging.Warnf("Failed to parse subnet %q for %q", subnetString, name)
continue
}
subnets = append(subnets, subnet)
}

if len(subnets) == 0 {
logging2.Warn("No valid subnets for", name)
logging.Warn("No valid subnets for", name)
continue
}

Expand All @@ -43,7 +43,7 @@ func StartNGINXAggregator(reader api.QueryAPI, writer api.WriteAPI, config *conf
return false
})

logging2.Infof("Added subnet aggregator for %q", name)
logging.Infof("Added subnet aggregator for %q", name)
}

nginxMetrics := make(chan aggregator.NGINXLogEntry)
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package datarithms2
package datarithms

import (
"fmt"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package datarithms2_test
package datarithms_test

import (
"testing"

"github.com/COSI-Lab/Mirror/datarithms2"
"github.com/COSI-Lab/Mirror/datarithms"
)

func TestQueue(t *testing.T) {
// Create a new queue
q := datarithms2.NewCircularQueue[int](5)
q := datarithms.NewCircularQueue[int](5)

if q.Capacity() != 5 {
t.Error("Capacity is not 5")
Expand Down
21 changes: 21 additions & 0 deletions logging/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# logging

This module provides thread-safe logging.

![Screenshot](screenshot.png)

## Usage

```go
package main

import (
"github.com/COSI-Lab/Mirror/logging"
)

func main() {
logging.Info("Hello, world!")
logging.Warn("Warning world didn't say hello back!")
logging.Error("Error world is broken!")
}
```
2 changes: 1 addition & 1 deletion logging2/logging.go → logging/logging.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package logging2
package logging

import (
"fmt"
Expand Down
File renamed without changes
21 changes: 0 additions & 21 deletions logging2/README.md

This file was deleted.

Loading

0 comments on commit f475640

Please sign in to comment.