initial
This commit is contained in:
0
.gitignore
vendored
Normal file
0
.gitignore
vendored
Normal file
10
Dockerfile
Normal file
10
Dockerfile
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
FROM golang:alpine3.22 AS prep-image
|
||||||
|
|
||||||
|
COPY . .
|
||||||
|
RUN CGO_ENABLED=0 GOOS=linux go build -o /logfly
|
||||||
|
|
||||||
|
FROM scratch
|
||||||
|
|
||||||
|
COPY --from=prep-image /logfly /logfly
|
||||||
|
|
||||||
|
CMD ["/logfly"]
|
||||||
4
Makefile
Normal file
4
Makefile
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
docker-build:
|
||||||
|
docker build -t liffsh/logfling:latest --progress=plain ./
|
||||||
|
docker-run:
|
||||||
|
docker run -e LOG_TYPE=json -v /var/run/docker.sock:/var/run/docker.sock liffsh/logfling:latest
|
||||||
23
main.go
Normal file
23
main.go
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"log/slog"
|
||||||
|
"os"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
logtype := os.Getenv("LOG_TYPE")
|
||||||
|
logger := slog.New(slog.NewTextHandler(os.Stdout, nil))
|
||||||
|
if logtype == "json" {
|
||||||
|
logger = slog.New(slog.NewJSONHandler(os.Stdout, nil))
|
||||||
|
}
|
||||||
|
logger.Info("Hello world!")
|
||||||
|
|
||||||
|
ticker := time.NewTicker(1 * time.Second)
|
||||||
|
defer ticker.Stop()
|
||||||
|
|
||||||
|
for _ = range ticker.C {
|
||||||
|
logger.Info("Ticking")
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user