This is an automated email from the ASF dual-hosted git repository.

wusheng pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/skywalking-rover.git


The following commit(s) were added to refs/heads/main by this push:
     new 780978b  Introduce Log module (#2)
780978b is described below

commit 780978b85f19c1bc02a3b7d85298588c5f1825ab
Author: mrproliu <[email protected]>
AuthorDate: Sat Feb 19 19:59:32 2022 +0800

    Introduce Log module (#2)
---
 .github/workflows/build-and-test.yaml              | 11 +++++-
 cmd/roverd.go                                      |  6 ++-
 dist/LICENSE                                       | 28 ++++++++++++++
 .../license-github.com-davecgh-go-spew.txt         | 15 ++++++++
 .../license-github.com-pmezard-go-difflib.txt      | 27 ++++++++++++++
 .../license-github.com-sirupsen-logrus.txt         | 21 +++++++++++
 .../license-github.com-stretchr-testify.txt        | 22 +++++++++++
 dist/licenses/license-golang.org-x-sys.txt         | 27 ++++++++++++++
 go.mod                                             |  4 ++
 go.sum                                             | 10 +++++
 cmd/roverd.go => pkg/logger/logger.go              | 43 ++++++++++++++++++++--
 cmd/roverd.go => pkg/logger/settings.go            | 27 ++++++++++++--
 12 files changed, 230 insertions(+), 11 deletions(-)

diff --git a/.github/workflows/build-and-test.yaml 
b/.github/workflows/build-and-test.yaml
index 9640493..2233088 100644
--- a/.github/workflows/build-and-test.yaml
+++ b/.github/workflows/build-and-test.yaml
@@ -54,4 +54,13 @@ jobs:
         run: make test
       - name: Check CI Consistency
         if: matrix.go-version == '1.17' && matrix.runner == 'ubuntu'
-        run: make check
\ No newline at end of file
+        run: make check
+
+  result:
+    name: Build and Test
+    runs-on: ubuntu-latest
+    timeout-minutes: 30
+    needs: [ build ]
+    steps:
+      - name: Build Result
+        run: echo "Just to make the GitHub merge button green"
\ No newline at end of file
diff --git a/cmd/roverd.go b/cmd/roverd.go
index 41b5368..3a05f59 100644
--- a/cmd/roverd.go
+++ b/cmd/roverd.go
@@ -17,8 +17,10 @@
 
 package main
 
-import "fmt"
+import (
+       "github.com/apache/skywalking-rover/pkg/logger"
+)
 
 func main() {
-       fmt.Printf("OK")
+       logger.GetLogger("roverd").Infof("OK")
 }
diff --git a/dist/LICENSE b/dist/LICENSE
index 1c29226..ad49145 100644
--- a/dist/LICENSE
+++ b/dist/LICENSE
@@ -208,3 +208,31 @@ notices and license terms. Your use of the source code for 
the these
 subcomponents is subject to the terms and conditions of the following
 licenses.
 
+========================================================================
+MIT licenses
+========================================================================
+
+The following components are provided under the MIT License. See project link 
for details.
+The text of each license is also included at licenses/license-[project].txt.
+
+    github.com-sirupsen-logrus v1.8.1 https://github.com/sirupsen/logrus MIT
+    github.com-stretchr-testify v1.2.2 https://github.com/stretchr/testify MIT
+
+========================================================================
+BSD licenses
+========================================================================
+
+The following components are provided under a BSD license. See project link 
for details.
+The text of each license is also included at licenses/license-[project].txt.
+
+    golang.org-x-sys v0.0.0 https://golang.org/x/sys BSD-3-Clause
+    github.com-pmezard-go-difflib v1.0.0 https://github.com/pmezard/go-difflib 
BSD-3-Clause
+
+========================================================================
+ISC Licenses
+========================================================================
+
+The following components are provided under the ISC license. See project link 
for details.
+The text of each license is also included at licenses/license-[project].txt.
+
+    github.com-davecgh-go-spew v1.1.1 https://github.com/davecgh/go-spew ISC
\ No newline at end of file
diff --git a/dist/licenses/license-github.com-davecgh-go-spew.txt 
b/dist/licenses/license-github.com-davecgh-go-spew.txt
new file mode 100644
index 0000000..bc52e96
--- /dev/null
+++ b/dist/licenses/license-github.com-davecgh-go-spew.txt
@@ -0,0 +1,15 @@
+ISC License
+
+Copyright (c) 2012-2016 Dave Collins <[email protected]>
+
+Permission to use, copy, modify, and/or distribute this software for any
+purpose with or without fee is hereby granted, provided that the above
+copyright notice and this permission notice appear in all copies.
+
+THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
diff --git a/dist/licenses/license-github.com-pmezard-go-difflib.txt 
b/dist/licenses/license-github.com-pmezard-go-difflib.txt
new file mode 100644
index 0000000..c67dad6
--- /dev/null
+++ b/dist/licenses/license-github.com-pmezard-go-difflib.txt
@@ -0,0 +1,27 @@
+Copyright (c) 2013, Patrick Mezard
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+    Redistributions of source code must retain the above copyright
+notice, this list of conditions and the following disclaimer.
+    Redistributions in binary form must reproduce the above copyright
+notice, this list of conditions and the following disclaimer in the
+documentation and/or other materials provided with the distribution.
+    The names of its contributors may not be used to endorse or promote
+products derived from this software without specific prior written
+permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/dist/licenses/license-github.com-sirupsen-logrus.txt 
b/dist/licenses/license-github.com-sirupsen-logrus.txt
new file mode 100644
index 0000000..f090cb4
--- /dev/null
+++ b/dist/licenses/license-github.com-sirupsen-logrus.txt
@@ -0,0 +1,21 @@
+The MIT License (MIT)
+
+Copyright (c) 2014 Simon Eskildsen
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
diff --git a/dist/licenses/license-github.com-stretchr-testify.txt 
b/dist/licenses/license-github.com-stretchr-testify.txt
new file mode 100644
index 0000000..473b670
--- /dev/null
+++ b/dist/licenses/license-github.com-stretchr-testify.txt
@@ -0,0 +1,22 @@
+Copyright (c) 2012 - 2013 Mat Ryer and Tyler Bunnell
+
+Please consider promoting this project if you find it useful.
+
+Permission is hereby granted, free of charge, to any person 
+obtaining a copy of this software and associated documentation 
+files (the "Software"), to deal in the Software without restriction, 
+including without limitation the rights to use, copy, modify, merge, 
+publish, distribute, sublicense, and/or sell copies of the Software, 
+and to permit persons to whom the Software is furnished to do so, 
+subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 
+OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 
+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 
+DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT 
+OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE 
+OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/dist/licenses/license-golang.org-x-sys.txt 
b/dist/licenses/license-golang.org-x-sys.txt
new file mode 100644
index 0000000..6a66aea
--- /dev/null
+++ b/dist/licenses/license-golang.org-x-sys.txt
@@ -0,0 +1,27 @@
+Copyright (c) 2009 The Go Authors. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+   * Redistributions of source code must retain the above copyright
+notice, this list of conditions and the following disclaimer.
+   * Redistributions in binary form must reproduce the above
+copyright notice, this list of conditions and the following disclaimer
+in the documentation and/or other materials provided with the
+distribution.
+   * Neither the name of Google Inc. nor the names of its
+contributors may be used to endorse or promote products derived from
+this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/go.mod b/go.mod
index b9d0f10..85344f0 100644
--- a/go.mod
+++ b/go.mod
@@ -1,3 +1,7 @@
 module github.com/apache/skywalking-rover
 
 go 1.17
+
+require github.com/sirupsen/logrus v1.8.1
+
+require golang.org/x/sys v0.0.0-20191026070338-33540a1f6037 // indirect
diff --git a/go.sum b/go.sum
new file mode 100644
index 0000000..59bd790
--- /dev/null
+++ b/go.sum
@@ -0,0 +1,10 @@
+github.com/davecgh/go-spew v1.1.1 
h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
+github.com/davecgh/go-spew v1.1.1/go.mod 
h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
+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/sirupsen/logrus v1.8.1 
h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE=
+github.com/sirupsen/logrus v1.8.1/go.mod 
h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
+github.com/stretchr/testify v1.2.2 
h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w=
+github.com/stretchr/testify v1.2.2/go.mod 
h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
+golang.org/x/sys v0.0.0-20191026070338-33540a1f6037 
h1:YyJpGZS1sBuBCzLAR1VEpK193GlqGZbnPFnPV/5Rsb4=
+golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod 
h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
diff --git a/cmd/roverd.go b/pkg/logger/logger.go
similarity index 55%
copy from cmd/roverd.go
copy to pkg/logger/logger.go
index 41b5368..5434a96 100644
--- a/cmd/roverd.go
+++ b/pkg/logger/logger.go
@@ -15,10 +15,45 @@
 // specific language governing permissions and limitations
 // under the License.
 
-package main
+package logger
 
-import "fmt"
+import (
+       "strings"
+       "sync"
 
-func main() {
-       fmt.Printf("OK")
+       "github.com/sirupsen/logrus"
+)
+
+var (
+       root = initializeDefaultLogger()
+       once sync.Once
+)
+
+type Config struct {
+       Level string
+}
+
+type Logger struct {
+       *logrus.Entry
+       module []string
+}
+
+// SetupLogger when Bootstrap
+func SetupLogger(config *Config) (err error) {
+       once.Do(func() {
+               err = updateLogger(root, config)
+       })
+       if err != nil {
+               return err
+       }
+       return nil
+}
+
+// GetLogger for the module
+func GetLogger(modules ...string) *Logger {
+       moduleString := ""
+       if len(modules) > 0 {
+               moduleString = strings.Join(modules, ".")
+       }
+       return &Logger{Entry: root.WithField("module", moduleString), module: 
modules}
 }
diff --git a/cmd/roverd.go b/pkg/logger/settings.go
similarity index 63%
copy from cmd/roverd.go
copy to pkg/logger/settings.go
index 41b5368..fd44b88 100644
--- a/cmd/roverd.go
+++ b/pkg/logger/settings.go
@@ -15,10 +15,29 @@
 // specific language governing permissions and limitations
 // under the License.
 
-package main
+package logger
 
-import "fmt"
+import "github.com/sirupsen/logrus"
 
-func main() {
-       fmt.Printf("OK")
+const (
+       DefaultLoggerLevel = logrus.InfoLevel
+)
+
+func updateLogger(log *logrus.Logger, config *Config) error {
+       level, err := logrus.ParseLevel(config.Level)
+       if err != nil {
+               return err
+       }
+       log.SetLevel(level)
+       return nil
+}
+
+func initializeDefaultLogger() *logrus.Logger {
+       l := logrus.New()
+       l.SetLevel(DefaultLoggerLevel)
+       l.SetFormatter(&logrus.TextFormatter{
+               FullTimestamp: true,
+               DisableColors: true,
+       })
+       return l
 }

Reply via email to