LogIt++
Header-only, macro-first C++ logging library
Loading...
Searching...
No Matches
OtlpJsonSerializer.hpp File Reference

Defines OTLP/HTTP JSON serialization helpers for logs. More...

#include "OtlpJsonFormatConfig.hpp"
#include "OtlpRecordSnapshot.hpp"
#include <cctype>
#include <cstdint>
#include <cmath>
#include <iomanip>
#include <limits>
#include <sstream>
#include <string>
#include <unordered_map>
#include <vector>

Go to the source code of this file.

Classes

struct  logit::OtlpLogItem
 Owns one formatted log message and its structured metadata. More...
 

Namespaces

namespace  logit
 The primary namespace for the LogIt++ library.
 

Macros

#define LOGIT_CPP_HEADER_LOGIT_CPP_LOGIT_LOGGERS_OTLP_OTLPJSONSERIALIZER_HPP_INCLUDED
 

Functions

std::string logit::otlp_json_escape (const std::string &value)
 Escapes a string for JSON output.
 
int logit::otlp_severity_number (LogLevel level)
 Maps LogIt++ levels to OpenTelemetry severity numbers.
 
void logit::otlp_write_comma_if_needed (std::ostringstream &os, bool &first)
 Writes a comma before the next JSON value when needed.
 
void logit::otlp_write_string_attr (std::ostringstream &os, const std::string &key, const std::string &value)
 Writes a string OTLP attribute.
 
void logit::otlp_write_int_attr (std::ostringstream &os, const std::string &key, int64_t value)
 Writes an int OTLP attribute.
 
void logit::otlp_write_bool_attr (std::ostringstream &os, const std::string &key, bool value)
 Writes a bool OTLP attribute.
 
void logit::otlp_write_double_attr (std::ostringstream &os, const std::string &key, double value)
 Writes a double OTLP attribute.
 
void logit::otlp_write_uint_attr (std::ostringstream &os, const std::string &key, uint64_t value)
 Writes a uint64 OTLP attribute.
 
std::string logit::sanitize_otlp_key (const std::string &name)
 Sanitizes an attribute key for OTLP.
 
void logit::otlp_write_log_record_json (std::ostringstream &os, const OtlpLogItem &item, const OtlpJsonFormatConfig &config)
 Writes one OTLP JSON log record.
 
std::string logit::build_otlp_logs_json_payload (const std::vector< OtlpLogItem > &batch, const OtlpJsonFormatConfig &config)
 Builds an OTLP ExportLogsServiceRequest JSON payload.
 

Detailed Description

Defines OTLP/HTTP JSON serialization helpers for logs.

Definition in file OtlpJsonSerializer.hpp.

Macro Definition Documentation

◆ LOGIT_CPP_HEADER_LOGIT_CPP_LOGIT_LOGGERS_OTLP_OTLPJSONSERIALIZER_HPP_INCLUDED

#define LOGIT_CPP_HEADER_LOGIT_CPP_LOGIT_LOGGERS_OTLP_OTLPJSONSERIALIZER_HPP_INCLUDED

Definition at line 3 of file OtlpJsonSerializer.hpp.