Browse Source

日志配置

longan 1 year ago
parent
commit
a72bb9f00e
10 changed files with 119 additions and 5 deletions
  1. 4 0
      build.bat
  2. BIN
      build/lcfns
  3. 1 0
      config.yaml
  4. 1 0
      config/config.go
  5. 1 1
      gatewayServer/c2s.go
  6. 2 1
      gatewayServer/gatewayServer.go
  7. 3 0
      go.mod
  8. 14 0
      go.sum
  9. 73 0
      log/info.20231017.log
  10. 20 3
      main.go

+ 4 - 0
build.bat

@@ -0,0 +1,4 @@
+set GOARCH=amd64
+set GOOS=linux
+set CGO_ENABLED=0
+go build -o ./build/lcfns ./

BIN
build/lcfns


+ 1 - 0
config.yaml

@@ -51,6 +51,7 @@ HttpHostNotificationList:
 #调用外部接口
 foreign:
   securityRewindUrl: "http://106.52.134.22:9099"
+  gatewayServer: "192.168.110.69:9001"
 #海康摄像头统一配置
 hikvision:
   user: admin

+ 1 - 0
config/config.go

@@ -147,6 +147,7 @@ type HttpHostNotification struct {
 
 type Foreign struct {
 	SecurityRewindUrl string `mapstructure:"securityRewindUrl" yaml:"securityRewindUrl"`
+	GatewayServer     string `mapstructure:"getawayServer" yaml:"gatewayServer"`
 }
 
 type Hikvision struct {

+ 1 - 1
gatewayServer/c2s.go

@@ -125,7 +125,7 @@ func c2s4002(adu AppDataUnit, c net.Conn) {
 	if err != nil {
 		logrus.Errorf("写入数据错误 %e\n", err)
 	}
-	logrus.Info("heartbeat :", adu.DevId)
+	//logrus.Info("heartbeat :", adu.DevId)
 	//todo 网关注册后,网关再接入摄像头如何注册摄像头--
 }
 

+ 2 - 1
gatewayServer/gatewayServer.go

@@ -3,12 +3,13 @@ package gatewayServer
 import (
 	"fmt"
 	"io"
+	"lcfns/global"
 	"log"
 	"net"
 	"sync/atomic"
 )
 
-var ipAddress = "192.168.110.69:9001"
+var ipAddress = global.Config.Foreign.GatewayServer
 var ConnMap = make(map[string]net.Conn, 50)
 var openDebug bool = false
 

+ 3 - 0
go.mod

@@ -56,11 +56,14 @@ require (
 	github.com/klauspost/cpuid/v2 v2.2.5 // indirect
 	github.com/kr/pretty v0.3.1 // indirect
 	github.com/leodido/go-urn v1.2.4 // indirect
+	github.com/lestrrat/go-file-rotatelogs v0.0.0-20180223000712-d3151e2a480f // indirect
+	github.com/lestrrat/go-strftime v0.0.0-20180220042222-ba3bf9c1d042 // indirect
 	github.com/mattn/go-isatty v0.0.19 // indirect
 	github.com/microsoft/go-mssqldb v1.1.0 // indirect
 	github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
 	github.com/modern-go/reflect2 v1.0.2 // indirect
 	github.com/pelletier/go-toml/v2 v2.1.0 // indirect
+	github.com/pkg/errors v0.9.1 // indirect
 	github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
 	github.com/rogpeppe/go-internal v1.11.0 // indirect
 	github.com/tidwall/gjson v1.14.4 // indirect

+ 14 - 0
go.sum

@@ -62,6 +62,7 @@ github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LB
 github.com/go-sql-driver/mysql v1.7.0/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI=
 github.com/go-sql-driver/mysql v1.7.1 h1:lUIinVbN1DY0xBg0eMOzmmtGoHwWBbvnWubQUrtU8EI=
 github.com/go-sql-driver/mysql v1.7.1/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI=
+github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
 github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE=
 github.com/go-test/deep v1.1.0 h1:WOcxcdHcvdgThNXjw0t76K42FXTU7HpNQWHpA2HHNlg=
 github.com/go-test/deep v1.1.0/go.mod h1:5C2ZWiW0ErCdrYzpqxLbTX7MG14M9iiw8DgHncVwcsE=
@@ -105,10 +106,16 @@ github.com/gorilla/sessions v1.2.1/go.mod h1:dk2InVEVJ0sfLlnXv9EAgkf6ecYs/i80K/z
 github.com/hashicorp/go-uuid v1.0.2/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
 github.com/hashicorp/go-uuid v1.0.3/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
 github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
+github.com/jackc/chunkreader/v2 v2.0.1/go.mod h1:odVSm741yZoC3dpHEUXIqA9tQRhFrgOHwnPIn9lDKlk=
+github.com/jackc/pgconn v1.13.0/go.mod h1:AnowpAqO4CMIIJNZl2VJp+KrkAZciAkhEl0W0JIobpI=
+github.com/jackc/pgio v1.0.0/go.mod h1:oP+2QK2wFfUWgr+gxjoBH9KGBb31Eio69xUb0w5bYf8=
 github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM=
 github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg=
+github.com/jackc/pgproto3/v2 v2.3.1/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA=
 github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a h1:bbPeKD0xmW/Y25WS6cokEszi5g+S0QxI/d45PkRi7Nk=
 github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM=
+github.com/jackc/pgtype v1.12.0/go.mod h1:LUMuVrfsFfdKGLw+AFFVv6KtHOFMwRgDDzBt76IqCA4=
+github.com/jackc/pgx/v4 v4.17.2/go.mod h1:lcxIZN44yMIrWI78a5CpucdD14hX0SBDbNRvjDBItsw=
 github.com/jackc/pgx/v5 v5.3.1 h1:Fcr8QJ1ZeLi5zsPZqQeUZhNhxfkkKBOgJuYkJHoBOtU=
 github.com/jackc/pgx/v5 v5.3.1/go.mod h1:t3JDKnCBlYIc0ewLF0Q7B8MXmoIaBOZj/ic7iHozM/8=
 github.com/jcmturner/aescts/v2 v2.0.0/go.mod h1:AiaICIRyfYg35RUkr8yESTqvSy7csK90qZ5xfvvsoNs=
@@ -135,7 +142,12 @@ github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
 github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
 github.com/leodido/go-urn v1.2.4 h1:XlAE/cm/ms7TE/VMVoduSpNBoyc2dOxHs5MZSwAN63Q=
 github.com/leodido/go-urn v1.2.4/go.mod h1:7ZrI8mTSeBSHl/UaRyKQW1qZeMgak41ANeCNaVckg+4=
+github.com/lestrrat/go-file-rotatelogs v0.0.0-20180223000712-d3151e2a480f h1:sgUSP4zdTUZYZgAGGtN5Lxk92rK+JUFOwf+FT99EEI4=
+github.com/lestrrat/go-file-rotatelogs v0.0.0-20180223000712-d3151e2a480f/go.mod h1:UGmTpUd3rjbtfIpwAPrcfmGf/Z1HS95TATB+m57TPB8=
+github.com/lestrrat/go-strftime v0.0.0-20180220042222-ba3bf9c1d042 h1:Bvq8AziQ5jFF4BHGAEDSqwPW1NJS3XshxbRCxtjFAZc=
+github.com/lestrrat/go-strftime v0.0.0-20180220042222-ba3bf9c1d042/go.mod h1:TPpsiPUEh0zFL1Snz4crhMlBe60PYxRHr5oFF3rRYg0=
 github.com/lib/pq v1.10.2 h1:AqzbZs4ZoCBp+GtejcpCpcxM3zlSMx29dXbUSeVtJb8=
+github.com/lib/pq v1.10.2/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
 github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA=
 github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
 github.com/microsoft/go-mssqldb v1.1.0 h1:jsV+tpvcPTbNNKW0o3kiCD69kOHICsfjZ2VcVu2lKYc=
@@ -165,6 +177,7 @@ github.com/pelletier/go-toml/v2 v2.1.0/go.mod h1:tJU2Z3ZkXwnxa4DPO899bsyIoywizdU
 github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8/go.mod h1:HKlIX3XHQyzLZPlr7++PzdhaXEj94dEiJgZDTsxEqUI=
 github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
 github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
+github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
 github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
 github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
 github.com/redis/go-redis/v9 v9.0.5 h1:CuQcn5HIEeK7BgElubPP8CGtE0KakrnbBSTLjathl5o=
@@ -317,6 +330,7 @@ google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs
 google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
 gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
 gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
+gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
 gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
 gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce h1:+JknDZhAj8YMt7GC73Ei8pv4MzjDUNPHgQWJdtMAaDU=
 gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce/go.mod h1:5AcXVHNjg+BDxry382+8OKon8SEWiKktQR07RKPsv1c=

+ 73 - 0
log/info.20231017.log

@@ -0,0 +1,73 @@
+time="2023-10-17T09:29:31+08:00" level=info msg="redis connect ping response:{pong 15 0 PONG <nil>}" func=lcfns/initialize.Redis file="D:/goProject/lcfns/initialize/redis.go:23"
+time="2023-10-17T09:29:31+08:00" level=info msg="router register success" func=lcfns/initialize.Routers file="D:/goProject/lcfns/initialize/router.go:68"
+time="2023-10-17T09:30:16+08:00" level=error msg="获取host失败:&{%!e(string=获取设备Id对应连接失败)}\n" func=lcfns/api/v1/isapi.SystemApi.GetInfo file="D:/goProject/lcfns/api/v1/isapi/system.go:19"
+time="2023-10-17T09:31:52+08:00" level=info msg="redis connect ping response:{pong 15 0 PONG <nil>}" func=lcfns/initialize.Redis file="D:/goProject/lcfns/initialize/redis.go:23"
+time="2023-10-17T09:31:52+08:00" level=info msg="router register success" func=lcfns/initialize.Routers file="D:/goProject/lcfns/initialize/router.go:68"
+time="2023-10-17T09:58:22+08:00" level=info msg="redis connect ping response:{pong 15 0 PONG <nil>}" func=lcfns/initialize.Redis file="D:/goProject/lcfns/initialize/redis.go:23"
+time="2023-10-17T09:58:22+08:00" level=info msg="router register success" func=lcfns/initialize.Routers file="D:/goProject/lcfns/initialize/router.go:68"
+time="2023-10-17T09:58:42+08:00" level=info msg="23092033882向登录服务器请求管理服务器" func=lcfns/gatewayServer.c2s4000 file="D:/goProject/lcfns/gatewayServer/c2s.go:49"
+time="2023-10-17T09:58:42+08:00" level=info msg="网关[23092033882]登录成功" func=lcfns/gatewayServer.c2s4001 file="D:/goProject/lcfns/gatewayServer/c2s.go:72"
+time="2023-10-17T09:58:42+08:00" level=error msg="摄像头已注册" func=lcfns/gatewayServer.c2s4001 file="D:/goProject/lcfns/gatewayServer/c2s.go:97" 摄像头注册失败=DS-2CD3T47WDA4-L20230325AACHL42365539
+time="2023-10-17T09:58:52+08:00" level=info msg="heartbeat :23092033882" func=lcfns/gatewayServer.c2s4002 file="D:/goProject/lcfns/gatewayServer/c2s.go:128"
+time="2023-10-17T09:59:02+08:00" level=info msg="heartbeat :23092033882" func=lcfns/gatewayServer.c2s4002 file="D:/goProject/lcfns/gatewayServer/c2s.go:128"
+time="2023-10-17T09:59:12+08:00" level=info msg="heartbeat :23092033882" func=lcfns/gatewayServer.c2s4002 file="D:/goProject/lcfns/gatewayServer/c2s.go:128"
+time="2023-10-17T09:59:22+08:00" level=info msg="heartbeat :23092033882" func=lcfns/gatewayServer.c2s4002 file="D:/goProject/lcfns/gatewayServer/c2s.go:128"
+time="2023-10-17T09:59:32+08:00" level=info msg="heartbeat :23092033882" func=lcfns/gatewayServer.c2s4002 file="D:/goProject/lcfns/gatewayServer/c2s.go:128"
+time="2023-10-17T09:59:42+08:00" level=info msg="heartbeat :23092033882" func=lcfns/gatewayServer.c2s4002 file="D:/goProject/lcfns/gatewayServer/c2s.go:128"
+time="2023-10-17T09:59:52+08:00" level=info msg="heartbeat :23092033882" func=lcfns/gatewayServer.c2s4002 file="D:/goProject/lcfns/gatewayServer/c2s.go:128"
+time="2023-10-17T10:00:02+08:00" level=info msg="heartbeat :23092033882" func=lcfns/gatewayServer.c2s4002 file="D:/goProject/lcfns/gatewayServer/c2s.go:128"
+time="2023-10-17T10:00:12+08:00" level=info msg="heartbeat :23092033882" func=lcfns/gatewayServer.c2s4002 file="D:/goProject/lcfns/gatewayServer/c2s.go:128"
+time="2023-10-17T10:00:21+08:00" level=info msg="heartbeat :23092033882" func=lcfns/gatewayServer.c2s4002 file="D:/goProject/lcfns/gatewayServer/c2s.go:128"
+time="2023-10-17T10:00:31+08:00" level=info msg="heartbeat :23092033882" func=lcfns/gatewayServer.c2s4002 file="D:/goProject/lcfns/gatewayServer/c2s.go:128"
+time="2023-10-17T10:00:41+08:00" level=info msg="heartbeat :23092033882" func=lcfns/gatewayServer.c2s4002 file="D:/goProject/lcfns/gatewayServer/c2s.go:128"
+time="2023-10-17T10:00:51+08:00" level=info msg="heartbeat :23092033882" func=lcfns/gatewayServer.c2s4002 file="D:/goProject/lcfns/gatewayServer/c2s.go:128"
+time="2023-10-17T10:01:01+08:00" level=info msg="heartbeat :23092033882" func=lcfns/gatewayServer.c2s4002 file="D:/goProject/lcfns/gatewayServer/c2s.go:128"
+time="2023-10-17T10:01:11+08:00" level=info msg="heartbeat :23092033882" func=lcfns/gatewayServer.c2s4002 file="D:/goProject/lcfns/gatewayServer/c2s.go:128"
+time="2023-10-17T10:01:21+08:00" level=info msg="heartbeat :23092033882" func=lcfns/gatewayServer.c2s4002 file="D:/goProject/lcfns/gatewayServer/c2s.go:128"
+time="2023-10-17T10:01:31+08:00" level=info msg="heartbeat :23092033882" func=lcfns/gatewayServer.c2s4002 file="D:/goProject/lcfns/gatewayServer/c2s.go:128"
+time="2023-10-17T10:01:41+08:00" level=info msg="heartbeat :23092033882" func=lcfns/gatewayServer.c2s4002 file="D:/goProject/lcfns/gatewayServer/c2s.go:128"
+time="2023-10-17T10:01:51+08:00" level=info msg="heartbeat :23092033882" func=lcfns/gatewayServer.c2s4002 file="D:/goProject/lcfns/gatewayServer/c2s.go:128"
+time="2023-10-17T10:02:01+08:00" level=info msg="heartbeat :23092033882" func=lcfns/gatewayServer.c2s4002 file="D:/goProject/lcfns/gatewayServer/c2s.go:128"
+time="2023-10-17T10:02:11+08:00" level=info msg="heartbeat :23092033882" func=lcfns/gatewayServer.c2s4002 file="D:/goProject/lcfns/gatewayServer/c2s.go:128"
+time="2023-10-17T10:02:21+08:00" level=info msg="heartbeat :23092033882" func=lcfns/gatewayServer.c2s4002 file="D:/goProject/lcfns/gatewayServer/c2s.go:128"
+time="2023-10-17T10:02:31+08:00" level=info msg="heartbeat :23092033882" func=lcfns/gatewayServer.c2s4002 file="D:/goProject/lcfns/gatewayServer/c2s.go:128"
+time="2023-10-17T10:02:40+08:00" level=info msg="heartbeat :23092033882" func=lcfns/gatewayServer.c2s4002 file="D:/goProject/lcfns/gatewayServer/c2s.go:128"
+time="2023-10-17T10:02:50+08:00" level=info msg="heartbeat :23092033882" func=lcfns/gatewayServer.c2s4002 file="D:/goProject/lcfns/gatewayServer/c2s.go:128"
+time="2023-10-17T10:03:00+08:00" level=info msg="heartbeat :23092033882" func=lcfns/gatewayServer.c2s4002 file="D:/goProject/lcfns/gatewayServer/c2s.go:128"
+time="2023-10-17T10:03:10+08:00" level=info msg="heartbeat :23092033882" func=lcfns/gatewayServer.c2s4002 file="D:/goProject/lcfns/gatewayServer/c2s.go:128"
+time="2023-10-17T10:03:20+08:00" level=info msg="heartbeat :23092033882" func=lcfns/gatewayServer.c2s4002 file="D:/goProject/lcfns/gatewayServer/c2s.go:128"
+time="2023-10-17T10:03:30+08:00" level=info msg="heartbeat :23092033882" func=lcfns/gatewayServer.c2s4002 file="D:/goProject/lcfns/gatewayServer/c2s.go:128"
+time="2023-10-17T10:03:40+08:00" level=info msg="heartbeat :23092033882" func=lcfns/gatewayServer.c2s4002 file="D:/goProject/lcfns/gatewayServer/c2s.go:128"
+time="2023-10-17T10:03:50+08:00" level=info msg="heartbeat :23092033882" func=lcfns/gatewayServer.c2s4002 file="D:/goProject/lcfns/gatewayServer/c2s.go:128"
+time="2023-10-17T10:04:00+08:00" level=info msg="heartbeat :23092033882" func=lcfns/gatewayServer.c2s4002 file="D:/goProject/lcfns/gatewayServer/c2s.go:128"
+time="2023-10-17T10:04:10+08:00" level=info msg="heartbeat :23092033882" func=lcfns/gatewayServer.c2s4002 file="D:/goProject/lcfns/gatewayServer/c2s.go:128"
+time="2023-10-17T10:04:20+08:00" level=info msg="heartbeat :23092033882" func=lcfns/gatewayServer.c2s4002 file="D:/goProject/lcfns/gatewayServer/c2s.go:128"
+time="2023-10-17T10:04:30+08:00" level=info msg="heartbeat :23092033882" func=lcfns/gatewayServer.c2s4002 file="D:/goProject/lcfns/gatewayServer/c2s.go:128"
+time="2023-10-17T10:04:40+08:00" level=info msg="heartbeat :23092033882" func=lcfns/gatewayServer.c2s4002 file="D:/goProject/lcfns/gatewayServer/c2s.go:128"
+time="2023-10-17T10:04:50+08:00" level=info msg="heartbeat :23092033882" func=lcfns/gatewayServer.c2s4002 file="D:/goProject/lcfns/gatewayServer/c2s.go:128"
+time="2023-10-17T10:04:59+08:00" level=info msg="heartbeat :23092033882" func=lcfns/gatewayServer.c2s4002 file="D:/goProject/lcfns/gatewayServer/c2s.go:128"
+time="2023-10-17T10:05:09+08:00" level=info msg="heartbeat :23092033882" func=lcfns/gatewayServer.c2s4002 file="D:/goProject/lcfns/gatewayServer/c2s.go:128"
+time="2023-10-17T10:05:19+08:00" level=info msg="heartbeat :23092033882" func=lcfns/gatewayServer.c2s4002 file="D:/goProject/lcfns/gatewayServer/c2s.go:128"
+time="2023-10-17T10:05:29+08:00" level=info msg="heartbeat :23092033882" func=lcfns/gatewayServer.c2s4002 file="D:/goProject/lcfns/gatewayServer/c2s.go:128"
+time="2023-10-17T10:05:39+08:00" level=info msg="heartbeat :23092033882" func=lcfns/gatewayServer.c2s4002 file="D:/goProject/lcfns/gatewayServer/c2s.go:128"
+time="2023-10-17T10:05:49+08:00" level=info msg="heartbeat :23092033882" func=lcfns/gatewayServer.c2s4002 file="D:/goProject/lcfns/gatewayServer/c2s.go:128"
+time="2023-10-17T10:05:59+08:00" level=info msg="heartbeat :23092033882" func=lcfns/gatewayServer.c2s4002 file="D:/goProject/lcfns/gatewayServer/c2s.go:128"
+time="2023-10-17T10:06:09+08:00" level=info msg="heartbeat :23092033882" func=lcfns/gatewayServer.c2s4002 file="D:/goProject/lcfns/gatewayServer/c2s.go:128"
+time="2023-10-17T10:06:19+08:00" level=info msg="heartbeat :23092033882" func=lcfns/gatewayServer.c2s4002 file="D:/goProject/lcfns/gatewayServer/c2s.go:128"
+time="2023-10-17T10:06:29+08:00" level=info msg="heartbeat :23092033882" func=lcfns/gatewayServer.c2s4002 file="D:/goProject/lcfns/gatewayServer/c2s.go:128"
+time="2023-10-17T10:06:39+08:00" level=info msg="heartbeat :23092033882" func=lcfns/gatewayServer.c2s4002 file="D:/goProject/lcfns/gatewayServer/c2s.go:128"
+time="2023-10-17T10:06:49+08:00" level=info msg="heartbeat :23092033882" func=lcfns/gatewayServer.c2s4002 file="D:/goProject/lcfns/gatewayServer/c2s.go:128"
+time="2023-10-17T10:06:59+08:00" level=info msg="heartbeat :23092033882" func=lcfns/gatewayServer.c2s4002 file="D:/goProject/lcfns/gatewayServer/c2s.go:128"
+time="2023-10-17T10:07:09+08:00" level=info msg="heartbeat :23092033882" func=lcfns/gatewayServer.c2s4002 file="D:/goProject/lcfns/gatewayServer/c2s.go:128"
+time="2023-10-17T10:07:18+08:00" level=info msg="heartbeat :23092033882" func=lcfns/gatewayServer.c2s4002 file="D:/goProject/lcfns/gatewayServer/c2s.go:128"
+time="2023-10-17T10:07:28+08:00" level=info msg="heartbeat :23092033882" func=lcfns/gatewayServer.c2s4002 file="D:/goProject/lcfns/gatewayServer/c2s.go:128"
+time="2023-10-17T10:07:38+08:00" level=info msg="heartbeat :23092033882" func=lcfns/gatewayServer.c2s4002 file="D:/goProject/lcfns/gatewayServer/c2s.go:128"
+time="2023-10-17T10:07:48+08:00" level=info msg="heartbeat :23092033882" func=lcfns/gatewayServer.c2s4002 file="D:/goProject/lcfns/gatewayServer/c2s.go:128"
+time="2023-10-17T10:07:58+08:00" level=info msg="heartbeat :23092033882" func=lcfns/gatewayServer.c2s4002 file="D:/goProject/lcfns/gatewayServer/c2s.go:128"
+time="2023-10-17T10:08:08+08:00" level=info msg="heartbeat :23092033882" func=lcfns/gatewayServer.c2s4002 file="D:/goProject/lcfns/gatewayServer/c2s.go:128"
+time="2023-10-17T10:08:18+08:00" level=info msg="heartbeat :23092033882" func=lcfns/gatewayServer.c2s4002 file="D:/goProject/lcfns/gatewayServer/c2s.go:128"
+time="2023-10-17T10:08:28+08:00" level=info msg="heartbeat :23092033882" func=lcfns/gatewayServer.c2s4002 file="D:/goProject/lcfns/gatewayServer/c2s.go:128"
+time="2023-10-17T10:08:38+08:00" level=info msg="heartbeat :23092033882" func=lcfns/gatewayServer.c2s4002 file="D:/goProject/lcfns/gatewayServer/c2s.go:128"
+time="2023-10-17T10:08:48+08:00" level=info msg="heartbeat :23092033882" func=lcfns/gatewayServer.c2s4002 file="D:/goProject/lcfns/gatewayServer/c2s.go:128"
+time="2023-10-17T10:08:58+08:00" level=info msg="heartbeat :23092033882" func=lcfns/gatewayServer.c2s4002 file="D:/goProject/lcfns/gatewayServer/c2s.go:128"
+time="2023-10-17T10:09:08+08:00" level=info msg="heartbeat :23092033882" func=lcfns/gatewayServer.c2s4002 file="D:/goProject/lcfns/gatewayServer/c2s.go:128"

+ 20 - 3
main.go

@@ -3,6 +3,7 @@ package main
 import (
 	"fmt"
 	"github.com/gin-gonic/gin"
+	rotatelogs "github.com/lestrrat/go-file-rotatelogs"
 	"github.com/sirupsen/logrus"
 	"lcfns/eventServer"
 	"lcfns/gatewayServer"
@@ -11,13 +12,12 @@ import (
 	"lcfns/service/system"
 	"net/http"
 	"os"
+	"path"
 	"time"
 )
 
 func main() {
-	logrus.SetLevel(logrus.DebugLevel)
-	logrus.SetOutput(os.Stdout)
-	logrus.SetReportCaller(true)
+	initLogrus()
 	go eventServer.StartEventServer() //摄像头事件监听服务端
 	go gatewayServer.GatewayServe()   //网关服务端
 	initialize.OtherInit()            //初始化缓存
@@ -56,3 +56,20 @@ func initServer(address string, router *gin.Engine) server {
 		MaxHeaderBytes: 1 << 20,
 	}
 }
+
+func initLogrus() {
+	err := os.MkdirAll("./log", os.ModeDir)
+	if err != nil {
+		panic(err)
+	}
+	fileName := path.Join("./log", "info")
+	writer, _ := rotatelogs.New(
+		fileName+".%Y%m%d.log",
+		rotatelogs.WithMaxAge(15*24*time.Hour),    // 文件最大保存时间
+		rotatelogs.WithRotationTime(24*time.Hour), // 日志切割时间间隔
+	)
+	logrus.SetLevel(logrus.DebugLevel)
+	logrus.SetOutput(os.Stdout)
+	logrus.SetReportCaller(true)
+	logrus.SetOutput(writer)
+}