• Stars
    star
    7,017
  • Rank 5,577 (Top 0.2 %)
  • Language
    C++
  • License
    BSD 3-Clause "New...
  • Created over 9 years ago
  • Updated 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

C++ implementation of the Google logging module

Google Logging Library

Linux Github actions Windows Github actions macOS Github actions Codecov

Google Logging (glog) is a C++14 library that implements application-level logging. The library provides logging APIs based on C++-style streams and various helper macros.

Getting Started

You can log a message by simply streaming things to LOG(<a particular severity level>), e.g.,

#include <glog/logging.h>

int main(int argc, char* argv[]) {
    // Initialize Google’s logging library.
    google::InitGoogleLogging(argv[0]);

    // ...
    LOG(INFO) << "Found " << num_cookies << " cookies";
}

The library can be installed using various package managers or compiled from source. For a detailed overview of glog features and their usage, please refer to the user guide.

The above example requires further Bazel or CMake setup for use in own projects.

Table of Contents

Usage in Projects

Assuming that glog was previously built using CMake or installed using a package manager, you can use the CMake command find_package to build against glog in your CMake project as follows:

cmake_minimum_required (VERSION 3.16)
project (myproj VERSION 1.0)

find_package (glog 0.7.0 REQUIRED)

add_executable (myapp main.cpp)
target_link_libraries (myapp glog::glog)

Compile definitions and options will be added automatically to your target as needed.

Alternatively, glog can be incorporated into using the CMake command add_subdirectory to include glog directly from a subdirectory of your project by replacing the find_package call from the previous snippet by add_subdirectory. The glog::glog target is in this case an ALIAS library target for the glog library target.

Building from Source

Bazel

To use glog within a project which uses the Bazel build tool, add the following lines to your WORKSPACE file:

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
    name = "com_github_gflags_gflags",
    sha256 = "34af2f15cf7367513b352bdcd2493ab14ce43692d2dcd9dfc499492966c64dcf",
    strip_prefix = "gflags-2.2.2",
    urls = ["https://github.com/gflags/gflags/archive/v2.2.2.tar.gz"],
)

http_archive(
    name = "com_github_google_glog",
    sha256 = "122fb6b712808ef43fbf80f75c52a21c9760683dae470154f02bddfc61135022",
    strip_prefix = "glog-0.6.0",
    urls = ["https://github.com/google/glog/archive/v0.6.0.zip"],
)

You can then add @com_github_google_glog//:glog to the deps section of a cc_binary or cc_library rule, and #include <glog/logging.h> to include it in your source code. Here’s a simple example:

cc_binary(
    name = "main",
    srcs = ["main.cc"],
    deps = ["@com_github_google_glog//:glog"],
)

CMake

glog can be compiled using CMake on a wide range of platforms. The typical workflow for building glog on a Unix-like system with GNU Make as build tool is as follows:

  1. Clone the repository and change into source directory.
git clone https://github.com/google/glog.git
cd glog
  1. Run CMake to configure the build tree.
cmake -S . -B build -G "Unix Makefiles"

CMake provides different generators, and by default will pick the most relevant one to your environment. If you need a specific version of Visual Studio, use cmake . -G <generator-name>, and see cmake --help for the available generators. Also see -T <toolset-name>, which can be used to request the native x64 toolchain with -T host=x64.

  1. Afterwards, generated files can be used to compile the project.
cmake --build build
  1. Test the build software (optional).
cmake --build build --target test
  1. Install the built files (optional).
cmake --build build --target install

Once successfully built, glog can be integrated into own projects.

conan

You can download and install glog using the conan package manager:

pip install conan
conan install -r conancenter glog/<glog-version>@

The glog recipe in conan center is kept up to date by conan center index community contributors. If the version is out of date, please create an issue or pull request on the conan-center-index repository.

vcpkg

You can download and install glog using the vcpkg dependency manager:

git clone https://github.com/Microsoft/vcpkg.git
cd vcpkg
./bootstrap-vcpkg.sh
./vcpkg integrate install
./vcpkg install glog

The glog port in vcpkg is kept up to date by Microsoft team members and community contributors. If the version is out of date, please create an issue or pull request on the vcpkg repository.

User Guide

glog defines a series of macros that simplify many common logging tasks. You can log messages by severity level, control logging behavior from the command line, log based on conditionals, abort the program when expected conditions are not met, introduce your own verbose logging levels, customize the prefix attached to log messages, and more.

Following sections describe the functionality supported by glog. Please note this description may not be complete but limited to the most useful ones. If you want to find less common features, please check header files under src/glog directory.

Severity Levels

You can specify one of the following severity levels (in increasing order of severity):

  1. INFO,
  2. WARNING,
  3. ERROR, and
  4. FATAL.

Logging a FATAL message terminates the program (after the message is logged).

Messages of a given severity are logged not only to corresponding severity logfile but also to other logfiles of lower severity. For instance, a message of severity FATAL will be logged to logfiles of severity FATAL, ERROR, WARNING, and INFO.

The DFATAL severity logs a FATAL error in debug mode (i.e., there is no NDEBUG macro defined), but avoids halting the program in production by automatically reducing the severity to ERROR.

Unless otherwise specified, glog uses the format

<tmp>/<program name>.<hostname>.<user name>.log.<severity level>.<date>-<time>.<pid>

for log filenames written to a directory designated as <tmp> and determined according to the following rules.

Windows

glog uses the GetTempPathA API function to retrieve the directory for temporary files with a fallback to

  1. C:\TMP\
  2. C:\TEMP\

(in the order given.)

non-Windows

The directory is determined by referencing the environment variables

  1. TMPDIR
  2. TMP

if set with a fallback to /tmp/.

The default path to a log file on Linux, for instance, could be

/tmp/hello_world.example.com.hamaji.log.INFO.20080709-222411.10474

By default, glog echos ERROR and FATAL messages to standard error in addition to log files.

Log Line Prefix Format

Log lines have this form:

Lyyyymmdd hh:mm:ss.uuuuuu threadid file:line] msg...

where the fields are defined as follows:

Placeholder Meaning
L A single character, representing the log level (e.g., I for INFO)
yyyy The year
mm The month (zero padded; i.e., May is 05)
dd The day (zero padded)
hh:mm:ss.uuuuuu Time in hours, minutes and fractional seconds
threadid The space-padded thread ID
file The file name
line The line number
msg The user-supplied message

Example:

I1103 11:57:31.739339 24395 google.cc:2341] Command line: ./some_prog
I1103 11:57:31.739403 24395 google.cc:2342] Process id 24395

Although microseconds are useful for comparing events on a single machine, clocks on different machines may not be well synchronized. Hence, use with caution when comparing the low bits of timestamps from different machines.

Customizing the Log Line Prefix

The predefined log line prefix can be replaced using a user-provided callback that formats the corresponding output.

For each log entry, the callback will be invoked with a reference to a google::LogMessage instance containing the severity, filename, line number, thread ID, and time of the event. It will also be given a reference to the output stream, whose contents will be prepended to the actual message in the final log line.

For example, the following function outputs a prefix that matches glog's default format. The third parameter data can be used to access user-supplied data which unless specified defaults to nullptr.

void MyPrefixFormatter(std::ostream& s, const google::LogMessage& m, void* /*data*/) {
   s << google::GetLogSeverityName(m.severity())[0]
   << setw(4) << 1900 + m.time().year()
   << setw(2) << 1 + m.time().month()
   << setw(2) << m.time().day()
   << ' '
   << setw(2) << m.time().hour() << ':'
   << setw(2) << m.time().min()  << ':'
   << setw(2) << m.time().sec() << "."
   << setw(6) << m.time().usec()
   << ' '
   << setfill(' ') << setw(5)
   << m.thread_id() << setfill('0')
   << ' '
   << m.basename() << ':' << m.line() << "]";
}

To enable the use of a prefix formatter, use the

google::InstallPrefixFormatter(&MyPrefixFormatter);

function to pass a pointer to the corresponding MyPrefixFormatter callback during initialization. InstallPrefixFormatter takes a second optional argument of type void* that allows supplying user data to the callback.

Setting Flags

Several flags influence glog’s output behavior. If the Google gflags library is installed on your machine, the build system will automatically detect and use it, allowing you to pass flags on the command line. For example, if you want to activate --logtostderr, you can start your application with the following command line:

./your_application --logtostderr=1

If the Google gflags library isn’t installed, you set flags via environment variables, prefixing the flag name with GLOG_, e.g.,

GLOG_logtostderr=1 ./your_application

The following flags are most commonly used:

logtostderr (bool, default=false)

Log messages to stderr instead of logfiles.

You can set boolean flags to true by specifying 1, true, or yes. To set boolean flags to false, specify 0, false, or no. In either case the spelling is case-insensitive.

stderrthreshold (int, default=2, which is ERROR)

Copy log messages at or above this level to stderr in addition to logfiles. The numbers of severity levels INFO, WARNING, ERROR, and FATAL are 0, 1, 2, and 3, respectively.

minloglevel (int, default=0, which is INFO)

Log messages at or above this level. Again, the numbers of severity levels INFO, WARNING, ERROR, and FATAL are 0, 1, 2, and 3, respectively.

log_dir (string, default="")

If specified, logfiles are written into this directory instead of the default logging directory.

v (int, default=0)

Show all VLOG(m) messages for m less or equal the value of this flag. Overridable by --vmodule. Refer to verbose logging for more detail.

vmodule (string, default="")

Per-module verbose level. The argument has to contain a comma-separated list of <module name>=<log level>. <module name> is a glob pattern (e.g., gfs* for all modules whose name starts with "gfs"), matched against the filename base (that is, name ignoring .cc/.h./-inl.h). <log level> overrides any value given by --v. See also verbose logging for more details.

Additional flags are defined in flags.cc. Please see the source for their complete list.

You can also modify flag values in your program by modifying global variables FLAGS_* . Most settings start working immediately after you update FLAGS_* . The exceptions are the flags related to destination files. For example, you might want to set FLAGS_log_dir before calling google::InitGoogleLogging . Here is an example:

LOG(INFO) << "file";
// Most flags work immediately after updating values.
FLAGS_logtostderr = 1;
LOG(INFO) << "stderr";
FLAGS_logtostderr = 0;
// This won’t change the log destination. If you want to set this
// value, you should do this before google::InitGoogleLogging .
FLAGS_log_dir = "/some/log/directory";
LOG(INFO) << "the same file";

Conditional / Occasional Logging

Sometimes, you may only want to log a message under certain conditions. You can use the following macros to perform conditional logging:

LOG_IF(INFO, num_cookies > 10) << "Got lots of cookies";

The "Got lots of cookies" message is logged only when the variable num_cookies exceeds 10. If a line of code is executed many times, it may be useful to only log a message at certain intervals. This kind of logging is most useful for informational messages.

LOG_EVERY_N(INFO, 10) << "Got the " << google::COUNTER << "th cookie";

The above line outputs a log messages on the 1st, 11th, 21st, ... times it is executed.

The placeholder google::COUNTER identifies the recurring repetition.

You can combine conditional and occasional logging with the following macro.

LOG_IF_EVERY_N(INFO, (size > 1024), 10) << "Got the " << google::COUNTER
                                        << "th big cookie";

Instead of outputting a message every nth time, you can also limit the output to the first n occurrences:

LOG_FIRST_N(INFO, 20) << "Got the " << google::COUNTER << "th cookie";

Outputs log messages for the first 20 times it is executed. The google::COUNTER identifier indicates which repetition is happening.

Other times, it is desired to only log a message periodically based on a time. For instance, to log a message every 10ms:

LOG_EVERY_T(INFO, 0.01) << "Got a cookie";

Or every 2.35s:

LOG_EVERY_T(INFO, 2.35) << "Got a cookie";

Debug Mode Support

Special "debug mode" logging macros only have an effect in debug mode and are compiled away to nothing for non-debug mode compiles. Use these macros to avoid slowing down your production application due to excessive logging.

DLOG(INFO) << "Found cookies";
DLOG_IF(INFO, num_cookies > 10) << "Got lots of cookies";
DLOG_EVERY_N(INFO, 10) << "Got the " << google::COUNTER << "th cookie";
DLOG_FIRST_N(INFO, 10) << "Got the " << google::COUNTER << "th cookie";
DLOG_EVERY_T(INFO, 0.01) << "Got a cookie";

CHECK Macros

It is a good practice to check expected conditions in your program frequently to detect errors as early as possible. The CHECK macro provides the ability to abort the application when a condition is not met, similar to the assert macro defined in the standard C library.

CHECK aborts the application if a condition is not true. Unlike assert, it is *not* controlled by NDEBUG, so the check will be executed regardless of compilation mode. Therefore, fp->Write(x) in the following example is always executed:

CHECK(fp->Write(x) == 4) << "Write failed!";

There are various helper macros for equality/inequality checks -CHECK_EQ, CHECK_NE, CHECK_LE, CHECK_LT, CHECK_GE, and CHECK_GT. They compare two values, and log a FATAL message including the two values when the result is not as expected. The values must have operator<<(ostream, ...) defined.

You may append to the error message like so:

CHECK_NE(1, 2) << ": The world must be ending!";

We are very careful to ensure that each argument is evaluated exactly once, and that anything which is legal to pass as a function argument is legal here. In particular, the arguments may be temporary expressions which will end up being destroyed at the end of the apparent statement, for example:

CHECK_EQ(string("abc")[1], ’b’);

The compiler reports an error if one of the arguments is a pointer and the other is nullptr. To work around this, simply static_cast nullptr to the type of the desired pointer.

CHECK_EQ(some_ptr, static_cast<SomeType*>(nullptr));

Better yet, use the CHECK_NOTNULL macro:

CHECK_NOTNULL(some_ptr);
some_ptr->DoSomething();

Since this macro returns the given pointer, this is very useful in constructor initializer lists.

struct S {
    S(Something* ptr) : ptr_(CHECK_NOTNULL(ptr)) {}
    Something* ptr_;
};

Due to the argument forwarding, CHECK_NOTNULL cannot be used to simultaneously stream an additional custom message. To provide a custom message, one can use the macro CHECK_EQ prior to the failing check.

If you are comparing C strings (char *), a handy set of macros performs both case sensitive and insensitive comparisons - CHECK_STREQ, CHECK_STRNE, CHECK_STRCASEEQ, and CHECK_STRCASENE. The CHECK_*CASE* macro variants are case-insensitive. You can safely pass nullptr pointers to this macro. They treat nullptr and any non-nullptr string as not equal. Two nullptrs are equal.

Both arguments may be temporary objects which are destructed at the end of the current "full expression", such as

CHECK_STREQ(Foo().c_str(), Bar().c_str());

where Foo and Bar return std::string.

The CHECK_DOUBLE_EQ macro checks the equality of two floating point values, accepting a small error margin. CHECK_NEAR accepts a third floating point argument, which specifies the acceptable error margin.

Verbose Logging

When you are chasing difficult bugs, thorough log messages are very useful. However, you may want to ignore too verbose messages in usual development. For such verbose logging, glog provides the VLOG macro, which allows you to define your own numeric logging levels. The --v command line option controls which verbose messages are logged:

VLOG(1) << "I’m printed when you run the program with --v=1 or higher";
VLOG(2) << "I’m printed when you run the program with --v=2 or higher";

With VLOG, the lower the verbose level, the more likely messages are to be logged. For example, if --v==1, VLOG(1) will log, but VLOG(2) will not log.

The VLOG behavior is opposite of the severity level logging, where INFO, ERROR, etc. are defined in increasing order and thus --minloglevel of 1 will only log WARNING and above.

Though you can specify any integers for both VLOG macro and --v flag, the common values for them are small positive integers. For example, if you write VLOG(0), you should specify --v=-1 or lower to silence it. This is less useful since we may not want verbose logs by default in most cases. The VLOG macros always log at the INFO log level (when they log at all).

Verbose logging can be controlled from the command line on a per-module basis:

--vmodule=mapreduce=2,file=1,gfs*=3 --v=0

Specifying these options will specficially:

  1. Print VLOG(2) and lower messages from mapreduce.{h,cc}
  2. Print VLOG(1) and lower messages from file.{h,cc}
  3. Print VLOG(3) and lower messages from files prefixed with "gfs"
  4. Print VLOG(0) and lower messages from elsewhere

The wildcarding functionality 3. supports both * (matches 0 or more characters) and ? (matches any single character) wildcards. Please also refer to command line flags for more information.

There’s also VLOG_IS_ON(n) "verbose level" condition macro. This macro returns true when the --v is equal to or greater than n. The macro can be used as follows:

if (VLOG_IS_ON(2)) {
    // do some logging preparation and logging
    // that can’t be accomplished with just VLOG(2) << ...;
}

Verbose level condition macros VLOG_IF, VLOG_EVERY_N and VLOG_IF_EVERY_N behave analogous to LOG_IF, LOG_EVERY_N, LOG_IF_EVERY_N, but accept a numeric verbosity level as opposed to a severity level.

VLOG_IF(1, (size > 1024))
   << "I’m printed when size is more than 1024 and when you run the "
      "program with --v=1 or more";
VLOG_EVERY_N(1, 10)
   << "I’m printed every 10th occurrence, and when you run the program "
      "with --v=1 or more. Present occurrence is " << google::COUNTER;
VLOG_IF_EVERY_N(1, (size > 1024), 10)
   << "I’m printed on every 10th occurrence of case when size is more "
      " than 1024, when you run the program with --v=1 or more. ";
      "Present occurrence is " << google::COUNTER;

Failure Signal Handler

The library provides a convenient signal handler that will dump useful information when the program crashes on certain signals such as SIGSEGV. The signal handler can be installed by google::InstallFailureSignalHandler(). The following is an example of output from the signal handler.

*** Aborted at 1225095260 (unix time) try "date -d @1225095260" if you are using GNU date ***
*** SIGSEGV (@0x0) received by PID 17711 (TID 0x7f893090a6f0) from PID 0; stack trace: ***
PC: @           0x412eb1 TestWaitingLogSink::send()
    @     0x7f892fb417d0 (unknown)
    @           0x412eb1 TestWaitingLogSink::send()
    @     0x7f89304f7f06 google::LogMessage::SendToLog()
    @     0x7f89304f35af google::LogMessage::Flush()
    @     0x7f89304f3739 google::LogMessage::~LogMessage()
    @           0x408cf4 TestLogSinkWaitTillSent()
    @           0x4115de main
    @     0x7f892f7ef1c4 (unknown)
    @           0x4046f9 (unknown)

By default, the signal handler writes the failure dump to the standard error. You can customize the destination by InstallFailureWriter().

Performance of Messages

The conditional logging macros provided by glog (e.g., CHECK, LOG_IF, VLOG, etc.) are carefully implemented and don’t execute the right hand side expressions when the conditions are false. So, the following check may not sacrifice the performance of your application.

CHECK(obj.ok) << obj.CreatePrettyFormattedStringButVerySlow();

User-defined Failure Function

FATAL severity level messages or unsatisfied CHECK condition terminate your program. You can change the behavior of the termination by InstallFailureFunction.

void YourFailureFunction() {
  // Reports something...
  exit(EXIT_FAILURE);
}

int main(int argc, char* argv[]) {
  google::InstallFailureFunction(&YourFailureFunction);
}

By default, glog tries to dump the stacktrace and calls std::abort. The stacktrace is generated only when running the application on a system supported by glog. Currently, glog supports x86, x86_64, PowerPC architectures, libunwind, and the Debug Help Library (dbghelp) on Windows for extracting the stack trace.

Raw Logging

The header file <glog/raw_logging.h> can be used for thread-safe logging, which does not allocate any memory or acquire any locks. Therefore, the macros defined in this header file can be used by low-level memory allocation and synchronization code. Please check src/glog/raw_logging.h for detail.

Google Style perror()

PLOG() and PLOG_IF() and PCHECK() behave exactly like their LOG* and CHECK equivalents with the addition that they append a description of the current state of errno to their output lines. E.g.

PCHECK(write(1, nullptr, 2) >= 0) << "Write nullptr failed";

This check fails with the following error message.

F0825 185142 test.cc:22] Check failed: write(1, nullptr, 2) >= 0 Write nullptr failed: Bad address [14]

Syslog

SYSLOG, SYSLOG_IF, and SYSLOG_EVERY_N macros are available. These log to syslog in addition to the normal logs. Be aware that logging to syslog can drastically impact performance, especially if syslog is configured for remote logging! Make sure you understand the implications of outputting to syslog before you use these macros. In general, it’s wise to use these macros sparingly.

Strip Logging Messages

Strings used in log messages can increase the size of your binary and present a privacy concern. You can therefore instruct glog to remove all strings which fall below a certain severity level by using the GOOGLE_STRIP_LOG macro:

If your application has code like this:

#define GOOGLE_STRIP_LOG 1    // this must go before the #include!
#include <glog/logging.h>

The compiler will remove the log messages whose severities are less than the specified integer value. Since VLOG logs at the severity level INFO (numeric value 0), setting GOOGLE_STRIP_LOG to 1 or greater removes all log messages associated with VLOGs as well as INFO log statements.

Automatically Remove Old Logs

To enable the log cleaner:

using namespace std::chrono_literals;
google::EnableLogCleaner(24h * 3); // keep your logs for 3 days

In C++20 (and later) this can be shortened to:

using namespace std::chrono_literals;
google::EnableLogCleaner(3d); // keep your logs for 3 days

And then glog will check if there are overdue logs whenever a flush is performed. In this example, any log file from your project whose last modified time is greater than 3 days will be unlink()ed.

This feature can be disabled at any time (if it has been enabled)

google::DisableLogCleaner();

Notes for Windows Users

glog defines a severity level ERROR, which is also defined in windows.h . You can make glog not define INFO, WARNING, ERROR, and FATAL by defining GLOG_NO_ABBREVIATED_SEVERITIES before including glog/logging.h . Even with this macro, you can still use the iostream like logging facilities:

#define GLOG_NO_ABBREVIATED_SEVERITIES
#include <windows.h>
#include <glog/logging.h>

// ...

LOG(ERROR) << "This should work";
LOG_IF(ERROR, x > y) << "This should be also OK";

However, you cannot use INFO, WARNING, ERROR, and FATAL anymore for functions defined in glog/logging.h .

#define GLOG_NO_ABBREVIATED_SEVERITIES
#include <windows.h>
#include <glog/logging.h>

// ...

// This won’t work.
// google::FlushLogFiles(google::ERROR);

// Use this instead.
google::FlushLogFiles(google::GLOG_ERROR);

If you don’t need ERROR defined by windows.h, there are a couple of more workarounds which sometimes don’t work:

  • #define WIN32_LEAN_AND_MEAN or NOGDI before #include <windows.h>.
  • #undef ERROR after #include <windows.h>.

See this issue for more detail.

Installation Notes for 64-bit Linux Systems

The glibc built-in stack-unwinder on 64-bit systems has some problems with glog. (In particular, if you are using InstallFailureSignalHandler(), the signal may be raised in the middle of malloc, holding some malloc-related locks when they invoke the stack unwinder. The built-in stack unwinder may call malloc recursively, which may require the thread to acquire a lock it already holds: deadlock.)

For that reason, if you use a 64-bit system and you need InstallFailureSignalHandler(), we strongly recommend you install libunwind before trying to configure or install google glog. libunwind can be found here.

Even if you already have libunwind installed, you will probably still need to install from the snapshot to get the latest version.

Caution: if you install libunwind from the URL above, be aware that you may have trouble if you try to statically link your binary with glog: that is, if you link with gcc -static -lgcc_eh .... This is because both libunwind and libgcc implement the same C++ exception handling APIs, but they implement them differently on some platforms. This is not likely to be a problem on ia64, but may be on x86-64.

Also, if you link binaries statically, make sure that you add -Wl,--eh-frame-hdr to your linker options. This is required so that libunwind can find the information generated by the compiler required for stack unwinding.

Using -static is rare, though, so unless you know this will affect you it probably won’t.

If you cannot or do not wish to install libunwind, you can still try to use two kinds of stack-unwinder:

glibc built-in stack-unwinder

As we already mentioned, glibc’s unwinder has a deadlock issue. However, if you don’t use InstallFailureSignalHandler() or you don’t worry about the rare possibilities of deadlocks, you can use this stack-unwinder. If you specify no options and libunwind isn’t detected on your system, the configure script chooses this unwinder by default.

frame pointer based stack-unwinder

The frame pointer based stack unwinder requires that your application, the glog library, and system libraries like libc, all be compiled with a frame pointer. This is not the default for x86-64.

How to Contribute

We’d love to accept your patches and contributions to this project. There are a just a few small guidelines you need to follow.

Contributor License Agreement (CLA)

Contributions to any Google project must be accompanied by a Contributor License Agreement. This is not a copyright assignment, it simply gives Google permission to use and redistribute your contributions as part of the project.

  • If you are an individual writing original source code and you’re sure you own the intellectual property, then you’ll need to sign an individual CLA.
  • If you work for a company that wants to allow you to contribute your work, then you’ll need to sign a corporate CLA.

You generally only need to submit a CLA once, so if you’ve already submitted one (even if it was for a different project), you probably don’t need to do it again.

Once your CLA is submitted (or if you already submitted one for another Google project), make a commit adding yourself to the AUTHORS and CONTRIBUTORS files. This commit can be part of your first pull request.

Submitting a Patch

  1. It’s generally best to start by opening a new issue describing the bug or feature you’re intending to fix. Even if you think it’s relatively minor, it’s helpful to know what people are working on. Mention in the initial issue that you are planning to work on that bug or feature so that it can be assigned to you.
  2. Follow the normal process of forking the project, and setup a new branch to work in. It’s important that each group of changes be done in separate branches in order to ensure that a pull request only includes the commits related to that bug or feature.
  3. Do your best to have well-formed commit messages for each change. This provides consistency throughout the project, and ensures that commit messages are able to be formatted properly by various git tools.
  4. Finally, push the commits to your fork and submit a pull request.

More Repositories

1

material-design-icons

Material Design icons by Google (Material Symbols)
50,560
star
2

guava

Google core libraries for Java
Java
48,313
star
3

zx

A tool for writing better scripts
JavaScript
42,760
star
4

styleguide

Style guides for Google-originated open-source projects
HTML
37,420
star
5

leveldb

LevelDB is a fast key-value storage library written at Google that provides an ordered mapping from string keys to string values.
C++
36,205
star
6

googletest

GoogleTest - Google Testing and Mocking Framework
C++
34,040
star
7

material-design-lite

Material Design Components in HTML/CSS/JS
HTML
32,281
star
8

comprehensive-rust

This is the Rust course used by the Android team at Google. It provides you the material to quickly teach Rust.
Rust
27,842
star
9

python-fire

Python Fire is a library for automatically generating command line interfaces (CLIs) from absolutely any Python object.
Python
26,842
star
10

mediapipe

Cross-platform, customizable ML solutions for live and streaming media.
C++
25,626
star
11

gson

A Java serialization/deserialization library to convert Java Objects into JSON and back
Java
23,317
star
12

flatbuffers

FlatBuffers: Memory Efficient Serialization Library
C++
23,037
star
13

iosched

The Google I/O Android App
Kotlin
21,772
star
14

ExoPlayer

This project is deprecated and stale. The latest ExoPlayer code is available in https://github.com/androidx/media
Java
21,710
star
15

eng-practices

Google's Engineering Practices documentation
19,942
star
16

web-starter-kit

Web Starter Kit - a workflow for multi-device websites
HTML
18,422
star
17

flexbox-layout

Flexbox for Android
Kotlin
18,230
star
18

fonts

Font files available from Google Fonts, and a public issue tracker for all things Google Fonts
HTML
18,222
star
19

filament

Filament is a real-time physically based rendering engine for Android, iOS, Windows, Linux, macOS, and WebGL2
C++
17,554
star
20

cadvisor

Analyzes resource usage and performance characteristics of running containers.
Go
17,078
star
21

gvisor

Application Kernel for Containers
Go
15,733
star
22

libphonenumber

Google's common Java, C++ and JavaScript library for parsing, formatting, and validating international phone numbers.
C++
15,728
star
23

WebFundamentals

Former git repo for WebFundamentals on developers.google.com
JavaScript
13,851
star
24

yapf

A formatter for Python files
Python
13,755
star
25

brotli

Brotli compression format
TypeScript
13,363
star
26

tink

Tink is a multi-language, cross-platform, open source library that provides cryptographic APIs that are secure, easy to use correctly, and hard(er) to misuse.
Java
13,318
star
27

deepdream

13,212
star
28

wire

Compile-time Dependency Injection for Go
Go
12,919
star
29

guetzli

Perceptual JPEG encoder
C++
12,917
star
30

guice

Guice (pronounced 'juice') is a lightweight dependency injection framework for Java 11 and above, brought to you by Google.
Java
12,458
star
31

blockly

The web-based visual programming editor.
TypeScript
12,392
star
32

sanitizers

AddressSanitizer, ThreadSanitizer, MemorySanitizer
C
11,410
star
33

or-tools

Google's Operations Research tools:
C++
11,144
star
34

dopamine

Dopamine is a research framework for fast prototyping of reinforcement learning algorithms.
Jupyter Notebook
10,529
star
35

grumpy

Grumpy is a Python to Go source code transcompiler and runtime.
Go
10,464
star
36

oss-fuzz

OSS-Fuzz - continuous fuzzing for open source software.
Shell
10,389
star
37

auto

A collection of source code generators for Java.
Java
10,234
star
38

go-github

Go library for accessing the GitHub v3 API
Go
10,206
star
39

go-cloud

The Go Cloud Development Kit (Go CDK): A library and tools for open cloud development in Go.
Go
9,546
star
40

sentencepiece

Unsupervised text tokenizer for Neural Network-based text generation.
C++
8,657
star
41

tsunami-security-scanner

Tsunami is a general purpose network security scanner with an extensible plugin system for detecting high severity vulnerabilities with high confidence.
Java
8,232
star
42

re2

RE2 is a fast, safe, thread-friendly alternative to backtracking regular expression engines like those used in PCRE, Perl, and Python. It is a C++ library.
C++
8,190
star
43

traceur-compiler

Traceur is a JavaScript.next-to-JavaScript-of-today compiler
JavaScript
8,173
star
44

trax

Trax — Deep Learning with Clear Code and Speed
Python
8,051
star
45

pprof

pprof is a tool for visualization and analysis of profiling data
Go
7,875
star
46

skia

Skia is a complete 2D graphic library for drawing Text, Geometries, and Images.
C++
7,874
star
47

benchmark

A microbenchmark support library
C++
7,812
star
48

magika

Detect file content types with deep learning
Rust
7,680
star
49

android-classyshark

Android and Java bytecode viewer
Java
7,492
star
50

accompanist

A collection of extension libraries for Jetpack Compose
Kotlin
7,442
star
51

closure-compiler

A JavaScript checker and optimizer.
Java
7,394
star
52

agera

Reactive Programming for Android
Java
7,227
star
53

latexify_py

A library to generate LaTeX expression from Python code.
Python
7,160
star
54

diff-match-patch

Diff Match Patch is a high-performance library in multiple languages that manipulates plain text.
Python
7,132
star
55

flutter-desktop-embedding

Experimental plugins for Flutter for Desktop
C++
7,102
star
56

jsonnet

Jsonnet - The data templating language
Jsonnet
6,938
star
57

model-viewer

Easily display interactive 3D models on the web and in AR!
TypeScript
6,858
star
58

lovefield

Lovefield is a relational database for web apps. Written in JavaScript, works cross-browser. Provides SQL-like APIs that are fast, safe, and easy to use.
JavaScript
6,847
star
59

error-prone

Catch common Java mistakes as compile-time errors
Java
6,818
star
60

draco

Draco is a library for compressing and decompressing 3D geometric meshes and point clouds. It is intended to improve the storage and transmission of 3D graphics.
C++
6,459
star
61

gops

A tool to list and diagnose Go processes currently running on your system
Go
6,375
star
62

gopacket

Provides packet processing capabilities for Go
Go
6,289
star
63

automl

Google Brain AutoML
Jupyter Notebook
6,230
star
64

osv-scanner

Vulnerability scanner written in Go which uses the data provided by https://osv.dev
Go
6,222
star
65

flax

Flax is a neural network library for JAX that is designed for flexibility.
Jupyter Notebook
6,085
star
66

grafika

Grafika test app
Java
6,071
star
67

snappy

A fast compressor/decompressor
C++
6,068
star
68

physical-web

The Physical Web: walk up and use anything
Java
6,017
star
69

j2objc

A Java to iOS Objective-C translation tool and runtime.
Java
5,990
star
70

gemma.cpp

lightweight, standalone C++ inference engine for Google's Gemma models.
C++
5,961
star
71

ios-webkit-debug-proxy

A DevTools proxy (Chrome Remote Debugging Protocol) for iOS devices (Safari Remote Web Inspector).
C
5,918
star
72

seesaw

Seesaw v2 is a Linux Virtual Server (LVS) based load balancing platform.
Go
5,634
star
73

EarlGrey

🍵 iOS UI Automation Test Framework
Objective-C
5,616
star
74

seq2seq

A general-purpose encoder-decoder framework for Tensorflow
Python
5,577
star
75

google-java-format

Reformats Java source code to comply with Google Java Style.
Java
5,538
star
76

mesop

Rapidly build AI apps in Python
Python
5,401
star
77

wireit

Wireit upgrades your npm/pnpm/yarn scripts to make them smarter and more efficient.
TypeScript
5,385
star
78

syzkaller

syzkaller is an unsupervised coverage-guided kernel fuzzer
Go
5,350
star
79

uuid

Go package for UUIDs based on RFC 4122 and DCE 1.1: Authentication and Security Services.
Go
5,284
star
80

clusterfuzz

Scalable fuzzing infrastructure.
Python
5,283
star
81

battery-historian

Battery Historian is a tool to analyze battery consumers using Android "bugreport" files.
Go
5,249
star
82

gemma_pytorch

The official PyTorch implementation of Google's Gemma models
Python
5,242
star
83

bbr

5,156
star
84

gumbo-parser

An HTML5 parsing library in pure C99
HTML
5,141
star
85

git-appraise

Distributed code review system for Git repos
Go
5,122
star
86

google-authenticator

Open source version of Google Authenticator (except the Android app)
Java
5,077
star
87

gts

☂️ TypeScript style guide, formatter, and linter.
TypeScript
5,071
star
88

closure-library

Google's common JavaScript library
JavaScript
4,881
star
89

grr

GRR Rapid Response: remote live forensics for incident response
Python
4,757
star
90

cameraview

[DEPRECATED] Easily integrate Camera features into your Android app
Java
4,734
star
91

pytype

A static type analyzer for Python code
Python
4,731
star
92

liquidfun

2D physics engine for games
C++
4,559
star
93

clasp

🔗 Command Line Apps Script Projects
TypeScript
4,525
star
94

google-ctf

Google CTF
Python
4,477
star
95

gxui

An experimental Go cross platform UI library.
Go
4,450
star
96

santa

A binary authorization and monitoring system for macOS
Objective-C++
4,402
star
97

bloaty

Bloaty: a size profiler for binaries
C++
4,386
star
98

tcmalloc

C++
4,339
star
99

ko

Build and deploy Go applications on Kubernetes
Go
4,329
star
100

orbit

C/C++ Performance Profiler
C++
4,190
star