Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| cf0288a11c | |||
| fa9c16f410 | |||
| 18dcafd440 | |||
| 6641d00247 | |||
| beaf18eb8e | |||
| 5c4a1272c1 |
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
nmdc-log-service
|
||||||
80
README.md
Normal file
80
README.md
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
# nmdc-log-service
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
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)*
|
||||||
@@ -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
|
|
||||||
1
build.sh
1
build.sh
@@ -11,6 +11,7 @@ sanitise() {
|
|||||||
local tmp=$(mktemp)
|
local tmp=$(mktemp)
|
||||||
cat "$1" | perl -pe 's~C:.Users.......Documents.DEV.~C:/xxxxxxxxxxxxxxxxxxxxxxxxx/~g' > "$tmp"
|
cat "$1" | perl -pe 's~C:.Users.......Documents.DEV.~C:/xxxxxxxxxxxxxxxxxxxxxxxxx/~g' > "$tmp"
|
||||||
mv "$tmp" "$1"
|
mv "$tmp" "$1"
|
||||||
|
chmod 755 "$1"
|
||||||
}
|
}
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
|
|||||||
BIN
dist-archive/nmdc-log-service-1.0.0-linux32.tar.xz
Normal file
BIN
dist-archive/nmdc-log-service-1.0.0-linux32.tar.xz
Normal file
Binary file not shown.
BIN
dist-archive/nmdc-log-service-1.0.0-linux64.tar.xz
Normal file
BIN
dist-archive/nmdc-log-service-1.0.0-linux64.tar.xz
Normal file
Binary file not shown.
BIN
dist-archive/nmdc-log-service-1.0.0-src.7z
Normal file
BIN
dist-archive/nmdc-log-service-1.0.0-src.7z
Normal file
Binary file not shown.
BIN
dist-archive/nmdc-log-service-1.0.0-win32.7z
Normal file
BIN
dist-archive/nmdc-log-service-1.0.0-win32.7z
Normal file
Binary file not shown.
BIN
dist-archive/nmdc-log-service-1.0.0-win64.7z
Normal file
BIN
dist-archive/nmdc-log-service-1.0.0-win64.7z
Normal file
Binary file not shown.
BIN
dist-archive/nmdc-log-service-1.0.1-linux32.tar.xz
Normal file
BIN
dist-archive/nmdc-log-service-1.0.1-linux32.tar.xz
Normal file
Binary file not shown.
BIN
dist-archive/nmdc-log-service-1.0.1-linux64.tar.xz
Normal file
BIN
dist-archive/nmdc-log-service-1.0.1-linux64.tar.xz
Normal file
Binary file not shown.
BIN
dist-archive/nmdc-log-service-1.0.1-src.7z
Normal file
BIN
dist-archive/nmdc-log-service-1.0.1-src.7z
Normal file
Binary file not shown.
BIN
dist-archive/nmdc-log-service-1.0.1-win32.7z
Normal file
BIN
dist-archive/nmdc-log-service-1.0.1-win32.7z
Normal file
Binary file not shown.
BIN
dist-archive/nmdc-log-service-1.0.1-win64.7z
Normal file
BIN
dist-archive/nmdc-log-service-1.0.1-win64.7z
Normal file
Binary file not shown.
BIN
dist-archive/nmdc-log-service-1.0.2-linux32.tar.xz
Normal file
BIN
dist-archive/nmdc-log-service-1.0.2-linux32.tar.xz
Normal file
Binary file not shown.
BIN
dist-archive/nmdc-log-service-1.0.2-linux64.tar.xz
Normal file
BIN
dist-archive/nmdc-log-service-1.0.2-linux64.tar.xz
Normal file
Binary file not shown.
BIN
dist-archive/nmdc-log-service-1.0.2-win32.7z
Normal file
BIN
dist-archive/nmdc-log-service-1.0.2-win32.7z
Normal file
Binary file not shown.
BIN
dist-archive/nmdc-log-service-1.0.2-win64.7z
Normal file
BIN
dist-archive/nmdc-log-service-1.0.2-win64.7z
Normal file
Binary file not shown.
BIN
dist-archive/nmdc-log-service-1.0.3-linux32.tar.xz
Normal file
BIN
dist-archive/nmdc-log-service-1.0.3-linux32.tar.xz
Normal file
Binary file not shown.
BIN
dist-archive/nmdc-log-service-1.0.3-linux64.tar.xz
Normal file
BIN
dist-archive/nmdc-log-service-1.0.3-linux64.tar.xz
Normal file
Binary file not shown.
BIN
dist-archive/nmdc-log-service-1.0.3-win32.7z
Normal file
BIN
dist-archive/nmdc-log-service-1.0.3-win32.7z
Normal file
Binary file not shown.
BIN
dist-archive/nmdc-log-service-1.0.3-win64.7z
Normal file
BIN
dist-archive/nmdc-log-service-1.0.3-win64.7z
Normal file
Binary file not shown.
BIN
dist-archive/nmdc-log-service-1.0.4-linux32.tar.xz
Normal file
BIN
dist-archive/nmdc-log-service-1.0.4-linux32.tar.xz
Normal file
Binary file not shown.
BIN
dist-archive/nmdc-log-service-1.0.4-linux64.tar.xz
Normal file
BIN
dist-archive/nmdc-log-service-1.0.4-linux64.tar.xz
Normal file
Binary file not shown.
BIN
dist-archive/nmdc-log-service-1.0.4-src.7z
Normal file
BIN
dist-archive/nmdc-log-service-1.0.4-src.7z
Normal file
Binary file not shown.
BIN
dist-archive/nmdc-log-service-1.0.4-win32.7z
Normal file
BIN
dist-archive/nmdc-log-service-1.0.4-win32.7z
Normal file
Binary file not shown.
BIN
dist-archive/nmdc-log-service-1.0.4-win64.7z
Normal file
BIN
dist-archive/nmdc-log-service-1.0.4-win64.7z
Normal file
Binary file not shown.
5
go.mod
Normal file
5
go.mod
Normal 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
6
go.sum
Normal 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
14
main.go
@@ -3,12 +3,13 @@ package main
|
|||||||
import (
|
import (
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"libnmdc"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"code.ivysaur.me/libnmdc"
|
||||||
)
|
)
|
||||||
|
|
||||||
var BaseDir string = "."
|
var BaseDir string = "."
|
||||||
@@ -60,13 +61,14 @@ func (this *HubWorker) MainLoop(addr, nick, password string) {
|
|||||||
opts := libnmdc.HubConnectionOptions{
|
opts := libnmdc.HubConnectionOptions{
|
||||||
Address: libnmdc.HubAddress(addr),
|
Address: libnmdc.HubAddress(addr),
|
||||||
SkipVerifyTLS: !VerifyTLS,
|
SkipVerifyTLS: !VerifyTLS,
|
||||||
Self: *libnmdc.NewUserInfo(nick),
|
Self: libnmdc.NewUserInfo(nick),
|
||||||
NickPassword: password,
|
NickPassword: password,
|
||||||
}
|
}
|
||||||
hub := opts.Connect()
|
|
||||||
|
|
||||||
for {
|
evChan := make(chan libnmdc.HubEvent, 1)
|
||||||
event := <-hub.OnEvent
|
hub := libnmdc.ConnectAsync(&opts, evChan)
|
||||||
|
|
||||||
|
for event := range evChan {
|
||||||
|
|
||||||
if DebugMode {
|
if DebugMode {
|
||||||
fmt.Printf("DEBUG: %s %v\n", addr, event)
|
fmt.Printf("DEBUG: %s %v\n", addr, event)
|
||||||
@@ -75,7 +77,7 @@ func (this *HubWorker) MainLoop(addr, nick, password string) {
|
|||||||
switch event.EventType {
|
switch event.EventType {
|
||||||
case libnmdc.EVENT_CONNECTION_STATE_CHANGED:
|
case libnmdc.EVENT_CONNECTION_STATE_CHANGED:
|
||||||
if LogConnectionState {
|
if LogConnectionState {
|
||||||
str := "* " + event.StateChange.Format()
|
str := "* " + event.StateChange.String()
|
||||||
if len(event.Message) > 0 {
|
if len(event.Message) > 0 {
|
||||||
str += " (" + event.Message + ")"
|
str += " (" + event.Message + ")"
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user