View Javadoc
1   /*
2    * Logback: the reliable, generic, fast and flexible logging framework.
3    * Copyright (C) 1999-2026, QOS.ch. All rights reserved.
4    *
5    * This program and the accompanying materials are dual-licensed under
6    * either the terms of the Eclipse Public License v2.0 as published by
7    * the Eclipse Foundation
8    *
9    *   or (per the licensee's choosing)
10   *
11   * under the terms of the GNU Lesser General Public License version 2.1
12   * as published by the Free Software Foundation.
13   */
14  package ch.qos.logback.classic.kryo;
15  
16  import com.esotericsoftware.kryo.kryo5.Kryo;
17  import com.esotericsoftware.kryo.kryo5.Serializer;
18  import com.esotericsoftware.kryo.kryo5.io.Input;
19  import com.esotericsoftware.kryo.kryo5.io.Output;
20  import org.slf4j.Marker;
21  import org.slf4j.helpers.BasicMarker;
22  import org.slf4j.helpers.BasicMarkerFactory;
23  
24  public class BasicMarkerSerializer extends Serializer<BasicMarker> {
25      BasicMarkerFactory basicMarkerFactory = new BasicMarkerFactory();
26  
27      @Override
28      public void write(Kryo kryo, Output output, BasicMarker marker) {
29          output.writeString(marker.getName());
30      }
31  
32      @Override
33      public BasicMarker read(Kryo kryo, Input input, Class<? extends BasicMarker> type) {
34          String name = input.readString();
35          BasicMarker marker = (BasicMarker) basicMarkerFactory.getMarker(name);
36          return marker;
37      }
38  }