Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pull log 1.14.0 with it's no_net (no_http) #34

Merged
merged 4 commits into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,3 +142,17 @@ It does this by defaulting to the bundle provided by `golang.org/x/crypto/x509ro
See https://github.com/fortio/multicurl for a good example.

If you do not want this behavior, build using `-tags no_tls_fallback`.

### Small binaries

If you application doesn't do http request/response logging at all, use `-tags no_http` or `-tags no_net` (that one will also imply `no_tls_fallback`) and save 1.6 Mbytes in your binary's size (because the linker isn't smart enough to see net/http isn't actually used) (1.1Mbytes for log's no_http and 530k from the no_tls_fallback)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nonblocking:

For constituency I would use, a space plus sane units

Suggested change
If you application doesn't do http request/response logging at all, use `-tags no_http` or `-tags no_net` (that one will also imply `no_tls_fallback`) and save 1.6 Mbytes in your binary's size (because the linker isn't smart enough to see net/http isn't actually used) (1.1Mbytes for log's no_http and 530k from the no_tls_fallback)
If you application doesn't do http request/response logging at all, use `-tags no_http` or `-tags no_net` (that one will also imply `no_tls_fallback`) and save 1.6 Mbytes in your binary's size (because the linker isn't smart enough to see net/http isn't actually used) (1.1 Mbytes for log's no_http and 530 kbytes from the no_tls_fallback)

or

Suggested change
If you application doesn't do http request/response logging at all, use `-tags no_http` or `-tags no_net` (that one will also imply `no_tls_fallback`) and save 1.6 Mbytes in your binary's size (because the linker isn't smart enough to see net/http isn't actually used) (1.1Mbytes for log's no_http and 530k from the no_tls_fallback)
If you application doesn't do http request/response logging at all, use `-tags no_http` or `-tags no_net` (that one will also imply `no_tls_fallback`) and save 1.6 MB in your binary's size (because the linker isn't smart enough to see net/http isn't actually used) (1.1 MB for log's no_http and 530 kB from the no_tls_fallback)


And, if you don't need any of the advanced JSON logging (which is quite likely with a cli), use `-tags no_json` the logger will still produce json structured logging just not as advanced if what you log are deep structures - this saves another 130k or so.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
And, if you don't need any of the advanced JSON logging (which is quite likely with a cli), use `-tags no_json` the logger will still produce json structured logging just not as advanced if what you log are deep structures - this saves another 130k or so.
And, if you don't need any of the advanced JSON logging (which is quite likely with a cli), use `-tags no_json` the logger will still produce json structured logging just not as advanced if what you log are deep structures - this saves another 130 kB or so.

or

Suggested change
And, if you don't need any of the advanced JSON logging (which is quite likely with a cli), use `-tags no_json` the logger will still produce json structured logging just not as advanced if what you log are deep structures - this saves another 130k or so.
And, if you don't need any of the advanced JSON logging (which is quite likely with a cli), use `-tags no_json` the logger will still produce JSON structured logging just not as advanced if what you log are deep structures - this saves another 130 kbytes or so.


These tags are from [fortio.org/log](https://github.com/fortio/log) v1.14 and later

In summary: for smallest pure local cli binaries using this package:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
In summary: for smallest pure local cli binaries using this package:
In summary: for smallest pure local CLI binaries using this package:

```
CGO_ENABLE=0 go build -trimpath -ldflags="-w -s" -tags no_net,no_json .
```
saves ~1.7Mbytes in total (a basic cli dependending on this package will then only be about 300k more as an hello world yet include color help, buildinfo, version, logging etc)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
saves ~1.7Mbytes in total (a basic cli dependending on this package will then only be about 300k more as an hello world yet include color help, buildinfo, version, logging etc)
saves ~1.7 Mbytes in total (a basic CLI dependending on this package will then only be about 300 kbytes more as an hello world yet include color help, buildinfo, version, logging etc)
Suggested change
saves ~1.7Mbytes in total (a basic cli dependending on this package will then only be about 300k more as an hello world yet include color help, buildinfo, version, logging etc)
saves ~1.7 MB in total (a basic CLI dependending on this package will then only be about 300 kB more as an hello world yet include color help, buildinfo, version, logging etc)

4 changes: 2 additions & 2 deletions ca_bundle.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
// (c) 2024 Fortio Authors
// See LICENSE

//go:build !no_tls_fallback
// +build !no_tls_fallback
//go:build !no_tls_fallback && !no_net
// +build !no_tls_fallback,!no_net

package cli // import "fortio.org/cli"

Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ module fortio.org/cli
go 1.18

require (
fortio.org/log v1.12.2
fortio.org/log v1.14.0
fortio.org/version v1.0.4
golang.org/x/crypto/x509roots/fallback v0.0.0-20240604170348-d4e7c9cb6cb8
golang.org/x/crypto/x509roots/fallback v0.0.0-20240626151235-a6a393ffd658
)

require fortio.org/struct2env v0.4.0 // indirect
require fortio.org/struct2env v0.4.1 // indirect
12 changes: 6 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
fortio.org/log v1.12.2 h1:JwLDFvEUKGfqA09fcf+mOn8kxsvwhjXV92xghxNnnwA=
fortio.org/log v1.12.2/go.mod h1:1tMBG/Elr6YqjmJCWiejJp2FPvXg7/9UAN0Rfpkyt1o=
fortio.org/struct2env v0.4.0 h1:k5alSOTf3YHiB3MuacjDHQ3YhVWvNZ95ZP/a6MqvyLo=
fortio.org/struct2env v0.4.0/go.mod h1:lENUe70UwA1zDUCX+8AsO663QCFqYaprk5lnPhjD410=
fortio.org/log v1.14.0 h1:ZkIc3Qqwfs9Dd931k07YzoC+bqCpJKEjVlZwxgXW3Nw=
fortio.org/log v1.14.0/go.mod h1:1tnXMqd5rZAgvSeHJkD2xXpyXRBzdeXtKLZuzNLIwtA=
fortio.org/struct2env v0.4.1 h1:rJludAMO5eBvpWplWEQNqoVDFZr4RWMQX7RUapgZyc0=
fortio.org/struct2env v0.4.1/go.mod h1:lENUe70UwA1zDUCX+8AsO663QCFqYaprk5lnPhjD410=
fortio.org/version v1.0.4 h1:FWUMpJ+hVTNc4RhvvOJzb0xesrlRmG/a+D6bjbQ4+5U=
fortio.org/version v1.0.4/go.mod h1:2JQp9Ax+tm6QKiGuzR5nJY63kFeANcgrZ0osoQFDVm0=
golang.org/x/crypto/x509roots/fallback v0.0.0-20240604170348-d4e7c9cb6cb8 h1:+kWDWI3Eb5cPIOr4cP+R2RLDwK3/dXppL+7XmSOh2LA=
golang.org/x/crypto/x509roots/fallback v0.0.0-20240604170348-d4e7c9cb6cb8/go.mod h1:kNa9WdvYnzFwC79zRpLRMJbdEFlhyM5RPFBBZp/wWH8=
golang.org/x/crypto/x509roots/fallback v0.0.0-20240626151235-a6a393ffd658 h1:i7K6wQLN/0oxF7FT3tKkfMCstxoT4VGG36YIB9ZKLzI=
golang.org/x/crypto/x509roots/fallback v0.0.0-20240626151235-a6a393ffd658/go.mod h1:kNa9WdvYnzFwC79zRpLRMJbdEFlhyM5RPFBBZp/wWH8=