LFInteractive Docs
  • Programming Documentation
  • C#
    • Installing Visual Studio
    • Understanding C#
      • Namespaces
      • Classes
      • Enum
      • Variables
        • Static Types
        • Primitive Types
        • Access Modifiers
        • Variables vs Properties
        • Nullable Variables
      • Getters and Setters
      • Solution vs Project
      • Struct vs Class
      • Coding Conventions
      • Tasks and Async
        • Parallel Tasks
      • Methods
      • PreProcessor Statements
    • Creating Your First Console App
      • Class Library
        • Models
          • File Model
          • Result Model
        • Controllers
          • File Controller
          • File System Controller
      • Console App
        • Nuget Packages
        • Main Method
    • Minecraft.NET
      • Minecraft.NET Library
      • Modrinth.NET Library
      • CurseForge.NET Library
      • Fabric.NET Library
    • Common Lib
      • Strings
      • Advanced Network Client
      • Advanced Timer
      • Advanced File Info
      • Configuration File
      • Application Config
      • Database File
      • Crypt Class
  • C++
    • Networking
      • Windows Socket (Client)
    • cclip
    • VCPKG
    • spdlog
      • Getting Started
      • Patterns
Powered by GitBook
On this page

Was this helpful?

Edit on GitHub
  1. C++
  2. spdlog

Patterns

this page describes all the different patterns in spdlog

PreviousGetting Started

Last updated 1 year ago

Was this helpful?

To set a custom logging pattern with spdlog in C++, you can use the set_pattern() function. The pattern string can contain various placeholders that will be replaced by corresponding values when logging. The following are some of the placeholders that can be used in the pattern string:

  • %v: the log message

  • %n: the logger name

  • %^: start color

  • %$: end color

  • %t: thread id

  • %T: time

  • %P: process id

  • %F: source file name

  • %l: log level

  • %L: short log level name

For example, to set a pattern that includes the log level, time, logger name, and log message, use the following code:

spdlog::set_pattern("[%l] [%T] [%n] %v");

This will produce logs in the following format:

[info] [12:34:56] [my_logger] This is a log message

For more information on the available placeholders and their usage, check out the .

spdlog documentation