1
0
Fork 0
mirror of https://github.com/chainguard-dev/clog synced 2026-07-15 18:06:43 +00:00
Commit graph

25 commits

Author SHA1 Message Date
dependabot[bot]
d26a705a05
Bump actions/checkout from 3 to 4 (#19)
Bumps [actions/checkout](https://github.com/actions/checkout) from 3 to
4.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/actions/checkout/releases">actions/checkout's
releases</a>.</em></p>
<blockquote>
<h2>v4.0.0</h2>
<h2>What's Changed</h2>
<ul>
<li>Update default runtime to node20 by <a
href="https://github.com/takost"><code>@​takost</code></a> in <a
href="https://redirect.github.com/actions/checkout/pull/1436">actions/checkout#1436</a></li>
<li>Support fetching without the --progress option by <a
href="https://github.com/simonbaird"><code>@​simonbaird</code></a> in <a
href="https://redirect.github.com/actions/checkout/pull/1067">actions/checkout#1067</a></li>
<li>Release 4.0.0 by <a
href="https://github.com/takost"><code>@​takost</code></a> in <a
href="https://redirect.github.com/actions/checkout/pull/1447">actions/checkout#1447</a></li>
</ul>
<h2>New Contributors</h2>
<ul>
<li><a href="https://github.com/takost"><code>@​takost</code></a> made
their first contribution in <a
href="https://redirect.github.com/actions/checkout/pull/1436">actions/checkout#1436</a></li>
<li><a
href="https://github.com/simonbaird"><code>@​simonbaird</code></a> made
their first contribution in <a
href="https://redirect.github.com/actions/checkout/pull/1067">actions/checkout#1067</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a
href="https://github.com/actions/checkout/compare/v3...v4.0.0">https://github.com/actions/checkout/compare/v3...v4.0.0</a></p>
<h2>v3.6.0</h2>
<h2>What's Changed</h2>
<ul>
<li>Mark test scripts with Bash'isms to be run via Bash by <a
href="https://github.com/dscho"><code>@​dscho</code></a> in <a
href="https://redirect.github.com/actions/checkout/pull/1377">actions/checkout#1377</a></li>
<li>Add option to fetch tags even if fetch-depth &gt; 0 by <a
href="https://github.com/RobertWieczoreck"><code>@​RobertWieczoreck</code></a>
in <a
href="https://redirect.github.com/actions/checkout/pull/579">actions/checkout#579</a></li>
<li>Release 3.6.0 by <a
href="https://github.com/luketomlinson"><code>@​luketomlinson</code></a>
in <a
href="https://redirect.github.com/actions/checkout/pull/1437">actions/checkout#1437</a></li>
</ul>
<h2>New Contributors</h2>
<ul>
<li><a
href="https://github.com/RobertWieczoreck"><code>@​RobertWieczoreck</code></a>
made their first contribution in <a
href="https://redirect.github.com/actions/checkout/pull/579">actions/checkout#579</a></li>
<li><a
href="https://github.com/luketomlinson"><code>@​luketomlinson</code></a>
made their first contribution in <a
href="https://redirect.github.com/actions/checkout/pull/1437">actions/checkout#1437</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a
href="https://github.com/actions/checkout/compare/v3.5.3...v3.6.0">https://github.com/actions/checkout/compare/v3.5.3...v3.6.0</a></p>
<h2>v3.5.3</h2>
<h2>What's Changed</h2>
<ul>
<li>Fix: Checkout Issue in self hosted runner due to faulty submodule
check-ins by <a
href="https://github.com/megamanics"><code>@​megamanics</code></a> in <a
href="https://redirect.github.com/actions/checkout/pull/1196">actions/checkout#1196</a></li>
<li>Fix typos found by codespell by <a
href="https://github.com/DimitriPapadopoulos"><code>@​DimitriPapadopoulos</code></a>
in <a
href="https://redirect.github.com/actions/checkout/pull/1287">actions/checkout#1287</a></li>
<li>Add support for sparse checkouts by <a
href="https://github.com/dscho"><code>@​dscho</code></a> and <a
href="https://github.com/dfdez"><code>@​dfdez</code></a> in <a
href="https://redirect.github.com/actions/checkout/pull/1369">actions/checkout#1369</a></li>
<li>Release v3.5.3 by <a
href="https://github.com/TingluoHuang"><code>@​TingluoHuang</code></a>
in <a
href="https://redirect.github.com/actions/checkout/pull/1376">actions/checkout#1376</a></li>
</ul>
<h2>New Contributors</h2>
<ul>
<li><a
href="https://github.com/megamanics"><code>@​megamanics</code></a> made
their first contribution in <a
href="https://redirect.github.com/actions/checkout/pull/1196">actions/checkout#1196</a></li>
<li><a
href="https://github.com/DimitriPapadopoulos"><code>@​DimitriPapadopoulos</code></a>
made their first contribution in <a
href="https://redirect.github.com/actions/checkout/pull/1287">actions/checkout#1287</a></li>
<li><a href="https://github.com/dfdez"><code>@​dfdez</code></a> made
their first contribution in <a
href="https://redirect.github.com/actions/checkout/pull/1369">actions/checkout#1369</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a
href="https://github.com/actions/checkout/compare/v3...v3.5.3">https://github.com/actions/checkout/compare/v3...v3.5.3</a></p>
<h2>v3.5.2</h2>
<h2>What's Changed</h2>
<ul>
<li>Fix: Use correct API url / endpoint in GHES by <a
href="https://github.com/fhammerl"><code>@​fhammerl</code></a> in <a
href="https://redirect.github.com/actions/checkout/pull/1289">actions/checkout#1289</a>
based on <a
href="https://redirect.github.com/actions/checkout/issues/1286">#1286</a>
by <a href="https://github.com/1newsr"><code>@​1newsr</code></a></li>
</ul>
<p><strong>Full Changelog</strong>: <a
href="https://github.com/actions/checkout/compare/v3.5.1...v3.5.2">https://github.com/actions/checkout/compare/v3.5.1...v3.5.2</a></p>
<h2>v3.5.1</h2>
<h2>What's Changed</h2>
<ul>
<li>Improve checkout performance on Windows runners by upgrading
<code>@​actions/github</code> dependency by <a
href="https://github.com/BrettDong"><code>@​BrettDong</code></a> in <a
href="https://redirect.github.com/actions/checkout/pull/1246">actions/checkout#1246</a></li>
</ul>
<h2>New Contributors</h2>
<ul>
<li><a href="https://github.com/BrettDong"><code>@​BrettDong</code></a>
made their first contribution in <a
href="https://redirect.github.com/actions/checkout/pull/1246">actions/checkout#1246</a></li>
</ul>
<!-- raw HTML omitted -->
</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="692973e3d9"><code>692973e</code></a>
Prepare 4.1.7 release (<a
href="https://redirect.github.com/actions/checkout/issues/1775">#1775</a>)</li>
<li><a
href="6ccd57f4c5"><code>6ccd57f</code></a>
Pin actions/checkout's own workflows to a known, good, stable version.
(<a
href="https://redirect.github.com/actions/checkout/issues/1776">#1776</a>)</li>
<li><a
href="b17fe1e4d5"><code>b17fe1e</code></a>
Handle hidden refs (<a
href="https://redirect.github.com/actions/checkout/issues/1774">#1774</a>)</li>
<li><a
href="b80ff79f17"><code>b80ff79</code></a>
Bump actions/checkout from 3 to 4 (<a
href="https://redirect.github.com/actions/checkout/issues/1697">#1697</a>)</li>
<li><a
href="b1ec3021b8"><code>b1ec302</code></a>
Bump the minor-npm-dependencies group across 1 directory with 4 updates
(<a
href="https://redirect.github.com/actions/checkout/issues/1739">#1739</a>)</li>
<li><a
href="a5ac7e51b4"><code>a5ac7e5</code></a>
Update for 4.1.6 release (<a
href="https://redirect.github.com/actions/checkout/issues/1733">#1733</a>)</li>
<li><a
href="24ed1a3528"><code>24ed1a3</code></a>
Check platform for extension (<a
href="https://redirect.github.com/actions/checkout/issues/1732">#1732</a>)</li>
<li><a
href="44c2b7a8a4"><code>44c2b7a</code></a>
README: Suggest <code>user.email</code> to be
`41898282+github-actions[bot]<a
href="https://github.com/users"><code>@​users</code></a>.norepl...</li>
<li><a
href="8459bc0c7e"><code>8459bc0</code></a>
Bump actions/upload-artifact from 2 to 4 (<a
href="https://redirect.github.com/actions/checkout/issues/1695">#1695</a>)</li>
<li><a
href="3f603f6d5e"><code>3f603f6</code></a>
Bump actions/setup-node from 1 to 4 (<a
href="https://redirect.github.com/actions/checkout/issues/1696">#1696</a>)</li>
<li>Additional commits viewable in <a
href="https://github.com/actions/checkout/compare/v3...v4">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=actions/checkout&package-manager=github_actions&previous-version=3&new-version=4)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

---------

Signed-off-by: dependabot[bot] <support@github.com>
Signed-off-by: Kenny Leung <kleung@chainguard.dev>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Kenny Leung <kleung@chainguard.dev>
2024-06-21 16:33:52 +00:00
Kenny Leung
1a2666f783
setup dependabot for clog (#18)
Signed-off-by: Kenny Leung <kleung@chainguard.dev>
2024-06-21 09:00:44 +02:00
Billy Lynch
40901e8d69
slogtest: Allow passing in logging config options. (#12)
- Enables debug logging by default.
- Adds `TestLoggerWithOptions` to allow overriding default config.
- Adds `Context` as a shorthand for TestContextWithLogger
   (e.g. `slogtest.TestContextWithLogger(t)` -> `slogtest.Context(t)`)
2024-06-20 20:49:22 -07:00
Nghia Tran
6962f14d44
Use traceparent instead of X-Cloud-Trace-Context (#16)
According to
https://cloud.google.com/trace/docs/trace-context#http-requests,
`X-Cloud-Trace-Context` is a legacy header that precedes the W3C
standard `traceparent` header. Google Cloud services that support trace
context propagation typically support both the `traceparent` and the
legacy `X-Cloud-Trace-Context` header.

Switching to use this so that we don't have to use the legacy header
`X-Cloud-Trace-Context` when restoring trace context header for pubsub
eventing, but only using `traceparent` every where.
2024-06-18 19:32:50 -07:00
Nghia Tran
f300b26592
Preserve context in With() calls (#17)
Currently `With()` will reset context back to `context.Background()`,
causing the `wrap/wrapf` calls to lose the original context.

This affects the `clog/gcp` handler who relies on a value keyed with
`"trace"` being set on the context
([see](https://github.com/chainguard-dev/clog/blob/main/gcp/trace.go#L110-L116))
(we should use a typed value though, but that's in a different PR).

---------

Signed-off-by: Nghia Tran <tcnghia@gmail.com>
2024-06-18 20:33:25 -04:00
Jason Hall
cb3093988f
gcp/trace: limit project ID lookups, add tests (#14)
If `WithCloudTraceContext` is called from tests where GCE metadata isn't
available, it hangs indefinitely, which is not a great experience.

Some improvements in this PR:

- project ID lookup will only be performed once, instead of each time
`WithCloudTraceContext` is called
- if we detect we're being called in tests, the project ID won't be
looked up and we won't log with trace context
- add a standard short timeout to metadata requests, consistent with the
official client

Also add a test that shows that the `trace` context value is set when
the project ID env var is set; because this logging must go to stderr,
we can't easily test what actually gets logged, but we can show it
working in the verbose output:

```
go test ./gcp -v -count=1
=== RUN   TestTrace
=== RUN   TestTrace/no_env_set
{"time":"2024-02-12T20:22:14.059143-05:00","severity":"DEBUG","logging.googleapis.com/sourceLocation":{"function":"github.com/chainguard-dev/clog/gcp.insideTest","file":"/Users/jason/git/clog/gcp/trace.go","line":33},"message":"WithCloudTraceContext: inside test","function":"testing.tRunner","file":"/opt/homebrew/Cellar/go/1.21.5/libexec/src/testing/testing.go","line":1595}
{"time":"2024-02-12T20:22:14.059343-05:00","severity":"DEBUG","logging.googleapis.com/sourceLocation":{"function":"github.com/chainguard-dev/clog/gcp.WithCloudTraceContext.func1","file":"/Users/jason/git/clog/gcp/trace.go","line":56},"message":"WithCloudTraceContext: inside test, not looking up project ID"}
{"time":"2024-02-12T20:22:14.060156-05:00","severity":"INFO","logging.googleapis.com/sourceLocation":{"function":"github.com/chainguard-dev/clog/gcp.TestTrace.func2.1","file":"/Users/jason/git/clog/gcp/trace_test.go","line":37},"message":"hello world"}
=== RUN   TestTrace/env_set
{"time":"2024-02-12T20:22:14.060678-05:00","severity":"INFO","logging.googleapis.com/sourceLocation":{"function":"github.com/chainguard-dev/clog/gcp.TestTrace.func2.1","file":"/Users/jason/git/clog/gcp/trace_test.go","line":37},"message":"hello world","logging.googleapis.com/trace":"projects/my-project/traces/trace"}
--- PASS: TestTrace (0.00s)
    --- PASS: TestTrace/no_env_set (0.00s)
    --- PASS: TestTrace/env_set (0.00s)
PASS
ok      github.com/chainguard-dev/clog/gcp      0.166s
```

The test also attempts to check that GCE metadata isn't requested.

Through this work I've found that `clog.FromContext(ctx).Info("hello")`
doesn't carry the `trace` context value, possibly related to
https://github.com/chainguard-dev/clog/pull/11

Signed-off-by: Jason Hall <jason@chainguard.dev>
2024-02-12 21:04:06 -05:00
Billy Lynch
f4145d29d4
Preserve context in logger when calling FromContext. (#11)
Modification of #5 

Allows for passing through the logger while still using default Info
methods. InfoContext remains to override the context with another value.

This changes the stored context value to store the underlying
slog.Logger instead of the wrapped logger so we're not storing a context
within a context.
2024-02-06 12:35:04 -05:00
Jason Hall
4d1a9405b3
add Fatal{Context}{f} (#8)
This adds `clog.Fatal{Context}{f}`, and
`clog.FromContext(ctx).Fatal{Context}{f}`

`Fatal` logs at `LevelError` then calls `os.Exit(1)`, like stdlib
`log.Fatal`:
https://cs.opensource.google/go/go/+/refs/tags/go1.21.6:src/log/log.go;l=413

---------

Signed-off-by: Jason Hall <jason@chainguard.dev>
Co-authored-by: Billy Lynch <1844673+wlynch@users.noreply.github.com>
2024-02-06 11:03:48 -05:00
Jason Hall
83244dc767
add a flag option (#10)
I don't like any of the names here, and we might want it to be in a
separate subpackage. This lets you say `--log-level=DEBUG` to set the
level. The default is still INFO.

---------

Signed-off-by: Jason Hall <jason@chainguard.dev>
2024-02-06 11:01:13 -05:00
Jason Hall
d34ebd4160
add GCP optimized slog package (#9)
Opening this to gather feedback.

This moves https://github.com/imjasonh/gcpslog into this repo, including
https://github.com/imjasonh/gcpslog/pull/2

---------

Signed-off-by: Jason Hall <jason@chainguard.dev>
2024-02-05 17:09:57 -05:00
Jason Hall
fec25b637d
Update README.md (#7)
Signed-off-by: Jason Hall <jason@chainguard.dev>
2024-01-18 11:37:43 -05:00
Jason Hall
04bee692f7
rename to clog (#6)
* rename to clog

Signed-off-by: Jason Hall <jason@chainguard.dev>

* fix example in README

Signed-off-by: Jason Hall <jason@chainguard.dev>

---------

Signed-off-by: Jason Hall <jason@chainguard.dev>
2024-01-16 13:28:27 -05:00
Billy Lynch
c071a43a42
Fix handler example to actually use the handler. (#4) 2024-01-16 11:15:36 -05:00
Billy Lynch
988f6253cd
Add source.yaml (#3) 2023-12-21 17:59:27 +01:00
Carlos Tadeu Panato Junior
7a6e5ac694
update to chainguard-dev (#2) 2023-12-21 11:54:22 -05:00
Billy Lynch
9bf46567a6
Create go.yml 2023-12-12 20:40:15 -05:00
Billy Lynch
0d562667b2
Update godoc 2023-12-12 19:59:57 -05:00
Billy Lynch
3f156fd3a4
Add missing slog.Logger functions.
- WithGroup
- Handler
2023-12-12 19:22:50 -05:00
Billy Lynch
765cf08124
Add slogtest helpers. 2023-12-12 18:45:04 -05:00
Billy Lynch
8aac927af2
Add godoc badge 2023-12-12 18:30:25 -05:00
Billy Lynch
5565dbc976
Add context logger.
This is heavily inspired by https://pkg.go.dev/knative.dev/pkg/logging

Also adds top level logging methods for convinience.
2023-12-12 18:29:22 -05:00
Billy Lynch
81392732b8
Update README 2023-12-12 14:32:28 -05:00
Billy Lynch
85b981e4b6
Add glog/zap style logging handlers. 2023-12-12 14:31:30 -05:00
Billy Lynch
4da9c60893
Initial commit 2023-12-06 16:31:14 -07:00
Billy Lynch
2bf1735ac5
Initial commit 2023-12-06 16:21:07 -07:00