Leveled execution logs for Go

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].
Owner
Go
The Go Programming Language
Go
Comments
  • Update README file to Markdown πŸ“ƒ

    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.

    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

    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 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

    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

    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

    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

    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

    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

    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.

    1. The default behaviour of the glog library is unchanged. So the current users of the library will not be affected.

    2. Any new users who wish to use the -v, or other glog-occupied flag, can do so at build time.

    3. The new users can still use the glog features/flags, albeit with a prefix.

    4. We are not enforcing some specific prefix, which may also conflict.

    5. 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.

CoLog is a prefix-based leveled execution log for Go
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

Dec 14, 2022
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

Jan 7, 2023
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

Apr 27, 2021
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

Dec 20, 2021
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

Aug 17, 2022
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 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

Jan 3, 2023
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.

May 28, 2022
Very powerful server agent for collecting & sending logs & metrics with an easy-to-use web console.
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

Dec 29, 2022
Like Prometheus, but for logs.
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

Dec 30, 2022
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.

Pixie gives you instant visibility by giving access to metrics, events, traces and logs without changing code.

Jan 4, 2023
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

Jan 5, 2023
gtl - Gemini Tiny Logs - A simple TUI for the tinylog format on gemini
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

Dec 1, 2022
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 - extract internal monitoring data from application logs for collection into a timeseries database mtail is a tool for extracting metrics from a

Dec 29, 2022
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

Nov 6, 2021
Lumberjack is a Go package for writing logs to rolling files.

Lumberjack is a Go package for writing logs to rolling files.

Feb 24, 2022
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
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

Nov 11, 2022
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

Feb 6, 2022
Stream logs through websockets, written in Go

Stream logs through websockets, written in Go

Jan 8, 2022
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

Jan 7, 2022