6 Commits

30 changed files with 101 additions and 58 deletions

1
.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
nmdc-log-service

80
README.md Normal file
View File

@@ -0,0 +1,80 @@
# nmdc-log-service
![](https://img.shields.io/badge/written%20in-golang-blue)
A logging service for NMDC hubs.
It logs public chat messages to a file, categorised by months. Binaries are provided for Windows/Linux amd64/i386.
## Usage
```
$nmdc-log-service -Help
Usage of nmdc-log-service:
-Debug
Print additional information on stdout
-Dir string
Output directory (default ".")
-LogConnectionState
Include connection state changes in log (default true)
-Nick string
Nick (default "nmdc-log-service")
-PMResponse string
Message to respond with on PM (default "This is an automated service. For enquiries, please contact an administrator.")
-Password string
Registered nick password
-Server string
Addresses to connect to (comma-separated)
-VerifyTLS
Verify TLS certificates (default true)
```
## Changelog
master
- Convert to Go Modules, upgrade `libnmdc` to `v0.18.0`
2016-04-16 1.0.4
- Enhancement: Upgrade `libnmdc` from `r5` to `r6`
- Include a sample systemd unit script in source archive
- Fix an issue showing zero connected hubs in user tag
- Fix a cosmetic issue with logging repeated identical connection failure messages
- [⬇️ nmdc-log-service-1.0.4-win64.7z](dist-archive/nmdc-log-service-1.0.4-win64.7z) *(873.36 KiB)*
- [⬇️ nmdc-log-service-1.0.4-win32.7z](dist-archive/nmdc-log-service-1.0.4-win32.7z) *(804.14 KiB)*
- [⬇️ nmdc-log-service-1.0.4-src.7z](dist-archive/nmdc-log-service-1.0.4-src.7z) *(2.05 KiB)*
- [⬇️ nmdc-log-service-1.0.4-linux64.tar.xz](dist-archive/nmdc-log-service-1.0.4-linux64.tar.xz) *(965.75 KiB)*
- [⬇️ nmdc-log-service-1.0.4-linux32.tar.xz](dist-archive/nmdc-log-service-1.0.4-linux32.tar.xz) *(903.36 KiB)*
2016-04-04 1.0.3
- Enhancement: Upgrade `libnmdc` from `r4` to `r5`
- [⬇️ nmdc-log-service-1.0.3-win64.7z](dist-archive/nmdc-log-service-1.0.3-win64.7z) *(873.26 KiB)*
- [⬇️ nmdc-log-service-1.0.3-win32.7z](dist-archive/nmdc-log-service-1.0.3-win32.7z) *(803.45 KiB)*
- [⬇️ nmdc-log-service-1.0.3-linux64.tar.xz](dist-archive/nmdc-log-service-1.0.3-linux64.tar.xz) *(965.26 KiB)*
- [⬇️ nmdc-log-service-1.0.3-linux32.tar.xz](dist-archive/nmdc-log-service-1.0.3-linux32.tar.xz) *(902.95 KiB)*
2016-04-03 1.0.2
- Enhancement: Upgrade `libnmdc` from `r3` to `r4`
- [⬇️ nmdc-log-service-1.0.2-win64.7z](dist-archive/nmdc-log-service-1.0.2-win64.7z) *(872.64 KiB)*
- [⬇️ nmdc-log-service-1.0.2-win32.7z](dist-archive/nmdc-log-service-1.0.2-win32.7z) *(802.16 KiB)*
- [⬇️ nmdc-log-service-1.0.2-linux64.tar.xz](dist-archive/nmdc-log-service-1.0.2-linux64.tar.xz) *(965.06 KiB)*
- [⬇️ nmdc-log-service-1.0.2-linux32.tar.xz](dist-archive/nmdc-log-service-1.0.2-linux32.tar.xz) *(902.40 KiB)*
2016-04-03 1.0.1
- Enhancement: Add `-VerifyTLS` option
- Enhancement: Upgrade `libnmdc` from `r2` to `r3`
- Fix an issue writing log files on Linux
- Fix a cosmetic issue with error message formatting
- [⬇️ nmdc-log-service-1.0.1-win64.7z](dist-archive/nmdc-log-service-1.0.1-win64.7z) *(874.59 KiB)*
- [⬇️ nmdc-log-service-1.0.1-win32.7z](dist-archive/nmdc-log-service-1.0.1-win32.7z) *(802.05 KiB)*
- [⬇️ nmdc-log-service-1.0.1-src.7z](dist-archive/nmdc-log-service-1.0.1-src.7z) *(2.13 KiB)*
- [⬇️ nmdc-log-service-1.0.1-linux64.tar.xz](dist-archive/nmdc-log-service-1.0.1-linux64.tar.xz) *(965.03 KiB)*
- [⬇️ nmdc-log-service-1.0.1-linux32.tar.xz](dist-archive/nmdc-log-service-1.0.1-linux32.tar.xz) *(902.57 KiB)*
2016-04-02 1.0.0
- Initial public release
- [⬇️ nmdc-log-service-1.0.0-win64.7z](dist-archive/nmdc-log-service-1.0.0-win64.7z) *(872.66 KiB)*
- [⬇️ nmdc-log-service-1.0.0-win32.7z](dist-archive/nmdc-log-service-1.0.0-win32.7z) *(802.90 KiB)*
- [⬇️ nmdc-log-service-1.0.0-src.7z](dist-archive/nmdc-log-service-1.0.0-src.7z) *(2.05 KiB)*
- [⬇️ nmdc-log-service-1.0.0-linux64.tar.xz](dist-archive/nmdc-log-service-1.0.0-linux64.tar.xz) *(964.44 KiB)*
- [⬇️ nmdc-log-service-1.0.0-linux32.tar.xz](dist-archive/nmdc-log-service-1.0.0-linux32.tar.xz) *(902.47 KiB)*

View File

@@ -1,52 +0,0 @@
A logging service for NMDC hubs.
It logs public chat messages to a file, categorised by months. Binaries are provided for Windows/Linux amd64/i386.
Written in golang
Tags: nmdc
=USAGE=
`$nmdc-log-service -Help
Usage of nmdc-log-service:
-Debug
Print additional information on stdout
-Dir string
Output directory (default ".")
-LogConnectionState
Include connection state changes in log (default true)
-Nick string
Nick (default "nmdc-log-service")
-PMResponse string
Message to respond with on PM (default "This is an automated service. For enquiries, please contact an administrator.")
-Password string
Registered nick password
-Server string
Addresses to connect to (comma-separated)
-VerifyTLS
Verify TLS certificates (default true)
`
=CHANGELOG=
2016-04-16 1.0.4
- Enhancement: Upgrade `libnmdc` from `r5` to `r6`
- Include a sample systemd unit script in source archive
- Fix an issue showing zero connected hubs in user tag
- Fix a cosmetic issue with logging repeated identical connection failure messages
2016-04-04 1.0.3
- Enhancement: Upgrade `libnmdc` from `r4` to `r5`
2016-04-03 1.0.2
- Enhancement: Upgrade `libnmdc` from `r3` to `r4`
2016-04-03 1.0.1
- Enhancement: Add `-VerifyTLS` option
- Enhancement: Upgrade `libnmdc` from `r2` to `r3`
- Fix an issue writing log files on Linux
- Fix a cosmetic issue with error message formatting
2016-04-02 1.0.0
- Initial public release

View File

@@ -11,6 +11,7 @@ sanitise() {
local tmp=$(mktemp)
cat "$1" | perl -pe 's~C:.Users.......Documents.DEV.~C:/xxxxxxxxxxxxxxxxxxxxxxxxx/~g' > "$tmp"
mv "$tmp" "$1"
chmod 755 "$1"
}
main() {

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

5
go.mod Normal file
View File

@@ -0,0 +1,5 @@
module code.ivysaur.me/nmdc-log-service
go 1.13
require code.ivysaur.me/libnmdc v0.18.0

6
go.sum Normal file
View File

@@ -0,0 +1,6 @@
code.ivysaur.me/libnmdc v0.6.0 h1:I1PygqHyS3Er/u7ekYramMQ5Rw957ighnDl53Jzz2Cc=
code.ivysaur.me/libnmdc v0.6.0/go.mod h1:ZHCjIX/zm29hd2H8YtzOBHiSyowZNOHvgoMRjKbBLLg=
code.ivysaur.me/libnmdc v0.18.0 h1:BobB138EidAC3wE55CuTY7bZrFXtOy/zlssI8V1zXMk=
code.ivysaur.me/libnmdc v0.18.0/go.mod h1:5FjI0QxZEPeVTeg/e2MyJzJUwpmyE5CBAOIi7eqSxlg=
github.com/cxmcc/tiger v0.0.0-20170524142333-bde35e2713d7 h1:jBEtq1t2gpn2kEzvRlCUxvvrxl5aSWkXNPwe/hwvSNQ=
github.com/cxmcc/tiger v0.0.0-20170524142333-bde35e2713d7/go.mod h1:ruCYvt9rtYymAr4rNmfYJrl1dz8HSXUFP7cufqKOsDI=

14
main.go
View File

@@ -3,12 +3,13 @@ package main
import (
"flag"
"fmt"
"libnmdc"
"os"
"path/filepath"
"regexp"
"strings"
"time"
"code.ivysaur.me/libnmdc"
)
var BaseDir string = "."
@@ -60,13 +61,14 @@ func (this *HubWorker) MainLoop(addr, nick, password string) {
opts := libnmdc.HubConnectionOptions{
Address: libnmdc.HubAddress(addr),
SkipVerifyTLS: !VerifyTLS,
Self: *libnmdc.NewUserInfo(nick),
Self: libnmdc.NewUserInfo(nick),
NickPassword: password,
}
hub := opts.Connect()
for {
event := <-hub.OnEvent
evChan := make(chan libnmdc.HubEvent, 1)
hub := libnmdc.ConnectAsync(&opts, evChan)
for event := range evChan {
if DebugMode {
fmt.Printf("DEBUG: %s %v\n", addr, event)
@@ -75,7 +77,7 @@ func (this *HubWorker) MainLoop(addr, nick, password string) {
switch event.EventType {
case libnmdc.EVENT_CONNECTION_STATE_CHANGED:
if LogConnectionState {
str := "* " + event.StateChange.Format()
str := "* " + event.StateChange.String()
if len(event.Message) > 0 {
str += " (" + event.Message + ")"
}