go mod vendor
+ move k8s.io/apimachinery fork from go.work to go.mod (and include it in vendor)
This commit is contained in:
3
vendor/go.elastic.co/ecszap/.gitignore
vendored
Normal file
3
vendor/go.elastic.co/ecszap/.gitignore
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
ecs-logging-go-zap
|
||||
build
|
||||
html_docs
|
14
vendor/go.elastic.co/ecszap/.pre-commit-config.yaml
vendored
Normal file
14
vendor/go.elastic.co/ecszap/.pre-commit-config.yaml
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
repos:
|
||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||
rev: v2.2.3
|
||||
hooks:
|
||||
- id: check-case-conflict
|
||||
- id: check-executables-have-shebangs
|
||||
- id: check-merge-conflict
|
||||
|
||||
- repo: git@github.com:elastic/apm-pipeline-library
|
||||
rev: current
|
||||
hooks:
|
||||
- id: check-bash-syntax
|
||||
- id: check-jenkins-pipelines
|
||||
- id: check-jjbb
|
36
vendor/go.elastic.co/ecszap/CHANGELOG.md
vendored
Normal file
36
vendor/go.elastic.co/ecszap/CHANGELOG.md
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
# CHANGELOG
|
||||
Changelog for ecszap
|
||||
|
||||
## unreleased
|
||||
|
||||
## 1.0.1
|
||||
* Updated zap to v1.21.1 [pull#42](https://github.com/elastic/ecs-logging-go-zap/pull/42)
|
||||
|
||||
## 1.0.0
|
||||
|
||||
### Enhancement
|
||||
* Add `ecszap.WrapCoreOption` for convenience [pull#22](https://github.com/elastic/ecs-logging-go-zap/pull/22)
|
||||
|
||||
### Bug Fixes
|
||||
* Change `stacktrace` to `stack_trace` in output and in json and yaml config option for `EncoderConfig.EnableStacktrace` [pull#21](https://github.com/elastic/ecs-logging-go-zap/pull/21)
|
||||
* Do not allow configuration of `@timestamp`, instead always set format to ISO8601 [pull#23](https://github.com/elastic/ecs-logging-go-zap/pull/23)
|
||||
|
||||
## 0.3.0
|
||||
|
||||
### Enhancement
|
||||
* Update ECS version to 1.6.0 [pull#17](https://github.com/elastic/ecs-logging-go-zap/pull/17)
|
||||
|
||||
## 0.2.0
|
||||
|
||||
### Enhancement
|
||||
* Add `ecszap.ECSCompatibleEncoderConfig` for making existing encoder config ECS conformant [pull#12](https://github.com/elastic/ecs-logging-go-zap/pull/12)
|
||||
* Add method `ToZapCoreEncoderConfig` to `ecszap.EncoderConfig` for advanced use cases [pull#12](https://github.com/elastic/ecs-logging-go-zap/pull/12)
|
||||
|
||||
### Bug Fixes
|
||||
* Use `zapcore.ISO8601TimeEncoder` as default instead of `ecszap.EpochMicrosTimeEncoder` [pull#12](https://github.com/elastic/ecs-logging-go-zap/pull/12)
|
||||
|
||||
### Breaking Change
|
||||
* remove `ecszap.NewJSONEncoder` [pull#12](https://github.com/elastic/ecs-logging-go-zap/pull/12)
|
||||
|
||||
## 0.1.0
|
||||
Initial Pre-Release supporting [MVP](https://github.com/elastic/ecs-logging/tree/main/spec#minimum-viable-product) for ECS conformant logging
|
202
vendor/go.elastic.co/ecszap/LICENSE
vendored
Normal file
202
vendor/go.elastic.co/ecszap/LICENSE
vendored
Normal file
@@ -0,0 +1,202 @@
|
||||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright 2020 Elastic and contributors
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
101
vendor/go.elastic.co/ecszap/NOTICE.txt
vendored
Normal file
101
vendor/go.elastic.co/ecszap/NOTICE.txt
vendored
Normal file
@@ -0,0 +1,101 @@
|
||||
ecszap
|
||||
Copyright 2020-2020 Elasticsearch B.V.
|
||||
|
||||
==========================================================================
|
||||
Third party libraries used by the Elastic ecszap project:
|
||||
==========================================================================
|
||||
|
||||
Dependency: github.com/stretchr/testify
|
||||
Version: v1.4.0
|
||||
License type: MIT
|
||||
https://github.com/stretchr/testify/blob/199de5f3a493a9bf2dcc7fa5bf841d7759c13d7d/LICENSE:
|
||||
--------------------------------------------------------------------
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2012-2018 Mat Ryer and Tyler Bunnell
|
||||
|
||||
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.
|
||||
--------------------------------------------------------------------
|
||||
|
||||
|
||||
Dependency: go.uber.org/zap
|
||||
Version: v1.14.0
|
||||
License type: MIT
|
||||
https://github.com/uber-go/zap/blob/0bd02a6308c1bac3a03b02dc385555297cb22f83/LICENSE.txt:
|
||||
--------------------------------------------------------------------
|
||||
Copyright (c) 2016-2017 Uber Technologies, Inc.
|
||||
|
||||
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.
|
||||
--------------------------------------------------------------------
|
||||
|
||||
|
||||
Dependency: github.com/magefile/mage
|
||||
Version: v1.9.0
|
||||
License type: Apache-2.0
|
||||
https://github.com/magefile/mage/blob/324c6690ed410efc1d9b597e477c46d42cbeb340/LICENSE:
|
||||
--------------------------------------------------------------------
|
||||
Apache License 2.0
|
||||
|
||||
|
||||
--------------------------------------------------------------------
|
||||
Dependency: github.com/pkg/errors
|
||||
Version: v0.9.1
|
||||
License type (autodetected): BSD-2-Clause
|
||||
https://github.com/pkg/errors/blob/614d223910a179a466c1767a985424175c39b465/LICENSE
|
||||
--------------------------------------------------------------------
|
||||
Copyright (c) 2015, Dave Cheney <dave@cheney.net>
|
||||
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.
|
||||
|
||||
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.
|
||||
--------------------------------------------------------------------
|
22
vendor/go.elastic.co/ecszap/README.md
vendored
Normal file
22
vendor/go.elastic.co/ecszap/README.md
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
# Elastic Common Schema (ECS) support for uber-go/zap logger
|
||||
|
||||
Use this library for automatically adding a minimal set of ECS fields to your logs, when using [uber-go/zap](https://github.com/uber-go/zap).
|
||||
|
||||
## Documentation
|
||||
|
||||
Ready to get started? Documentation is at [elastic.co](https://www.elastic.co/guide/en/ecs-logging/go-zap/current/index.html).
|
||||
|
||||
## Test
|
||||
```
|
||||
go test ./...
|
||||
```
|
||||
|
||||
## Contribute
|
||||
Create a Pull Request from your own fork.
|
||||
|
||||
Run `mage` to update and format you changes before submitting.
|
||||
|
||||
Add new dependencies to the NOTICE.txt.
|
||||
|
||||
## License
|
||||
This software is licensed under the [Apache 2 license](https://github.com/elastic/ecs-logging-go-zap/blob/main/LICENSE).
|
87
vendor/go.elastic.co/ecszap/core.go
vendored
Normal file
87
vendor/go.elastic.co/ecszap/core.go
vendored
Normal file
@@ -0,0 +1,87 @@
|
||||
// Licensed to Elasticsearch B.V. under one or more contributor
|
||||
// license agreements. See the NOTICE file distributed with
|
||||
// this work for additional information regarding copyright
|
||||
// ownership. Elasticsearch B.V. licenses this file to you under
|
||||
// the Apache License, Version 2.0 (the "License"); you may
|
||||
// not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
|
||||
package ecszap
|
||||
|
||||
import (
|
||||
"go.uber.org/zap"
|
||||
"go.uber.org/zap/zapcore"
|
||||
|
||||
"go.elastic.co/ecszap/internal"
|
||||
)
|
||||
|
||||
const version = "1.6.0"
|
||||
|
||||
// NewCore creates a zapcore.Core that uses an ECS conformant JSON encoder.
|
||||
// This is the safest way to create an ECS compatible core.
|
||||
func NewCore(cfg EncoderConfig, ws zapcore.WriteSyncer, enab zapcore.LevelEnabler) zapcore.Core {
|
||||
enc := zapcore.NewJSONEncoder(cfg.ToZapCoreEncoderConfig())
|
||||
return WrapCore(zapcore.NewCore(enc, ws, enab))
|
||||
}
|
||||
|
||||
// WrapCore wraps a core with ECS core functionality and returns a zapcore.Core.
|
||||
// For ECS compatibility, ensure that the wrapped zapcore.Core uses an encoder
|
||||
// that is created from an ECS compatible configuration. For further details
|
||||
// check out ecszap.EncoderConfig or ecszap.ECSCompatibleEncoderConfig.
|
||||
func WrapCore(c zapcore.Core) zapcore.Core {
|
||||
return &core{c}
|
||||
}
|
||||
|
||||
// WrapCoreOption returns a zap.Option, wrapping the underlying zapcore.Core.
|
||||
func WrapCoreOption() zap.Option {
|
||||
return zap.WrapCore(WrapCore)
|
||||
}
|
||||
|
||||
type core struct {
|
||||
zapcore.Core
|
||||
}
|
||||
|
||||
// With converts error fields into ECS compliant errors
|
||||
// before adding them to the logger.
|
||||
func (c core) With(fields []zapcore.Field) zapcore.Core {
|
||||
convertToECSFields(fields)
|
||||
return &core{c.Core.With(fields)}
|
||||
}
|
||||
|
||||
// Check verifies whether or not the provided entry should be logged,
|
||||
// by comparing the log level with the configured log level in the core.
|
||||
// If it should be logged the core is added to the returned entry.
|
||||
func (c core) Check(ent zapcore.Entry, ce *zapcore.CheckedEntry) *zapcore.CheckedEntry {
|
||||
if c.Enabled(ent.Level) {
|
||||
return ce.AddCore(ent, c)
|
||||
}
|
||||
return ce
|
||||
}
|
||||
|
||||
// Write converts error fields into ECS compliant errors
|
||||
// before serializing the entry and fields.
|
||||
func (c core) Write(ent zapcore.Entry, fields []zapcore.Field) error {
|
||||
convertToECSFields(fields)
|
||||
fields = append(fields, zap.String("ecs.version", version))
|
||||
return c.Core.Write(ent, fields)
|
||||
}
|
||||
|
||||
func convertToECSFields(fields []zapcore.Field) {
|
||||
for i, f := range fields {
|
||||
if f.Type == zapcore.ErrorType {
|
||||
fields[i] = zapcore.Field{Key: "error",
|
||||
Type: zapcore.ObjectMarshalerType,
|
||||
Interface: internal.NewError(f.Interface.(error)),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
22
vendor/go.elastic.co/ecszap/doc.go
vendored
Normal file
22
vendor/go.elastic.co/ecszap/doc.go
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
// Licensed to Elasticsearch B.V. under one or more contributor
|
||||
// license agreements. See the NOTICE file distributed with
|
||||
// this work for additional information regarding copyright
|
||||
// ownership. Elasticsearch B.V. licenses this file to you under
|
||||
// the Apache License, Version 2.0 (the "License"); you may
|
||||
// not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
|
||||
// Package ecszap provides a formatter to be used
|
||||
// with the go.uber.org/zap logger library
|
||||
// that helps creating Elastic Common Schema (ECS)
|
||||
// conformant log entries.
|
||||
package ecszap // import "go.elastic.co/ecszap"
|
89
vendor/go.elastic.co/ecszap/encoder.go
vendored
Normal file
89
vendor/go.elastic.co/ecszap/encoder.go
vendored
Normal file
@@ -0,0 +1,89 @@
|
||||
// Licensed to Elasticsearch B.V. under one or more contributor
|
||||
// license agreements. See the NOTICE file distributed with
|
||||
// this work for additional information regarding copyright
|
||||
// ownership. Elasticsearch B.V. licenses this file to you under
|
||||
// the Apache License, Version 2.0 (the "License"); you may
|
||||
// not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
|
||||
package ecszap
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"go.uber.org/zap/zapcore"
|
||||
)
|
||||
|
||||
// EpochMicrosTimeEncoder encodes a given time in microseconds.
|
||||
func EpochMicrosTimeEncoder(t time.Time, enc zapcore.PrimitiveArrayEncoder) {
|
||||
micros := float64(t.UnixNano()) / float64(time.Microsecond)
|
||||
enc.AppendFloat64(micros)
|
||||
}
|
||||
|
||||
// CallerEncoder is equivalent to zapcore.CallerEncoder, except that its UnmarshalText
|
||||
// method uses FullCallerEncoder and ShortCallerEncoder from this package instead,
|
||||
// in order to encode callers in the ECS format.
|
||||
type CallerEncoder func(zapcore.EntryCaller, zapcore.PrimitiveArrayEncoder)
|
||||
|
||||
// FullCallerEncoder serializes the file name and line from the caller
|
||||
// in an ECS compliant way; serializing the full path of the file name
|
||||
// using the underlying zapcore.EntryCaller.
|
||||
func FullCallerEncoder(c zapcore.EntryCaller, enc zapcore.PrimitiveArrayEncoder) {
|
||||
encodeCaller(&caller{c, true}, enc)
|
||||
}
|
||||
|
||||
// ShortCallerEncoder serializes the file name and line from the caller
|
||||
// in an ECS compliant way; removing everything except the final directory from the
|
||||
// file name by calling the underlying zapcore.EntryCaller TrimmedPath().
|
||||
func ShortCallerEncoder(c zapcore.EntryCaller, enc zapcore.PrimitiveArrayEncoder) {
|
||||
encodeCaller(&caller{c, false}, enc)
|
||||
}
|
||||
|
||||
// UnmarshalText creates a CallerEncoder function,
|
||||
// `full` is unmarshalled to FullCallerEncoder,
|
||||
// defaults to ShortCallerEncoder,
|
||||
func (e *CallerEncoder) UnmarshalText(text []byte) error {
|
||||
switch string(text) {
|
||||
case "full":
|
||||
*e = FullCallerEncoder
|
||||
default:
|
||||
*e = ShortCallerEncoder
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func encodeCaller(c *caller, enc zapcore.PrimitiveArrayEncoder) {
|
||||
// this function can only be called internally so we have full control over it
|
||||
// and can ensure that enc is always of type zapcore.ArrayEncoder
|
||||
if e, ok := enc.(zapcore.ArrayEncoder); ok {
|
||||
e.AppendObject(c)
|
||||
}
|
||||
}
|
||||
|
||||
type caller struct {
|
||||
zapcore.EntryCaller
|
||||
fullPath bool
|
||||
}
|
||||
|
||||
func (c *caller) MarshalLogObject(enc zapcore.ObjectEncoder) error {
|
||||
var file string
|
||||
if c.fullPath {
|
||||
file = c.File
|
||||
} else {
|
||||
file = c.TrimmedPath()
|
||||
file = file[:strings.LastIndex(file, ":")]
|
||||
}
|
||||
enc.AddString("file.name", file)
|
||||
enc.AddInt("file.line", c.Line)
|
||||
return nil
|
||||
}
|
163
vendor/go.elastic.co/ecszap/encoder_config.go
vendored
Normal file
163
vendor/go.elastic.co/ecszap/encoder_config.go
vendored
Normal file
@@ -0,0 +1,163 @@
|
||||
// Licensed to Elasticsearch B.V. under one or more contributor
|
||||
// license agreements. See the NOTICE file distributed with
|
||||
// this work for additional information regarding copyright
|
||||
// ownership. Elasticsearch B.V. licenses this file to you under
|
||||
// the Apache License, Version 2.0 (the "License"); you may
|
||||
// not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
|
||||
package ecszap
|
||||
|
||||
import (
|
||||
"go.uber.org/zap/zapcore"
|
||||
)
|
||||
|
||||
var (
|
||||
defaultLineEnding = zapcore.DefaultLineEnding
|
||||
defaultEncodeName = zapcore.FullNameEncoder
|
||||
defaultEncodeDuration = zapcore.NanosDurationEncoder
|
||||
defaultEncodeLevel = zapcore.LowercaseLevelEncoder
|
||||
defaultEncodeCaller = ShortCallerEncoder
|
||||
|
||||
callerKey = "log.origin"
|
||||
logLevelKey = "log.level"
|
||||
logNameKey = "log.logger"
|
||||
messageKey = "message"
|
||||
stackTraceKey = "log.origin.stack_trace"
|
||||
timeKey = "@timestamp"
|
||||
encodeTime = zapcore.ISO8601TimeEncoder
|
||||
)
|
||||
|
||||
// EncoderConfig exports all non ECS related configurable settings.
|
||||
// The configuration can be used to create an ECS compatible zapcore.Core
|
||||
type EncoderConfig struct {
|
||||
// EnableName controls if a logger's name should be serialized
|
||||
// when available. If enabled, the EncodeName configuration is
|
||||
// used for serialization.
|
||||
EnableName bool `json:"enableName" yaml:"enableName"`
|
||||
|
||||
// EnableStackTrace controls if a stack trace should be serialized when available.
|
||||
EnableStackTrace bool `json:"enableStackTrace" yaml:"enableStackTrace"`
|
||||
|
||||
// EnableCaller controls if the entry caller should be serialized.
|
||||
// If enabled, the EncodeCaller configuration is used for serialization.
|
||||
EnableCaller bool `json:"enableCaller" yaml:"enableCaller"`
|
||||
|
||||
// LineEnding defines the string used for line endings.
|
||||
LineEnding string `json:"lineEnding" yaml:"lineEnding"`
|
||||
|
||||
// EncodeName defines how to encode a loggers name.
|
||||
// It will only be applied if EnableName is set to true.
|
||||
EncodeName zapcore.NameEncoder `json:"nameEncoder" yaml:"nameEncoder"`
|
||||
|
||||
// EncodeLevel sets the log level for which any context should be logged.
|
||||
EncodeLevel zapcore.LevelEncoder `json:"levelEncoder" yaml:"levelEncoder"`
|
||||
|
||||
// EncodeDuration sets the format for encoding time.Duration values.
|
||||
EncodeDuration zapcore.DurationEncoder `json:"durationEncoder" yaml:"durationEncoder"`
|
||||
|
||||
// EncodeCaller defines how an entry caller should be serialized.
|
||||
// It will only be applied if EnableCaller is set to true.
|
||||
EncodeCaller CallerEncoder `json:"callerEncoder" yaml:"callerEncoder"`
|
||||
}
|
||||
|
||||
// NewDefaultEncoderConfig returns an EncoderConfig with default settings.
|
||||
func NewDefaultEncoderConfig() EncoderConfig {
|
||||
return EncoderConfig{
|
||||
EnableName: true,
|
||||
EnableCaller: true,
|
||||
EnableStackTrace: true,
|
||||
LineEnding: defaultLineEnding,
|
||||
EncodeName: defaultEncodeName,
|
||||
EncodeLevel: defaultEncodeLevel,
|
||||
EncodeDuration: defaultEncodeDuration,
|
||||
EncodeCaller: defaultEncodeCaller,
|
||||
}
|
||||
}
|
||||
|
||||
// ToZapCoreEncoderConfig transforms the ecszap.EncoderConfig into
|
||||
// a zapcore.EncoderConfig
|
||||
func (cfg EncoderConfig) ToZapCoreEncoderConfig() zapcore.EncoderConfig {
|
||||
encCfg := zapcore.EncoderConfig{
|
||||
MessageKey: messageKey,
|
||||
LevelKey: logLevelKey,
|
||||
TimeKey: timeKey,
|
||||
EncodeTime: encodeTime,
|
||||
LineEnding: cfg.LineEnding,
|
||||
EncodeDuration: cfg.EncodeDuration,
|
||||
EncodeName: cfg.EncodeName,
|
||||
EncodeLevel: cfg.EncodeLevel,
|
||||
}
|
||||
if encCfg.EncodeDuration == nil {
|
||||
encCfg.EncodeDuration = defaultEncodeDuration
|
||||
}
|
||||
if cfg.EnableName {
|
||||
encCfg.NameKey = logNameKey
|
||||
if encCfg.EncodeName == nil {
|
||||
encCfg.EncodeName = defaultEncodeName
|
||||
}
|
||||
}
|
||||
if cfg.EnableStackTrace {
|
||||
encCfg.StacktraceKey = stackTraceKey
|
||||
}
|
||||
if cfg.EnableCaller {
|
||||
encCfg.CallerKey = callerKey
|
||||
if cfg.EncodeCaller == nil {
|
||||
encCfg.EncodeCaller = defaultEncodeCaller
|
||||
} else {
|
||||
encCfg.EncodeCaller = zapcore.CallerEncoder(cfg.EncodeCaller)
|
||||
}
|
||||
}
|
||||
if encCfg.EncodeLevel == nil {
|
||||
encCfg.EncodeLevel = defaultEncodeLevel
|
||||
}
|
||||
return encCfg
|
||||
}
|
||||
|
||||
// ECSCompatibleEncoderConfig takes an existing zapcore.EncoderConfig
|
||||
// and sets ECS relevant configuration options to ECS conformant values.
|
||||
// The returned zapcore.EncoderConfig can be used to create
|
||||
// an ECS conformant encoder.
|
||||
// Be aware that this will always replace any set EncodeCaller function
|
||||
// with the ecszap.ShortCallerEncoder.
|
||||
// This is a pure convenience function for making a transition from
|
||||
// existing an zap logger to an ECS conformant zap loggers easier.
|
||||
// It is recommended to make use of the ecszap.EncoderConfig whenever possible.
|
||||
func ECSCompatibleEncoderConfig(cfg zapcore.EncoderConfig) zapcore.EncoderConfig {
|
||||
// set the required MVP ECS keys
|
||||
cfg.MessageKey = messageKey
|
||||
cfg.LevelKey = logLevelKey
|
||||
cfg.TimeKey = timeKey
|
||||
if cfg.NameKey != "" {
|
||||
cfg.NameKey = logNameKey
|
||||
}
|
||||
// set further ECS defined keys only if keys were defined,
|
||||
// as zap omits these log attributes when keys are not defined
|
||||
// and ecszap does not intend to change this logic
|
||||
if cfg.StacktraceKey != "" {
|
||||
cfg.StacktraceKey = stackTraceKey
|
||||
}
|
||||
if cfg.CallerKey != "" {
|
||||
cfg.CallerKey = callerKey
|
||||
cfg.EncodeCaller = defaultEncodeCaller
|
||||
}
|
||||
// always set the time encoding to the ISO8601 time format
|
||||
cfg.EncodeTime = encodeTime
|
||||
// ensure all required encoders are set
|
||||
if cfg.EncodeDuration == nil {
|
||||
cfg.EncodeDuration = defaultEncodeDuration
|
||||
}
|
||||
if cfg.EncodeLevel == nil {
|
||||
cfg.EncodeLevel = defaultEncodeLevel
|
||||
}
|
||||
return cfg
|
||||
}
|
132
vendor/go.elastic.co/ecszap/internal/error.go
vendored
Normal file
132
vendor/go.elastic.co/ecszap/internal/error.go
vendored
Normal file
@@ -0,0 +1,132 @@
|
||||
// Licensed to Elasticsearch B.V. under one or more contributor
|
||||
// license agreements. See the NOTICE file distributed with
|
||||
// this work for additional information regarding copyright
|
||||
// ownership. Elasticsearch B.V. licenses this file to you under
|
||||
// the Apache License, Version 2.0 (the "License"); you may
|
||||
// not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
|
||||
package internal
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"sync"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"go.uber.org/zap/zapcore"
|
||||
)
|
||||
|
||||
type ecsError struct {
|
||||
error
|
||||
}
|
||||
|
||||
func NewError(err error) zapcore.ObjectMarshaler {
|
||||
return ecsError{err}
|
||||
}
|
||||
|
||||
func (err ecsError) MarshalLogObject(enc zapcore.ObjectEncoder) error {
|
||||
enc.AddString("message", err.Error())
|
||||
if e, ok := err.error.(stackTracer); ok {
|
||||
enc.AddString("stack_trace", fmt.Sprintf("%+v", e.StackTrace()))
|
||||
}
|
||||
|
||||
// TODO(simitt): support for improved error handling
|
||||
// https://github.com/elastic/ecs-logging-go-zap/issues/8
|
||||
if e, ok := err.error.(errorGroup); ok {
|
||||
if errorCause := e.Errors(); len(errorCause) > 0 {
|
||||
return enc.AddArray("cause", errArray(errorCause))
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// interface used by github.com/pkg/errors
|
||||
type stackTracer interface {
|
||||
StackTrace() errors.StackTrace
|
||||
}
|
||||
|
||||
// *** code below this line is mostly copied from github.com/zapcore/core.go
|
||||
// and is subject to the license below***
|
||||
|
||||
// Copyright (c) 2017 Uber Technologies, Inc.
|
||||
//
|
||||
// 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.
|
||||
|
||||
type errorGroup interface {
|
||||
// Provides read-only access to the underlying list of errors, preferably
|
||||
// without causing any allocs.
|
||||
Errors() []error
|
||||
}
|
||||
|
||||
// Note that errArry and errArrayElem are very similar to the version
|
||||
// implemented in the top-level error.go file. We can't re-use this because
|
||||
// that would require exporting errArray as part of the zapcore API.
|
||||
|
||||
// Encodes a list of errors using the standard error encoding logic.
|
||||
type errArray []error
|
||||
|
||||
func (errs errArray) MarshalLogArray(arr zapcore.ArrayEncoder) error {
|
||||
for i := range errs {
|
||||
if errs[i] == nil {
|
||||
continue
|
||||
}
|
||||
|
||||
el := newErrArrayElem(errs[i])
|
||||
arr.AppendObject(el)
|
||||
el.Free()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
var _errArrayElemPool = sync.Pool{New: func() interface{} {
|
||||
return &errArrayElem{}
|
||||
}}
|
||||
|
||||
// Encodes any error into a {"error": ...} re-using the same errors logic.
|
||||
//
|
||||
// May be passed in place of an array to build a single-element array.
|
||||
type errArrayElem struct{ err error }
|
||||
|
||||
func newErrArrayElem(err error) *errArrayElem {
|
||||
e := _errArrayElemPool.Get().(*errArrayElem)
|
||||
e.err = err
|
||||
return e
|
||||
}
|
||||
|
||||
func (e *errArrayElem) MarshalLogArray(arr zapcore.ArrayEncoder) error {
|
||||
return arr.AppendObject(e)
|
||||
}
|
||||
|
||||
func (e *errArrayElem) MarshalLogObject(enc zapcore.ObjectEncoder) error {
|
||||
return ecsError{e.err}.MarshalLogObject(enc)
|
||||
}
|
||||
|
||||
func (e *errArrayElem) Free() {
|
||||
e.err = nil
|
||||
_errArrayElemPool.Put(e)
|
||||
}
|
58
vendor/go.elastic.co/ecszap/magefile.go
vendored
Normal file
58
vendor/go.elastic.co/ecszap/magefile.go
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
// Licensed to Elasticsearch B.V. under one or more contributor
|
||||
// license agreements. See the NOTICE file distributed with
|
||||
// this work for additional information regarding copyright
|
||||
// ownership. Elasticsearch B.V. licenses this file to you under
|
||||
// the Apache License, Version 2.0 (the "License"); you may
|
||||
// not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
|
||||
// +build mage
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os/exec"
|
||||
|
||||
"github.com/magefile/mage/mg" // mg contains helpful utility functions, like Deps
|
||||
)
|
||||
|
||||
var Default = Update
|
||||
|
||||
// Update go files to contain license header
|
||||
func Update() error {
|
||||
mg.Deps(InstallDeps)
|
||||
fmt.Println("Updating...")
|
||||
for _, cmd := range []*exec.Cmd{
|
||||
exec.Command("go-licenser", "."),
|
||||
exec.Command("go", "fmt"),
|
||||
exec.Command("go", "mod", "tidy"),
|
||||
} {
|
||||
if err := cmd.Run(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Install development dependencies
|
||||
func InstallDeps() error {
|
||||
fmt.Println("Installing Deps...")
|
||||
for _, cmd := range []*exec.Cmd{
|
||||
exec.Command("go", "get", "github.com/elastic/go-licenser"),
|
||||
} {
|
||||
if err := cmd.Run(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
Reference in New Issue
Block a user