Skip to content

Instantly share code, notes, and snippets.

View gexclaude's full-sized avatar
🤘

Claude Gex gexclaude

🤘
View GitHub Profile
@gexclaude
gexclaude / basic_lazy_file_sink.h
Created May 25, 2020 07:36
Basic Lazy File Sink for spdlog
//
// spdlog Copyright(c) 2015-2018 Gabi Melman, see https://github.com/gabime/spdlog
// this is a simple lazy variant of https://github.com/gabime/spdlog/blob/v1.x/include/spdlog/sinks/basic_file_sink.h
//
#pragma once
#ifndef SPDLOG_H
#include "spdlog/spdlog.h"
#endif
@gexclaude
gexclaude / Description.md
Created October 22, 2017 20:41
Filter long data from XML before logging

In the last post I showed how to log SOAP messages with JAX-WS and SLF4J. The solution is simple and straight forward, but it logs the entire message. This can be a problem if the message is large, either because the XML has a lot of nodes or the message contains large data in some of the nodes. In this post I focus on the latter one. Often binary data such as documents, images or any other type of data are transferred as Base64 encoded strings. Such data can be relatively large and encoded using Base64 it gets one third (1/3 or 33%) bigger. For instance if you transfer a document that is 1 MB large, it will be 1.3 MB encoded in Base64. Logging large data has multiple drawbacks. It may affect application performance, especially when messages become big and logging is done using synchronous appenders Readability of messages in the log file suffer. In most cases not the binary is of interest to analyze bugs and the like but the other data is Log files grow very fast and consume disk space or due to maximum log

@gexclaude
gexclaude / SOAPRequestResponseTracer.java
Created October 22, 2017 20:37
If you want to log SOAP messages with JAX-WS you can implement this with a SOAPHandler. The following is simple implementation that logs every message including faults with SLF4J. Then you need to register the SOAPHandler in an XML (let's name it handler-chain.xml) as follows. And finally reference the just created XML file using the @HandlerCha…
package ch.claudegex.examples.jaxws;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.Collections;
import java.util.Set;
import javax.xml.namespace.QName;
import javax.xml.soap.SOAPException;
import javax.xml.ws.handler.MessageContext;
@gexclaude
gexclaude / NotepadPlusPlus_Omnimark_Syntax_Highlighting.xml
Created August 28, 2017 20:23
Simple Notepad++ OmniMark Syntax Highlighting File
<NotepadPlus>
<UserLang name="OmniMark" ext="ARG XAR XIN XMD XOM XOP">
<Settings>
<Global caseIgnored="yes" escapeChar="%" />
<TreatAsSymbol comment="no" commentLine="yes" />
<Prefix words1="no" words2="no" words3="no" words4="no" />
</Settings>
<KeywordLists>
<Keywords name="Delimiters">&quot;&apos;0&quot;&apos;0</Keywords>
<Keywords name="Folder+"></Keywords>
@gexclaude
gexclaude / LocalDateRange.java
Created August 24, 2017 21:59
Java LocalDateRange - a class that represents a fixed period of time. It has a start and and end and one can check if a specific date is in this range.
import java.time.LocalDate;
import java.time.YearMonth;
public class LocalDateRange {
private final LocalDate start;
private final LocalDate end;
public LocalDateRange(final LocalDate start, final LocalDate end) {
if(start == null) {
throw new IllegalArgumentException("Start date mustn't be null. Use LocalDate.MIN to represent no limit");
@gexclaude
gexclaude / Prozentsatz.java
Created August 24, 2017 21:53
Java Datentyp Prozentsatz / datatype percentage
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.text.ParsePosition;
import java.util.Objects;
public class Prozentsatz {
private static final BigDecimal HUNDERT = BigDecimal.valueOf(100);
private static final String DECIMAL_FORMAT_PATTERN = "###,###,##0.##########";