All Projects → appliedgocode → What

appliedgocode / What

Licence: bsd-3-clause
Debug-level logging for developers (only!)

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to What

Stern
⎈ Multi pod and container log tailing for Kubernetes -- Friendly fork of https://github.com/wercker/stern
Stars: ✭ 268 (+267.12%)
Mutual labels:  logging, debugging
Clockwork Chrome
Clockwork - php dev tools integrated to your browser - Chrome extension
Stars: ✭ 415 (+468.49%)
Mutual labels:  logging, debugging
Clockwork
Clockwork - php dev tools in your browser - server-side component
Stars: ✭ 4,076 (+5483.56%)
Mutual labels:  logging, debugging
Wonolog
Monolog-based logging package for WordPress.
Stars: ✭ 142 (+94.52%)
Mutual labels:  logging, debugging
Stern
⎈ Multi pod and container log tailing for Kubernetes
Stars: ✭ 5,614 (+7590.41%)
Mutual labels:  logging, debugging
Timber Elixir
🌲 Great Elixir logging made easy
Stars: ✭ 226 (+209.59%)
Mutual labels:  logging, debugging
Xcglogger
A debug log framework for use in Swift projects. Allows you to log details to the console (and optionally a file), just like you would have with NSLog() or print(), but with additional information, such as the date, function name, filename and line number.
Stars: ✭ 3,710 (+4982.19%)
Mutual labels:  logging, debugging
React Native Logs
Performance-aware simple logger for React-Native with namespaces, custom levels and custom transports (colored console, file writing, etc.)
Stars: ✭ 84 (+15.07%)
Mutual labels:  logging, debugging
Traceback with variables
Adds variables to python traceback. Simple, lightweight, controllable. Debug reasons of exceptions by logging or pretty printing colorful variable contexts for each frame in a stacktrace, showing every value. Dump locals environments after errors to console, files, and loggers. Works in Jupyter and IPython. Install with pip or conda.
Stars: ✭ 509 (+597.26%)
Mutual labels:  logging, debugging
Snoop
A powerful set of Python debugging tools, based on PySnooper
Stars: ✭ 467 (+539.73%)
Mutual labels:  logging, debugging
Rogcat
A `adb logcat` wrapper
Stars: ✭ 137 (+87.67%)
Mutual labels:  logging, debugging
Httplog
Log outgoing HTTP requests in ruby
Stars: ✭ 633 (+767.12%)
Mutual labels:  logging, debugging
Android Remote Debugger
A library for remote logging, database debugging, shared preferences and network requests
Stars: ✭ 132 (+80.82%)
Mutual labels:  logging, debugging
Utern
Multi group and stream log tailing for AWS CloudWatch Logs.
Stars: ✭ 241 (+230.14%)
Mutual labels:  logging, debugging
Debug
A tiny JavaScript debugging utility modelled after Node.js core's debugging technique. Works in Node.js and web browsers
Stars: ✭ 9,912 (+13478.08%)
Mutual labels:  logging, debugging
Cocoadebug
iOS Debugging Tool 🚀
Stars: ✭ 3,769 (+5063.01%)
Mutual labels:  logging, debugging
Vlog
An in-display logging library for Android 📲
Stars: ✭ 86 (+17.81%)
Mutual labels:  logging, debugging
Log Process Errors
Show some ❤️ to Node.js process errors
Stars: ✭ 424 (+480.82%)
Mutual labels:  logging, debugging
Rxjs Spy
A debugging library for RxJS
Stars: ✭ 576 (+689.04%)
Mutual labels:  logging, debugging
Viztracer
VizTracer is a low-overhead logging/debugging/profiling tool that can trace and visualize your python code execution.
Stars: ✭ 874 (+1097.26%)
Mutual labels:  logging, debugging

What: debug-level logging that vanishes from production code

How to import the package

import "appliedgo.net/what"

(Do not use the direct path to the repo.)

What does what do

what is a set of simple and easy logging functions, suitable for tracing any kind of activities in your code. what can print the current function name, quickly Printf-format your data, and dumps data structures.

And last not least, no what calls reach your production binary (unless you want it so). Debug-level logging is for developers only.

Who need this?

You definitely should give what a closer look if you -

How does it work?

First of all, what is intended for debug-level logging only. So,

  • Use what for tracing and debugging your code. ("Does my code do what I intended? Does this variable contain what I expect? Why does the loop not stop when the break condition should be fulfilled?...")
  • Use log for user-facing log output. ("What was the app doing before it said, 'cannot connect to server'? Did that service already sync or is it still waiting for other services?...")

You have to explicitly enable what logging through build flags (see below).

Available functions

what.Happens("Foo: %s", bar) // log.Printf("Foo: %s\n", bar)
what.If(cond, "Foo: %s", bar) // only print if cond is true
what.Func() // Print out the fully qualified function name
what.Is(var) // dump the structure and contents of var 

Spread these calls across your code, especially in places you want to observe closer.

Debug-level logging is useful alongside unit testing as well as using a debugger. It does not attempt to replace any of these concepts.

Enabling and disabling

Enable all functions

Simply pass the what tag to go build, go install, go test etc:

go build -tags what

And now just lean back and see your code talking about what it does.

Enable specific functions

To reduce the noise, you can decide to compile only specific parts of what:

  • whathappens only enables what.Happens() and what.If().
  • whatfunc only enables what.Func().
  • whatis only enables what.Is().

All disabled functions get replaced by no-ops.

Example:

go build -tags whathappens

You can also choose a combination of the above, for example: go build -tags whathappens,whatis

Enable debug logging for specific packages only

Go's build tag mechanism cannot help here, so this is done through an environment variable called "WHAT".

To enable specific packages for debug logging, set WHAT to a package name, or a list of package names.

Disable what

Nothing easier than that! Without any of the above build tags, all funtions get replace by no-ops, ready for being optimized away entirely (if the compiler decides to do so).

  • No log output
  • No bloated binary
  • No security leak from chatty binaries.

Non-features

  • Uses only stdlib log, no custom logger configurable
  • No custom variable dumper/pretty-printer. At the moment, what uses github.com/davecgh/go-spew. See Spew's docs about the syntax used for printing a variable.

Restrictions

Although go run should recognize all build flags that go build recognizes (including -tags), it seems that go run main.go -tags what does not consider the tag. Use go build -tags what && ./main instead.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].