├── go.mod ├── go.sum ├── README.md ├── .github └── workflows │ ├── tests.yaml │ ├── apidiff.yaml │ └── lint.yaml ├── example └── main.go ├── example_test.go ├── _tools └── apidiff.sh ├── stdr.go └── LICENSE /go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-logr/stdr 2 | 3 | go 1.16 4 | 5 | require github.com/go-logr/logr v1.2.2 6 | -------------------------------------------------------------------------------- /go.sum: -------------------------------------------------------------------------------- 1 | github.com/go-logr/logr v1.2.2 h1:ahHml/yUpnlb96Rp8HCvtYVPY8ZYpxq3g7UYchIYwbs= 2 | github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= 3 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Minimal Go logging using logr and Go's standard library 2 | 3 | [![Go Reference](https://pkg.go.dev/badge/github.com/go-logr/stdr.svg)](https://pkg.go.dev/github.com/go-logr/stdr) 4 | 5 | This package implements the [logr interface](https://github.com/go-logr/logr) 6 | in terms of Go's standard log package(https://pkg.go.dev/log). 7 | -------------------------------------------------------------------------------- /.github/workflows/tests.yaml: -------------------------------------------------------------------------------- 1 | name: Run tests 2 | 3 | on: [ push, pull_request ] 4 | 5 | jobs: 6 | test: 7 | strategy: 8 | matrix: 9 | go-versions: [ 1.14.x, 1.15.x, 1.16.x ] 10 | platform: [ ubuntu-latest, macos-latest, windows-latest ] 11 | runs-on: ${{ matrix.platform }} 12 | steps: 13 | - name: Install Go 14 | uses: actions/setup-go@v2 15 | with: 16 | go-version: ${{ matrix.go-version }} 17 | - name: Checkout code 18 | uses: actions/checkout@v2 19 | - name: Build 20 | run: go build -v ./... 21 | - name: Test 22 | run: go test -v -race ./... 23 | -------------------------------------------------------------------------------- /.github/workflows/apidiff.yaml: -------------------------------------------------------------------------------- 1 | name: Run apidiff 2 | 3 | on: [ pull_request ] 4 | 5 | jobs: 6 | apidiff: 7 | runs-on: ubuntu-latest 8 | if: github.base_ref 9 | steps: 10 | - name: Install Go 11 | uses: actions/setup-go@v2 12 | with: 13 | go-version: 1.18.x 14 | - name: Add GOBIN to PATH 15 | run: echo "PATH=$(go env GOPATH)/bin:$PATH" >>$GITHUB_ENV 16 | - name: Install dependencies 17 | run: GO111MODULE=off go get golang.org/x/exp/cmd/apidiff 18 | - name: Checkout old code 19 | uses: actions/checkout@v2 20 | with: 21 | ref: ${{ github.base_ref }} 22 | path: "old" 23 | - name: Checkout new code 24 | uses: actions/checkout@v2 25 | with: 26 | path: "new" 27 | - name: APIDiff 28 | run: ./_tools/apidiff.sh -d ../old 29 | working-directory: "new" 30 | -------------------------------------------------------------------------------- /.github/workflows/lint.yaml: -------------------------------------------------------------------------------- 1 | name: Run lint 2 | 3 | on: [ push, pull_request ] 4 | 5 | jobs: 6 | lint: 7 | runs-on: ubuntu-latest 8 | steps: 9 | - name: Checkout code 10 | uses: actions/checkout@v2 11 | - name: Lint 12 | uses: golangci/golangci-lint-action@v2 13 | with: 14 | # version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version 15 | version: latest 16 | 17 | # Optional: show only new issues if it's a pull request. The default value is `false`. 18 | # only-new-issues: true 19 | 20 | # golangci-lint command line arguments. 21 | args: 22 | -v 23 | --max-same-issues 10 24 | --disable-all 25 | --exclude-use-default=false 26 | -E asciicheck 27 | -E deadcode 28 | -E errcheck 29 | -E forcetypeassert 30 | -E gocritic 31 | -E gofmt 32 | -E goimports 33 | -E gosimple 34 | -E govet 35 | -E ineffassign 36 | -E misspell 37 | -E revive 38 | -E staticcheck 39 | -E structcheck 40 | -E typecheck 41 | -E unused 42 | -E varcheck 43 | -------------------------------------------------------------------------------- /example/main.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 The logr Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package main 18 | 19 | import ( 20 | stdlog "log" 21 | "os" 22 | 23 | "github.com/go-logr/logr" 24 | "github.com/go-logr/stdr" 25 | ) 26 | 27 | type e struct { 28 | str string 29 | } 30 | 31 | func (e e) Error() string { 32 | return e.str 33 | } 34 | 35 | func helper(log logr.Logger, msg string) { 36 | helper2(log, msg) 37 | } 38 | 39 | func helper2(log logr.Logger, msg string) { 40 | log.WithCallDepth(2).Info(msg) 41 | } 42 | 43 | func main() { 44 | stdr.SetVerbosity(1) 45 | log := stdr.NewWithOptions(stdlog.New(os.Stderr, "", stdlog.LstdFlags), stdr.Options{LogCaller: stdr.All}) 46 | log = log.WithName("MyName") 47 | example(log.WithValues("module", "example")) 48 | } 49 | 50 | // If this were in another package, all it would depend on in logr, not stdr. 51 | func example(log logr.Logger) { 52 | log.Info("hello", "val1", 1, "val2", map[string]int{"k": 1}) 53 | log.V(1).Info("you should see this") 54 | log.V(1).V(1).Info("you should NOT see this") 55 | log.Error(nil, "uh oh", "trouble", true, "reasons", []float64{0.1, 0.11, 3.14}) 56 | log.Error(e{"an error occurred"}, "goodbye", "code", -1) 57 | helper(log, "thru a helper") 58 | } 59 | -------------------------------------------------------------------------------- /example_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 The logr Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package stdr_test 18 | 19 | import ( 20 | "errors" 21 | "log" 22 | "os" 23 | 24 | "github.com/go-logr/stdr" 25 | ) 26 | 27 | var errSome = errors.New("some error") 28 | 29 | func newStdLogger(flags int) stdr.StdLogger { 30 | return log.New(os.Stdout, "", flags) 31 | } 32 | 33 | func ExampleNew() { 34 | log := stdr.New(newStdLogger(log.Lshortfile)) 35 | log.Info("info message with default options") 36 | log.Error(errSome, "error message with default options") 37 | log.Info("invalid key", 42, "answer") 38 | log.Info("missing value", "answer") 39 | // Output: 40 | // example_test.go:35: "level"=0 "msg"="info message with default options" 41 | // example_test.go:36: "msg"="error message with default options" "error"="some error" 42 | // example_test.go:37: "level"=0 "msg"="invalid key" ""="answer" 43 | // example_test.go:38: "level"=0 "msg"="missing value" "answer"="" 44 | } 45 | 46 | func ExampleNew_withName() { 47 | log := stdr.New(newStdLogger(0)) 48 | log.WithName("hello").WithName("world").Info("thanks for the fish") 49 | // Output: 50 | // hello/world: "level"=0 "msg"="thanks for the fish" 51 | } 52 | 53 | func ExampleNewWithOptions() { 54 | log := stdr.NewWithOptions(newStdLogger(0), stdr.Options{LogCaller: stdr.All}) 55 | log.Info("with LogCaller=All") 56 | // Output: 57 | // "caller"={"file":"example_test.go","line":55} "level"=0 "msg"="with LogCaller=All" 58 | } 59 | -------------------------------------------------------------------------------- /_tools/apidiff.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Copyright 2020 The Kubernetes Authors. 4 | # Copyright 2021 The logr Authors. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | 18 | set -o errexit 19 | set -o nounset 20 | set -o pipefail 21 | 22 | function usage { 23 | local script="$(basename $0)" 24 | 25 | echo >&2 "Usage: ${script} [-r | -d ] 26 | 27 | This script should be run at the root of a module. 28 | 29 | -r 30 | Compare the exported API of the local working copy with the 31 | exported API of the local repo at the specified branch or tag. 32 | 33 | -d 34 | Compare the exported API of the local working copy with the 35 | exported API of the specified directory, which should point 36 | to the root of a different version of the same module. 37 | 38 | Examples: 39 | ${script} -r master 40 | ${script} -r v1.10.0 41 | ${script} -r release-1.10 42 | ${script} -d /path/to/historical/version 43 | " 44 | exit 1 45 | } 46 | 47 | ref="" 48 | dir="" 49 | while getopts r:d: o 50 | do case "$o" in 51 | r) ref="$OPTARG";; 52 | d) dir="$OPTARG";; 53 | [?]) usage;; 54 | esac 55 | done 56 | 57 | # If REF and DIR are empty, print usage and error 58 | if [[ -z "${ref}" && -z "${dir}" ]]; then 59 | usage; 60 | fi 61 | # If REF and DIR are both set, print usage and error 62 | if [[ -n "${ref}" && -n "${dir}" ]]; then 63 | usage; 64 | fi 65 | 66 | if ! which apidiff > /dev/null; then 67 | echo "Installing golang.org/x/exp/cmd/apidiff" 68 | pushd "${TMPDIR:-/tmp}" > /dev/null 69 | GO111MODULE=off go get golang.org/x/exp/cmd/apidiff 70 | popd > /dev/null 71 | fi 72 | 73 | output=$(mktemp -d -t "apidiff.output.XXXX") 74 | cleanup_output () { rm -fr "${output}"; } 75 | trap cleanup_output EXIT 76 | 77 | # If ref is set, clone . to temp dir at $ref, and set $dir to the temp dir 78 | clone="" 79 | base="${dir}" 80 | if [[ -n "${ref}" ]]; then 81 | base="${ref}" 82 | clone=$(mktemp -d -t "apidiff.clone.XXXX") 83 | cleanup_clone_and_output () { rm -fr "${clone}"; cleanup_output; } 84 | trap cleanup_clone_and_output EXIT 85 | git clone . -q --no-tags "${clone}" 86 | git -C "${clone}" co "${ref}" 87 | dir="${clone}" 88 | fi 89 | 90 | pushd "${dir}" >/dev/null 91 | echo "Inspecting API of ${base}" 92 | go list ./... > packages.txt 93 | for pkg in $(cat packages.txt); do 94 | mkdir -p "${output}/${pkg}" 95 | apidiff -w "${output}/${pkg}/apidiff.output" "${pkg}" 96 | done 97 | popd >/dev/null 98 | 99 | retval=0 100 | 101 | echo "Comparing with ${base}" 102 | for pkg in $(go list ./...); do 103 | # New packages are ok 104 | if [ ! -f "${output}/${pkg}/apidiff.output" ]; then 105 | continue 106 | fi 107 | 108 | # Check for incompatible changes to previous packages 109 | incompatible=$(apidiff -incompatible "${output}/${pkg}/apidiff.output" "${pkg}") 110 | if [[ -n "${incompatible}" ]]; then 111 | echo >&2 "FAIL: ${pkg} contains incompatible changes: 112 | ${incompatible} 113 | " 114 | retval=1 115 | fi 116 | done 117 | 118 | # Check for removed packages 119 | removed=$(comm -23 "${dir}/packages.txt" <(go list ./...)) 120 | if [[ -n "${removed}" ]]; then 121 | echo >&2 "FAIL: removed packages: 122 | ${removed} 123 | " 124 | retval=1 125 | fi 126 | 127 | exit $retval 128 | -------------------------------------------------------------------------------- /stdr.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 The logr Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Package stdr implements github.com/go-logr/logr.Logger in terms of 18 | // Go's standard log package. 19 | package stdr 20 | 21 | import ( 22 | "log" 23 | "os" 24 | 25 | "github.com/go-logr/logr" 26 | "github.com/go-logr/logr/funcr" 27 | ) 28 | 29 | // The global verbosity level. See SetVerbosity(). 30 | var globalVerbosity int 31 | 32 | // SetVerbosity sets the global level against which all info logs will be 33 | // compared. If this is greater than or equal to the "V" of the logger, the 34 | // message will be logged. A higher value here means more logs will be written. 35 | // The previous verbosity value is returned. This is not concurrent-safe - 36 | // callers must be sure to call it from only one goroutine. 37 | func SetVerbosity(v int) int { 38 | old := globalVerbosity 39 | globalVerbosity = v 40 | return old 41 | } 42 | 43 | // New returns a logr.Logger which is implemented by Go's standard log package, 44 | // or something like it. If std is nil, this will use a default logger 45 | // instead. 46 | // 47 | // Example: stdr.New(log.New(os.Stderr, "", log.LstdFlags|log.Lshortfile))) 48 | func New(std StdLogger) logr.Logger { 49 | return NewWithOptions(std, Options{}) 50 | } 51 | 52 | // NewWithOptions returns a logr.Logger which is implemented by Go's standard 53 | // log package, or something like it. See New for details. 54 | func NewWithOptions(std StdLogger, opts Options) logr.Logger { 55 | if std == nil { 56 | // Go's log.Default() is only available in 1.16 and higher. 57 | std = log.New(os.Stderr, "", log.LstdFlags) 58 | } 59 | 60 | if opts.Depth < 0 { 61 | opts.Depth = 0 62 | } 63 | 64 | fopts := funcr.Options{ 65 | LogCaller: funcr.MessageClass(opts.LogCaller), 66 | } 67 | 68 | sl := &logger{ 69 | Formatter: funcr.NewFormatter(fopts), 70 | std: std, 71 | verbosity: opts.Verbosity, 72 | } 73 | 74 | // For skipping our own logger.Info/Error. 75 | sl.Formatter.AddCallDepth(1 + opts.Depth) 76 | 77 | return logr.New(sl) 78 | } 79 | 80 | // Options carries parameters which influence the way logs are generated. 81 | type Options struct { 82 | // Depth biases the assumed number of call frames to the "true" caller. 83 | // This is useful when the calling code calls a function which then calls 84 | // stdr (e.g. a logging shim to another API). Values less than zero will 85 | // be treated as zero. 86 | Depth int 87 | 88 | // LogCaller tells stdr to add a "caller" key to some or all log lines. 89 | // Go's log package has options to log this natively, too. 90 | LogCaller MessageClass 91 | 92 | // Verbosity tells the logger which V logs to write. Higher values enable more logs. 93 | // If nil, the global value set by SetVerbosity will be used. A pointer is used to provide 94 | // nil as the default value. 95 | Verbosity *int 96 | 97 | // TODO: add an option to log the date/time 98 | } 99 | 100 | // MessageClass indicates which category or categories of messages to consider. 101 | type MessageClass int 102 | 103 | const ( 104 | // None ignores all message classes. 105 | None MessageClass = iota 106 | // All considers all message classes. 107 | All 108 | // Info only considers info messages. 109 | Info 110 | // Error only considers error messages. 111 | Error 112 | ) 113 | 114 | // StdLogger is the subset of the Go stdlib log.Logger API that is needed for 115 | // this adapter. 116 | type StdLogger interface { 117 | // Output is the same as log.Output and log.Logger.Output. 118 | Output(calldepth int, logline string) error 119 | } 120 | 121 | type logger struct { 122 | funcr.Formatter 123 | std StdLogger 124 | verbosity *int 125 | } 126 | 127 | var _ logr.LogSink = &logger{} 128 | var _ logr.CallDepthLogSink = &logger{} 129 | 130 | func (l logger) Enabled(level int) bool { 131 | if l.verbosity != nil { 132 | return *l.verbosity >= level 133 | } 134 | return globalVerbosity >= level 135 | } 136 | 137 | func (l logger) Info(level int, msg string, kvList ...interface{}) { 138 | prefix, args := l.FormatInfo(level, msg, kvList) 139 | if prefix != "" { 140 | args = prefix + ": " + args 141 | } 142 | _ = l.std.Output(l.Formatter.GetDepth()+1, args) 143 | } 144 | 145 | func (l logger) Error(err error, msg string, kvList ...interface{}) { 146 | prefix, args := l.FormatError(err, msg, kvList) 147 | if prefix != "" { 148 | args = prefix + ": " + args 149 | } 150 | _ = l.std.Output(l.Formatter.GetDepth()+1, args) 151 | } 152 | 153 | func (l logger) WithName(name string) logr.LogSink { 154 | l.Formatter.AddName(name) 155 | return &l 156 | } 157 | 158 | func (l logger) WithValues(kvList ...interface{}) logr.LogSink { 159 | l.Formatter.AddValues(kvList) 160 | return &l 161 | } 162 | 163 | func (l logger) WithCallDepth(depth int) logr.LogSink { 164 | l.Formatter.AddCallDepth(depth) 165 | return &l 166 | } 167 | 168 | // Underlier exposes access to the underlying logging implementation. Since 169 | // callers only have a logr.Logger, they have to know which implementation is 170 | // in use, so this interface is less of an abstraction and more of way to test 171 | // type conversion. 172 | type Underlier interface { 173 | GetUnderlying() StdLogger 174 | } 175 | 176 | // GetUnderlying returns the StdLogger underneath this logger. Since StdLogger 177 | // is itself an interface, the result may or may not be a Go log.Logger. 178 | func (l logger) GetUnderlying() StdLogger { 179 | return l.std 180 | } 181 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | --------------------------------------------------------------------------------