Git Product home page Git Product logo

asynclog's Introduction

asynclog

A small, fast, colorful, asynchronous, type-safe C++ logging library. Uses libuv.

Example output:

Example Screenshot

Go ahead and copy files from this repo. Then include log.h somewhere in your project, for example:

#include "al/log.h"

Initialize. The logger will be automatically uninitialized at the end of the scope, when raii is destructed.

al::Scoped_Log_Init raii;

Unconditional logging:

Each message includes time and severity, with an added color. Check log.cpp to change the escape codes used for each severity.

Prints "Hello, World" as an error

al::log_e("Hello, World!");

Prints the warning Player at (5.0, 12.0, 1.0)

glm::vec3 pos(5.0f, 12.0f, 1.0f);
al::log_w("Player at (%, %, %)", pos.x, pos.y, pos.z);

Prints "Hello, World" as debug information

al::log_d("%, %", "Hello", "World");

Anything that supports to_string works in the % replacement!

Conditional logging:

These messages can be turned off by defining AL_DISABLE_LOGGING before including log.h.

Logs "Hello, Luke" as "information".

// Log a conditional information message the same way, C strings work too!
const char *const player_name = "Luke";
AL_LOG_I("Hello, %", player_name);

Translation:

Load in a mapping from semantic strings to strings in a language

#include "al/translate.h"
al::Lang lang;
lang.dict.push_back({"greeting", "Nice to meet you, %!"});
al::set_lang(lang);

Build the actual message using replacement featured earlier:

std::string message = al::t("greeting", "Luke");

Or if you want to be more explicit:

std::string message = al::translate("greeting", "Luke");

No matter which you chose, message now equals "Nice to meet you, Luke".

asynclog's People

Contributors

lukesanantonio avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

wzit randydom

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.