Golang Glog

7 views
Skip to first unread message

Terese Kofoot

unread,
Dec 5, 2023, 1:34:14 AM12/5/23
to Mew ユーザ

Package glog implements logging analogous to the Google-internal C++ INFO/ERROR/V setup. It provides the functions Info, Warning, Error, Fatal, plus formatting variants such as Infof. It also provides V-style loggingcontrolled by the -v and -vmodule=file=2 flags.

Package glog implements logging analogous to the Google-internal C++ INFO/ERROR/V setup.It provides functions Info, Warning, Error, Fatal, plus formatting variants such asInfof. It also provides V-style logging controlled by the -v and -vmodule=file=2 flags.

Golang glog


Download Zip https://urluss.com/2wIh9d



Well, I skimmed the docs and glog is controlled by flags, so they have to be present in order for this to work. In your case, you will have to set them at runtime. You are going to want to set logtostderr=true to log to stderr and set the severity level to one of the possible options:
stderrthreshold=[WARNINGERRORINFOFATAL]

$ go build
go: finding github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b
go: github.com/golang/gl...@v0.0.0-20160126235308-23def4e6c14b: unexpected status ( :pa...@artifacts.domain.com/api/go/go-domain/github.com/golang/glog/@v/23def4e6c14b.mod): 404 Not Found
go: error loading module requirements

JFROG_CLI_LOG_LEVEL=DEBUG jfrog rt go build go-domain --url= --user=user --password=pass
The CLI commands require the Artifactory URL and authentication details
Configuring JFrog CLI with these parameters now will save you having to include them as command options.
You can also configure these parameters later using the 'config' command.
Configure now? (y/n): n
[Info] Using go: go version go1.12 darwin/amd64[Debug] Initializing protocol regexp
[Debug] Initializing not found regexp
[Debug] Initializing unrecognized import path regexp
[Debug] Initializing unknown revision regexp
go: finding github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b
go: github.com/golang/gl...@v0.0.0-20160126235308-23def4e6c14b: unexpected status (https://***.***@artifacts.domain.com/api/go/go-domain/github.com/golang/glog/@v/23def4e6c14b.mod): 404 Not Found
[Info] Received 404 Not Found:github.com/golang/gl...@v0.0.0-20160126235308-23def4edomain6c14b from Artifactory. Trying to download dependencies from VCS...
[Debug] Trying download the dependencies from the VCS...
[Debug] Sum file exists: /Users/ghe.rivero/code/github.com/gherivero/hello
[Debug] Removing file: /Users/ghe.rivero/code/github.com/gherivero/hello/go.sum
[Info] Running 'go mod graph' in /Users/ghe.rivero/code/github.com/gherivero/hello
go: finding github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b
github.com/GheRivero/hello github.com/golang/gl...@v0.0.0-20160126235308-23def4e6c14b
[Debug] github.com/GheRivero/hello github.com/golang/gl...@v0.0.0-20160126235308-23def4e6c14b[Debug] Restoring file: /Users/ghe.rivero/code/github.com/gherivero/hello/go.sum
[Debug] Sum file exists: /Users/ghe.rivero/code/github.com/gherivero/hello
[Debug] Removing file: /Users/ghe.rivero/code/github.com/gherivero/hello/go.sum
[Debug] Artifactory head request response for -domain/github.com/golang/glog/@v/v0.0.0-20160126235308-23def4e6c14b.mod : 404
[Debug] Downloading dependency from VCS: github.com/golang/gl...@v0.0.0-20160126235308-23def4e6c14b
[Debug] Running go mod download -json github.com/golang/gl...@v0.0.0-20160126235308-23def4e6c14b

"Path": "github.com/golang/glog",
"Version": "v0.0.0-20160126235308-23def4e6c14b",
"Info": "/Users/ghe.rivero/go/pkg/mod/cache/download/github.com/golang/glog/@v/v0.0.0-20160126235308-23def4e6c14b.info",
"GoMod": "/Users/ghe.rivero/go/pkg/mod/cache/download/github.com/golang/glog/@v/v0.0.0-20160126235308-23def4e6c14b.mod",
"Zip": "/Users/ghe.rivero/go/pkg/mod/cache/download/github.com/golang/glog/@v/v0.0.0-20160126235308-23def4e6c14b.zip",
"Dir": "/Users/ghe.rivero/go/pkg/mod/github.com/golang/gl...@v0.0.0-20160126235308-23def4e6c14b",
"Sum": "h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58=",
"GoModSum": "h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q="

[Debug] Restoring file: /Users/ghe.rivero/code/github.com/gherivero/hello/go.sum
[Info] Publishing: github.com/golang/glog:v0.0.0-20160126235308-23def4e6c14b to go-domain:1/1
[Debug] The Artifactory version is: 6.7.3
[Info] Done building and publishing 1 go dependencies to Artifactory out of a total of 1 dependencies.

The decision to create klog was one that wasn't made lightly, but it was necessary due to somedrawbacks that are present in glog. Ultimately, the fork was created due to glog not being under active development; this can be seen in the glog README:

This package can be used side by side with glog. This example shows how to initialize and synchronize flags from the global flag.CommandLine FlagSet. In addition, the example makes use of stderr as combined output by setting alsologtostderr (or logtostderr) to true.

First, the import path is derived in a known way from the URL of thesource code. For Bitbucket, GitHub, Google Code, and Launchpad, theroot directory of the repository is identified by the repository'smain URL, without the https:// prefix. Subdirectories are named byadding to that path.For example, the source code of the Google logging package glogis obtained by running

Projects should generally follow the official recommendation to organize theirGo workspaces: golang.org/doc/code.htmlThese are some additional recommendations and naming conventions for organizingGo project workspaces in Chromium OS:

After seeing people pointing out the challenges of using glog, I expected to runinto a few myself. A couple of resources that I came across once I had decided to useglog were this blog postand this GitHub gist.Both of these resources display the usage in code with only a single, main package,but did effectively display the use of flag.Parse() before logging.

I am trying to integrate a package into a go-swagger generated API that is using the github.com/golang/glog logger.When I initialize the glog logger it appears to shield the flags defined in the go-swagger runtime.

If I initialize glog in the config_xxx.go I don't get the go-swagger runtime flags, and if I initialize glog in the engine, I get the error: logging before flag.Parse.I realize that this question is not so much about logging per se, but more about how to merge the flag sets defined by different packages.

Implementation of an RPC system called gRPC in Golang.Remote Procedure Calls (RPCs) provide a useful abstraction for buildingdistributed applications and services. This library provides a concreteimplementation of the gRPC protocol, layered over HTTP/2. Other Packages Related to golang-google-grpc-dev

  • depends
  • recommends
  • suggests
  • enhances
  • dep:golang-github-golang-protobuf-1-3-dev Go support for protocol buffers (version v1.3.x) or golang-github-golang-protobuf-1-5-dev Go support for protocol buffers (version v1.5.x)
  • dep:golang-github-google-go-cmp-dev Package for comparing Go values in tests
  • dep:golang-glog-dev Leveled execution logs for Go or golang-github-golang-glog-dev Package not available
  • dep:golang-golang-x-net-dev (>= 1:0.0+git20170629) Supplementary Go networking libraries
  • dep:golang-golang-x-oauth2-dev make OAuth2 authorized and authenticated HTTP requests
  • dep:golang-golang-x-oauth2-google-dev Google APIs support for OAuth2
  • dep:golang-golang-x-sys-dev Low-level interaction with the operating system
  • dep:golang-google-genproto-dev Generated Go packages for common protocol buffer types Download golang-google-grpc-dev Download for all available architectures ArchitecturePackage SizeInstalled SizeFiles all522.5 kB3,633.0 kB [list of files] This page is also available in the following languages (How to set the default document language):

The two most popular logging frameworks for Go appear to beglog and logrus. The popularity of glog is surprising, since it hasn't been updated in several years. logrus is better maintained and used in popular projects like Docker, so we'll be focusing on it.

For example I have a library that uses glog for logging. If I import that library and also use glog in the main application I see a panic because a flag is redefined. There are other examples of this. For example only a single version of database/sql library can be imported.

Thanks. There was another conflict with another imported library importing another version of glog that was causing a panic but was not showing up in stack trace leading me to believe the libraries would not automatically use the vendor directory.

eebf2c3492
Reply all
Reply to author
Forward
0 new messages