glog ==== Leveled execution logs for Go. This is an efficient pure Go implementation of leveled logs in the manner of the open source C++ package https://github.com/google/glog By binding methods to booleans it is possible to use the log package without paying the expense of evaluating the arguments to the log. Through the -vmodule flag, the package also provides fine-grained control over logging at the file level. The comment from glog.go introduces the ideas: 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 as Infof. It also provides V-style logging controlled by the -v and -vmodule=file=2 flags. Basic examples: glog.Info("Prepare to repel boarders") glog.Fatalf("Initialization failed: %s", err) See the documentation for the V function for an explanation of these examples: if glog.V(2) { glog.Info("Starting transaction...") } glog.V(2).Infoln("Processed", nItems, "elements") The repository contains an open source version of the log package used inside Google. The master copy of the source lives inside Google, not here. The code in this repo is for export only and is not itself under development. Feature requests will be ignored. Send bug reports to [email protected].
Leveled execution logs for Go
Owner
Go
Comments
-
Update README file to Markdown π
Since the README file of this repository was 5 years old. I took the initiative of creating this update in formatting using markdown. If you need anything else please respond to this pull request so I can change it.
Leave your thoughts below about this change. I would appreciate it if my pull request is accepted since this is my first contribution to golang. I would certainly like to contribute more.
Best Regards
-
Export glog bugfix.
@robpike This is an export of an internal bug fix. The original author is @Sajmani
Fix problem that -log_dir will not be respected when anything is logged before flag.Parse().
Before this change, premature logging resulted into log files being put in the default location (e.g. /tmp), but not the one specified by the log_dir flag.
After this change, premature logging will not result into the creation of the log files yet. Instead, the log message will be printed to stderr.
-
Add examples of flag use to README
It took me forever to figure out how to use the flag functionality; even in the generate godoc for glog, the instruction to call flag.Parse() is very easy to overlook.
By putting the information in the pull request in the README it will help prevent confusion to people either new to golang or who lack knowledge of the flag package.
-
Glogger type to allow adding prefixes to logs
Glogger contains a copy of the exported glog logging functions but it turns them into methods and allows adding prefixes to the logs. This allows "namespacing" the printout with something such as the name of the function that triggered it.
-
Configuration stack depth to fetch file name
In case glog is called from the delegate, file name in log is always the name of the delgate go file.
New flag "fileNameStackDepth" added to get the right file name from the stack trace in case logger is delegated.
Please merge
-
add max-logfile-size flag to config max threshold for log rotating
Hi @robpike : The existing glog will rotate log file only when its size reach 1.8GB, but it is too large and not configurable, so I add the max-logfile-size flag in order to support custom configuration max log file size.
-
Feature/logstash
Adds "--logstashtype" and "--logstashurl" CLI options.
--logstashtype: logs generated will be sent to the logstash server with the provided type. Defaults to "" (disabled). Examples:
The following results in logs that can be queried with the "serviced-master" type in elastic search/kibana: serviced -master --logstashtype="serviced-master"
The following results in logs that can be queried with the "serviced-add-host-foo" type in elastic search/kibana: serviced add-template foo --logstashtype="serviced-add-host-foo"
--logstashurl: defines the logstash url and port. Defaults to "172.17.42.1:5042".
-
Initial PR
The purpose of this PR is to:
- Ensure the rules set on the main branch work as expected
- Get initial feedback on the changes made to include year in the timestamp
Example log output before adding year
I0715 11:40:13.688222 77957 controller.go:839] NGINX is ready
Example log output after adding year
I20220715 11:40:13.688222 77957 controller.go:839] NGINX is ready
-
Rename -v flag to -vlevel
Setting flags in init() can cause conflicts with user's flags. Using -v is very common in cmdline utilities, so rename it to -vlevel to prevent problems.
-
Allow the user to prefix our flags' names
This problem has been reported quite a few times over the years; for example, see it reported at golang-nuts mailing list 1, and cue lang issue 2.
The problem is that, that glog package registers some flags in its init() function. The list of registered flags also includes the
-v
flag, which is usually used by developers either to control verbosity of their code-execution, or to show the software version. It's notable that all the complaints are regarding the-v
flag, and none about the other flags, since those other flags are unlikely be used by any other developer.The proposed fix allows the user of the glog package to change/prefix glog's flags' names, so that they will not conflict with any flags that they want to use.
This approach to the problem has a few advantages, compared to other options like, disabling all the flags in glog.
-
The default behaviour of the glog library is unchanged. So the current users of the library will not be affected.
-
Any new users who wish to use the -v, or other glog-occupied flag, can do so at build time.
-
The new users can still use the glog features/flags, albeit with a prefix.
-
We are not enforcing some specific prefix, which may also conflict.
-
The --help flag, correctly reports the changed/prefixed flag names.
$ ./main --help Usage of ./main: ... other glog: prefixed flags ... -glog:v value log level for V logs -glog:vmodule value comma-separated list of pattern=N settings for file-filtered logging -v value Emit verbose execution progress
Please also see sample code 3 that demonstrates the problem, and how the patch fixes the problem.
-
Related tags
CoLog is a prefix-based leveled execution log for Go
What's CoLog? CoLog is a prefix-based leveled execution log for Go. It's heavily inspired by Logrus and aims to offer similar features by parsing the
Blazing fast, structured, leveled logging in Go.
β‘ zap Blazing fast, structured, leveled logging in Go. Installation go get -u go.uber.org/zap Note that zap only supports the two most recent minor ve
Hierarchical, leveled, and structured logging library for Go
spacelog Please see http://godoc.org/github.com/spacemonkeygo/spacelog for info License Copyright (C) 2014 Space Monkey, Inc. Licensed under the Apach
Simple, customizable, leveled and efficient logging in Go
log Simple, customizable, leveled and efficient logging in Go Installation go get -u github.com/ermanimer/log Features log is a simple logging package
Library and program to parse and forward HAProxy logs
haminer Library and program to parse and forward HAProxy logs. Supported forwarder, Influxdb Requirements Go for building from source code git for dow
The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
The open-source platform for monitoring and observability. Grafana allows you to query, visualize, alert on and understand your metrics no matter wher
raft variant with topology order logs
Safe: A log that is safe if it has been replicated to a quorum, no matter whether or not the committed flag is set on any replica.
Very powerful server agent for collecting & sending logs & metrics with an easy-to-use web console.
logkit-community δΈζη Introduce Very powerful server agent for collecting & sending logs & metrics with an easy-to-use web console. logkit-community De
Like Prometheus, but for logs.
Loki: like Prometheus, but for logs. Loki is a horizontally-scalable, highly-available, multi-tenant log aggregation system inspired by Prometheus. It
Pixie gives you instant visibility by giving access to metrics, events, traces and logs without changing code.
Pixie gives you instant visibility by giving access to metrics, events, traces and logs without changing code.
Search and analysis tooling for structured logs
Zed The Zed system provides an open-source, cloud-native, and searchable data lake for semi-structured and structured data. Zed lakes utilize a supers
gtl - Gemini Tiny Logs - A simple TUI for the tinylog format on gemini
GTL: Gemini Tiny Logs Goal: A TUI for the tinylogs format on the gemini space. See screenshots Installation gtl requires go β₯ 1.16 From Source git clo
mtail - extract internal monitoring data from application logs for collection into a timeseries database
mtail - extract internal monitoring data from application logs for collection into a timeseries database mtail is a tool for extracting metrics from a
A customized GORM logger that implements the appropriate interface and uses Logrus to output logs
CryptoMath GORM Logger A customized GORM logger that implements the appropriate interface and uses Logrus to output logs. Install go get github.com/ma
Lumberjack is a Go package for writing logs to rolling files.
Lumberjack is a Go package for writing logs to rolling files.
This POC is built with the goal to collect events/logs from the host systems such as Kubernetes, Docker, VMs, etc. A buffering layer is added to buffer events from the collector
What is does This POC is build with the goal to collect events/logs from the host systems such as Kubernetes, docker, VMs etc. A buffering layer is ad
WIP Go Thing to download HCP Vault Logs
Example Go Script to pull HCP Vault Audit Logs WARNING: This makes use of unstable preview APIs which could change at any time! USE AT YOUR OWN PERIL
Stream logs through websockets, written in Go
Stream logs through websockets, written in Go
Request-logging-tool - A tool logs the md5 codes of the responses of the given domains in parameter
request-logging-tool Application to send http requests and log the md5 responses