Skip to content

Examples Basic

Eduard Mishkurov edited this page Apr 24, 2026 · 7 revisions

Basic example

Basic

This example shows the most basic logme usage.

What it demonstrates

  • Stream-style logging with LogmeI() << ...
  • Printf-style logging with LogmeI("...", ...)
  • Logging to a custom channel
  • Applying a local override to a single call
  • Using OBF(...) for an obfuscated string literal

Notes

  • The default channel ::CH is available automatically.
  • Custom channels must be made visible by linking them to ::CH or by attaching backends directly.

Source code

Repository: examples/Basic

Basic.cpp

Open in repository

#include <Logme/Logme.h>

static void BasicStream()
{
  LogmeI() << "Hello from stream API";
  LogmeW() << 123;
}

static void BasicPrintf()
{
  LogmeI("Hello %s", "World");
  LogmeE("Error code: %d", -1);
}

static void ChannelAndOverride()
{
  Logme::ID ch{"mychannel"};

  auto channel = Logme::Instance->CreateChannel(ch);
  channel->AddLink(::CH);

  Logme::Override ovr;
  ovr.Remove.Method = true;

  LogmeI(ch) << "Channel stream";
  LogmeI(ch, "Channel printf: %d", 42);

  LogmeI(ch, ovr) << "Override stream";
  LogmeI(ch, ovr, "Override printf: %s", "ok");
}

static void ObfuscatedPrint()
{
  LogmeI(OBF("This line cannot be found when viewing the exe"));
}

int main()
{
  BasicStream();
  BasicPrintf();
  ChannelAndOverride();
  ObfuscatedPrint();
  return 0;
}

Next: Channels

Clone this wiki locally