diff --git a/.fossa.yml b/.fossa.yml deleted file mode 100644 index a01b9b6..0000000 --- a/.fossa.yml +++ /dev/null @@ -1,20 +0,0 @@ -# Copyright 2020-present Open Networking Foundation -# -# SPDX-License-Identifier: Apache-2.0 -# -# Generated by FOSSA CLI (https://github.com/fossas/fossa-cli) -# Visit https://fossa.com to learn more -# -# Usage: FOSSA_API_KEY=<> fossa analyze -# -T is not supported at this moment from fossa side. -version: 2 -cli: - server: https://app.fossa.com - fetcher: custom - project: simapp -analyze: - modules: - - name: simapp - type: raw - target: ../simapp - path: ../simapp diff --git a/VERSION b/VERSION index f9f73cc..bc80560 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.4.2-dev +1.5.0 diff --git a/go.mod b/go.mod index c6e5f95..b562ae8 100644 --- a/go.mod +++ b/go.mod @@ -4,52 +4,29 @@ go 1.21 require ( github.com/fsnotify/fsnotify v1.7.0 - github.com/omec-project/util v1.1.0 github.com/spf13/viper v1.19.0 + go.uber.org/zap v1.23.0 golang.org/x/net v0.29.0 gopkg.in/yaml.v2 v2.4.0 ) require ( - github.com/antonfisher/nested-logrus-formatter v1.3.1 // indirect - github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d // indirect - github.com/bytedance/sonic v1.9.1 // indirect - github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect - github.com/gabriel-vasile/mimetype v1.4.2 // indirect - github.com/gin-contrib/sse v0.1.0 // indirect - github.com/gin-gonic/gin v1.9.1 // indirect - github.com/go-playground/locales v0.14.1 // indirect - github.com/go-playground/universal-translator v0.18.1 // indirect - github.com/go-playground/validator/v10 v10.14.0 // indirect - github.com/goccy/go-json v0.10.2 // indirect github.com/hashicorp/hcl v1.0.0 // indirect - github.com/json-iterator/go v1.1.12 // indirect - github.com/klauspost/cpuid/v2 v2.2.4 // indirect - github.com/leodido/go-urn v1.2.4 // indirect github.com/magiconair/properties v1.8.7 // indirect - github.com/mattn/go-isatty v0.0.19 // indirect github.com/mitchellh/mapstructure v1.5.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.2.2 // indirect github.com/sagikazarmark/locafero v0.4.0 // indirect github.com/sagikazarmark/slog-shim v0.1.0 // indirect - github.com/sirupsen/logrus v1.9.0 // indirect github.com/sourcegraph/conc v0.3.0 // indirect github.com/spf13/afero v1.11.0 // indirect github.com/spf13/cast v1.6.0 // indirect github.com/spf13/pflag v1.0.5 // indirect github.com/subosito/gotenv v1.6.0 // indirect - github.com/twitchyliquid64/golang-asm v0.15.1 // indirect - github.com/ugorji/go/codec v1.2.11 // indirect go.uber.org/atomic v1.9.0 // indirect go.uber.org/multierr v1.9.0 // indirect - golang.org/x/arch v0.3.0 // indirect - golang.org/x/crypto v0.27.0 // indirect golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect golang.org/x/sys v0.25.0 // indirect golang.org/x/text v0.18.0 // indirect - google.golang.org/protobuf v1.33.0 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index 3f638de..d830a59 100644 --- a/go.sum +++ b/go.sum @@ -1,13 +1,5 @@ -github.com/antonfisher/nested-logrus-formatter v1.3.1 h1:NFJIr+pzwv5QLHTPyKz9UMEoHck02Q9L0FP13b/xSbQ= -github.com/antonfisher/nested-logrus-formatter v1.3.1/go.mod h1:6WTfyWFkBc9+zyBaKIqRrg/KwMqBbodBjgbHjDz7zjA= -github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d h1:Byv0BzEl3/e6D5CLfI0j/7hiIEtvGVFPCZ7Ei2oq8iQ= -github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d/go.mod h1:WaHUgvxTVq04UNunO+XhnAqY/wQc+bxr74GqbsZ/Jqw= -github.com/bytedance/sonic v1.5.0/go.mod h1:ED5hyg4y6t3/9Ku1R6dU/4KyJ48DZ4jPhfY1O2AihPM= -github.com/bytedance/sonic v1.9.1 h1:6iJ6NqdoxCDr6mbY8h18oSO+cShGSMRGCEo7F2h0x8s= -github.com/bytedance/sonic v1.9.1/go.mod h1:i736AoUSYt75HyZLoJW9ERYxcy6eaN6h4BZXU064P/U= -github.com/chenzhuoyu/base64x v0.0.0-20211019084208-fb5309c8db06/go.mod h1:DH46F32mSOjUmXrMHnKwZdA8wcEefY7UVqBKYGjpdQY= -github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 h1:qSGYFH7+jGhDF8vLC+iwCD4WpbV1EBDSzWkJODFLams= -github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311/go.mod h1:b583jCggY9gE99b6G5LEC39OIiVsWj+R97kbl5odCEk= +github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8= +github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= @@ -16,53 +8,22 @@ github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHk github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0= github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA= github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM= -github.com/gabriel-vasile/mimetype v1.4.2 h1:w5qFW6JKBz9Y393Y4q372O9A7cUSequkh1Q7OhCmWKU= -github.com/gabriel-vasile/mimetype v1.4.2/go.mod h1:zApsH/mKG4w07erKIaJPFiX0Tsq9BFQgN3qGY5GnNgA= -github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= -github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= -github.com/gin-gonic/gin v1.9.1 h1:4idEAncQnU5cB7BeOkPtxjfCSye0AAm1R0RVIqJ+Jmg= -github.com/gin-gonic/gin v1.9.1/go.mod h1:hPrL7YrpYKXt5YId3A/Tnip5kqbEAP+KLuI3SUcPTeU= -github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s= -github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= -github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA= -github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY= -github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY= -github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY= -github.com/go-playground/validator/v10 v10.14.0 h1:vgvQWe3XCz3gIeFDm/HnTIbj6UGmg/+t63MyGU2n5js= -github.com/go-playground/validator/v10 v10.14.0/go.mod h1:9iXMNT7sEkjXb0I+enO7QXmzG6QCsPWY4zveKFVRSyU= -github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU= -github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= -github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= -github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= -github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= -github.com/klauspost/cpuid/v2 v2.2.4 h1:acbojRNwl3o09bUq+yDCtZFc1aiwaAAxtcn8YkZXnvk= -github.com/klauspost/cpuid/v2 v2.2.4/go.mod h1:RVVoqg1df56z8g3pUjL/3lE5UfnlrJX8tyFgg4nqhuY= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= -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/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY= github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0= -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/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= -github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= -github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= -github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= -github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= -github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= -github.com/omec-project/util v1.1.0 h1:TUuLmzqTLChIEXQlK9g5Ihgmw4FUm/UJnjfu0wT8Gz0= -github.com/omec-project/util v1.1.0/go.mod h1:BEv8nCokB4j0fgAQ6VVkKuQ2PSP3DJMEmz25pFMw5X8= github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM= github.com/pelletier/go-toml/v2 v2.2.2/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs= +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/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= @@ -72,8 +33,6 @@ github.com/sagikazarmark/locafero v0.4.0 h1:HApY1R9zGo4DBgr7dqsTH/JJxLTTsOt7u6ke github.com/sagikazarmark/locafero v0.4.0/go.mod h1:Pe1W6UlPYUk/+wc/6KFhbORCfqzgYEpgQ3O5fPuL3H4= github.com/sagikazarmark/slog-shim v0.1.0 h1:diDBnUNK9N/354PgrxMywXnAwEr1QZcOr6gto+ugjYE= github.com/sagikazarmark/slog-shim v0.1.0/go.mod h1:SrcSrq8aKtyuqEI1uvTDTK1arOWRIczQRv+GVI1AkeQ= -github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0= -github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= github.com/sourcegraph/conc v0.3.0 h1:OQTbbt6P72L20UqAkXXuLOj79LfEanQ+YQFNpLA9ySo= github.com/sourcegraph/conc v0.3.0/go.mod h1:Sdozi7LEKbFPqYX2/J+iBAM6HpqSLTASQIKqDmF7Mt0= github.com/spf13/afero v1.11.0 h1:WJQKhtpdm3v2IzqG8VMqrr6Rf3UYpEF239Jy9wNepM8= @@ -89,42 +48,29 @@ github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSS github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= -github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8= github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU= -github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI= -github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08= -github.com/ugorji/go/codec v1.2.11 h1:BMaWp1Bb6fHwEtbplGBGJ498wD+LKlNSl25MjdZY4dU= -github.com/ugorji/go/codec v1.2.11/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg= go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE= go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= +go.uber.org/goleak v1.1.11 h1:wy28qYRKZgnJTxGxvye5/wgWr1EKjmUDGYox5mGlRlI= +go.uber.org/goleak v1.1.11/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ= go.uber.org/multierr v1.9.0 h1:7fIwc/ZtS0q++VgcfqFDxSBZVv/Xo49/SYnDFupUwlI= go.uber.org/multierr v1.9.0/go.mod h1:X2jQV1h+kxSjClGpnseKVIxpmcjrj7MNnI0bnlfKTVQ= -golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8= -golang.org/x/arch v0.3.0 h1:02VY4/ZcO/gBOH6PUaoiptASxtXU10jazRCP865E97k= -golang.org/x/arch v0.3.0/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8= -golang.org/x/crypto v0.27.0 h1:GXm2NjJrPaiv/h1tb2UH8QfgC/hOf/+z0p6PT8o1w7A= -golang.org/x/crypto v0.27.0/go.mod h1:1Xngt8kV6Dvbssa53Ziq6Eqn0HqbZi5Z6R0ZpwQzt70= +go.uber.org/zap v1.23.0 h1:OjGQ5KQDEUawVHxNwQgPpiypGHOxo2mNZsOqTak4fFY= +go.uber.org/zap v1.23.0/go.mod h1:D+nX8jyLsMHMYrln8A0rJjFt/T/9/bGgIhAqxv5URuY= golang.org/x/exp v0.0.0-20230905200255-921286631fa9 h1:GoHiUyI/Tp2nVkLI2mCxVkOjsbSXD66ic0XW0js0R9g= golang.org/x/exp v0.0.0-20230905200255-921286631fa9/go.mod h1:S2oDrQGGwySpoQPVqRShND87VCbxmc6bL1Yd2oYrm6k= golang.org/x/net v0.29.0 h1:5ORfpBpCs4HzDYoodCDBbwHzdR5UrLBZ3sOnUJmFoHo= golang.org/x/net v0.29.0/go.mod h1:gLkgy8jTGERgjzMic6DS9+SP0ajcu6Xu3Orq/SpETg0= -golang.org/x/sys v0.0.0-20220704084225-05e143d24a9e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34= golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224= golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= -google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= -google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= @@ -135,4 +81,3 @@ gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4= diff --git a/logger/logger.go b/logger/logger.go new file mode 100644 index 0000000..b91749f --- /dev/null +++ b/logger/logger.go @@ -0,0 +1,55 @@ +// SPDX-FileCopyrightText: 2024 Intel Corporation +// +// SPDX-License-Identifier: Apache-2.0 + +package logger + +import ( + "go.uber.org/zap" + "go.uber.org/zap/zapcore" +) + +var ( + log *zap.Logger + SimappLog *zap.SugaredLogger + atomicLevel zap.AtomicLevel +) + +func init() { + atomicLevel = zap.NewAtomicLevelAt(zap.InfoLevel) + config := zap.Config{ + Level: atomicLevel, + Development: false, + Encoding: "console", + EncoderConfig: zap.NewProductionEncoderConfig(), + OutputPaths: []string{"stdout"}, + ErrorOutputPaths: []string{"stderr"}, + } + + config.EncoderConfig.TimeKey = "timestamp" + config.EncoderConfig.EncodeTime = zapcore.ISO8601TimeEncoder + config.EncoderConfig.LevelKey = "level" + config.EncoderConfig.EncodeLevel = zapcore.CapitalLevelEncoder + config.EncoderConfig.CallerKey = "caller" + config.EncoderConfig.EncodeCaller = zapcore.ShortCallerEncoder + config.EncoderConfig.MessageKey = "message" + config.EncoderConfig.StacktraceKey = "" + + var err error + log, err = config.Build() + if err != nil { + panic(err) + } + + SimappLog = log.Sugar() +} + +func GetLogger() *zap.Logger { + return log +} + +// SetLogLevel: set the log level (panic|fatal|error|warn|info|debug) +func SetLogLevel(level zapcore.Level) { + SimappLog.Infoln("set log level:", level) + atomicLevel.SetLevel(level) +} diff --git a/simapp.go b/simapp.go index f46e0f0..e373c93 100644 --- a/simapp.go +++ b/simapp.go @@ -14,7 +14,6 @@ import ( "encoding/json" "fmt" "io" - "log" "net" "net/http" "os" @@ -24,8 +23,10 @@ import ( "time" "github.com/fsnotify/fsnotify" - "github.com/omec-project/util/logger" + "github.com/omec-project/simapp/logger" "github.com/spf13/viper" + "go.uber.org/zap" + "go.uber.org/zap/zapcore" "golang.org/x/net/http2" "gopkg.in/yaml.v2" ) @@ -33,7 +34,15 @@ import ( type Config struct { Info *Info `yaml:"info"` Configuration *Configuration `yaml:"configuration"` - Logger *logger.Logger `yaml:"logger"` + Logger *Logger `yaml:"logger"` +} + +type Logger struct { + APP *LogSetting `yaml:"APP" valid:"optional"` +} + +type LogSetting struct { + DebugLevel string `yaml:"debugLevel" valid:"debugLevel"` } type Info struct { @@ -71,8 +80,8 @@ type IpDomain struct { type Subscriber struct { UeId string - UeIdStart string `yaml:"ueId-start,omitempty" json:"-",omitempty` - UeIdEnd string `yaml:"ueId-end,omitempty" json:"-", omitempty` + UeIdStart string `yaml:"ueId-start,omitempty" json:"-"` + UeIdEnd string `yaml:"ueId-end,omitempty" json:"-"` PlmnId string `yaml:"plmnId,omitempty" json:"plmnId,omitempty"` OPc string `yaml:"opc,omitempty" json:"opc,omitempty"` OP string `yaml:"op,omitempty" json:"op,omitempty"` @@ -209,7 +218,7 @@ func (msg configMessage) String() string { case subscriber: msgType = "subscriber" } - return fmt.Sprintf("Config msg name [%v], type [%v], op [%v]", msg.name, msgType, msgOp) + return fmt.Sprintf("config msg name [%v], type [%v], op [%v]", msg.name, msgType, msgOp) } var ( @@ -219,20 +228,36 @@ var ( ) func InitConfigFactory(f string, configMsgChan chan configMessage, subProvisionEndpt *SubProvisionEndpt, subProxyEndpt *SubProxyEndpt) error { - log.Println("Function called ", f) + logger.SimappLog.Infoln("function called", f) if content, err := os.ReadFile(f); err != nil { - log.Println("Readfile failed called ", err) + logger.SimappLog.Infoln("readfile failed called", err) return err } else { SimappConfig = Config{} if yamlErr := yaml.Unmarshal(content, &SimappConfig); yamlErr != nil { - log.Println("yaml parsing failed ", yamlErr) + logger.SimappLog.Errorln("yaml parsing failed", yamlErr) return yamlErr } } + + if SimappConfig.Logger.APP != nil { + if SimappConfig.Logger.APP.DebugLevel != "" { + if level, err := zapcore.ParseLevel(SimappConfig.Logger.APP.DebugLevel); err != nil { + logger.SimappLog.Warnf("Simapp log level [%s] is invalid, set to [info] level", + SimappConfig.Logger.APP.DebugLevel) + logger.SetLogLevel(zap.InfoLevel) + } else { + logger.SetLogLevel(level) + } + } else { + logger.SimappLog.Warnln("Simapp log level not set. Default set to [info] level") + logger.SetLogLevel(zap.InfoLevel) + } + } + if SimappConfig.Configuration == nil { - log.Println("Configuration Parsing Failed ", SimappConfig.Configuration) + logger.SimappLog.Infoln("configuration parsing failed", SimappConfig.Configuration) return nil } @@ -253,16 +278,12 @@ func InitConfigFactory(f string, configMsgChan chan configMessage, subProvisionE } } - log.Println("Subscriber Provision Endpoint:") - log.Println("Address ", SimappConfig.Configuration.SubProvisionEndpt.Addr) - log.Println("Port ", SimappConfig.Configuration.SubProvisionEndpt.Port) + logger.SimappLog.Infof("subscriber provision endpoint: %s:%s", SimappConfig.Configuration.SubProvisionEndpt.Addr, SimappConfig.Configuration.SubProvisionEndpt.Port) subProvisionEndpt.Addr = SimappConfig.Configuration.SubProvisionEndpt.Addr subProvisionEndpt.Port = SimappConfig.Configuration.SubProvisionEndpt.Port if SimappConfig.Configuration.SubProxyEndpt != nil && SimappConfig.Configuration.SubProxyEndpt.Addr != "" { - log.Println("Subscriber Proxy Endpoint:") - log.Println("Address ", SimappConfig.Configuration.SubProxyEndpt.Addr) - log.Println("Port ", SimappConfig.Configuration.SubProxyEndpt.Port) + logger.SimappLog.Infof("subscriber proxy endpoint: %s:%s", SimappConfig.Configuration.SubProxyEndpt.Addr, SimappConfig.Configuration.SubProxyEndpt.Port) subProxyEndpt.Addr = SimappConfig.Configuration.SubProxyEndpt.Addr subProxyEndpt.Port = SimappConfig.Configuration.SubProxyEndpt.Port } @@ -280,21 +301,21 @@ func InitConfigFactory(f string, configMsgChan chan configMessage, subProvisionE func syncConfig(w http.ResponseWriter, req *http.Request) { _, err := fmt.Fprintf(w, "OK\n") if err != nil { - log.Println(err) + logger.SimappLog.Errorln(err) } dispatchAllGroups(configMsgChan) dispatchAllNetworkSlices(configMsgChan) } func main() { - log.Println("SimApp started") + logger.SimappLog.Infoln("simApp started") configMsgChan = make(chan configMessage, 100) var subProvisionEndpt SubProvisionEndpt var subProxyEndpt SubProxyEndpt err := InitConfigFactory("./config/simapp.yaml", configMsgChan, &subProvisionEndpt, &subProxyEndpt) if err != nil { - log.Println(err) + logger.SimappLog.Errorln(err) } go sendMessage(configMsgChan, subProvisionEndpt, subProxyEndpt) @@ -308,7 +329,7 @@ func main() { err = http.ListenAndServe(":8080", nil) if err != nil { // Note: as per the `ListenAndServe` documentation: "ListenAndServe always returns a non-nil error." - log.Println(err) + logger.SimappLog.Errorln(err) } for { time.Sleep(100 * time.Second) @@ -331,7 +352,7 @@ func sendHttpReqMsg(req *http.Request) (*http.Response, error) { var retries uint = 0 body, err := io.ReadAll(req.Body) if err != nil { - log.Println(err) + logger.SimappLog.Errorln(err) } for { cloneReq := req.Clone(context.Background()) @@ -341,7 +362,7 @@ func sendHttpReqMsg(req *http.Request) (*http.Response, error) { retries += 1 if err != nil { nextInterval := getNextBackoffInterval(retries, 2) - log.Printf("http req send error [%v], retrying after %v sec...", err.Error(), nextInterval) + logger.SimappLog.Errorf("http req send error [%v], retrying after %d sec...", err, nextInterval) time.Sleep(time.Second * time.Duration(nextInterval)) continue } @@ -349,18 +370,18 @@ func sendHttpReqMsg(req *http.Request) (*http.Response, error) { if rsp.StatusCode == http.StatusAccepted || rsp.StatusCode == http.StatusOK || rsp.StatusCode == http.StatusNoContent || rsp.StatusCode == http.StatusCreated { - log.Println("config push success") + logger.SimappLog.Debugln("config push success") err = req.Body.Close() if err != nil { - log.Println(err) + logger.SimappLog.Errorln(err) } return rsp, nil } else { nextInterval := getNextBackoffInterval(retries, 2) - log.Printf("http rsp error [%v], retrying after [%v] sec...", http.StatusText(rsp.StatusCode), nextInterval) + logger.SimappLog.Infof("http rsp error [%v], retrying after %d sec...", http.StatusText(rsp.StatusCode), nextInterval) err = rsp.Body.Close() if err != nil { - log.Println(err) + logger.SimappLog.Infoln(err) } time.Sleep(time.Second * time.Duration(nextInterval)) } @@ -372,34 +393,32 @@ func sendMessage(msgChan chan configMessage, subProvisionEndpt SubProvisionEndpt var networkSliceHttpend string var subscriberHttpend string - log.Println("Subscriber Provision Endpoint in sendMessage:") - log.Println("Address ", subProvisionEndpt.Addr) - log.Println("Port ", subProvisionEndpt.Port) + logger.SimappLog.Infof("subscriber provision endpoint in sendMessage: %s:%s", subProvisionEndpt.Addr, subProvisionEndpt.Port) ip := strings.TrimSpace(subProvisionEndpt.Addr) - log.Println("webui running at ", ip) + logger.SimappLog.Infoln("webui running at", ip) devGroupHttpend = httpProtocol + ip + ":" + subProvisionEndpt.Port + "/config/v1/device-group/" - log.Println("device trigger http endpoint ", devGroupHttpend) + logger.SimappLog.Infoln("device trigger http endpoint", devGroupHttpend) networkSliceHttpend = httpProtocol + ip + ":" + subProvisionEndpt.Port + "/config/v1/network-slice/" - log.Println("network slice http endpoint ", devGroupHttpend) + logger.SimappLog.Infoln("network slice http endpoint", devGroupHttpend) subscriberHttpend = httpProtocol + ip + ":" + subProvisionEndpt.Port + "/api/subscriber/imsi-" - log.Println("subscriber http endpoint ", subscriberHttpend) + logger.SimappLog.Infoln("subscriber http endpoint", subscriberHttpend) baseDestUrl := subscriberHttpend if subProxyEndpt.Port != "" { ip := strings.TrimSpace(subProxyEndpt.Addr) devGroupHttpend = httpProtocol + ip + ":" + subProxyEndpt.Port + "/config/v1/device-group/" - log.Println("device trigger Proxy http endpoint ", devGroupHttpend) + logger.SimappLog.Infoln("device trigger Proxy http endpoint", devGroupHttpend) networkSliceHttpend = httpProtocol + ip + ":" + subProxyEndpt.Port + "/config/v1/network-slice/" - log.Println("network slice Proxy http endpoint ", devGroupHttpend) + logger.SimappLog.Infoln("network slice Proxy http endpoint", devGroupHttpend) subscriberHttpend = httpProtocol + ip + ":" + subProxyEndpt.Port + "/api/subscriber/imsi-" - log.Println("subscriber Proxy http endpoint ", subscriberHttpend) + logger.SimappLog.Infoln("subscriber Proxy http endpoint", subscriberHttpend) } for msg := range msgChan { var httpend string var destUrl string - log.Println("Received Message from Channel", msgChan, msg) + logger.SimappLog.Debugln("received message from channel", msg) switch msg.msgType { case device_group: httpend = devGroupHttpend + msg.name @@ -413,10 +432,10 @@ func sendMessage(msgChan chan configMessage, subProvisionEndpt SubProvisionEndpt var httpErr error for { if msg.msgOp == add_op { - log.Printf("Post Message [%v] to %v", msg.String(), httpend) + logger.SimappLog.Infof("post message [%v] to %v", msg.String(), httpend) req, err := http.NewRequestWithContext(context.Background(), http.MethodPost, httpend, msg.msgPtr) if err != nil { - log.Printf("An Error Occurred %v", err) + logger.SimappLog.Errorf("An Error Occurred %v", err) time.Sleep(1 * time.Second) continue } @@ -427,17 +446,17 @@ func sendMessage(msgChan chan configMessage, subProvisionEndpt SubProvisionEndpt } rsp, httpErr = sendHttpReqMsg(req) if httpErr != nil { - log.Printf("Post Message [%v] returned error [%v] ", httpend, httpErr.Error()) + logger.SimappLog.Errorf("post message [%v] returned error [%v]", httpend, httpErr.Error()) } - log.Printf("Message POST %v Success\n", rsp.StatusCode) + logger.SimappLog.Infof("message POST %v success", rsp.StatusCode) } else if msg.msgOp == modify_op { - log.Printf("Put Message [%v] to %v", msg.String(), httpend) + logger.SimappLog.Infof("put message [%v] to %v", msg.String(), httpend) req, err := http.NewRequestWithContext(context.Background(), http.MethodPut, httpend, msg.msgPtr) // Handle Error if err != nil { - log.Printf("An Error Occurred %v", err) + logger.SimappLog.Errorf("an error occurred %v", err) time.Sleep(1 * time.Second) continue } @@ -448,17 +467,17 @@ func sendMessage(msgChan chan configMessage, subProvisionEndpt SubProvisionEndpt } rsp, httpErr = sendHttpReqMsg(req) if httpErr != nil { - log.Printf("Put Message [%v] returned error [%v] ", httpend, httpErr.Error()) + logger.SimappLog.Errorf("put message [%v] returned error [%v]", httpend, httpErr.Error()) } - log.Printf("Message PUT %v Success\n", rsp.StatusCode) + logger.SimappLog.Infof("message PUT %v success", rsp.StatusCode) } else if msg.msgOp == delete_op { - log.Printf("Delete Message [%v] to %v", msg.String(), httpend) + logger.SimappLog.Infof("delete message [%v] to %v", msg.String(), httpend) req, err := http.NewRequestWithContext(context.Background(), http.MethodDelete, httpend, msg.msgPtr) // Handle Error if err != nil { - log.Printf("An Error Occurred %v", err) + logger.SimappLog.Errorf("an error occurred %v", err) time.Sleep(1 * time.Second) continue } @@ -469,13 +488,13 @@ func sendMessage(msgChan chan configMessage, subProvisionEndpt SubProvisionEndpt } rsp, httpErr = sendHttpReqMsg(req) if httpErr != nil { - log.Printf("Delete Message [%v] returned error [%v] ", httpend, httpErr.Error()) + logger.SimappLog.Errorf("delete message [%v] returned error [%v]", httpend, httpErr.Error()) } - log.Printf("Message DEL %v Success\n", rsp.StatusCode) + logger.SimappLog.Infof("message DEL %v success", rsp.StatusCode) } err := rsp.Body.Close() if err != nil { - log.Println(err) + logger.SimappLog.Errorln(err) } break } @@ -484,23 +503,23 @@ func sendMessage(msgChan chan configMessage, subProvisionEndpt SubProvisionEndpt func compareSubscriber(subscriberNew *Subscriber, subscriberOld *Subscriber) bool { if subscriberNew.PlmnId != subscriberOld.PlmnId { - log.Println("Plmn ID changed.") + logger.SimappLog.Infoln("plmn ID changed") return true } if subscriberNew.OPc != subscriberOld.OPc { - log.Println("OPc changed.") + logger.SimappLog.Infoln("OPc changed") return true } if subscriberNew.OP != subscriberOld.OP { - log.Println("OP changed.") + logger.SimappLog.Infoln("OP changed") return true } if subscriberNew.Key != subscriberOld.Key { - log.Println("Key changed.") + logger.SimappLog.Infoln("Key changed") return true } if subscriberNew.SequenceNumber != subscriberOld.SequenceNumber { - log.Println("SequenceNumber changed.") + logger.SimappLog.Infoln("SequenceNumber changed") return true } return false @@ -508,17 +527,17 @@ func compareSubscriber(subscriberNew *Subscriber, subscriberOld *Subscriber) boo func compareGroup(groupNew *DevGroup, groupOld *DevGroup) bool { if groupNew.IpDomainName != groupOld.IpDomainName { - log.Println("IP domain name changed.") + logger.SimappLog.Infoln("ip domain name changed") return true } if groupNew.SiteInfo != groupOld.SiteInfo { - log.Println("SIteInfo name changed.") + logger.SimappLog.Infoln("siteInfo name changed") return true } if len(groupNew.Imsis) != len(groupOld.Imsis) { - log.Println("number of Imsis changed.") + logger.SimappLog.Infoln("number of Imsis changed") return true } var allimsiNew string @@ -539,7 +558,7 @@ func compareGroup(groupNew *DevGroup, groupOld *DevGroup) bool { bs2 := h2.Sum(nil) strcode2 := hex.EncodeToString(bs2[:]) - log.Println("CODE1 and CODE2 ", strcode1, strcode2) + logger.SimappLog.Infof("CODE1: %s and CODE2: %s", strcode1, strcode2) if strcode2 != strcode1 { return true } @@ -587,7 +606,7 @@ func compareNetworkSlice(sliceNew *NetworkSlice, sliceOld *NetworkSlice) bool { } } if !found { - log.Println("new Dev Group added in slice ") + logger.SimappLog.Infoln("new dev group added in slice") return true // 2 network slices have some difference } } @@ -600,20 +619,20 @@ func compareNetworkSlice(sliceNew *NetworkSlice, sliceOld *NetworkSlice) bool { } } if !found { - log.Println("Dev Group Deleted in slice ") + logger.SimappLog.Infoln("dev group deleted in slice") return true // 2 network slices have some difference } } oldSite := sliceOld.SiteInfo newSite := sliceNew.SiteInfo if oldSite.SiteName != newSite.SiteName { - log.Println("site name changed ") + logger.SimappLog.Infoln("site name changed") return true } oldUpf := oldSite.Upf newUpf := newSite.Upf if (oldUpf.UpfName != newUpf.UpfName) && (oldUpf.UpfPort != newUpf.UpfPort) { - log.Println("Upf details changed") + logger.SimappLog.Infoln("upf details changed") return true } @@ -626,12 +645,12 @@ func compareNetworkSlice(sliceNew *NetworkSlice, sliceOld *NetworkSlice) bool { } } if !found { - log.Println("gnb changed in slice ") + logger.SimappLog.Infoln("gnb changed in slice") return true // change in slice details } } - log.Println("No change in slices ") + logger.SimappLog.Warnln("no change in slices") return false } @@ -645,31 +664,31 @@ func UpdateConfig(f string) error { return yamlErr } if NewSimappConfig.Configuration == nil { - log.Println("Configuration Parsing Failed ", NewSimappConfig.Configuration) + logger.SimappLog.Infoln("configuration parsing failed", NewSimappConfig.Configuration) return nil } - log.Println("Number of subscriber ranges in updated config", len(SimappConfig.Configuration.Subscriber)) + logger.SimappLog.Infoln("number of subscriber ranges in updated config", len(SimappConfig.Configuration.Subscriber)) var newImsiList []uint64 for o := 0; o < len(NewSimappConfig.Configuration.Subscriber); o++ { newSubscribers := NewSimappConfig.Configuration.Subscriber[o] - log.Println("Subscribers:") - log.Println(" UeIdStart", newSubscribers.UeIdStart) - log.Println(" UeIdEnd", newSubscribers.UeIdEnd) - log.Println(" PlmnId", newSubscribers.PlmnId) - log.Println(" OPc", newSubscribers.OPc) - log.Println(" OP", newSubscribers.OP) - log.Println(" Key", newSubscribers.Key) - log.Println(" SequenceNumber", newSubscribers.SequenceNumber) + logger.SimappLog.Infoln("Subscribers:") + logger.SimappLog.Infoln(" UeIdStart", newSubscribers.UeIdStart) + logger.SimappLog.Infoln(" UeIdEnd", newSubscribers.UeIdEnd) + logger.SimappLog.Infoln(" PlmnId", newSubscribers.PlmnId) + logger.SimappLog.Infoln(" OPc", newSubscribers.OPc) + logger.SimappLog.Infoln(" OP", newSubscribers.OP) + logger.SimappLog.Infoln(" Key", newSubscribers.Key) + logger.SimappLog.Infoln(" SequenceNumber", newSubscribers.SequenceNumber) newStart, err := strconv.Atoi(newSubscribers.UeIdStart) if err != nil { - log.Println("error in Atoi with UeIdStart", err) + logger.SimappLog.Errorln("error in Atoi with UeIdStart", err) continue } newEnd, err := strconv.Atoi(newSubscribers.UeIdEnd) if err != nil { - log.Println("error in Atoi with UeIdEnd", err) + logger.SimappLog.Errorln("error in Atoi with UeIdEnd", err) continue } for i := newStart; i <= newEnd; i++ { @@ -679,19 +698,19 @@ func UpdateConfig(f string) error { subscribers := SimappConfig.Configuration.Subscriber[s] start, err := strconv.Atoi(subscribers.UeIdStart) if err != nil { - log.Println("error in Atoi with UeIdStart", err) + logger.SimappLog.Errorln("error in Atoi with UeIdStart", err) continue } end, err := strconv.Atoi(subscribers.UeIdEnd) if err != nil { - log.Println("error in Atoi with UeIdEnd", err) + logger.SimappLog.Errorln("error in Atoi with UeIdEnd", err) continue } for j := start; j <= end; j++ { if i == j { // two subcribers' imsi are same found = true if compareSubscriber(newSubscribers, subscribers) { - log.Println("WARNING: subscriber provision not support modify yet!") + logger.SimappLog.Warnln("subscriber provision not support modify yet") } break } @@ -705,7 +724,7 @@ func UpdateConfig(f string) error { b, err := json.Marshal(newSubscribers) if err != nil { - log.Println("error in marshal with newSubscriber", err) + logger.SimappLog.Errorln("error in marshal with newSubscriber", err) continue } reqMsgBody := bytes.NewBuffer(b) @@ -722,12 +741,12 @@ func UpdateConfig(f string) error { subscribers := SimappConfig.Configuration.Subscriber[o] start, err := strconv.Atoi(subscribers.UeIdStart) if err != nil { - log.Println("error in Atoi with UeIdStart", err) + logger.SimappLog.Errorln("error in Atoi with UeIdStart", err) continue } end, err := strconv.Atoi(subscribers.UeIdEnd) if err != nil { - log.Println("error in Atoi with UeIdEnd", err) + logger.SimappLog.Errorln("error in Atoi with UeIdEnd", err) continue } for k := start; k <= end; k++ { @@ -738,10 +757,10 @@ func UpdateConfig(f string) error { } } if !has { - log.Println("going to delete subscriber: ", k) + logger.SimappLog.Infoln("going to delete subscriber:", k) b, err := json.Marshal("") if err != nil { - log.Println("error in marshal with subscriber", err) + logger.SimappLog.Infoln("error in marshal with subscriber", err) continue } reqMsgBody := bytes.NewBuffer(b) @@ -767,7 +786,7 @@ func UpdateConfig(f string) error { configChange := compareGroup(groupNew, groupOld) if configChange { // send Group Put - log.Println("Updated group config ", groupNew.Name) + logger.SimappLog.Infoln("updated group config", groupNew.Name) dispatchGroup(configMsgChan, groupNew, modify_op) // find all slices which are using this device group and mark them modified for _, slice := range SimappConfig.Configuration.NetworkSlice { @@ -779,7 +798,7 @@ func UpdateConfig(f string) error { } } } else { - log.Println("Config not updated for group ", groupNew.Name) + logger.SimappLog.Infoln("config not updated for group", groupNew.Name) } found = true groupOld.visited = true @@ -788,14 +807,14 @@ func UpdateConfig(f string) error { } if !found { // new Group - Send Post - log.Println("New group config ", groupNew.Name) + logger.SimappLog.Infoln("new group config", groupNew.Name) dispatchGroup(configMsgChan, groupNew, add_op) } } // visit all groups see if slice is deleted...if found = false for _, group := range SimappConfig.Configuration.DevGroup { if !group.visited { - log.Println("Group deleted ", group.Name) + logger.SimappLog.Infoln("group deleted", group.Name) dispatchGroup(configMsgChan, group, delete_op) // find all slices which are using this device group and mark them modified for _, slice := range SimappConfig.Configuration.NetworkSlice { @@ -822,15 +841,15 @@ func UpdateConfig(f string) error { if sliceNew.Name == sliceOld.Name { configChange := compareNetworkSlice(sliceNew, sliceOld) if sliceOld.modified { - log.Println("Updated slice config ", sliceNew.Name) + logger.SimappLog.Infoln("updated slice config", sliceNew.Name) sliceOld.modified = false dispatchNetworkSlice(configMsgChan, sliceNew, modify_op) } else if configChange { // send Slice Put - log.Println("Updated slice config ", sliceNew.Name) + logger.SimappLog.Infoln("updated slice config", sliceNew.Name) dispatchNetworkSlice(configMsgChan, sliceNew, modify_op) } else { - log.Println("Config not updated for slice ", sliceNew.Name) + logger.SimappLog.Infoln("config not updated for slice", sliceNew.Name) } found = true sliceOld.visited = true @@ -839,14 +858,14 @@ func UpdateConfig(f string) error { } if !found { // new Slice - Send Post - log.Println("New slice config ", sliceNew.Name) + logger.SimappLog.Infoln("new slice config", sliceNew.Name) dispatchNetworkSlice(configMsgChan, sliceNew, add_op) } } // visit all sliceOld see if slice is deleted...if found = false for _, slice := range SimappConfig.Configuration.NetworkSlice { if !slice.visited { - log.Println("Slice deleted ", slice.Name) + logger.SimappLog.Infoln("slice deleted", slice.Name) dispatchNetworkSlice(configMsgChan, slice, delete_op) } } @@ -858,47 +877,37 @@ func UpdateConfig(f string) error { func WatchConfig() { viper.WatchConfig() viper.OnConfigChange(func(e fsnotify.Event) { - log.Println("****Config file changed:", e.Name) + logger.SimappLog.Infoln("****config file changed:", e.Name) if err := UpdateConfig("config/simapp.yaml"); err != nil { - log.Println("error in loading updated configuration ", err) + logger.SimappLog.Errorln("error in loading updated configuration ", err) } else { - log.Println("****Successfully updated configuration****") + logger.SimappLog.Infoln("****successfully updated configuration****") } }) - log.Println("WatchConfig done") + logger.SimappLog.Infoln("watchConfig done") } func dispatchAllSubscribers(configMsgChan chan configMessage) { - log.Println("Number of subscriber ranges", len(SimappConfig.Configuration.Subscriber)) + logger.SimappLog.Infoln("number of subscriber ranges", len(SimappConfig.Configuration.Subscriber)) for o := 0; o < len(SimappConfig.Configuration.Subscriber); o++ { subscribers := SimappConfig.Configuration.Subscriber[o] - log.Println("Subscribers:") - log.Println(" UeIdStart", subscribers.UeIdStart) - log.Println(" UeIdEnd", subscribers.UeIdEnd) - log.Println(" PlmnId", subscribers.PlmnId) - log.Println(" OPc", subscribers.OPc) - log.Println(" OP", subscribers.OP) - log.Println(" Key", subscribers.Key) - log.Println(" SequenceNumber", subscribers.SequenceNumber) - + logger.SimappLog.Infof("Subscribers: UeIdStart: %s, UeIdEnd: %s, PlmnId: %s, OPc: %s, OP: %s, Key: %s, SequenceNumber: %s", subscribers.UeIdStart, subscribers.UeIdEnd, subscribers.PlmnId, subscribers.OPc, subscribers.OP, subscribers.Key, subscribers.SequenceNumber) start, err := strconv.Atoi(subscribers.UeIdStart) if err != nil { - log.Println("error in Atoi with UeIdStart", err) + logger.SimappLog.Errorln("error in Atoi with UeIdStart", err) continue } end, err := strconv.Atoi(subscribers.UeIdEnd) if err != nil { - log.Println("error in Atoi with UeIdEnd", err) + logger.SimappLog.Errorln("error in Atoi with UeIdEnd", err) continue } for i := start; i <= end; i++ { subscribers.UeId = fmt.Sprintf("%015d", i) - log.Println(" UeId", subscribers.UeId) - // subscribers.UeIdStart = "" - // subscribers.UeIdEnd = "" + logger.SimappLog.Debugln("UeId", subscribers.UeId) b, err := json.Marshal(subscribers) if err != nil { - log.Println("error in marshal with subscribers", err) + logger.SimappLog.Errorln("error in marshal with subscribers", err) continue } reqMsgBody := bytes.NewBuffer(b) @@ -913,28 +922,28 @@ func dispatchAllSubscribers(configMsgChan chan configMessage) { } func dispatchGroup(configMsgChan chan configMessage, group *DevGroup, msgOp int) { - log.Println("Group Name ", group.Name) - log.Println(" Site Name ", group.SiteInfo) - log.Println(" Imsis ", group.Imsis) + logger.SimappLog.Infoln("group name", group.Name) + logger.SimappLog.Infoln(" site name", group.SiteInfo) + logger.SimappLog.Infoln(" imsis", group.Imsis) for im := 0; im < len(group.Imsis); im++ { - log.Println(" IMSI ", group.Imsis[im]) + logger.SimappLog.Debugln(" IMSI", group.Imsis[im]) } - log.Println(" IpDomainName ", group.IpDomainName) + logger.SimappLog.Infoln(" IpDomainName", group.IpDomainName) ipDomain := group.IpDomain if group.IpDomain != nil { - log.Println(" IpDomain Dnn ", ipDomain.Dnn) - log.Println(" IpDomain Dns Primary ", ipDomain.DnsPrimary) - log.Println(" IpDomain Mtu ", ipDomain.Mtu) - log.Println(" IpDomain UePool ", ipDomain.UePool) + logger.SimappLog.Infoln(" IpDomain Dnn", ipDomain.Dnn) + logger.SimappLog.Infoln(" IpDomain Dns Primary", ipDomain.DnsPrimary) + logger.SimappLog.Infoln(" IpDomain Mtu", ipDomain.Mtu) + logger.SimappLog.Infoln(" IpDomain UePool", ipDomain.UePool) } b, err := json.Marshal(group) if err != nil { - log.Println("error in marshal ", err) + logger.SimappLog.Errorln("error in marshal", err) return } reqMsgBody := bytes.NewBuffer(b) if !SimappConfig.Configuration.ConfigSlice { - log.Println("Don't configure network slice ") + logger.SimappLog.Warnln("do not configure network slice") return } var msg configMessage @@ -946,39 +955,39 @@ func dispatchGroup(configMsgChan chan configMessage, group *DevGroup, msgOp int) } func dispatchAllGroups(configMsgChan chan configMessage) { - log.Println("Number of device Groups ", len(SimappConfig.Configuration.DevGroup)) + logger.SimappLog.Infoln("number of device groups", len(SimappConfig.Configuration.DevGroup)) for _, group := range SimappConfig.Configuration.DevGroup { dispatchGroup(configMsgChan, group, add_op) } } func dispatchNetworkSlice(configMsgChan chan configMessage, slice *NetworkSlice, msgOp int) { - log.Println(" Slice Name : ", slice.Name) - log.Printf(" Slice sst %v, sd %v", slice.SliceId.Sst, slice.SliceId.Sd) - log.Println(" Slice site info ", slice.SiteInfo) + logger.SimappLog.Infoln(" Slice Name:", slice.Name) + logger.SimappLog.Infof(" Slice sst %v, sd %v", slice.SliceId.Sst, slice.SliceId.Sd) + logger.SimappLog.Infoln(" Slice site info", slice.SiteInfo) site := slice.SiteInfo - log.Println(" Slice site name ", site.SiteName) - log.Println(" Slice gNB ", len(site.Gnb)) + logger.SimappLog.Infoln(" Slice site name", site.SiteName) + logger.SimappLog.Infoln(" Slice gNB", len(site.Gnb)) for e := 0; e < len(site.Gnb); e++ { - log.Printf(" Slice gNB[%v] = %v \n", e, site.Gnb[e]) + logger.SimappLog.Infof(" Slice gNB[%v] = %s, tac: %d", e, site.Gnb[e].Name, site.Gnb[e].Tac) } - log.Println(" Slice Plmn ", site.Plmn) - log.Println(" Slice Upf ", site.Upf) + logger.SimappLog.Infoln(" Slice Plmn", site.Plmn) + logger.SimappLog.Infoln(" Slice Upf", site.Upf) - log.Println(" Slice Device Groups ", slice.DevGroups) + logger.SimappLog.Infoln(" Slice Device Groups", slice.DevGroups) for im := 0; im < len(slice.DevGroups); im++ { - log.Println(" Attached Device Groups ", slice.DevGroups[im]) + logger.SimappLog.Infoln(" Attached Device Groups", slice.DevGroups[im]) } b, err := json.Marshal(slice) if err != nil { - log.Println("error in marshal ", err) + logger.SimappLog.Errorln("error in marshal", err) return } reqMsgBody := bytes.NewBuffer(b) if !SimappConfig.Configuration.ConfigSlice { - log.Println("Don't configure network slice ") + logger.SimappLog.Warnln("Do not configure network slice") return } var msg configMessage @@ -990,7 +999,7 @@ func dispatchNetworkSlice(configMsgChan chan configMessage, slice *NetworkSlice, } func dispatchAllNetworkSlices(configMsgChan chan configMessage) { - log.Println("Number of network Slices ", len(SimappConfig.Configuration.NetworkSlice)) + logger.SimappLog.Infoln("number of network slices", len(SimappConfig.Configuration.NetworkSlice)) for _, slice := range SimappConfig.Configuration.NetworkSlice { dispatchNetworkSlice(configMsgChan, slice, add_op) }