From abc35e9c26a947d498940a312b776b905ceb5141 Mon Sep 17 00:00:00 2001 From: alex Date: Fri, 17 Feb 2023 08:35:28 +0100 Subject: [PATCH] changed logger to go-cnj-helper logger --- go.mod | 24 +++++++----- go.sum | 62 ++++++++++++++++++++++++++----- main.go | 8 +--- modules/config/config.go | 6 +-- modules/image/image.go | 22 +++++------ modules/scylladb/scylladb.go | 6 +-- routers/api/v1/user/useravatar.go | 12 +++--- 7 files changed, 91 insertions(+), 49 deletions(-) diff --git a/go.mod b/go.mod index adc293e..dcf7b46 100644 --- a/go.mod +++ b/go.mod @@ -2,27 +2,31 @@ module clickandjoin.app/storageserver go 1.19 +require ( + git.clickandjoin.umbach.dev/ClickandJoin/go-cnj-helper v1.0.36 + github.com/gocql/gocql v1.3.1 + github.com/gofiber/fiber/v2 v2.40.1 + github.com/google/uuid v1.3.0 + github.com/h2non/bimg v1.1.9 + github.com/scylladb/gocqlx/v2 v2.7.0 + gopkg.in/yaml.v2 v2.4.0 +) + require ( github.com/andybalholm/brotli v1.0.4 // indirect - github.com/gocql/gocql v1.3.1 // indirect - github.com/gofiber/fiber/v2 v2.40.1 // indirect github.com/golang/snappy v0.0.4 // indirect - github.com/google/uuid v1.3.0 // indirect - github.com/h2non/bimg v1.1.9 // indirect github.com/hailocab/go-hostpool v0.0.0-20160125115350-e80d13ce29ed // indirect github.com/klauspost/compress v1.15.9 // indirect - github.com/kolesa-team/go-webp v1.0.2 // indirect github.com/mattn/go-colorable v0.1.13 // indirect - github.com/mattn/go-isatty v0.0.16 // indirect + github.com/mattn/go-isatty v0.0.17 // indirect github.com/mattn/go-runewidth v0.0.14 // indirect + github.com/rabbitmq/amqp091-go v1.5.0 // indirect github.com/rivo/uniseg v0.2.0 // indirect + github.com/rs/zerolog v1.29.0 // indirect github.com/scylladb/go-reflectx v1.0.1 // indirect - github.com/scylladb/gocqlx/v2 v2.7.0 // indirect - github.com/sirupsen/logrus v1.9.0 // indirect github.com/valyala/bytebufferpool v1.0.0 // indirect github.com/valyala/fasthttp v1.41.0 // indirect github.com/valyala/tcplisten v1.0.0 // indirect - golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab // indirect + golang.org/x/sys v0.5.0 // indirect gopkg.in/inf.v0 v0.9.1 // indirect - gopkg.in/yaml.v2 v2.4.0 // indirect ) diff --git a/go.sum b/go.sum index 27e8fda..628c7b7 100644 --- a/go.sum +++ b/go.sum @@ -1,16 +1,22 @@ +git.clickandjoin.umbach.dev/ClickandJoin/go-cnj-helper v1.0.36 h1:tqx39cmvtID3lbjvUbN6Vv2Xt16fXQSwnxiw4esMqnQ= +git.clickandjoin.umbach.dev/ClickandJoin/go-cnj-helper v1.0.36/go.mod h1:RnqJsFYGR0cdxbeQjB1dDlr/MeKgnMkc7XoZtFDhMbo= github.com/andybalholm/brotli v1.0.4 h1:V7DdXeJtZscaqfNuAdSRuRFzuiKlHSC/Zh3zl9qY3JY= github.com/andybalholm/brotli v1.0.4/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig= +github.com/bitly/go-hostpool v0.0.0-20171023180738-a3a6125de932 h1:mXoPYz/Ul5HYEDvkta6I8/rnYM5gSdSV2tJ6XbZuEtY= github.com/bitly/go-hostpool v0.0.0-20171023180738-a3a6125de932/go.mod h1:NOuUCSz6Q9T7+igc/hlvDOUdtWKryOrtFyIVABv/p7k= +github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869 h1:DDGfHa7BWjL4YnC6+E63dPcxHo2sUxDIu8g3QgEJdRY= github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869/go.mod h1:Ekp36dRnpXw/yCqJaO+ZrUyxD+3VXMFFr56k5XYrpB4= +github.com/coreos/go-systemd/v22 v22.3.3-0.20220203105225-a9a7ef127534/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= 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/gocql/gocql v1.3.1 h1:BTwM4rux+ah5G3oH6/MQa+tur/TDd/XAAOXDxBBs7rg= github.com/gocql/gocql v1.3.1/go.mod h1:3gM2c4D3AnkISwBxGnMMsS8Oy4y2lhbPRsH4xnJrHG8= +github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/gofiber/fiber/v2 v2.40.1 h1:pc7n9VVpGIqNsvg9IPLQhyFEMJL8gCs1kneH5D1pIl4= github.com/gofiber/fiber/v2 v2.40.1/go.mod h1:Gko04sLksnHbzLSRBFWPFdzM9Ws9pRxvvIaohJK1dsk= github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM= github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= +github.com/google/go-cmp v0.5.4 h1:L8R9j+yAqZuZjsqh/z+F1NCffTKKLShY6zXTItVIZ8M= github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/h2non/bimg v1.1.9 h1:WH20Nxko9l/HFm4kZCA3Phbgu2cbHvYzxwxn9YROEGg= @@ -19,26 +25,33 @@ github.com/hailocab/go-hostpool v0.0.0-20160125115350-e80d13ce29ed h1:5upAirOpQc github.com/hailocab/go-hostpool v0.0.0-20160125115350-e80d13ce29ed/go.mod h1:tMWxXQ9wFIaZeTI9F+hmhFiGpFmhOHzyShyFUhRm0H4= github.com/klauspost/compress v1.15.9 h1:wKRjX6JRtDdrE9qwa4b/Cip7ACOshUI4smpCQanqjSY= github.com/klauspost/compress v1.15.9/go.mod h1:PhcZ0MbTNciWF3rruxRgKxI5NkcHHrHUDtV4Yw2GlzU= -github.com/kolesa-team/go-webp v1.0.2 h1:XCrWqxI7tNOI3dr0YufD9TUb+54vBDogg9KsHH7q5Lc= -github.com/kolesa-team/go-webp v1.0.2/go.mod h1:oMvdivD6K+Q5qIIkVC2w4k2ZUnI1H+MyP7inwgWq9aA= +github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= -github.com/mattn/go-isatty v0.0.16 h1:bq3VjFmv/sOjHtdEhmkEV4x1AJtvUvOJ2PFAZ5+peKQ= +github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= +github.com/mattn/go-isatty v0.0.17 h1:BTarxUcIeDqL27Mc+vyvdWYSL28zpIhv3RoTdsLMPng= +github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mattn/go-runewidth v0.0.14 h1:+xnbZSEeDbOIg5/mE6JF0w6n9duR1l3/WmbinWVwUuU= github.com/mattn/go-runewidth v0.0.14/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= +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/rabbitmq/amqp091-go v1.5.0 h1:VouyHPBu1CrKyJVfteGknGOGCzmOz0zcv/tONLkb7rg= +github.com/rabbitmq/amqp091-go v1.5.0/go.mod h1:JsV0ofX5f1nwOGafb8L5rBItt9GyhfQfcJj+oyz0dGg= github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY= github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= +github.com/rs/xid v1.4.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= +github.com/rs/zerolog v1.29.0 h1:Zes4hju04hjbvkVkOhdl2HpZa+0PmVwigmo8XoORE5w= +github.com/rs/zerolog v1.29.0/go.mod h1:NILgTygv/Uej1ra5XxGf82ZFSLk58MFGAUS2o6usyD0= github.com/scylladb/go-reflectx v1.0.1 h1:b917wZM7189pZdlND9PbIJ6NQxfDPfBvUaQ7cjj1iZQ= github.com/scylladb/go-reflectx v1.0.1/go.mod h1:rWnOfDIRWBGN0miMLIcoPt/Dhi2doCMZqwMCJ3KupFc= github.com/scylladb/gocqlx/v2 v2.7.0 h1:/w1VeJHCEAsg9eTculTvIS9eIe/VmEu0clhlH1CF7lc= github.com/scylladb/gocqlx/v2 v2.7.0/go.mod h1:jKhM0/LkEAhEOSwd10TCMQdlC5x8aEzK7cXjQcPyMJ0= -github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0= -github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= 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= @@ -48,24 +61,53 @@ github.com/valyala/fasthttp v1.41.0 h1:zeR0Z1my1wDHTRiamBCXVglQdbUwgb9uWG3k1HQz6 github.com/valyala/fasthttp v1.41.0/go.mod h1:f6VbjjoI3z1NDOZOv17o6RvtRSWxC77seBFc2uWtgiY= github.com/valyala/tcplisten v1.0.0 h1:rBHj/Xf+E1tRGZyWIWwJDiRY0zc1Js+CV5DqwacVSA8= github.com/valyala/tcplisten v1.0.0/go.mod h1:T0xQ8SeCZGxckz9qRXTfG43PvQ/mcWh7FwZEA7Ioqkc= +github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= +go.uber.org/goleak v1.1.12 h1:gZAh5/EyT/HQwlpkCy6wTpqfH9H8Lz8zbm3dZh+OyzA= +go.uber.org/goleak v1.1.12/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20220214200702-86341886e292/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/image v0.0.0-20210628002857-a66eb6448b8d/go.mod h1:023OzeP/+EPmXeapQh35lcL3II3LrY8Ic+EFFKVhULM= +golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20220906165146-f3363e06e74c/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20210220032951-036812b2e83c h1:5KslGYwFpkhGh+Q16bwMP3cOontH8FOep7tGV86Y7SQ= +golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 h1:0A+M6Uqn+Eje4kHMK80dtF3JCXC4ykBgQG4Fe06QRhQ= -golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab h1:2QkjZIsXupsJbJIdSjjUOgWK3aEtzyuh2mPt3l/CkeU= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU= +golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc= gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= diff --git a/main.go b/main.go index e59bdee..387f2fe 100644 --- a/main.go +++ b/main.go @@ -21,20 +21,16 @@ import ( "clickandjoin.app/storageserver/modules/config" "clickandjoin.app/storageserver/modules/scylladb" "clickandjoin.app/storageserver/routers/router" + gocnjhelper "git.clickandjoin.umbach.dev/ClickandJoin/go-cnj-helper" "github.com/gofiber/fiber/v2" "github.com/gofiber/fiber/v2/middleware/cors" "github.com/gofiber/fiber/v2/middleware/logger" - "github.com/sirupsen/logrus" ) func init() { config.LoadConfig() - if config.Cfg.Debug { - logrus.SetLevel(logrus.DebugLevel) - } - - logrus.Println("Debug:", config.Cfg.Debug) + gocnjhelper.InitLogger(config.Cfg.Debug, true, true) scylladb.InitDatabase() } diff --git a/modules/config/config.go b/modules/config/config.go index 2f153a5..02db7ce 100644 --- a/modules/config/config.go +++ b/modules/config/config.go @@ -3,7 +3,7 @@ package config import ( "os" - "github.com/sirupsen/logrus" + gocnjhelper "git.clickandjoin.umbach.dev/ClickandJoin/go-cnj-helper" "gopkg.in/yaml.v2" ) @@ -27,10 +27,10 @@ func LoadConfig() { data, err := os.ReadFile("config.yml") if err != nil { - logrus.Fatalln("Failed to read config file, err:", err) + gocnjhelper.LogFatalf("Failed to read config file, err: %s", err) } if err := yaml.Unmarshal(data, &Cfg); err != nil { - logrus.Fatalln("Failed to unmarshal config file, err:", err) + gocnjhelper.LogFatalf("Failed to unmarshal config file, err: %s", err) } } diff --git a/modules/image/image.go b/modules/image/image.go index 7ca833b..5aff604 100644 --- a/modules/image/image.go +++ b/modules/image/image.go @@ -8,8 +8,8 @@ import ( "strconv" "clickandjoin.app/storageserver/modules/utils" + gocnjhelper "git.clickandjoin.umbach.dev/ClickandJoin/go-cnj-helper" "github.com/h2non/bimg" - "github.com/sirupsen/logrus" ) // is specified in the form data of the frontend @@ -46,7 +46,7 @@ func createUserFolder(userId string) error { err = os.Mkdir(path, os.ModePerm) if err != nil && !errors.Is(err, os.ErrExist) { - logrus.Errorln("Failed to create user folder, err:", err) + gocnjhelper.LogErrorf("Failed to create user folder, err: %s", err) return err } } @@ -63,14 +63,14 @@ func SaveImage(fileHeader *multipart.FileHeader, userId string, imagePath string f, err := fileHeader.Open() if err != nil { - logrus.Errorln("Failed to open file header, err:", err) + gocnjhelper.LogErrorf("Failed to open file header, err: %s", err) return err } fileData, err := io.ReadAll(f) if err != nil { - logrus.Errorln("Failed to read file, err:", err) + gocnjhelper.LogErrorf("Failed to read file, err: %s", err) return err } @@ -78,7 +78,7 @@ func SaveImage(fileHeader *multipart.FileHeader, userId string, imagePath string size, err := bimg.NewImage(fileData).Size() if err != nil { - logrus.Errorln("Failed to get image size, err:", err) + gocnjhelper.LogErrorf("Failed to get image size, err: %s", err) return err } @@ -102,7 +102,7 @@ func SaveImage(fileHeader *multipart.FileHeader, userId string, imagePath string newImage, err = bimg.NewImage(fileData).Convert(bimg.JPEG) if err != nil { - logrus.Errorln("Failed to convert image to png, err:", err) + gocnjhelper.LogErrorf("Failed to convert image to png, err: %s", err) return err } } @@ -114,14 +114,14 @@ func SaveImage(fileHeader *multipart.FileHeader, userId string, imagePath string }) if err != nil { - logrus.Errorln("Failed to process image, err:", err) + gocnjhelper.LogErrorf("Failed to process image, err: %s", err) return err } err = bimg.Write(imagePath+".webp", newImage) if err != nil { - logrus.Errorln("Failed to save image, err:", err) + gocnjhelper.LogErrorf("Failed to save image, err: %s", err) return err } @@ -138,7 +138,7 @@ func GetImage(userId string, fileName string, imageSize string) ([]byte, error) buffer, err := bimg.Read(utils.GetUserStoragePath(userId) + fileName) if err != nil { - logrus.Errorln("Failed to read image, err:", err) + gocnjhelper.LogErrorf("Failed to read image, err: %s", err) return []byte{}, err } @@ -152,7 +152,7 @@ func GetImage(userId string, fileName string, imageSize string) ([]byte, error) newImage, err := bimg.NewImage(buffer).ForceResize(resolution, resolution) if err != nil { - logrus.Errorln("Failed to force resize, err:", err) + gocnjhelper.LogErrorf("Failed to force resize, err: %s", err) return []byte{}, err } @@ -165,7 +165,7 @@ func DeleteOldAvatarImage(userId string) error { dir, err := os.ReadDir(path) if err != nil && !errors.Is(err, os.ErrNotExist) { - logrus.Errorln("Failed to read dir, err:", err) + gocnjhelper.LogErrorf("Failed to read dir, err: %s", err) return err } diff --git a/modules/scylladb/scylladb.go b/modules/scylladb/scylladb.go index fb47c96..2bff828 100644 --- a/modules/scylladb/scylladb.go +++ b/modules/scylladb/scylladb.go @@ -2,9 +2,9 @@ package scylladb import ( "clickandjoin.app/storageserver/modules/config" + gocnjhelper "git.clickandjoin.umbach.dev/ClickandJoin/go-cnj-helper" "github.com/gocql/gocql" "github.com/scylladb/gocqlx/v2" - "github.com/sirupsen/logrus" ) var Session gocqlx.Session @@ -25,8 +25,8 @@ func InitDatabase() { Session, err = gocqlx.WrapSession(Cluster.CreateSession()) if err != nil { - logrus.Fatal(err) + gocnjhelper.LogFatalf(err.Error()) } - logrus.Info("Database connected") + gocnjhelper.LogDebug("Database connected") } diff --git a/routers/api/v1/user/useravatar.go b/routers/api/v1/user/useravatar.go index 629f295..df5d23e 100644 --- a/routers/api/v1/user/useravatar.go +++ b/routers/api/v1/user/useravatar.go @@ -5,9 +5,9 @@ import ( "clickandjoin.app/storageserver/modules/scylladb" "clickandjoin.app/storageserver/modules/structs" "clickandjoin.app/storageserver/modules/utils" + gocnjhelper "git.clickandjoin.umbach.dev/ClickandJoin/go-cnj-helper" "github.com/gofiber/fiber/v2" "github.com/google/uuid" - "github.com/sirupsen/logrus" ) func GetAvatar(c *fiber.Ctx) error { @@ -33,7 +33,7 @@ func GetAvatar(c *fiber.Ctx) error { userId := c.Params("userId") if len(userId) != structs.LenUserId { - logrus.Debugln("UserId is longer than allowed") + gocnjhelper.LogDebug("UserId is longer than allowed") return c.SendStatus(fiber.StatusUnprocessableEntity) } @@ -41,7 +41,7 @@ func GetAvatar(c *fiber.Ctx) error { // check if the filename length has not been manipulated by the user if len(fileName) > image.MaxFileNameLen { - logrus.Debugln("Filename is longer than allowed") + gocnjhelper.LogDebug("Filename is longer than allowed") return c.SendStatus(fiber.StatusUnprocessableEntity) } @@ -102,14 +102,14 @@ func UpdateAvatar(c *fiber.Ctx) error { q := scylladb.Session.Query(scylladb.Sessions.Get("user_id")).BindStruct(foundSession) if err := q.GetRelease(&foundSession); err != nil { - logrus.Errorln("Failed to get user session, err:", err) + gocnjhelper.LogErrorf("Failed to get user session, err: %s", err) return c.SendStatus(fiber.StatusUnauthorized) } file, err := c.FormFile(image.FormFileKey) if err != nil { - logrus.Errorln("Failed to get form file, err:", err) + gocnjhelper.LogErrorf("Failed to get form file, err: %s", err) return c.SendStatus(fiber.StatusBadRequest) } @@ -145,7 +145,7 @@ func UpdateAvatar(c *fiber.Ctx) error { q = scylladb.Session.Query(scylladb.Users.Update("avatar_url")).BindStruct(user) if err := q.ExecRelease(); err != nil { - logrus.Errorln("Failed to update user avatar url, err:", err) + gocnjhelper.LogErrorf("Failed to update user avatar url, err: %s", err) return c.SendStatus(fiber.StatusInternalServerError) }