├── .java-version
├── gradle
├── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── LICENSE_HEADER
└── release.gradle
├── logback-audio
├── src
│ ├── test
│ │ ├── resources
│ │ │ ├── bark.ogg
│ │ │ ├── drip.ogg
│ │ │ ├── glass.ogg
│ │ │ ├── sample.ogg
│ │ │ ├── message.ogg
│ │ │ ├── logback-with-converter.xml
│ │ │ └── logback-with-marker-appender.xml
│ │ └── java
│ │ │ └── com
│ │ │ └── tersesystems
│ │ │ └── logback
│ │ │ └── audio
│ │ │ └── TestNested.java
│ └── main
│ │ └── java
│ │ └── com
│ │ └── tersesystems
│ │ └── logback
│ │ └── audio
│ │ ├── Player.java
│ │ ├── PlayerAttachable.java
│ │ ├── URLPlayer.java
│ │ ├── SystemPlayer.java
│ │ ├── PlayerException.java
│ │ ├── AudioAppender.java
│ │ ├── AudioMarkerAppender.java
│ │ ├── AudioMarker.java
│ │ ├── PlayerConverter.java
│ │ ├── FilePlayer.java
│ │ ├── ResourcePlayer.java
│ │ ├── PlayMethods.java
│ │ └── SimplePlayer.java
├── gradle.properties
└── logback-audio.gradle
├── logback-exception-mapping-providers
├── src
│ └── test
│ │ ├── resources
│ │ ├── logback.conf
│ │ └── logback-with-exception-mapping.xml
│ │ └── java
│ │ └── com
│ │ └── tersesystems
│ │ └── logback
│ │ └── exceptionmapping
│ │ └── json
│ │ ├── MySpecialException.java
│ │ └── TypesafeConfigMappingsActionTest.java
├── gradle.properties
└── logback-exception-mapping-providers.gradle
├── logback-typesafe-config
├── src
│ ├── test
│ │ ├── resources
│ │ │ ├── logback-test.conf
│ │ │ └── typesafeconfig
│ │ │ │ ├── config-with-local.xml
│ │ │ │ ├── config-with-default.xml
│ │ │ │ └── config-with-context.xml
│ │ └── java
│ │ │ └── com
│ │ │ └── tersesystems
│ │ │ └── logback
│ │ │ └── typesafeconfig
│ │ │ └── ConfigListConverterTest.java
│ └── main
│ │ └── java
│ │ └── com
│ │ └── tersesystems
│ │ └── logback
│ │ └── typesafeconfig
│ │ ├── ConfigConstants.java
│ │ └── ConfigConversion.java
├── gradle.properties
└── logback-typesafe-config.gradle
├── logback-honeycomb-client
├── logback-honeycomb-client.gradle
├── gradle.properties
└── src
│ └── main
│ └── java
│ └── com
│ └── tersesystems
│ └── logback
│ └── honeycomb
│ └── client
│ ├── HoneycombClientService.java
│ ├── HoneycombHeaders.java
│ ├── HoneycombRequest.java
│ ├── HoneycombClient.java
│ └── HoneycombResponse.java
├── logback-budget
├── gradle.properties
├── src
│ ├── main
│ │ └── java
│ │ │ └── com
│ │ │ └── tersesystems
│ │ │ └── logback
│ │ │ └── budget
│ │ │ ├── BudgetRuleAttachable.java
│ │ │ └── BudgetRule.java
│ └── test
│ │ ├── java
│ │ └── com.tersesystems.logback.budget
│ │ │ ├── BudgetTurboFilterTest.java
│ │ │ └── BudgetEvaluatorTest.java
│ │ └── resources
│ │ ├── logback-turbofilter.xml
│ │ └── logback-budget.xml
└── logback-budget.gradle
├── logback-classic
├── gradle.properties
├── src
│ ├── test
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── tersesystems
│ │ │ │ └── logback
│ │ │ │ └── classic
│ │ │ │ ├── SetLoggerLevelsActionTest.java
│ │ │ │ ├── ChangeLogLevelTest.java
│ │ │ │ ├── CorrelationIdMarker.java
│ │ │ │ ├── EnabledFilterTest.java
│ │ │ │ ├── TerseHighlightConverterTest.java
│ │ │ │ └── UtilsTest.java
│ │ └── resources
│ │ │ ├── logback-tapfilter.xml
│ │ │ └── logback-tapfilter-correlation.xml
│ └── main
│ │ └── java
│ │ └── com
│ │ └── tersesystems
│ │ └── logback
│ │ └── classic
│ │ ├── StartTimeSupplier.java
│ │ ├── NanoTimeSupplier.java
│ │ ├── sift
│ │ ├── DiscriminatingValue.java
│ │ ├── DiscriminatingMarkerFactory.java
│ │ └── DiscriminatingMarker.java
│ │ ├── IContainerLoggingEvent.java
│ │ ├── TimeSinceEpochConverter.java
│ │ ├── ILoggingEventFactory.java
│ │ ├── NanoTimeConverter.java
│ │ ├── StartTimeConverter.java
│ │ ├── LoggerDecider.java
│ │ ├── FormatParamsDecider.java
│ │ ├── MarkerLoggerDecider.java
│ │ ├── ContainerEventAppender.java
│ │ ├── LoggingEventFactory.java
│ │ ├── NanoTimeMarker.java
│ │ ├── StartTimeMarker.java
│ │ ├── TurboFilterDecider.java
│ │ ├── functional
│ │ ├── RootLoggerSupplier.java
│ │ ├── GetSiftedAppenderFunction.java
│ │ └── GetAppenderFunction.java
│ │ ├── encoder
│ │ └── PatternLayoutEncoder.java
│ │ ├── NanoTimeComponentAppender.java
│ │ ├── ContainerProxyLoggingEvent.java
│ │ ├── SLF4JBridgeHandlerAction.java
│ │ └── ChangeLogLevel.java
└── logback-classic.gradle
├── logback-correlationid
├── src
│ ├── test
│ │ └── resources
│ │ │ ├── spy.properties
│ │ │ ├── logback-correlationid.xml
│ │ │ └── logback-correlationid-tapfilter.xml
│ └── main
│ │ └── java
│ │ └── com
│ │ └── tersesystems
│ │ └── logback
│ │ └── correlationid
│ │ ├── CorrelationIdProvider.java
│ │ ├── CorrelationIdMarker.java
│ │ ├── CorrelationIdDecider.java
│ │ └── CorrelationIdFilter.java
├── gradle.properties
└── logback-correlationid.gradle
├── logback-turbomarker
├── gradle.properties
├── src
│ ├── test
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── tersesystems
│ │ │ │ └── logback
│ │ │ │ └── turbomarker
│ │ │ │ ├── ApplicationContext.java
│ │ │ │ ├── UserMarker.java
│ │ │ │ ├── UserMarkerFactory.java
│ │ │ │ └── LDMarkerFactory.java
│ │ └── resources
│ │ │ └── logback-test.xml
│ └── main
│ │ └── java
│ │ └── com
│ │ └── tersesystems
│ │ └── logback
│ │ └── turbomarker
│ │ ├── TurboMarker.java
│ │ ├── ContextAwareTurboFilterDecider.java
│ │ ├── ContextDecider.java
│ │ ├── LoggerContextDecider.java
│ │ ├── MarkerContextDecider.java
│ │ └── ContextAwareTurboMarker.java
└── logback-turbomarker.gradle
├── logback-core
├── gradle.properties
├── src
│ ├── main
│ │ └── java
│ │ │ └── com
│ │ │ └── tersesystems
│ │ │ └── logback
│ │ │ └── core
│ │ │ ├── Component.java
│ │ │ ├── ComponentContainer.java
│ │ │ ├── EnabledFilter.java
│ │ │ └── DefaultAppenderAttachable.java
│ └── test
│ │ ├── resources
│ │ └── logback-with-composite-appender.xml
│ │ └── java
│ │ └── com
│ │ └── tersesystems
│ │ └── logback
│ │ └── core
│ │ ├── TestAppender.java
│ │ └── CompositeAppenderTest.java
└── logback-core.gradle
├── logback-jdbc-appender
├── gradle.properties
├── logback-jdbc-appender.gradle
└── src
│ └── test
│ └── resources
│ ├── logback-reference.conf
│ └── logback-test.xml
├── logback-tracing
├── gradle.properties
├── logback-tracing.gradle
└── src
│ └── main
│ └── java
│ └── com
│ └── tersesystems
│ └── logback
│ └── tracing
│ ├── Nullable.java
│ ├── EventInfo.java
│ ├── LinkInfo.java
│ ├── LinkMarkerFactory.java
│ ├── EventMarkerFactory.java
│ └── SpanMarkerFactory.java
├── logback-compress-encoder
├── gradle.properties
├── logback-compress-encoder.gradle
└── src
│ └── test
│ ├── resources
│ └── logback-with-zstd-encoder.xml
│ └── java
│ └── com
│ └── tersesystems
│ └── logback
│ └── compress
│ └── Utils.java
├── logback-bytebuddy
├── gradle.properties
└── src
│ ├── test
│ ├── resources
│ │ ├── logback.conf
│ │ └── logback-test.xml
│ └── java
│ │ └── com
│ │ └── tersesystems
│ │ └── logback
│ │ └── bytebuddy
│ │ ├── ClassCalledByAgent.java
│ │ ├── PreloadedInstrumentationExample.java
│ │ └── AdviceConfigTest.java
│ └── main
│ └── java
│ └── com
│ └── tersesystems
│ └── logback
│ └── bytebuddy
│ ├── impl
│ ├── LoggerResolver.java
│ ├── FixedLoggerResolver.java
│ ├── DeclaringTypeLoggerResolver.java
│ └── SafeArguments.java
│ ├── MethodInfo.java
│ └── MethodInfoLookup.java
├── logback-exception-mapping
├── gradle.properties
├── logback-exception-mapping.gradle
└── src
│ ├── main
│ └── java
│ │ └── com
│ │ └── tersesystems
│ │ └── logback
│ │ └── exceptionmapping
│ │ ├── Constants.java
│ │ ├── ExceptionMapping.java
│ │ ├── FunctionExceptionMapping.java
│ │ ├── KeyValueExceptionProperty.java
│ │ ├── ExceptionHierarchyIterator.java
│ │ ├── ExceptionCauseIterator.java
│ │ ├── ExceptionMappingRegistry.java
│ │ └── ExceptionProperty.java
│ └── test
│ ├── java
│ └── com
│ │ └── tersesystems
│ │ └── logback
│ │ └── exceptionmapping
│ │ ├── MyCustomException.java
│ │ └── Thrower.java
│ └── resources
│ └── logback-test.xml
├── logback-honeycomb-appender
├── gradle.properties
└── logback-honeycomb-appender.gradle
├── logback-uniqueid-appender
├── gradle.properties
├── src
│ ├── main
│ │ └── java
│ │ │ └── com
│ │ │ └── tersesystems
│ │ │ └── logback
│ │ │ └── uniqueid
│ │ │ ├── IdGenerator.java
│ │ │ ├── UniqueIdProvider.java
│ │ │ ├── TsidIdgenerator.java
│ │ │ ├── KsuidSubsecondIdGenerator.java
│ │ │ ├── UlidIdGenerator.java
│ │ │ ├── UniqueIdConverter.java
│ │ │ ├── FlakeIdGenerator.java
│ │ │ ├── RandomUUIDIdGenerator.java
│ │ │ └── UniqueIdComponentAppender.java
│ └── test
│ │ ├── resources
│ │ └── logback-with-uniqueid-appender.xml
│ │ └── java
│ │ └── com
│ │ └── tersesystems
│ │ └── logback
│ │ └── uniqueid
│ │ └── UniqueIdAppenderTest.java
└── logback-uniqueid-appender.gradle
├── .gitignore
├── logback-postgresjson-appender
├── gradle.properties
├── src
│ ├── test
│ │ ├── resources
│ │ │ └── db
│ │ │ │ └── migration
│ │ │ │ └── V1__logging_table.sql
│ │ └── java
│ │ │ └── com
│ │ │ └── tersesystems
│ │ │ └── logback
│ │ │ └── postgresjson
│ │ │ └── PostgresJsonAppenderTest.java
│ └── main
│ │ └── java
│ │ └── com
│ │ └── tersesystems
│ │ └── logback
│ │ └── postgresjson
│ │ └── PostgresJsonAppender.java
└── logback-postgresjson-appender.gradle
├── logback-honeycomb-okhttp
├── gradle.properties
├── src
│ └── main
│ │ ├── resources
│ │ └── META-INF
│ │ │ └── services
│ │ │ └── com.tersesystems.logback.honeycomb.client.HoneycombClientService
│ │ └── java
│ │ └── com
│ │ └── tersesystems
│ │ └── logback
│ │ └── honeycomb
│ │ └── okhttp
│ │ └── HoneycombOkHTTPClientService.java
└── logback-honeycomb-okhttp.gradle
├── logback-censor
├── gradle.properties
├── src
│ ├── main
│ │ └── java
│ │ │ └── com
│ │ │ └── tersesystems
│ │ │ └── logback
│ │ │ └── censor
│ │ │ ├── CensorAttachable.java
│ │ │ ├── Censor.java
│ │ │ ├── CensorConstants.java
│ │ │ ├── CensoringPrettyPrintingJsonGeneratorDecorator.java
│ │ │ └── CensorContextAware.java
│ └── test
│ │ ├── java
│ │ └── com
│ │ │ └── tersesystems
│ │ │ └── logback
│ │ │ └── censor
│ │ │ ├── TestAppender.java
│ │ │ └── RegexCensorTest.java
│ │ └── resources
│ │ ├── test1.xml
│ │ ├── test2.xml
│ │ ├── test3.xml
│ │ └── test4.xml
└── logback-censor.gradle
├── LICENSE
├── version.properties
├── .github
└── ISSUE_TEMPLATE
│ ├── feature_request.md
│ └── bug_report.md
├── gradle.properties
└── settings.gradle
/.java-version:
--------------------------------------------------------------------------------
1 | 1.8
2 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tersesystems/terse-logback/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/logback-audio/src/test/resources/bark.ogg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tersesystems/terse-logback/HEAD/logback-audio/src/test/resources/bark.ogg
--------------------------------------------------------------------------------
/logback-audio/src/test/resources/drip.ogg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tersesystems/terse-logback/HEAD/logback-audio/src/test/resources/drip.ogg
--------------------------------------------------------------------------------
/logback-audio/src/test/resources/glass.ogg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tersesystems/terse-logback/HEAD/logback-audio/src/test/resources/glass.ogg
--------------------------------------------------------------------------------
/logback-audio/src/test/resources/sample.ogg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tersesystems/terse-logback/HEAD/logback-audio/src/test/resources/sample.ogg
--------------------------------------------------------------------------------
/logback-audio/src/test/resources/message.ogg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tersesystems/terse-logback/HEAD/logback-audio/src/test/resources/message.ogg
--------------------------------------------------------------------------------
/logback-exception-mapping-providers/src/test/resources/logback.conf:
--------------------------------------------------------------------------------
1 | levels {
2 | root = INFO
3 | }
4 |
5 |
6 | exceptionmappings {
7 | com.tersesystems.logback.exceptionmapping.json.MySpecialException: ["timestamp"]
8 | }
--------------------------------------------------------------------------------
/logback-typesafe-config/src/test/resources/logback-test.conf:
--------------------------------------------------------------------------------
1 | levels {
2 | examples = "INFO"
3 | }
4 |
5 | some.random.path = "pathValue"
6 |
7 | local {
8 | localKey = "bar"
9 | }
10 |
11 | context {
12 | contextKey = "bar"
13 | }
14 |
--------------------------------------------------------------------------------
/gradle/LICENSE_HEADER:
--------------------------------------------------------------------------------
1 | SPDX-License-Identifier: CC0-1.0
2 |
3 | Copyright ${copyrightYear} ${author}.
4 |
5 | Licensed under the CC0 Public Domain Dedication;
6 | You may obtain a copy of the License at
7 |
8 | http://creativecommons.org/publicdomain/zero/1.0/
9 |
10 |
--------------------------------------------------------------------------------
/logback-honeycomb-client/logback-honeycomb-client.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: CC0-1.0
3 | *
4 | * Copyright 2018-2020 Will Sargent.
5 | *
6 | * Licensed under the CC0 Public Domain Dedication;
7 | * You may obtain a copy of the License at
8 | *
9 | * http://creativecommons.org/publicdomain/zero/1.0/
10 | */
11 |
--------------------------------------------------------------------------------
/logback-budget/gradle.properties:
--------------------------------------------------------------------------------
1 | #
2 | # SPDX-License-Identifier: CC0-1.0
3 | #
4 | # Copyright 2018-2020 Will Sargent.
5 | #
6 | # Licensed under the CC0 Public Domain Dedication;
7 | # You may obtain a copy of the License at
8 | #
9 | # http://creativecommons.org/publicdomain/zero/1.0/
10 | #
11 |
12 | project_description = Logback Budget
--------------------------------------------------------------------------------
/logback-audio/gradle.properties:
--------------------------------------------------------------------------------
1 | #
2 | # SPDX-License-Identifier: CC0-1.0
3 | #
4 | # Copyright 2018-2020 Will Sargent.
5 | #
6 | # Licensed under the CC0 Public Domain Dedication;
7 | # You may obtain a copy of the License at
8 | #
9 | # http://creativecommons.org/publicdomain/zero/1.0/
10 | #
11 |
12 | project_description = Logback Audio Markers
--------------------------------------------------------------------------------
/logback-classic/gradle.properties:
--------------------------------------------------------------------------------
1 | #
2 | # SPDX-License-Identifier: CC0-1.0
3 | #
4 | # Copyright 2018-2020 Will Sargent.
5 | #
6 | # Licensed under the CC0 Public Domain Dedication;
7 | # You may obtain a copy of the License at
8 | #
9 | # http://creativecommons.org/publicdomain/zero/1.0/
10 | #
11 |
12 | project_description = Logback Classic
--------------------------------------------------------------------------------
/logback-correlationid/src/test/resources/spy.properties:
--------------------------------------------------------------------------------
1 | #
2 | # SPDX-License-Identifier: CC0-1.0
3 | #
4 | # Copyright 2018-2020 Will Sargent.
5 | #
6 | # Licensed under the CC0 Public Domain Dedication;
7 | # You may obtain a copy of the License at
8 | #
9 | # http://creativecommons.org/publicdomain/zero/1.0/
10 | #
11 |
12 | driverlist=org.h2.Driver
--------------------------------------------------------------------------------
/logback-turbomarker/gradle.properties:
--------------------------------------------------------------------------------
1 | #
2 | # SPDX-License-Identifier: CC0-1.0
3 | #
4 | # Copyright 2018-2020 Will Sargent.
5 | #
6 | # Licensed under the CC0 Public Domain Dedication;
7 | # You may obtain a copy of the License at
8 | #
9 | # http://creativecommons.org/publicdomain/zero/1.0/
10 | #
11 |
12 | project_description = Logback TurboMarker
--------------------------------------------------------------------------------
/logback-core/gradle.properties:
--------------------------------------------------------------------------------
1 | #
2 | # SPDX-License-Identifier: CC0-1.0
3 | #
4 | # Copyright 2018-2020 Will Sargent.
5 | #
6 | # Licensed under the CC0 Public Domain Dedication;
7 | # You may obtain a copy of the License at
8 | #
9 | # http://creativecommons.org/publicdomain/zero/1.0/
10 | #
11 |
12 | project_description = Logback Core (code only) Library
--------------------------------------------------------------------------------
/logback-jdbc-appender/gradle.properties:
--------------------------------------------------------------------------------
1 | #
2 | # SPDX-License-Identifier: CC0-1.0
3 | #
4 | # Copyright 2018-2020 Will Sargent.
5 | #
6 | # Licensed under the CC0 Public Domain Dedication;
7 | # You may obtain a copy of the License at
8 | #
9 | # http://creativecommons.org/publicdomain/zero/1.0/
10 | #
11 |
12 | project_description = Logback JDBC Appender
--------------------------------------------------------------------------------
/logback-tracing/gradle.properties:
--------------------------------------------------------------------------------
1 | #
2 | # SPDX-License-Identifier: CC0-1.0
3 | #
4 | # Copyright 2018-2020 Will Sargent.
5 | #
6 | # Licensed under the CC0 Public Domain Dedication;
7 | # You may obtain a copy of the License at
8 | #
9 | # http://creativecommons.org/publicdomain/zero/1.0/
10 | #
11 |
12 | project_description = Logback Honeycomb Tracing
--------------------------------------------------------------------------------
/logback-compress-encoder/gradle.properties:
--------------------------------------------------------------------------------
1 | #
2 | # SPDX-License-Identifier: CC0-1.0
3 | #
4 | # Copyright 2018-2020 Will Sargent.
5 | #
6 | # Licensed under the CC0 Public Domain Dedication;
7 | # You may obtain a copy of the License at
8 | #
9 | # http://creativecommons.org/publicdomain/zero/1.0/
10 | #
11 |
12 | project_description = Logback Compress Encoder
--------------------------------------------------------------------------------
/logback-bytebuddy/gradle.properties:
--------------------------------------------------------------------------------
1 | #
2 | # SPDX-License-Identifier: CC0-1.0
3 | #
4 | # Copyright 2018-2020 Will Sargent.
5 | #
6 | # Licensed under the CC0 Public Domain Dedication;
7 | # You may obtain a copy of the License at
8 | #
9 | # http://creativecommons.org/publicdomain/zero/1.0/
10 | #
11 |
12 | project_description = Logback ByteBuddy Instrumentation
--------------------------------------------------------------------------------
/logback-bytebuddy/src/test/resources/logback.conf:
--------------------------------------------------------------------------------
1 | logback.bytebuddy {
2 | service-name = "example-app"
3 |
4 | tracing {
5 | "com.tersesystems.logback.bytebuddy.ClassCalledByAgent" = [
6 | "printStatement",
7 | "printArgument",
8 | "throwException",
9 | ]
10 |
11 | "java.lang.Thread" = [
12 | "run"
13 | ]
14 | }
15 | }
--------------------------------------------------------------------------------
/logback-correlationid/gradle.properties:
--------------------------------------------------------------------------------
1 | #
2 | # SPDX-License-Identifier: CC0-1.0
3 | #
4 | # Copyright 2018-2020 Will Sargent.
5 | #
6 | # Licensed under the CC0 Public Domain Dedication;
7 | # You may obtain a copy of the License at
8 | #
9 | # http://creativecommons.org/publicdomain/zero/1.0/
10 | #
11 |
12 | project_description = Logback Correlation ID Utilities
--------------------------------------------------------------------------------
/logback-exception-mapping/gradle.properties:
--------------------------------------------------------------------------------
1 | #
2 | # SPDX-License-Identifier: CC0-1.0
3 | #
4 | # Copyright 2018-2020 Will Sargent.
5 | #
6 | # Licensed under the CC0 Public Domain Dedication;
7 | # You may obtain a copy of the License at
8 | #
9 | # http://creativecommons.org/publicdomain/zero/1.0/
10 | #
11 |
12 | project_description = Logback Exception Mapping
--------------------------------------------------------------------------------
/logback-honeycomb-appender/gradle.properties:
--------------------------------------------------------------------------------
1 | #
2 | # SPDX-License-Identifier: CC0-1.0
3 | #
4 | # Copyright 2018-2020 Will Sargent.
5 | #
6 | # Licensed under the CC0 Public Domain Dedication;
7 | # You may obtain a copy of the License at
8 | #
9 | # http://creativecommons.org/publicdomain/zero/1.0/
10 | #
11 |
12 | project_description = Logback Honeycomb Appender
--------------------------------------------------------------------------------
/logback-honeycomb-client/gradle.properties:
--------------------------------------------------------------------------------
1 | #
2 | # SPDX-License-Identifier: CC0-1.0
3 | #
4 | # Copyright 2018-2020 Will Sargent.
5 | #
6 | # Licensed under the CC0 Public Domain Dedication;
7 | # You may obtain a copy of the License at
8 | #
9 | # http://creativecommons.org/publicdomain/zero/1.0/
10 | #
11 |
12 | project_description = Logback Honeycomb Client API
--------------------------------------------------------------------------------
/logback-uniqueid-appender/gradle.properties:
--------------------------------------------------------------------------------
1 | #
2 | # SPDX-License-Identifier: CC0-1.0
3 | #
4 | # Copyright 2018-2020 Will Sargent.
5 | #
6 | # Licensed under the CC0 Public Domain Dedication;
7 | # You may obtain a copy of the License at
8 | #
9 | # http://creativecommons.org/publicdomain/zero/1.0/
10 | #
11 |
12 | project_description = Logback Unique ID Appender
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Ignore Gradle project-specific cache directory
2 | .gradle
3 |
4 | logback-sigar/native/
5 |
6 | # Ignore Gradle build output directory
7 | build
8 | target/
9 |
10 | site/
11 |
12 | .idea
13 | log/
14 |
15 | out/
16 | logback-example/log/*
17 |
18 | .classpath
19 | .project
20 | .settings
21 | .vscode/
22 | bin/
23 | *.iml
24 | *.ipr
25 | *.iws
26 |
--------------------------------------------------------------------------------
/logback-postgresjson-appender/gradle.properties:
--------------------------------------------------------------------------------
1 | #
2 | # SPDX-License-Identifier: CC0-1.0
3 | #
4 | # Copyright 2018-2020 Will Sargent.
5 | #
6 | # Licensed under the CC0 Public Domain Dedication;
7 | # You may obtain a copy of the License at
8 | #
9 | # http://creativecommons.org/publicdomain/zero/1.0/
10 | #
11 |
12 | project_description = Logback Postgres JSON Appender
--------------------------------------------------------------------------------
/logback-exception-mapping-providers/gradle.properties:
--------------------------------------------------------------------------------
1 | #
2 | # SPDX-License-Identifier: CC0-1.0
3 | #
4 | # Copyright 2018-2020 Will Sargent.
5 | #
6 | # Licensed under the CC0 Public Domain Dedication;
7 | # You may obtain a copy of the License at
8 | #
9 | # http://creativecommons.org/publicdomain/zero/1.0/
10 | #
11 |
12 | project_description = Extra exception mapping providers
--------------------------------------------------------------------------------
/logback-typesafe-config/gradle.properties:
--------------------------------------------------------------------------------
1 | #
2 | # SPDX-License-Identifier: CC0-1.0
3 | #
4 | # Copyright 2018-2020 Will Sargent.
5 | #
6 | # Licensed under the CC0 Public Domain Dedication;
7 | # You may obtain a copy of the License at
8 | #
9 | # http://creativecommons.org/publicdomain/zero/1.0/
10 | #
11 |
12 | project_description = Logback using Typesafe Config for configuration
--------------------------------------------------------------------------------
/logback-honeycomb-okhttp/gradle.properties:
--------------------------------------------------------------------------------
1 | #
2 | # SPDX-License-Identifier: CC0-1.0
3 | #
4 | # Copyright 2018-2020 Will Sargent.
5 | #
6 | # Licensed under the CC0 Public Domain Dedication;
7 | # You may obtain a copy of the License at
8 | #
9 | # http://creativecommons.org/publicdomain/zero/1.0/
10 | #
11 |
12 | project_description = Logback Honeycomb Client Implementation using OKHTTP
--------------------------------------------------------------------------------
/logback-censor/gradle.properties:
--------------------------------------------------------------------------------
1 | #
2 | # SPDX-License-Identifier: CC0-1.0
3 | #
4 | # Copyright 2018-2020 Will Sargent.
5 | #
6 | # Licensed under the CC0 Public Domain Dedication;
7 | # You may obtain a copy of the License at
8 | #
9 | # http://creativecommons.org/publicdomain/zero/1.0/
10 | #
11 |
12 | project_description = Logback Censor Project (regular esxpression and Jackson JSON filtering)
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | License
2 | -------
3 | Written in 2019 by Will Sargent will@tersesystems.com
4 | To the extent possible under law, the author(s) have dedicated all copyright and related and neighboring rights to this software to the public domain worldwide. This software is distributed without any warranty.
5 | You should have received a copy of the CC0 Public Domain Dedication along with this software. If not, see
--------------------------------------------------------------------------------
/logback-exception-mapping/logback-exception-mapping.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: CC0-1.0
3 | *
4 | * Copyright 2018-2020 Will Sargent.
5 | *
6 | * Licensed under the CC0 Public Domain Dedication;
7 | * You may obtain a copy of the License at
8 | *
9 | * http://creativecommons.org/publicdomain/zero/1.0/
10 | */
11 | plugins {
12 | id 'java-library'
13 | }
14 |
15 | dependencies {
16 | api project(':logback-classic')
17 | }
--------------------------------------------------------------------------------
/version.properties:
--------------------------------------------------------------------------------
1 | #
2 | # SPDX-License-Identifier: CC0-1.0
3 | #
4 | # Copyright 2018-2020 Will Sargent.
5 | #
6 | # Licensed under the CC0 Public Domain Dedication;
7 | # You may obtain a copy of the License at
8 | #
9 | # http://creativecommons.org/publicdomain/zero/1.0/
10 | #
11 |
12 | #Version of the produced binaries. This file is intended to be checked-in.
13 | #It will be automatically bumped by release automation.
14 | version=1.2.*
15 |
16 |
--------------------------------------------------------------------------------
/logback-classic/src/test/java/com/tersesystems/logback/classic/SetLoggerLevelsActionTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: CC0-1.0
3 | *
4 | * Copyright 2018-2020 Will Sargent.
5 | *
6 | * Licensed under the CC0 Public Domain Dedication;
7 | * You may obtain a copy of the License at
8 | *
9 | * http://creativecommons.org/publicdomain/zero/1.0/
10 | */
11 | package com.tersesystems.logback.classic;
12 |
13 | public class SetLoggerLevelsActionTest {}
14 |
--------------------------------------------------------------------------------
/logback-audio/src/main/java/com/tersesystems/logback/audio/Player.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: CC0-1.0
3 | *
4 | * Copyright 2018-2020 Will Sargent.
5 | *
6 | * Licensed under the CC0 Public Domain Dedication;
7 | * You may obtain a copy of the License at
8 | *
9 | * http://creativecommons.org/publicdomain/zero/1.0/
10 | */
11 | package com.tersesystems.logback.audio;
12 |
13 | /** This can play audio sounds. */
14 | public interface Player {
15 | void play();
16 | }
17 |
--------------------------------------------------------------------------------
/logback-uniqueid-appender/src/main/java/com/tersesystems/logback/uniqueid/IdGenerator.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: CC0-1.0
3 | *
4 | * Copyright 2018-2020 Will Sargent.
5 | *
6 | * Licensed under the CC0 Public Domain Dedication;
7 | * You may obtain a copy of the License at
8 | *
9 | * http://creativecommons.org/publicdomain/zero/1.0/
10 | */
11 | package com.tersesystems.logback.uniqueid;
12 |
13 | public interface IdGenerator {
14 | String generateId();
15 | }
16 |
--------------------------------------------------------------------------------
/logback-censor/src/main/java/com/tersesystems/logback/censor/CensorAttachable.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: CC0-1.0
3 | *
4 | * Copyright 2018-2020 Will Sargent.
5 | *
6 | * Licensed under the CC0 Public Domain Dedication;
7 | * You may obtain a copy of the License at
8 | *
9 | * http://creativecommons.org/publicdomain/zero/1.0/
10 | */
11 | package com.tersesystems.logback.censor;
12 |
13 | public interface CensorAttachable {
14 | void addCensor(CensorContextAware censor);
15 | }
16 |
--------------------------------------------------------------------------------
/logback-typesafe-config/logback-typesafe-config.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: CC0-1.0
3 | *
4 | * Copyright 2018-2020 Will Sargent.
5 | *
6 | * Licensed under the CC0 Public Domain Dedication;
7 | * You may obtain a copy of the License at
8 | *
9 | * http://creativecommons.org/publicdomain/zero/1.0/
10 | */
11 | plugins {
12 | id 'java-library'
13 | }
14 |
15 | dependencies {
16 | api "ch.qos.logback:logback-classic:$logbackVersion"
17 | api "com.typesafe:config:$configVersion"
18 | }
19 |
--------------------------------------------------------------------------------
/logback-audio/src/main/java/com/tersesystems/logback/audio/PlayerAttachable.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: CC0-1.0
3 | *
4 | * Copyright 2018-2020 Will Sargent.
5 | *
6 | * Licensed under the CC0 Public Domain Dedication;
7 | * You may obtain a copy of the License at
8 | *
9 | * http://creativecommons.org/publicdomain/zero/1.0/
10 | */
11 | package com.tersesystems.logback.audio;
12 |
13 | public interface PlayerAttachable {
14 | void addPlayer(Player player);
15 |
16 | void clearAllPlayers();
17 | }
18 |
--------------------------------------------------------------------------------
/logback-classic/src/main/java/com/tersesystems/logback/classic/StartTimeSupplier.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: CC0-1.0
3 | *
4 | * Copyright 2018-2020 Will Sargent.
5 | *
6 | * Licensed under the CC0 Public Domain Dedication;
7 | * You may obtain a copy of the License at
8 | *
9 | * http://creativecommons.org/publicdomain/zero/1.0/
10 | */
11 | package com.tersesystems.logback.classic;
12 |
13 | import java.time.Instant;
14 |
15 | public interface StartTimeSupplier {
16 | Instant getStartTime();
17 | }
18 |
--------------------------------------------------------------------------------
/logback-core/src/main/java/com/tersesystems/logback/core/Component.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: CC0-1.0
3 | *
4 | * Copyright 2018-2020 Will Sargent.
5 | *
6 | * Licensed under the CC0 Public Domain Dedication;
7 | * You may obtain a copy of the License at
8 | *
9 | * http://creativecommons.org/publicdomain/zero/1.0/
10 | */
11 |
12 | package com.tersesystems.logback.core;
13 |
14 | /** A marker interface to let the caller know this can be placed in a ContainerComponent. */
15 | public interface Component {}
16 |
--------------------------------------------------------------------------------
/logback-classic/logback-classic.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: CC0-1.0
3 | *
4 | * Copyright 2018-2020 Will Sargent.
5 | *
6 | * Licensed under the CC0 Public Domain Dedication;
7 | * You may obtain a copy of the License at
8 | *
9 | * http://creativecommons.org/publicdomain/zero/1.0/
10 | */
11 |
12 | plugins {
13 | id 'java-library'
14 | }
15 |
16 | dependencies {
17 | api project(':logback-core')
18 | api "org.slf4j:jul-to-slf4j:$slf4jVersion"
19 | api "ch.qos.logback:logback-classic:$logbackVersion"
20 | }
--------------------------------------------------------------------------------
/logback-budget/src/main/java/com/tersesystems/logback/budget/BudgetRuleAttachable.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: CC0-1.0
3 | *
4 | * Copyright 2018-2020 Will Sargent.
5 | *
6 | * Licensed under the CC0 Public Domain Dedication;
7 | * You may obtain a copy of the License at
8 | *
9 | * http://creativecommons.org/publicdomain/zero/1.0/
10 | */
11 | package com.tersesystems.logback.budget;
12 |
13 | public interface BudgetRuleAttachable {
14 |
15 | void addBudgetRule(BudgetRule budget);
16 |
17 | void clearAllBudgetRules();
18 | }
19 |
--------------------------------------------------------------------------------
/gradle/release.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: "io.github.gradle-nexus.publish-plugin" //https://github.com/gradle-nexus/publish-plugin/
2 | nexusPublishing {
3 | repositories {
4 | if (System.getenv("SONATYPE_PWD")) {
5 | sonatype {
6 | username = System.getenv("SONATYPE_USER")
7 | password = System.getenv("SONATYPE_PWD")
8 | }
9 | }
10 | }
11 | }
12 |
13 | allprojects { p ->
14 | plugins.withId("java") {
15 | p.apply from: "$rootDir/gradle/java-publication.gradle"
16 | }
17 | }
--------------------------------------------------------------------------------
/logback-correlationid/logback-correlationid.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: CC0-1.0
3 | *
4 | * Copyright 2018-2020 Will Sargent.
5 | *
6 | * Licensed under the CC0 Public Domain Dedication;
7 | * You may obtain a copy of the License at
8 | *
9 | * http://creativecommons.org/publicdomain/zero/1.0/
10 | */
11 | dependencies {
12 | implementation project(":logback-classic")
13 |
14 | testImplementation 'org.awaitility:awaitility:4.0.2'
15 | testImplementation "net.logstash.logback:logstash-logback-encoder:$logstashVersion"
16 | }
17 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #
2 | # SPDX-License-Identifier: CC0-1.0
3 | #
4 | # Copyright 2018-2020 Will Sargent.
5 | #
6 | # Licensed under the CC0 Public Domain Dedication;
7 | # You may obtain a copy of the License at
8 | #
9 | # http://creativecommons.org/publicdomain/zero/1.0/
10 | #
11 |
12 | #Fri Mar 06 17:39:40 PST 2020
13 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.8-all.zip
14 | distributionBase=GRADLE_USER_HOME
15 | distributionPath=wrapper/dists
16 | zipStorePath=wrapper/dists
17 | zipStoreBase=GRADLE_USER_HOME
18 |
--------------------------------------------------------------------------------
/logback-classic/src/main/java/com/tersesystems/logback/classic/NanoTimeSupplier.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: CC0-1.0
3 | *
4 | * Copyright 2018-2020 Will Sargent.
5 | *
6 | * Licensed under the CC0 Public Domain Dedication;
7 | * You may obtain a copy of the License at
8 | *
9 | * http://creativecommons.org/publicdomain/zero/1.0/
10 | */
11 |
12 | package com.tersesystems.logback.classic;
13 |
14 | import com.tersesystems.logback.core.Component;
15 |
16 | public interface NanoTimeSupplier extends Component {
17 | long getNanoTime();
18 | }
19 |
--------------------------------------------------------------------------------
/logback-core/logback-core.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: CC0-1.0
3 | *
4 | * Copyright 2018-2020 Will Sargent.
5 | *
6 | * Licensed under the CC0 Public Domain Dedication;
7 | * You may obtain a copy of the License at
8 | *
9 | * http://creativecommons.org/publicdomain/zero/1.0/
10 | */
11 | plugins {
12 | id 'java-library'
13 | }
14 |
15 | dependencies {
16 | api "org.slf4j:slf4j-api:$slf4jVersion"
17 | implementation "ch.qos.logback:logback-core:$logbackVersion"
18 | testImplementation "ch.qos.logback:logback-classic:$logbackVersion"
19 | }
--------------------------------------------------------------------------------
/logback-exception-mapping-providers/logback-exception-mapping-providers.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: CC0-1.0
3 | *
4 | * Copyright 2018-2020 Will Sargent.
5 | *
6 | * Licensed under the CC0 Public Domain Dedication;
7 | * You may obtain a copy of the License at
8 | *
9 | * http://creativecommons.org/publicdomain/zero/1.0/
10 | */
11 | dependencies {
12 | implementation project(':logback-exception-mapping')
13 | implementation project(':logback-typesafe-config')
14 |
15 | implementation "net.logstash.logback:logstash-logback-encoder:$logstashVersion"
16 | }
--------------------------------------------------------------------------------
/logback-classic/src/main/java/com/tersesystems/logback/classic/sift/DiscriminatingValue.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: CC0-1.0
3 | *
4 | * Copyright 2018-2020 Will Sargent.
5 | *
6 | * Licensed under the CC0 Public Domain Dedication;
7 | * You may obtain a copy of the License at
8 | *
9 | * http://creativecommons.org/publicdomain/zero/1.0/
10 | */
11 | package com.tersesystems.logback.classic.sift;
12 |
13 | import ch.qos.logback.classic.spi.ILoggingEvent;
14 |
15 | public interface DiscriminatingValue {
16 | String getDiscriminatingValue(ILoggingEvent loggingEvent);
17 | }
18 |
--------------------------------------------------------------------------------
/logback-censor/src/main/java/com/tersesystems/logback/censor/Censor.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: CC0-1.0
3 | *
4 | * Copyright 2018-2020 Will Sargent.
5 | *
6 | * Licensed under the CC0 Public Domain Dedication;
7 | * You may obtain a copy of the License at
8 | *
9 | * http://creativecommons.org/publicdomain/zero/1.0/
10 | */
11 | package com.tersesystems.logback.censor;
12 |
13 | import com.tersesystems.logback.core.Component;
14 |
15 | /** Basic censor functionality. */
16 | public interface Censor extends Component {
17 | CharSequence censorText(CharSequence input);
18 | }
19 |
--------------------------------------------------------------------------------
/logback-budget/logback-budget.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: CC0-1.0
3 | *
4 | * Copyright 2018-2020 Will Sargent.
5 | *
6 | * Licensed under the CC0 Public Domain Dedication;
7 | * You may obtain a copy of the License at
8 | *
9 | * http://creativecommons.org/publicdomain/zero/1.0/
10 | */
11 | dependencies {
12 | implementation project(':logback-core')
13 | implementation project(':logback-classic')
14 | // https://mvnrepository.com/artifact/org.apache.commons/commons-lang3
15 | implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.9'
16 | }
17 |
--------------------------------------------------------------------------------
/logback-honeycomb-appender/logback-honeycomb-appender.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: CC0-1.0
3 | *
4 | * Copyright 2018-2020 Will Sargent.
5 | *
6 | * Licensed under the CC0 Public Domain Dedication;
7 | * You may obtain a copy of the License at
8 | *
9 | * http://creativecommons.org/publicdomain/zero/1.0/
10 | */
11 | plugins {
12 | id 'java-library'
13 | }
14 |
15 | dependencies {
16 | api project(":logback-honeycomb-client")
17 |
18 | implementation project(":logback-classic")
19 | implementation "net.logstash.logback:logstash-logback-encoder:$logstashVersion"
20 | }
21 |
--------------------------------------------------------------------------------
/logback-censor/logback-censor.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: CC0-1.0
3 | *
4 | * Copyright 2018-2020 Will Sargent.
5 | *
6 | * Licensed under the CC0 Public Domain Dedication;
7 | * You may obtain a copy of the License at
8 | *
9 | * http://creativecommons.org/publicdomain/zero/1.0/
10 | */
11 | dependencies {
12 | implementation project(":logback-core")
13 |
14 | implementation "org.slf4j:slf4j-api:$slf4jVersion"
15 | implementation "net.logstash.logback:logstash-logback-encoder:$logstashVersion"
16 | implementation "ch.qos.logback:logback-classic:$logbackVersion"
17 | }
18 |
--------------------------------------------------------------------------------
/logback-audio/logback-audio.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: CC0-1.0
3 | *
4 | * Copyright 2018-2020 Will Sargent.
5 | *
6 | * Licensed under the CC0 Public Domain Dedication;
7 | * You may obtain a copy of the License at
8 | *
9 | * http://creativecommons.org/publicdomain/zero/1.0/
10 | */
11 | dependencies {
12 | implementation project(':logback-core')
13 | implementation project(':logback-classic')
14 | implementation group: 'com.googlecode.soundlibs', name: 'mp3spi', version: '1.9.5.4'
15 | implementation group: 'com.github.trilarion', name: 'vorbis-support', version: '1.1.0'
16 | }
17 |
--------------------------------------------------------------------------------
/logback-exception-mapping/src/main/java/com/tersesystems/logback/exceptionmapping/Constants.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: CC0-1.0
3 | *
4 | * Copyright 2018-2020 Will Sargent.
5 | *
6 | * Licensed under the CC0 Public Domain Dedication;
7 | * You may obtain a copy of the License at
8 | *
9 | * http://creativecommons.org/publicdomain/zero/1.0/
10 | */
11 | package com.tersesystems.logback.exceptionmapping;
12 |
13 | public final class Constants {
14 |
15 | public static final String REGISTRY_BAG = "EXCEPTION_REGISTRY_BAG";
16 |
17 | public static final String DEFAULT_MAPPINGS_KEY = "default";
18 | }
19 |
--------------------------------------------------------------------------------
/logback-censor/src/main/java/com/tersesystems/logback/censor/CensorConstants.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: CC0-1.0
3 | *
4 | * Copyright 2018-2020 Will Sargent.
5 | *
6 | * Licensed under the CC0 Public Domain Dedication;
7 | * You may obtain a copy of the License at
8 | *
9 | * http://creativecommons.org/publicdomain/zero/1.0/
10 | */
11 | package com.tersesystems.logback.censor;
12 |
13 | public class CensorConstants {
14 |
15 | public static final String CENSOR_BAG = "CENSOR_BAG";
16 | public static final String REF_ATTRIBUTE = "ref";
17 | public static final String CENSOR_RULE_NAME = "censor";
18 | }
19 |
--------------------------------------------------------------------------------
/logback-exception-mapping/src/main/java/com/tersesystems/logback/exceptionmapping/ExceptionMapping.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: CC0-1.0
3 | *
4 | * Copyright 2018-2020 Will Sargent.
5 | *
6 | * Licensed under the CC0 Public Domain Dedication;
7 | * You may obtain a copy of the License at
8 | *
9 | * http://creativecommons.org/publicdomain/zero/1.0/
10 | */
11 | package com.tersesystems.logback.exceptionmapping;
12 |
13 | import java.util.List;
14 | import java.util.function.Function;
15 |
16 | public interface ExceptionMapping extends Function> {
17 | String getName();
18 | }
19 |
--------------------------------------------------------------------------------
/logback-correlationid/src/main/java/com/tersesystems/logback/correlationid/CorrelationIdProvider.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: CC0-1.0
3 | *
4 | * Copyright 2018-2020 Will Sargent.
5 | *
6 | * Licensed under the CC0 Public Domain Dedication;
7 | * You may obtain a copy of the License at
8 | *
9 | * http://creativecommons.org/publicdomain/zero/1.0/
10 | */
11 |
12 | package com.tersesystems.logback.correlationid;
13 |
14 | import com.tersesystems.logback.core.Component;
15 |
16 | /** A correlation id component. */
17 | public interface CorrelationIdProvider extends Component {
18 | String getCorrelationId();
19 | }
20 |
--------------------------------------------------------------------------------
/logback-compress-encoder/logback-compress-encoder.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: CC0-1.0
3 | *
4 | * Copyright 2018-2020 Will Sargent.
5 | *
6 | * Licensed under the CC0 Public Domain Dedication;
7 | * You may obtain a copy of the License at
8 | *
9 | * http://creativecommons.org/publicdomain/zero/1.0/
10 | */
11 | dependencies {
12 | implementation project(':logback-classic')
13 |
14 | implementation group: 'org.apache.commons', name: 'commons-compress', version: '1.18'
15 | implementation "com.github.luben:zstd-jni:$zstdVersion"
16 |
17 | testImplementation "ch.qos.logback:logback-classic:$logbackVersion"
18 | }
--------------------------------------------------------------------------------
/logback-uniqueid-appender/src/main/java/com/tersesystems/logback/uniqueid/UniqueIdProvider.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: CC0-1.0
3 | *
4 | * Copyright 2018-2020 Will Sargent.
5 | *
6 | * Licensed under the CC0 Public Domain Dedication;
7 | * You may obtain a copy of the License at
8 | *
9 | * http://creativecommons.org/publicdomain/zero/1.0/
10 | */
11 |
12 | package com.tersesystems.logback.uniqueid;
13 |
14 | import com.tersesystems.logback.core.Component;
15 |
16 | /** This interface returns a unique id identifying the entity. */
17 | public interface UniqueIdProvider extends Component {
18 | String uniqueId();
19 | }
20 |
--------------------------------------------------------------------------------
/logback-turbomarker/src/test/java/com/tersesystems/logback/turbomarker/ApplicationContext.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: CC0-1.0
3 | *
4 | * Copyright 2018-2020 Will Sargent.
5 | *
6 | * Licensed under the CC0 Public Domain Dedication;
7 | * You may obtain a copy of the License at
8 | *
9 | * http://creativecommons.org/publicdomain/zero/1.0/
10 | */
11 | package com.tersesystems.logback.turbomarker;
12 |
13 | public class ApplicationContext {
14 |
15 | private final String userId;
16 |
17 | public ApplicationContext(String userId) {
18 | this.userId = userId;
19 | }
20 |
21 | public String currentUserId() {
22 | return userId;
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/logback-honeycomb-client/src/main/java/com/tersesystems/logback/honeycomb/client/HoneycombClientService.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: CC0-1.0
3 | *
4 | * Copyright 2018-2020 Will Sargent.
5 | *
6 | * Licensed under the CC0 Public Domain Dedication;
7 | * You may obtain a copy of the License at
8 | *
9 | * http://creativecommons.org/publicdomain/zero/1.0/
10 | */
11 |
12 | package com.tersesystems.logback.honeycomb.client;
13 |
14 | import java.util.function.Function;
15 |
16 | public interface HoneycombClientService {
17 | HoneycombClient newClient(
18 | String apiKey, String dataset, Function, byte[]> encodeFunction);
19 | }
20 |
--------------------------------------------------------------------------------
/logback-classic/src/main/java/com/tersesystems/logback/classic/IContainerLoggingEvent.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: CC0-1.0
3 | *
4 | * Copyright 2018-2020 Will Sargent.
5 | *
6 | * Licensed under the CC0 Public Domain Dedication;
7 | * You may obtain a copy of the License at
8 | *
9 | * http://creativecommons.org/publicdomain/zero/1.0/
10 | */
11 |
12 | package com.tersesystems.logback.classic;
13 |
14 | import ch.qos.logback.classic.spi.ILoggingEvent;
15 | import com.tersesystems.logback.core.ComponentContainer;
16 |
17 | /** A logging event that is a container of components. */
18 | public interface IContainerLoggingEvent extends ILoggingEvent, ComponentContainer {}
19 |
--------------------------------------------------------------------------------
/logback-bytebuddy/src/test/resources/logback-test.xml:
--------------------------------------------------------------------------------
1 |
11 |
12 |
13 |
14 |
15 | %-5relative %-5level %logger{35} - %msg%n
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/feature_request.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Feature request
3 | about: Suggest an idea for this project
4 | title: ''
5 | labels: ''
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Is your feature request related to a problem? Please describe.**
11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12 |
13 | **Describe the solution you'd like**
14 | A clear and concise description of what you want to happen.
15 |
16 | **Describe alternatives you've considered**
17 | A clear and concise description of any alternative solutions or features you've considered.
18 |
19 | **Additional context**
20 | Add any other context or screenshots about the feature request here.
21 |
--------------------------------------------------------------------------------
/logback-correlationid/src/test/resources/logback-correlationid.xml:
--------------------------------------------------------------------------------
1 |
11 |
12 |
13 |
14 | correlationId
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/logback-bytebuddy/src/main/java/com/tersesystems/logback/bytebuddy/impl/LoggerResolver.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: CC0-1.0
3 | *
4 | * Copyright 2018-2020 Will Sargent.
5 | *
6 | * Licensed under the CC0 Public Domain Dedication;
7 | * You may obtain a copy of the License at
8 | *
9 | * http://creativecommons.org/publicdomain/zero/1.0/
10 | */
11 | package com.tersesystems.logback.bytebuddy.impl;
12 |
13 | import org.slf4j.Logger;
14 |
15 | /** Finds a logger given some input. */
16 | public interface LoggerResolver {
17 | /**
18 | * @param origin the class name plus other stuff, provided from bytebuddy advice.
19 | * @return a logger.
20 | */
21 | Logger resolve(String origin);
22 | }
23 |
--------------------------------------------------------------------------------
/logback-uniqueid-appender/src/main/java/com/tersesystems/logback/uniqueid/TsidIdgenerator.java:
--------------------------------------------------------------------------------
1 | package com.tersesystems.logback.uniqueid;
2 |
3 | import com.github.f4b6a3.tsid.TsidFactory;
4 |
5 | /**
6 | * Generates a TSID according to https://github.com/f4b6a3/tsid-creator.
8 | */
9 | public class TsidIdgenerator implements IdGenerator {
10 |
11 | // "tsidcreator.node" system property should be set,
12 | // but small hope of that happening, so choose a large node count.
13 | private final TsidFactory factory = TsidFactory.newInstance4096();
14 |
15 | @Override
16 | public String generateId() {
17 | return factory.create().toString();
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/logback-turbomarker/src/test/java/com/tersesystems/logback/turbomarker/UserMarker.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: CC0-1.0
3 | *
4 | * Copyright 2018-2020 Will Sargent.
5 | *
6 | * Licensed under the CC0 Public Domain Dedication;
7 | * You may obtain a copy of the License at
8 | *
9 | * http://creativecommons.org/publicdomain/zero/1.0/
10 | */
11 | package com.tersesystems.logback.turbomarker;
12 |
13 | public class UserMarker extends ContextAwareTurboMarker {
14 | public UserMarker(
15 | String name,
16 | ApplicationContext applicationContext,
17 | ContextAwareTurboFilterDecider decider) {
18 | super(name, applicationContext, decider);
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/logback-classic/src/main/java/com/tersesystems/logback/classic/TimeSinceEpochConverter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: CC0-1.0
3 | *
4 | * Copyright 2018-2020 Will Sargent.
5 | *
6 | * Licensed under the CC0 Public Domain Dedication;
7 | * You may obtain a copy of the License at
8 | *
9 | * http://creativecommons.org/publicdomain/zero/1.0/
10 | */
11 | package com.tersesystems.logback.classic;
12 |
13 | import ch.qos.logback.classic.pattern.ClassicConverter;
14 | import ch.qos.logback.classic.spi.ILoggingEvent;
15 |
16 | public class TimeSinceEpochConverter extends ClassicConverter {
17 | @Override
18 | public String convert(ILoggingEvent event) {
19 | return Long.toString(event.getTimeStamp());
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/logback-core/src/main/java/com/tersesystems/logback/core/ComponentContainer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: CC0-1.0
3 | *
4 | * Copyright 2018-2020 Will Sargent.
5 | *
6 | * Licensed under the CC0 Public Domain Dedication;
7 | * You may obtain a copy of the License at
8 | *
9 | * http://creativecommons.org/publicdomain/zero/1.0/
10 | */
11 |
12 | package com.tersesystems.logback.core;
13 |
14 | /**
15 | * A component container.
16 | *
17 | *
Entries are encouraged but not required to extend Component.
18 | */
19 | public interface ComponentContainer {
20 | void putComponent(Class type, T instance);
21 |
22 | T getComponent(Class type);
23 |
24 | boolean hasComponent(Class type);
25 | }
26 |
--------------------------------------------------------------------------------
/logback-honeycomb-okhttp/src/main/resources/META-INF/services/com.tersesystems.logback.honeycomb.client.HoneycombClientService:
--------------------------------------------------------------------------------
1 | #
2 | # SPDX-License-Identifier: CC0-1.0
3 | #
4 | # Copyright 2018-2020 Will Sargent.
5 | #
6 | # Licensed under the CC0 Public Domain Dedication;
7 | # You may obtain a copy of the License at
8 | #
9 | # http://creativecommons.org/publicdomain/zero/1.0/
10 | #
11 |
12 | #
13 | # SPDX-License-Identifier: CC0-1.0
14 | #
15 | # Copyright 2018-2020 Will Sargent.
16 | #
17 | # Licensed under the CC0 Public Domain Dedication;
18 | # You may obtain a copy of the License at
19 | #
20 | # http://creativecommons.org/publicdomain/zero/1.0/
21 | #
22 |
23 | com.tersesystems.logback.honeycomb.okhttp.HoneycombOkHTTPClientService
--------------------------------------------------------------------------------
/logback-classic/src/main/java/com/tersesystems/logback/classic/ILoggingEventFactory.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: CC0-1.0
3 | *
4 | * Copyright 2018-2020 Will Sargent.
5 | *
6 | * Licensed under the CC0 Public Domain Dedication;
7 | * You may obtain a copy of the License at
8 | *
9 | * http://creativecommons.org/publicdomain/zero/1.0/
10 | */
11 | package com.tersesystems.logback.classic;
12 |
13 | import ch.qos.logback.classic.Level;
14 | import ch.qos.logback.classic.Logger;
15 | import ch.qos.logback.classic.spi.ILoggingEvent;
16 | import org.slf4j.Marker;
17 |
18 | public interface ILoggingEventFactory {
19 | E create(Marker marker, Logger logger, Level level, String msg, Object[] params, Throwable t);
20 | }
21 |
--------------------------------------------------------------------------------
/logback-honeycomb-client/src/main/java/com/tersesystems/logback/honeycomb/client/HoneycombHeaders.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: CC0-1.0
3 | *
4 | * Copyright 2018-2020 Will Sargent.
5 | *
6 | * Licensed under the CC0 Public Domain Dedication;
7 | * You may obtain a copy of the License at
8 | *
9 | * http://creativecommons.org/publicdomain/zero/1.0/
10 | */
11 | package com.tersesystems.logback.honeycomb.client;
12 |
13 | public class HoneycombHeaders {
14 | public static String teamHeader() {
15 | return "X-Honeycomb-Team";
16 | }
17 |
18 | public static String eventTimeHeader() {
19 | return "X-Honeycomb-Event-Time";
20 | }
21 |
22 | public static String sampleRateHeader() {
23 | return "X-Honeycomb-Samplerate";
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/logback-censor/src/main/java/com/tersesystems/logback/censor/CensoringPrettyPrintingJsonGeneratorDecorator.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: CC0-1.0
3 | *
4 | * Copyright 2018-2020 Will Sargent.
5 | *
6 | * Licensed under the CC0 Public Domain Dedication;
7 | * You may obtain a copy of the License at
8 | *
9 | * http://creativecommons.org/publicdomain/zero/1.0/
10 | */
11 | package com.tersesystems.logback.censor;
12 |
13 | import com.fasterxml.jackson.core.JsonGenerator;
14 |
15 | public class CensoringPrettyPrintingJsonGeneratorDecorator extends CensoringJsonGeneratorDecorator
16 | implements CensorAttachable {
17 | @Override
18 | public JsonGenerator decorate(JsonGenerator generator) {
19 | return super.decorate(generator.useDefaultPrettyPrinter());
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/logback-audio/src/main/java/com/tersesystems/logback/audio/URLPlayer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: CC0-1.0
3 | *
4 | * Copyright 2018-2020 Will Sargent.
5 | *
6 | * Licensed under the CC0 Public Domain Dedication;
7 | * You may obtain a copy of the License at
8 | *
9 | * http://creativecommons.org/publicdomain/zero/1.0/
10 | */
11 | package com.tersesystems.logback.audio;
12 |
13 | import ch.qos.logback.core.spi.ContextAwareBase;
14 | import java.net.URL;
15 |
16 | public class URLPlayer extends ContextAwareBase implements Player {
17 |
18 | private URL url;
19 |
20 | public URLPlayer() {}
21 |
22 | public void URLPlayer(URL url) {
23 | this.url = url;
24 | }
25 |
26 | @Override
27 | public void play() {
28 | SimplePlayer.fromURL(url).play();
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/logback-audio/src/main/java/com/tersesystems/logback/audio/SystemPlayer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: CC0-1.0
3 | *
4 | * Copyright 2018-2020 Will Sargent.
5 | *
6 | * Licensed under the CC0 Public Domain Dedication;
7 | * You may obtain a copy of the License at
8 | *
9 | * http://creativecommons.org/publicdomain/zero/1.0/
10 | */
11 | package com.tersesystems.logback.audio;
12 |
13 | import java.awt.*;
14 |
15 | public class SystemPlayer implements Player {
16 | @Override
17 | public void play() {
18 | Toolkit toolkit = Toolkit.getDefaultToolkit();
19 |
20 | final Runnable exclam = (Runnable) toolkit.getDesktopProperty("win.sound.exclamation");
21 | if (exclam != null) {
22 | exclam.run();
23 | } else {
24 | toolkit.beep();
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/logback-audio/src/test/resources/logback-with-converter.xml:
--------------------------------------------------------------------------------
1 |
11 |
12 |
13 |
14 |
15 |
16 | %-5relative %-5level %logger{35} %audio - %msg%n
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/logback-uniqueid-appender/src/main/java/com/tersesystems/logback/uniqueid/KsuidSubsecondIdGenerator.java:
--------------------------------------------------------------------------------
1 | package com.tersesystems.logback.uniqueid;
2 |
3 | import com.github.f4b6a3.ksuid.*;
4 | import java.util.Random;
5 | import java.util.concurrent.ThreadLocalRandom;
6 |
7 | /**
8 | * Creates a subsecond KSUID according to https://github.com/f4b6a3/ksuid-creator.
10 | */
11 | public class KsuidSubsecondIdGenerator implements IdGenerator {
12 |
13 | private Random random() {
14 | return ThreadLocalRandom.current();
15 | }
16 |
17 | private final KsuidFactory factory = KsuidFactory.newSubsecondInstance(() -> random().nextLong());
18 |
19 | @Override
20 | public String generateId() {
21 | return factory.create().toString();
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/logback-tracing/logback-tracing.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: CC0-1.0
3 | *
4 | * Copyright 2018-2020 Will Sargent.
5 | *
6 | * Licensed under the CC0 Public Domain Dedication;
7 | * You may obtain a copy of the License at
8 | *
9 | * http://creativecommons.org/publicdomain/zero/1.0/
10 | */
11 | dependencies {
12 | //implementation "org.slf4j:slf4j-api:$slf4jVersion"
13 | //implementation project(':logback-uniqueid-appender')
14 | implementation project(':logback-classic')
15 |
16 | implementation "com.google.auto.value:auto-value-annotations:1.6.2"
17 | annotationProcessor "com.google.auto.value:auto-value:1.6.2"
18 |
19 | implementation "net.logstash.logback:logstash-logback-encoder:$logstashVersion"
20 | implementation "ch.qos.logback:logback-classic:$logbackVersion"
21 | }
--------------------------------------------------------------------------------
/logback-uniqueid-appender/src/main/java/com/tersesystems/logback/uniqueid/UlidIdGenerator.java:
--------------------------------------------------------------------------------
1 | package com.tersesystems.logback.uniqueid;
2 |
3 | import com.github.f4b6a3.ulid.UlidFactory;
4 | import java.util.Random;
5 | import java.util.concurrent.ThreadLocalRandom;
6 |
7 | /**
8 | * Creates a monotonic ULID using a threadlocal random according to https://github.com/f4b6a3/ulid-creator.
10 | */
11 | public class UlidIdGenerator implements IdGenerator {
12 |
13 | private Random random() {
14 | return ThreadLocalRandom.current();
15 | }
16 |
17 | private final UlidFactory factory = UlidFactory.newMonotonicInstance(() -> random().nextLong());
18 |
19 | @Override
20 | public String generateId() {
21 | return factory.create().toString();
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/logback-turbomarker/src/main/java/com/tersesystems/logback/turbomarker/TurboMarker.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: CC0-1.0
3 | *
4 | * Copyright 2018-2020 Will Sargent.
5 | *
6 | * Licensed under the CC0 Public Domain Dedication;
7 | * You may obtain a copy of the License at
8 | *
9 | * http://creativecommons.org/publicdomain/zero/1.0/
10 | */
11 | package com.tersesystems.logback.turbomarker;
12 |
13 | import com.tersesystems.logback.classic.TerseBasicMarker;
14 | import com.tersesystems.logback.classic.TurboFilterDecider;
15 |
16 | /**
17 | * This class is a marker that can test to see whether an event should be allowed through a turbo
18 | * filter.
19 | */
20 | public abstract class TurboMarker extends TerseBasicMarker implements TurboFilterDecider {
21 | public TurboMarker(String name) {
22 | super(name);
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/logback-postgresjson-appender/src/test/resources/db/migration/V1__logging_table.sql:
--------------------------------------------------------------------------------
1 | --
2 | -- SPDX-License-Identifier: CC0-1.0
3 | --
4 | -- Copyright 2018-2019 Will Sargent.
5 | --
6 | -- Licensed under the CC0 Public Domain Dedication;
7 | -- You may obtain a copy of the License at
8 | --
9 | -- http://creativecommons.org/publicdomain/zero/1.0/
10 | --
11 |
12 | -- timestamp will only give microsecond precision, so we store both timestamp and time since epoch in milliseconds.
13 | -- store the start time in milliseconds.
14 | CREATE TABLE logging_table (
15 | ID serial NOT NULL PRIMARY KEY,
16 | ts TIMESTAMPTZ(6) NOT NULL,
17 | tse_ms numeric NOT NULL,
18 | start_ms numeric NULL,
19 | level_value int NOT NULL,
20 | level VARCHAR(7) NOT NULL,
21 | evt jsonb NOT NULL
22 | );
23 |
24 | CREATE INDEX idxgin ON logging_table USING gin (evt);
--------------------------------------------------------------------------------
/logback-bytebuddy/src/test/java/com/tersesystems/logback/bytebuddy/ClassCalledByAgent.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: CC0-1.0
3 | *
4 | * Copyright 2018-2020 Will Sargent.
5 | *
6 | * Licensed under the CC0 Public Domain Dedication;
7 | * You may obtain a copy of the License at
8 | *
9 | * http://creativecommons.org/publicdomain/zero/1.0/
10 | */
11 | package com.tersesystems.logback.bytebuddy;
12 |
13 | /** This class does no logging. */
14 | public class ClassCalledByAgent {
15 | public void printStatement() {
16 | System.out.println("I am a simple println method with no logging");
17 | }
18 |
19 | public void printArgument(String arg) {
20 | System.out.println("I am a simple println, printing " + arg);
21 | }
22 |
23 | public void throwException(String arg) {
24 | throw new RuntimeException("I'm a squirrel!");
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/logback-classic/src/main/java/com/tersesystems/logback/classic/NanoTimeConverter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: CC0-1.0
3 | *
4 | * Copyright 2018-2020 Will Sargent.
5 | *
6 | * Licensed under the CC0 Public Domain Dedication;
7 | * You may obtain a copy of the License at
8 | *
9 | * http://creativecommons.org/publicdomain/zero/1.0/
10 | */
11 |
12 | package com.tersesystems.logback.classic;
13 |
14 | import ch.qos.logback.classic.pattern.ClassicConverter;
15 | import ch.qos.logback.classic.spi.ILoggingEvent;
16 |
17 | /** A relative time converter that returns number of nanoseconds from NanoTime.start. */
18 | public class NanoTimeConverter extends ClassicConverter {
19 | @Override
20 | public String convert(ILoggingEvent event) {
21 | return NanoTime.fromOptional(getContext(), event).map(st -> Long.toString(st)).orElse(null);
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/logback-audio/src/test/resources/logback-with-marker-appender.xml:
--------------------------------------------------------------------------------
1 |
11 |
12 |
13 |
14 |
15 | %-5relative %-5level %logger{35} - %msg%n
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/logback-bytebuddy/src/main/java/com/tersesystems/logback/bytebuddy/impl/FixedLoggerResolver.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: CC0-1.0
3 | *
4 | * Copyright 2018-2020 Will Sargent.
5 | *
6 | * Licensed under the CC0 Public Domain Dedication;
7 | * You may obtain a copy of the License at
8 | *
9 | * http://creativecommons.org/publicdomain/zero/1.0/
10 | */
11 | package com.tersesystems.logback.bytebuddy.impl;
12 |
13 | import static java.util.Objects.requireNonNull;
14 |
15 | import org.slf4j.Logger;
16 |
17 | /** Always returns the same logger. */
18 | public class FixedLoggerResolver implements LoggerResolver {
19 | private final Logger logger;
20 |
21 | public FixedLoggerResolver(Logger logger) {
22 | this.logger = requireNonNull(logger);
23 | }
24 |
25 | @Override
26 | public Logger resolve(String origin) {
27 | return logger;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/logback-censor/src/main/java/com/tersesystems/logback/censor/CensorContextAware.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: CC0-1.0
3 | *
4 | * Copyright 2018-2020 Will Sargent.
5 | *
6 | * Licensed under the CC0 Public Domain Dedication;
7 | * You may obtain a copy of the License at
8 | *
9 | * http://creativecommons.org/publicdomain/zero/1.0/
10 | */
11 | package com.tersesystems.logback.censor;
12 |
13 | import ch.qos.logback.core.spi.ContextAware;
14 | import ch.qos.logback.core.spi.LifeCycle;
15 |
16 | public interface CensorContextAware extends Censor, ContextAware, LifeCycle {
17 |
18 | /** Get the name of this appender. The name uniquely identifies the appender. */
19 | String getName();
20 |
21 | /**
22 | * Set the name of this appender. The name is used by other components to identify this appender.
23 | */
24 | void setName(String name);
25 | }
26 |
--------------------------------------------------------------------------------
/logback-compress-encoder/src/test/resources/logback-with-zstd-encoder.xml:
--------------------------------------------------------------------------------
1 |
11 |
12 |
13 |
14 | encoded.zst
15 | zstd
16 | 10240
17 |
18 | UTF-8
19 | %-5level %logger{35} - %msg%n
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/logback-jdbc-appender/logback-jdbc-appender.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: CC0-1.0
3 | *
4 | * Copyright 2018-2020 Will Sargent.
5 | *
6 | * Licensed under the CC0 Public Domain Dedication;
7 | * You may obtain a copy of the License at
8 | *
9 | * http://creativecommons.org/publicdomain/zero/1.0/
10 | */
11 | plugins {
12 | id 'java-library'
13 | }
14 |
15 | dependencies {
16 | api project(':logback-classic')
17 |
18 | // .200 has the JSON data type
19 | implementation "com.zaxxer:HikariCP:3.4.2"
20 |
21 | testImplementation "com.h2database:h2:1.4.200"
22 | testImplementation project(':logback-typesafe-config')
23 | testImplementation 'org.awaitility:awaitility:4.0.2'
24 |
25 | testImplementation 'org.apiguardian:apiguardian-api:1.1.0'
26 | testImplementation "net.logstash.logback:logstash-logback-encoder:$logstashVersion"
27 | }
--------------------------------------------------------------------------------
/logback-postgresjson-appender/logback-postgresjson-appender.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: CC0-1.0
3 | *
4 | * Copyright 2018-2020 Will Sargent.
5 | *
6 | * Licensed under the CC0 Public Domain Dedication;
7 | * You may obtain a copy of the License at
8 | *
9 | * http://creativecommons.org/publicdomain/zero/1.0/
10 | */
11 | dependencies {
12 | implementation project(":logback-jdbc-appender")
13 |
14 | implementation group: 'org.postgresql', name: 'postgresql', version: '42.2.6'
15 |
16 | // Need to set up a FlywayBaseTest, the gradle plugin won't run a "testFlywayMigrate" task
17 | // testImplementation "org.flywaydb:flyway-core:6.0.0"
18 | // technically any JSON string is valid input, so we only require logstash-logback-encoder for testing
19 | testImplementation "net.logstash.logback:logstash-logback-encoder:$logstashVersion"
20 | }
21 |
--------------------------------------------------------------------------------
/logback-audio/src/main/java/com/tersesystems/logback/audio/PlayerException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: CC0-1.0
3 | *
4 | * Copyright 2018-2020 Will Sargent.
5 | *
6 | * Licensed under the CC0 Public Domain Dedication;
7 | * You may obtain a copy of the License at
8 | *
9 | * http://creativecommons.org/publicdomain/zero/1.0/
10 | */
11 | package com.tersesystems.logback.audio;
12 |
13 | public class PlayerException extends RuntimeException {
14 | public PlayerException() {}
15 |
16 | public PlayerException(String s) {
17 | super(s);
18 | }
19 |
20 | public PlayerException(String s, Throwable throwable) {
21 | super(s, throwable);
22 | }
23 |
24 | public PlayerException(Throwable throwable) {
25 | super(throwable);
26 | }
27 |
28 | public PlayerException(String s, Throwable throwable, boolean b, boolean b1) {
29 | super(s, throwable, b, b1);
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/logback-turbomarker/src/main/java/com/tersesystems/logback/turbomarker/ContextAwareTurboFilterDecider.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: CC0-1.0
3 | *
4 | * Copyright 2018-2020 Will Sargent.
5 | *
6 | * Licensed under the CC0 Public Domain Dedication;
7 | * You may obtain a copy of the License at
8 | *
9 | * http://creativecommons.org/publicdomain/zero/1.0/
10 | */
11 | package com.tersesystems.logback.turbomarker;
12 |
13 | import ch.qos.logback.classic.Level;
14 | import ch.qos.logback.classic.Logger;
15 | import ch.qos.logback.core.spi.FilterReply;
16 | import org.slf4j.Marker;
17 |
18 | public interface ContextAwareTurboFilterDecider {
19 | FilterReply decide(
20 | ContextAwareTurboMarker marker,
21 | C context,
22 | Marker rootMarker,
23 | Logger logger,
24 | Level level,
25 | String format,
26 | Object[] params,
27 | Throwable t);
28 | }
29 |
--------------------------------------------------------------------------------
/logback-core/src/test/resources/logback-with-composite-appender.xml:
--------------------------------------------------------------------------------
1 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/logback-tracing/src/main/java/com/tersesystems/logback/tracing/Nullable.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: CC0-1.0
3 | *
4 | * Copyright 2018-2020 Will Sargent.
5 | *
6 | * Licensed under the CC0 Public Domain Dedication;
7 | * You may obtain a copy of the License at
8 | *
9 | * http://creativecommons.org/publicdomain/zero/1.0/
10 | */
11 | package com.tersesystems.logback.tracing;
12 |
13 | import static java.lang.annotation.ElementType.TYPE_USE;
14 | import static java.lang.annotation.RetentionPolicy.SOURCE;
15 |
16 | import java.lang.annotation.Retention;
17 | import java.lang.annotation.Target;
18 |
19 | /**
20 | * autovalue wants a Nullable but doesn't tell us from where.
21 | *
22 | *
anything will work, so defining one here.
23 | *
24 | *
https://github.com/google/auto/issues/283#issuecomment-337281043
25 | */
26 | @Target(TYPE_USE)
27 | @Retention(SOURCE)
28 | @interface Nullable {}
29 |
--------------------------------------------------------------------------------
/logback-classic/src/test/java/com/tersesystems/logback/classic/ChangeLogLevelTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: CC0-1.0
3 | *
4 | * Copyright 2018-2020 Will Sargent.
5 | *
6 | * Licensed under the CC0 Public Domain Dedication;
7 | * You may obtain a copy of the License at
8 | *
9 | * http://creativecommons.org/publicdomain/zero/1.0/
10 | */
11 | package com.tersesystems.logback.classic;
12 |
13 | import org.junit.Test;
14 |
15 | public class ChangeLogLevelTest {
16 |
17 | @Test
18 | public void testChangeLogLevel() {
19 | // ILoggerFactory loggerFactory = LoggerFactory.getILoggerFactory();
20 | // ChangeLogLevel changeLogLevel = new ChangeLogLevel();
21 | // Logger logger = loggerFactory.getLogger("example");
22 | // assertThat(logger.isTraceEnabled()).isFalse();
23 | // changeLogLevel.changeLogLevel(logger, "TRACE");
24 | // assertThat(logger.isTraceEnabled()).isTrue();
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/logback-classic/src/main/java/com/tersesystems/logback/classic/StartTimeConverter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: CC0-1.0
3 | *
4 | * Copyright 2018-2020 Will Sargent.
5 | *
6 | * Licensed under the CC0 Public Domain Dedication;
7 | * You may obtain a copy of the License at
8 | *
9 | * http://creativecommons.org/publicdomain/zero/1.0/
10 | */
11 | package com.tersesystems.logback.classic;
12 |
13 | import ch.qos.logback.classic.pattern.ClassicConverter;
14 | import ch.qos.logback.classic.spi.ILoggingEvent;
15 | import java.util.Optional;
16 |
17 | /** Returns start time in milliseconds. */
18 | public class StartTimeConverter extends ClassicConverter {
19 | @Override
20 | public String convert(ILoggingEvent event) {
21 | Optional optStartTime =
22 | StartTime.fromOptional(getContext(), event).map(st -> Long.toString(st.toEpochMilli()));
23 | return optStartTime.orElse(null);
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/logback-classic/src/main/java/com/tersesystems/logback/classic/LoggerDecider.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: CC0-1.0
3 | *
4 | * Copyright 2018-2020 Will Sargent.
5 | *
6 | * Licensed under the CC0 Public Domain Dedication;
7 | * You may obtain a copy of the License at
8 | *
9 | * http://creativecommons.org/publicdomain/zero/1.0/
10 | */
11 | package com.tersesystems.logback.classic;
12 |
13 | import ch.qos.logback.classic.Logger;
14 | import ch.qos.logback.core.spi.FilterReply;
15 | import java.util.function.Function;
16 | import org.slf4j.Marker;
17 |
18 | @FunctionalInterface
19 | public interface LoggerDecider extends Function, TurboFilterDecider {
20 | default FilterReply decide(
21 | Marker marker,
22 | Logger logger,
23 | ch.qos.logback.classic.Level level,
24 | String format,
25 | Object[] params,
26 | Throwable t) {
27 | return apply(logger);
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/logback-turbomarker/src/test/resources/logback-test.xml:
--------------------------------------------------------------------------------
1 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/logback-uniqueid-appender/src/main/java/com/tersesystems/logback/uniqueid/UniqueIdConverter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: CC0-1.0
3 | *
4 | * Copyright 2018-2020 Will Sargent.
5 | *
6 | * Licensed under the CC0 Public Domain Dedication;
7 | * You may obtain a copy of the License at
8 | *
9 | * http://creativecommons.org/publicdomain/zero/1.0/
10 | */
11 | package com.tersesystems.logback.uniqueid;
12 |
13 | import ch.qos.logback.classic.spi.ILoggingEvent;
14 | import ch.qos.logback.core.pattern.DynamicConverter;
15 | import com.tersesystems.logback.core.ComponentContainer;
16 |
17 | public class UniqueIdConverter extends DynamicConverter {
18 | @Override
19 | public String convert(ILoggingEvent event) {
20 | if (event instanceof ComponentContainer) {
21 | return ((ComponentContainer) event).getComponent(UniqueIdProvider.class).uniqueId();
22 | } else {
23 | return null;
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/logback-bytebuddy/src/test/java/com/tersesystems/logback/bytebuddy/PreloadedInstrumentationExample.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: CC0-1.0
3 | *
4 | * Copyright 2018-2020 Will Sargent.
5 | *
6 | * Licensed under the CC0 Public Domain Dedication;
7 | * You may obtain a copy of the License at
8 | *
9 | * http://creativecommons.org/publicdomain/zero/1.0/
10 | */
11 | package com.tersesystems.logback.bytebuddy;
12 |
13 | /**
14 | * Borrowed from securityfixer, showing tracing when you set the security manager.
15 | *
16 | *
Will not work on native methods, i.e. `System.currentTimeMillis`.
17 | *
18 | *
Move this into the main source path and redeploy if you want to test (I can't figure out how
19 | * to do agent stuff in Gradle)
20 | */
21 | public class PreloadedInstrumentationExample {
22 | public static void main(String[] args) throws Exception {
23 | Thread thread = Thread.currentThread();
24 | thread.run();
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/logback-classic/src/main/java/com/tersesystems/logback/classic/FormatParamsDecider.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: CC0-1.0
3 | *
4 | * Copyright 2018-2020 Will Sargent.
5 | *
6 | * Licensed under the CC0 Public Domain Dedication;
7 | * You may obtain a copy of the License at
8 | *
9 | * http://creativecommons.org/publicdomain/zero/1.0/
10 | */
11 | package com.tersesystems.logback.classic;
12 |
13 | import ch.qos.logback.classic.Level;
14 | import ch.qos.logback.classic.Logger;
15 | import ch.qos.logback.core.spi.FilterReply;
16 | import java.util.function.BiFunction;
17 | import org.slf4j.Marker;
18 |
19 | @FunctionalInterface
20 | public interface FormatParamsDecider
21 | extends BiFunction, TurboFilterDecider {
22 | @Override
23 | default FilterReply decide(
24 | Marker marker, Logger logger, Level level, String format, Object[] params, Throwable t) {
25 | return apply(format, params);
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/logback-honeycomb-okhttp/logback-honeycomb-okhttp.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: CC0-1.0
3 | *
4 | * Copyright 2018-2020 Will Sargent.
5 | *
6 | * Licensed under the CC0 Public Domain Dedication;
7 | * You may obtain a copy of the License at
8 | *
9 | * http://creativecommons.org/publicdomain/zero/1.0/
10 | */
11 | plugins {
12 | id 'java-library'
13 | }
14 |
15 | dependencies {
16 | api project(":logback-honeycomb-client")
17 |
18 | implementation "ch.qos.logback:logback-classic:$logbackVersion"
19 |
20 | // https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind
21 | implementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.9.9'
22 |
23 | implementation("com.squareup.okhttp3:okhttp:4.1.0")
24 |
25 | implementation group: 'com.google.auto.service', name: 'auto-service', version: '1.0-rc6'
26 | annotationProcessor "com.google.auto.service:auto-service:1.0-rc6"
27 | }
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | #
2 | # SPDX-License-Identifier: CC0-1.0
3 | #
4 | # Copyright 2018-2020 Will Sargent.
5 | #
6 | # Licensed under the CC0 Public Domain Dedication;
7 | # You may obtain a copy of the License at
8 | #
9 | # http://creativecommons.org/publicdomain/zero/1.0/
10 | #
11 |
12 | group = com.tersesystems.logback
13 |
14 | org.gradle.caching=true
15 |
16 | # Set to true to attach a debugger
17 | org.gradle.debug=false
18 |
19 | # Set the memory size of the daemon to be higher because animalsniffer needs it.
20 | #org.gradle.jvmargs=-Xmx2g -XX:MaxMetaspaceSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
21 |
22 | bytebuddyVersion = 1.11.5
23 | junitVersion = 4.12
24 | junitJupiterVersion = 5.0.1
25 | junitVintageVersion = 4.12.1
26 | junitPlatformVersion = 1.0.1
27 | slf4jVersion = 1.7.36
28 | logstashVersion = 6.3
29 | logbackVersion = 1.2.10
30 | configVersion = 1.4.0
31 | zstdVersion = 1.5.2-2
32 |
--------------------------------------------------------------------------------
/logback-classic/src/main/java/com/tersesystems/logback/classic/MarkerLoggerDecider.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: CC0-1.0
3 | *
4 | * Copyright 2018-2020 Will Sargent.
5 | *
6 | * Licensed under the CC0 Public Domain Dedication;
7 | * You may obtain a copy of the License at
8 | *
9 | * http://creativecommons.org/publicdomain/zero/1.0/
10 | */
11 | package com.tersesystems.logback.classic;
12 |
13 | import ch.qos.logback.classic.Logger;
14 | import ch.qos.logback.core.spi.FilterReply;
15 | import java.util.function.BiFunction;
16 | import org.slf4j.Marker;
17 |
18 | @FunctionalInterface
19 | public interface MarkerLoggerDecider
20 | extends BiFunction, TurboFilterDecider {
21 | default FilterReply decide(
22 | Marker marker,
23 | Logger logger,
24 | ch.qos.logback.classic.Level level,
25 | String format,
26 | Object[] params,
27 | Throwable t) {
28 | return apply(marker, logger);
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/logback-exception-mapping-providers/src/test/java/com/tersesystems/logback/exceptionmapping/json/MySpecialException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: CC0-1.0
3 | *
4 | * Copyright 2018-2020 Will Sargent.
5 | *
6 | * Licensed under the CC0 Public Domain Dedication;
7 | * You may obtain a copy of the License at
8 | *
9 | * http://creativecommons.org/publicdomain/zero/1.0/
10 | */
11 | package com.tersesystems.logback.exceptionmapping.json;
12 |
13 | import java.time.Instant;
14 |
15 | public class MySpecialException extends Exception {
16 |
17 | private final Instant timestamp;
18 |
19 | public MySpecialException(String message, Instant timestamp) {
20 | super(message);
21 | this.timestamp = timestamp;
22 | }
23 |
24 | public MySpecialException(String message, Instant timestamp, Throwable cause) {
25 | super(message, cause);
26 | this.timestamp = timestamp;
27 | }
28 |
29 | public Instant getTimestamp() {
30 | return timestamp;
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/logback-uniqueid-appender/logback-uniqueid-appender.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: CC0-1.0
3 | *
4 | * Copyright 2018-2020 Will Sargent.
5 | *
6 | * Licensed under the CC0 Public Domain Dedication;
7 | * You may obtain a copy of the License at
8 | *
9 | * http://creativecommons.org/publicdomain/zero/1.0/
10 | */
11 | dependencies {
12 | implementation project(':logback-classic')
13 |
14 | // https://github.com/f4b6a3/ulid-creator
15 | implementation 'com.github.f4b6a3:ulid-creator:5.1.0'
16 |
17 | // https://github.com/f4b6a3/tsid-creator
18 | implementation 'com.github.f4b6a3:tsid-creator:5.2.0'
19 |
20 | // https://github.com/f4b6a3/uuid-creator
21 | implementation 'com.github.f4b6a3:uuid-creator:5.2.0'
22 |
23 | // https://github.com/f4b6a3/ksuid-creator
24 | implementation 'com.github.f4b6a3:ksuid-creator:4.1.0'
25 |
26 | // https://github.com/mguenther/idem
27 | implementation 'net.mguenther.idem:idem-core:0.1.0'
28 | }
29 |
--------------------------------------------------------------------------------
/logback-classic/src/main/java/com/tersesystems/logback/classic/ContainerEventAppender.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: CC0-1.0
3 | *
4 | * Copyright 2018-2020 Will Sargent.
5 | *
6 | * Licensed under the CC0 Public Domain Dedication;
7 | * You may obtain a copy of the License at
8 | *
9 | * http://creativecommons.org/publicdomain/zero/1.0/
10 | */
11 |
12 | package com.tersesystems.logback.classic;
13 |
14 | import ch.qos.logback.classic.spi.ILoggingEvent;
15 | import com.tersesystems.logback.core.DecoratingAppender;
16 |
17 | /**
18 | * This appender decorates the out of the box logging event with a component system, which allows
19 | * extra attributes to be added to the event.
20 | */
21 | public class ContainerEventAppender
22 | extends DecoratingAppender {
23 | @Override
24 | protected IContainerLoggingEvent decorateEvent(ILoggingEvent eventObject) {
25 | return new ContainerProxyLoggingEvent(eventObject);
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/bug_report.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Bug report
3 | about: Create a report to help us improve
4 | title: ''
5 | labels: ''
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Describe the bug**
11 | A clear and concise description of what the bug is.
12 |
13 | **To Reproduce**
14 | Steps to reproduce the behavior:
15 | 1. Go to '...'
16 | 2. Click on '....'
17 | 3. Scroll down to '....'
18 | 4. See error
19 |
20 | **Expected behavior**
21 | A clear and concise description of what you expected to happen.
22 |
23 | **Screenshots**
24 | If applicable, add screenshots to help explain your problem.
25 |
26 | **Desktop (please complete the following information):**
27 | - OS: [e.g. iOS]
28 | - Browser [e.g. chrome, safari]
29 | - Version [e.g. 22]
30 |
31 | **Smartphone (please complete the following information):**
32 | - Device: [e.g. iPhone6]
33 | - OS: [e.g. iOS8.1]
34 | - Browser [e.g. stock browser, safari]
35 | - Version [e.g. 22]
36 |
37 | **Additional context**
38 | Add any other context about the problem here.
39 |
--------------------------------------------------------------------------------
/logback-core/src/main/java/com/tersesystems/logback/core/EnabledFilter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: CC0-1.0
3 | *
4 | * Copyright 2018-2020 Will Sargent.
5 | *
6 | * Licensed under the CC0 Public Domain Dedication;
7 | * You may obtain a copy of the License at
8 | *
9 | * http://creativecommons.org/publicdomain/zero/1.0/
10 | */
11 | package com.tersesystems.logback.core;
12 |
13 | import ch.qos.logback.core.filter.Filter;
14 | import ch.qos.logback.core.spi.FilterReply;
15 |
16 | /** Used to enable and disable appenders. */
17 | public class EnabledFilter extends Filter {
18 |
19 | private boolean enabled;
20 |
21 | @Override
22 | public FilterReply decide(E event) {
23 | if (isStarted() && isEnabled()) {
24 | return FilterReply.NEUTRAL;
25 | } else {
26 | return FilterReply.DENY;
27 | }
28 | }
29 |
30 | public boolean isEnabled() {
31 | return enabled;
32 | }
33 |
34 | public void setEnabled(boolean enabled) {
35 | this.enabled = enabled;
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/logback-exception-mapping/src/test/java/com/tersesystems/logback/exceptionmapping/MyCustomException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: CC0-1.0
3 | *
4 | * Copyright 2018-2020 Will Sargent.
5 | *
6 | * Licensed under the CC0 Public Domain Dedication;
7 | * You may obtain a copy of the License at
8 | *
9 | * http://creativecommons.org/publicdomain/zero/1.0/
10 | */
11 | package com.tersesystems.logback.exceptionmapping;
12 |
13 | public class MyCustomException extends RuntimeException {
14 | private final String one;
15 | private final String two;
16 | private final String three;
17 |
18 | public MyCustomException(String message, String one, String two, String three, Throwable cause) {
19 | super(message, cause);
20 | this.one = one;
21 | this.two = two;
22 | this.three = three;
23 | }
24 |
25 | public String getOne() {
26 | return one;
27 | }
28 |
29 | public String getTwo() {
30 | return two;
31 | }
32 |
33 | public String getThree() {
34 | return three;
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/logback-jdbc-appender/src/test/resources/logback-reference.conf:
--------------------------------------------------------------------------------
1 | levels {
2 | ROOT = INFO
3 | }
4 |
5 | local {
6 | jdbc {
7 | url = "jdbc:h2:mem:terse-logback"
8 | driver = "org.h2.Driver"
9 | username = "sa"
10 | password = ""
11 | insertStatement = "insert into events(ts, relative_ns, start_ms, level_value, level, evt) values(?, ?, ?, ?, ?, ?)"
12 | createStatements = """
13 | CREATE TABLE IF NOT EXISTS events (
14 | ID INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
15 | ts TIMESTAMP(9) WITH TIME ZONE NOT NULL,
16 | relative_ns numeric NULL,
17 | start_ms numeric NULL,
18 | level_value int NOT NULL,
19 | level VARCHAR(7) NOT NULL,
20 | evt JSON NOT NULL
21 | );
22 | """
23 | reaperStatement = "delete from events where ts < ?"
24 | reaperSchedule = PT30
25 | }
26 | }
27 |
28 | # Defines properties (Strings) to be set in context scope (loggerContext.putProperty)
29 | # See https://logback.qos.ch/manual/configuration.html#scopes
30 | context {
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/logback-classic/src/main/java/com/tersesystems/logback/classic/LoggingEventFactory.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: CC0-1.0
3 | *
4 | * Copyright 2018-2020 Will Sargent.
5 | *
6 | * Licensed under the CC0 Public Domain Dedication;
7 | * You may obtain a copy of the License at
8 | *
9 | * http://creativecommons.org/publicdomain/zero/1.0/
10 | */
11 | package com.tersesystems.logback.classic;
12 |
13 | import static ch.qos.logback.classic.Logger.FQCN;
14 |
15 | import ch.qos.logback.classic.Level;
16 | import ch.qos.logback.classic.Logger;
17 | import ch.qos.logback.classic.spi.ILoggingEvent;
18 | import ch.qos.logback.classic.spi.LoggingEvent;
19 | import org.slf4j.Marker;
20 |
21 | public class LoggingEventFactory implements ILoggingEventFactory {
22 | public ILoggingEvent create(
23 | Marker marker, Logger logger, Level level, String msg, Object[] params, Throwable t) {
24 | LoggingEvent le = new LoggingEvent(FQCN, logger, level, msg, t, params);
25 | le.setMarker(marker);
26 | return le;
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/logback-honeycomb-client/src/main/java/com/tersesystems/logback/honeycomb/client/HoneycombRequest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: CC0-1.0
3 | *
4 | * Copyright 2018-2020 Will Sargent.
5 | *
6 | * Licensed under the CC0 Public Domain Dedication;
7 | * You may obtain a copy of the License at
8 | *
9 | * http://creativecommons.org/publicdomain/zero/1.0/
10 | */
11 | package com.tersesystems.logback.honeycomb.client;
12 |
13 | import java.time.Instant;
14 |
15 | public class HoneycombRequest {
16 |
17 | private final Integer sampleRate;
18 | private final E event;
19 | private final Instant timestamp;
20 |
21 | public HoneycombRequest(Integer sampleRate, Instant timestamp, E event) {
22 | this.sampleRate = sampleRate;
23 | this.timestamp = timestamp;
24 | this.event = event;
25 | }
26 |
27 | public E getEvent() {
28 | return event;
29 | }
30 |
31 | public Integer getSampleRate() {
32 | return sampleRate;
33 | }
34 |
35 | public Instant getTimestamp() {
36 | return timestamp;
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/logback-budget/src/test/java/com.tersesystems.logback.budget/BudgetTurboFilterTest.java:
--------------------------------------------------------------------------------
1 | package com.tersesystems.logback.budget;
2 |
3 | import ch.qos.logback.classic.Logger;
4 | import ch.qos.logback.classic.LoggerContext;
5 | import ch.qos.logback.classic.joran.JoranConfigurator;
6 | import ch.qos.logback.core.joran.spi.JoranException;
7 | import java.net.URL;
8 | import org.junit.Test;
9 |
10 | public class BudgetTurboFilterTest {
11 |
12 | @Test
13 | public void testBudget() throws JoranException, InterruptedException {
14 | LoggerContext context = new LoggerContext();
15 |
16 | URL resource = getClass().getResource("/logback-turbofilter.xml");
17 | JoranConfigurator configurator = new JoranConfigurator();
18 | configurator.setContext(context);
19 | configurator.doConfigure(resource);
20 |
21 | Logger logger = context.getLogger("some.random.Logger");
22 |
23 | for (int i = 0; i < 10; i++) {
24 | logger.info("Hello world");
25 | }
26 | Thread.sleep(1000);
27 |
28 | logger.info("Hello world");
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/logback-classic/src/main/java/com/tersesystems/logback/classic/NanoTimeMarker.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: CC0-1.0
3 | *
4 | * Copyright 2018-2020 Will Sargent.
5 | *
6 | * Licensed under the CC0 Public Domain Dedication;
7 | * You may obtain a copy of the License at
8 | *
9 | * http://creativecommons.org/publicdomain/zero/1.0/
10 | */
11 |
12 | package com.tersesystems.logback.classic;
13 |
14 | public class NanoTimeMarker extends TerseBasicMarker implements NanoTimeSupplier {
15 | private static final String NANOTIME_MARKER_NAME = "TS_NANOTIME_MARKER";
16 | private final long nanoTime;
17 |
18 | public NanoTimeMarker() {
19 | super(NANOTIME_MARKER_NAME);
20 | this.nanoTime = System.nanoTime() - NanoTime.start;
21 | }
22 |
23 | public long getNanoTime() {
24 | return nanoTime;
25 | }
26 |
27 | public static NanoTimeMarker create() {
28 | return new NanoTimeMarker();
29 | }
30 |
31 | @Override
32 | public String toString() {
33 | return "NanoTimeMarker{" + "nanoTime=" + nanoTime + '}';
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/logback-classic/src/test/resources/logback-tapfilter.xml:
--------------------------------------------------------------------------------
1 |
11 |
12 |
13 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 | %-5relative %-5level %logger{35} - %msg%n
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/logback-turbomarker/src/main/java/com/tersesystems/logback/turbomarker/ContextDecider.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: CC0-1.0
3 | *
4 | * Copyright 2018-2020 Will Sargent.
5 | *
6 | * Licensed under the CC0 Public Domain Dedication;
7 | * You may obtain a copy of the License at
8 | *
9 | * http://creativecommons.org/publicdomain/zero/1.0/
10 | */
11 | package com.tersesystems.logback.turbomarker;
12 |
13 | import ch.qos.logback.classic.Level;
14 | import ch.qos.logback.classic.Logger;
15 | import ch.qos.logback.core.spi.FilterReply;
16 | import java.util.function.Function;
17 | import org.slf4j.Marker;
18 |
19 | public interface ContextDecider
20 | extends Function, ContextAwareTurboFilterDecider {
21 | @Override
22 | default FilterReply decide(
23 | ContextAwareTurboMarker marker,
24 | C context,
25 | Marker rootMarker,
26 | Logger logger,
27 | Level level,
28 | String format,
29 | Object[] params,
30 | Throwable t) {
31 | return apply(context);
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/logback-classic/src/main/java/com/tersesystems/logback/classic/StartTimeMarker.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: CC0-1.0
3 | *
4 | * Copyright 2018-2020 Will Sargent.
5 | *
6 | * Licensed under the CC0 Public Domain Dedication;
7 | * You may obtain a copy of the License at
8 | *
9 | * http://creativecommons.org/publicdomain/zero/1.0/
10 | */
11 | package com.tersesystems.logback.classic;
12 |
13 | import java.time.Instant;
14 | import java.util.Objects;
15 |
16 | public class StartTimeMarker extends TerseBasicMarker implements StartTimeSupplier {
17 | private static final String TS_STARTTIME_MARKER = "TS_STARTTIME_MARKER";
18 | private final Instant startTime;
19 |
20 | public StartTimeMarker(Instant start) {
21 | super(TS_STARTTIME_MARKER);
22 | this.startTime = Objects.requireNonNull(start);
23 | }
24 |
25 | @Override
26 | public Instant getStartTime() {
27 | return startTime;
28 | }
29 |
30 | @Override
31 | public String toString() {
32 | return "StartTimeMarker{" + "startTime=" + startTime + '}';
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/logback-exception-mapping/src/main/java/com/tersesystems/logback/exceptionmapping/FunctionExceptionMapping.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: CC0-1.0
3 | *
4 | * Copyright 2018-2020 Will Sargent.
5 | *
6 | * Licensed under the CC0 Public Domain Dedication;
7 | * You may obtain a copy of the License at
8 | *
9 | * http://creativecommons.org/publicdomain/zero/1.0/
10 | */
11 | package com.tersesystems.logback.exceptionmapping;
12 |
13 | import java.util.List;
14 | import java.util.function.Function;
15 |
16 | public class FunctionExceptionMapping implements ExceptionMapping {
17 | private final Function> function;
18 | private final String name;
19 |
20 | public FunctionExceptionMapping(String name, Function> f) {
21 | this.name = name;
22 | this.function = f;
23 | }
24 |
25 | @Override
26 | public List apply(Throwable e) {
27 | return function.apply(e);
28 | }
29 |
30 | @Override
31 | public String getName() {
32 | return name;
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/logback-typesafe-config/src/test/resources/typesafeconfig/config-with-local.xml:
--------------------------------------------------------------------------------
1 |
11 |
12 |
13 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 | [%-5level] %logger{15} - %msg%n%xException{10}
25 |
26 |
27 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/logback-typesafe-config/src/test/resources/typesafeconfig/config-with-default.xml:
--------------------------------------------------------------------------------
1 |
11 |
12 |
13 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 | [%-5level] %logger{15} - %msg%n%xException{10}
25 |
26 |
27 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/logback-bytebuddy/src/test/java/com/tersesystems/logback/bytebuddy/AdviceConfigTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: CC0-1.0
3 | *
4 | * Copyright 2018-2020 Will Sargent.
5 | *
6 | * Licensed under the CC0 Public Domain Dedication;
7 | * You may obtain a copy of the License at
8 | *
9 | * http://creativecommons.org/publicdomain/zero/1.0/
10 | */
11 | package com.tersesystems.logback.bytebuddy;
12 |
13 | import static org.assertj.core.api.Assertions.assertThat;
14 |
15 | import com.typesafe.config.Config;
16 | import org.junit.jupiter.api.Test;
17 |
18 | public class AdviceConfigTest {
19 |
20 | @Test
21 | public void testConfig() throws Exception {
22 | ClassLoader classLoader = ClassLoader.getSystemClassLoader();
23 | Config config = LoggingInstrumentationAdvice.generateConfig(classLoader, false);
24 | AdviceConfig adviceConfig =
25 | LoggingInstrumentationAdvice.generateAdviceConfig(classLoader, config, false);
26 | assertThat(adviceConfig.classNames())
27 | .contains("com.tersesystems.logback.bytebuddy.ClassCalledByAgent");
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/logback-uniqueid-appender/src/main/java/com/tersesystems/logback/uniqueid/FlakeIdGenerator.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: CC0-1.0
3 | *
4 | * Copyright 2018-2020 Will Sargent.
5 | *
6 | * Licensed under the CC0 Public Domain Dedication;
7 | * You may obtain a copy of the License at
8 | *
9 | * http://creativecommons.org/publicdomain/zero/1.0/
10 | */
11 | package com.tersesystems.logback.uniqueid;
12 |
13 | import net.mguenther.idem.flake.Flake128S;
14 | import net.mguenther.idem.provider.LinearTimeProvider;
15 | import net.mguenther.idem.provider.MacAddressWorkerIdProvider;
16 |
17 | /**
18 | * This class generates a 128 bit flake id with a macaddress workerid according to https://github.com/mguenther/idem.
20 | */
21 | public class FlakeIdGenerator implements IdGenerator {
22 |
23 | private static final Flake128S flake64 =
24 | new Flake128S(new LinearTimeProvider(), new MacAddressWorkerIdProvider());
25 |
26 | @Override
27 | public String generateId() {
28 | return flake64.nextId();
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/logback-typesafe-config/src/test/resources/typesafeconfig/config-with-context.xml:
--------------------------------------------------------------------------------
1 |
11 |
12 |
13 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 | [%-5level] %logger{15} - %msg%n%xException{10}
25 |
26 |
27 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/logback-budget/src/test/resources/logback-turbofilter.xml:
--------------------------------------------------------------------------------
1 |
11 |
12 |
13 |
14 |
15 | INFO
16 | 5
17 | 1
18 | second
19 |
20 | DENY
21 | NEUTRAL
22 |
23 |
24 |
25 |
26 | %-5relative %-5level %logger{35} - %msg%n
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/logback-classic/src/main/java/com/tersesystems/logback/classic/TurboFilterDecider.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: CC0-1.0
3 | *
4 | * Copyright 2018-2020 Will Sargent.
5 | *
6 | * Licensed under the CC0 Public Domain Dedication;
7 | * You may obtain a copy of the License at
8 | *
9 | * http://creativecommons.org/publicdomain/zero/1.0/
10 | */
11 | package com.tersesystems.logback.classic;
12 |
13 | import ch.qos.logback.classic.Level;
14 | import ch.qos.logback.classic.Logger;
15 | import ch.qos.logback.core.spi.FilterReply;
16 | import org.slf4j.Marker;
17 |
18 | /**
19 | * An interface that decides what sort of filter reply there is.
20 | *
21 | *
Logback doesn't provide an interface for this out of the box for all turbofilters, so we have
22 | * to add one in by hand when we want decisions without the whole turbo filter.
23 | *
24 | *
This comes in handy for turbomarkers and tap filters.
25 | */
26 | public interface TurboFilterDecider {
27 | FilterReply decide(
28 | Marker marker, Logger logger, Level level, String format, Object[] params, Throwable t);
29 | }
30 |
--------------------------------------------------------------------------------
/logback-turbomarker/src/main/java/com/tersesystems/logback/turbomarker/LoggerContextDecider.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: CC0-1.0
3 | *
4 | * Copyright 2018-2020 Will Sargent.
5 | *
6 | * Licensed under the CC0 Public Domain Dedication;
7 | * You may obtain a copy of the License at
8 | *
9 | * http://creativecommons.org/publicdomain/zero/1.0/
10 | */
11 | package com.tersesystems.logback.turbomarker;
12 |
13 | import ch.qos.logback.classic.Level;
14 | import ch.qos.logback.classic.Logger;
15 | import ch.qos.logback.core.spi.FilterReply;
16 | import java.util.function.BiFunction;
17 | import org.slf4j.Marker;
18 |
19 | @FunctionalInterface
20 | public interface LoggerContextDecider
21 | extends BiFunction, ContextAwareTurboFilterDecider {
22 | default FilterReply decide(
23 | ContextAwareTurboMarker marker,
24 | C context,
25 | Marker rootMarker,
26 | Logger logger,
27 | Level level,
28 | String format,
29 | Object[] params,
30 | Throwable t) {
31 | return apply(logger, context);
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/logback-core/src/test/java/com/tersesystems/logback/core/TestAppender.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: CC0-1.0
3 | *
4 | * Copyright 2018-2020 Will Sargent.
5 | *
6 | * Licensed under the CC0 Public Domain Dedication;
7 | * You may obtain a copy of the License at
8 | *
9 | * http://creativecommons.org/publicdomain/zero/1.0/
10 | */
11 | package com.tersesystems.logback.core;
12 |
13 | import ch.qos.logback.classic.spi.ILoggingEvent;
14 | import ch.qos.logback.core.AppenderBase;
15 | import ch.qos.logback.core.encoder.Encoder;
16 | import java.util.ArrayList;
17 | import java.util.List;
18 |
19 | public class TestAppender extends AppenderBase {
20 |
21 | protected Encoder encoder;
22 |
23 | public static List events = new ArrayList<>();
24 |
25 | public Encoder getEncoder() {
26 | return encoder;
27 | }
28 |
29 | public void setEncoder(Encoder encoder) {
30 | this.encoder = encoder;
31 | }
32 |
33 | @Override
34 | protected void append(ILoggingEvent e) {
35 | events.add(e);
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/logback-censor/src/test/java/com/tersesystems/logback/censor/TestAppender.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: CC0-1.0
3 | *
4 | * Copyright 2018-2020 Will Sargent.
5 | *
6 | * Licensed under the CC0 Public Domain Dedication;
7 | * You may obtain a copy of the License at
8 | *
9 | * http://creativecommons.org/publicdomain/zero/1.0/
10 | */
11 | package com.tersesystems.logback.censor;
12 |
13 | import ch.qos.logback.classic.spi.ILoggingEvent;
14 | import ch.qos.logback.core.AppenderBase;
15 | import ch.qos.logback.core.encoder.Encoder;
16 | import java.util.ArrayList;
17 | import java.util.List;
18 |
19 | public class TestAppender extends AppenderBase {
20 |
21 | protected Encoder encoder;
22 |
23 | public static List events = new ArrayList<>();
24 |
25 | public Encoder getEncoder() {
26 | return encoder;
27 | }
28 |
29 | public void setEncoder(Encoder encoder) {
30 | this.encoder = encoder;
31 | }
32 |
33 | @Override
34 | protected void append(ILoggingEvent e) {
35 | events.add(e);
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/logback-classic/src/test/java/com/tersesystems/logback/classic/CorrelationIdMarker.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: CC0-1.0
3 | *
4 | * Copyright 2018-2020 Will Sargent.
5 | *
6 | * Licensed under the CC0 Public Domain Dedication;
7 | * You may obtain a copy of the License at
8 | *
9 | * http://creativecommons.org/publicdomain/zero/1.0/
10 | */
11 |
12 | package com.tersesystems.logback.classic;
13 |
14 | import org.slf4j.Marker;
15 |
16 | /** A very simple correlation id marker. */
17 | public interface CorrelationIdMarker extends Marker {
18 | String getCorrelationId();
19 |
20 | static CorrelationIdMarker create(String value) {
21 | return new CorrelationIdBasicMarker(value);
22 | }
23 | }
24 |
25 | /** Implementation of correlation id. */
26 | class CorrelationIdBasicMarker extends TerseBasicMarker implements CorrelationIdMarker {
27 | private final String value;
28 |
29 | public CorrelationIdBasicMarker(String value) {
30 | super("TS_CORRELATION_ID");
31 | this.value = value;
32 | }
33 |
34 | public String getCorrelationId() {
35 | return value;
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/logback-postgresjson-appender/src/test/java/com/tersesystems/logback/postgresjson/PostgresJsonAppenderTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: CC0-1.0
3 | *
4 | * Copyright 2018-2020 Will Sargent.
5 | *
6 | * Licensed under the CC0 Public Domain Dedication;
7 | * You may obtain a copy of the License at
8 | *
9 | * http://creativecommons.org/publicdomain/zero/1.0/
10 | */
11 | package com.tersesystems.logback.postgresjson;
12 |
13 | import ch.qos.logback.classic.Logger;
14 | import ch.qos.logback.core.joran.spi.JoranException;
15 | import com.tersesystems.logback.classic.Utils;
16 | import org.junit.jupiter.api.Disabled;
17 | import org.junit.jupiter.api.Test;
18 |
19 | public class PostgresJsonAppenderTest {
20 |
21 | @Disabled
22 | @Test
23 | public void testJson() throws JoranException, InterruptedException {
24 |
25 | Utils utils = Utils.create("/logback-postgres-json.xml");
26 | Logger logger1 = utils.getLogger("com.example.Test");
27 | logger1.info("THIS IS A TEST");
28 |
29 | Thread.sleep(1000);
30 |
31 | utils.getStatusList().forEach(System.out::println);
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/logback-uniqueid-appender/src/main/java/com/tersesystems/logback/uniqueid/RandomUUIDIdGenerator.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: CC0-1.0
3 | *
4 | * Copyright 2018-2020 Will Sargent.
5 | *
6 | * Licensed under the CC0 Public Domain Dedication;
7 | * You may obtain a copy of the License at
8 | *
9 | * http://creativecommons.org/publicdomain/zero/1.0/
10 | */
11 | package com.tersesystems.logback.uniqueid;
12 |
13 | import com.github.f4b6a3.uuid.factory.rfc4122.RandomBasedFactory;
14 | import java.util.Random;
15 | import java.util.concurrent.ThreadLocalRandom;
16 |
17 | /**
18 | * Generates a Random UUIDv4 using a ThreadLocalRandom from https://github.com/f4b6a3/uuid-creator
20 | */
21 | public class RandomUUIDIdGenerator implements IdGenerator {
22 | private Random random() {
23 | return ThreadLocalRandom.current();
24 | }
25 |
26 | private final RandomBasedFactory factory = new RandomBasedFactory(() -> random().nextLong());
27 |
28 | @Override
29 | public String generateId() {
30 | return factory.create().toString();
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/logback-audio/src/main/java/com/tersesystems/logback/audio/AudioAppender.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: CC0-1.0
3 | *
4 | * Copyright 2018-2020 Will Sargent.
5 | *
6 | * Licensed under the CC0 Public Domain Dedication;
7 | * You may obtain a copy of the License at
8 | *
9 | * http://creativecommons.org/publicdomain/zero/1.0/
10 | */
11 | package com.tersesystems.logback.audio;
12 |
13 | import ch.qos.logback.classic.spi.ILoggingEvent;
14 | import ch.qos.logback.core.AppenderBase;
15 |
16 | public class AudioAppender extends AppenderBase implements PlayerAttachable {
17 |
18 | private Player player;
19 |
20 | @Override
21 | protected void append(ILoggingEvent eventObject) {
22 | player.play();
23 | }
24 |
25 | @Override
26 | public void addPlayer(Player player) {
27 | this.player = player;
28 | }
29 |
30 | @Override
31 | public void clearAllPlayers() {
32 | this.player = null;
33 | }
34 |
35 | @Override
36 | public void start() {
37 | if (player == null) {
38 | addError("No player found!");
39 | } else {
40 | super.start();
41 | }
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/logback-correlationid/src/test/resources/logback-correlationid-tapfilter.xml:
--------------------------------------------------------------------------------
1 |
11 |
12 |
13 |
15 |
16 |
17 |
18 |
19 |
20 | correlationId
21 |
22 |
23 |
24 |
25 |
26 | %-5relative %-5level %logger{35} - %msg%n
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/logback-honeycomb-client/src/main/java/com/tersesystems/logback/honeycomb/client/HoneycombClient.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: CC0-1.0
3 | *
4 | * Copyright 2018-2020 Will Sargent.
5 | *
6 | * Licensed under the CC0 Public Domain Dedication;
7 | * You may obtain a copy of the License at
8 | *
9 | * http://creativecommons.org/publicdomain/zero/1.0/
10 | */
11 | package com.tersesystems.logback.honeycomb.client;
12 |
13 | import java.util.List;
14 | import java.util.concurrent.CompletionStage;
15 | import java.util.function.Function;
16 |
17 | public interface HoneycombClient {
18 |
19 | CompletionStage post(HoneycombRequest request);
20 |
21 | CompletionStage post(
22 | HoneycombRequest request, Function, byte[]> encodeFunction);
23 |
24 | CompletionStage> postBatch(Iterable> requests);
25 |
26 | CompletionStage> postBatch(
27 | Iterable> requests, Function, byte[]> encodeFunction);
28 |
29 | CompletionStage close();
30 | }
31 |
--------------------------------------------------------------------------------
/logback-turbomarker/src/main/java/com/tersesystems/logback/turbomarker/MarkerContextDecider.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: CC0-1.0
3 | *
4 | * Copyright 2018-2020 Will Sargent.
5 | *
6 | * Licensed under the CC0 Public Domain Dedication;
7 | * You may obtain a copy of the License at
8 | *
9 | * http://creativecommons.org/publicdomain/zero/1.0/
10 | */
11 | package com.tersesystems.logback.turbomarker;
12 |
13 | import ch.qos.logback.classic.Level;
14 | import ch.qos.logback.classic.Logger;
15 | import ch.qos.logback.core.spi.FilterReply;
16 | import java.util.function.BiFunction;
17 | import org.slf4j.Marker;
18 |
19 | @FunctionalInterface
20 | public interface MarkerContextDecider
21 | extends BiFunction, C, FilterReply>,
22 | ContextAwareTurboFilterDecider {
23 | @Override
24 | default FilterReply decide(
25 | ContextAwareTurboMarker marker,
26 | C context,
27 | Marker rootMarker,
28 | Logger logger,
29 | Level level,
30 | String format,
31 | Object[] params,
32 | Throwable t) {
33 | return apply(marker, context);
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/logback-classic/src/main/java/com/tersesystems/logback/classic/sift/DiscriminatingMarkerFactory.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: CC0-1.0
3 | *
4 | * Copyright 2018-2020 Will Sargent.
5 | *
6 | * Licensed under the CC0 Public Domain Dedication;
7 | * You may obtain a copy of the License at
8 | *
9 | * http://creativecommons.org/publicdomain/zero/1.0/
10 | */
11 | package com.tersesystems.logback.classic.sift;
12 |
13 | import ch.qos.logback.classic.spi.ILoggingEvent;
14 | import java.util.function.Function;
15 |
16 | public class DiscriminatingMarkerFactory {
17 |
18 | private final Function discriminatingFunction;
19 |
20 | public DiscriminatingMarkerFactory(Function discriminatingFunction) {
21 | this.discriminatingFunction = discriminatingFunction;
22 | }
23 |
24 | public static DiscriminatingMarkerFactory create(
25 | Function discriminatingFunction) {
26 | return new DiscriminatingMarkerFactory(discriminatingFunction);
27 | }
28 |
29 | public DiscriminatingMarker createMarker() {
30 | return new DiscriminatingMarker(discriminatingFunction);
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/logback-correlationid/src/main/java/com/tersesystems/logback/correlationid/CorrelationIdMarker.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: CC0-1.0
3 | *
4 | * Copyright 2018-2020 Will Sargent.
5 | *
6 | * Licensed under the CC0 Public Domain Dedication;
7 | * You may obtain a copy of the License at
8 | *
9 | * http://creativecommons.org/publicdomain/zero/1.0/
10 | */
11 |
12 | package com.tersesystems.logback.correlationid;
13 |
14 | import com.tersesystems.logback.classic.TerseBasicMarker;
15 | import org.slf4j.Marker;
16 |
17 | /** A very simple correlation id marker. */
18 | public interface CorrelationIdMarker extends Marker, CorrelationIdProvider {
19 | static CorrelationIdMarker create(String value) {
20 | return new CorrelationIdBasicMarker(value);
21 | }
22 | }
23 |
24 | /** Implementation of correlation id. */
25 | class CorrelationIdBasicMarker extends TerseBasicMarker implements CorrelationIdMarker {
26 | private final String value;
27 |
28 | public CorrelationIdBasicMarker(String value) {
29 | super("TS_CORRELATION_ID");
30 | this.value = value;
31 | }
32 |
33 | public String getCorrelationId() {
34 | return value;
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/logback-honeycomb-okhttp/src/main/java/com/tersesystems/logback/honeycomb/okhttp/HoneycombOkHTTPClientService.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: CC0-1.0
3 | *
4 | * Copyright 2018-2020 Will Sargent.
5 | *
6 | * Licensed under the CC0 Public Domain Dedication;
7 | * You may obtain a copy of the License at
8 | *
9 | * http://creativecommons.org/publicdomain/zero/1.0/
10 | */
11 |
12 | package com.tersesystems.logback.honeycomb.okhttp;
13 |
14 | import com.fasterxml.jackson.core.JsonFactory;
15 | import com.tersesystems.logback.honeycomb.client.HoneycombClient;
16 | import com.tersesystems.logback.honeycomb.client.HoneycombClientService;
17 | import com.tersesystems.logback.honeycomb.client.HoneycombRequest;
18 | import java.util.function.Function;
19 | import okhttp3.OkHttpClient;
20 |
21 | public class HoneycombOkHTTPClientService implements HoneycombClientService {
22 | @Override
23 | public HoneycombClient newClient(
24 | String apiKey, String dataset, Function, byte[]> encodeFunction) {
25 | return new HoneycombOkHTTPClient(
26 | new OkHttpClient(), new JsonFactory(), apiKey, dataset, encodeFunction);
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/logback-exception-mapping/src/test/java/com/tersesystems/logback/exceptionmapping/Thrower.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: CC0-1.0
3 | *
4 | * Copyright 2018-2020 Will Sargent.
5 | *
6 | * Licensed under the CC0 Public Domain Dedication;
7 | * You may obtain a copy of the License at
8 | *
9 | * http://creativecommons.org/publicdomain/zero/1.0/
10 | */
11 | package com.tersesystems.logback.exceptionmapping;
12 |
13 | import java.sql.BatchUpdateException;
14 | import org.slf4j.Logger;
15 | import org.slf4j.LoggerFactory;
16 |
17 | public class Thrower {
18 | private static final Logger logger = LoggerFactory.getLogger(Thrower.class);
19 |
20 | public static void main(String[] progArgs) {
21 | try {
22 | doSomethingExceptional();
23 | } catch (RuntimeException e) {
24 | logger.error("domain specific message", e);
25 | }
26 | }
27 |
28 | static void doSomethingExceptional() {
29 | Throwable cause = new BatchUpdateException();
30 | throw new MyCustomException(
31 | "This is my message",
32 | "one is one",
33 | "two is more than one",
34 | "three is more than two and one",
35 | cause);
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/logback-turbomarker/src/test/java/com/tersesystems/logback/turbomarker/UserMarkerFactory.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: CC0-1.0
3 | *
4 | * Copyright 2018-2020 Will Sargent.
5 | *
6 | * Licensed under the CC0 Public Domain Dedication;
7 | * You may obtain a copy of the License at
8 | *
9 | * http://creativecommons.org/publicdomain/zero/1.0/
10 | */
11 | package com.tersesystems.logback.turbomarker;
12 |
13 | import ch.qos.logback.core.spi.FilterReply;
14 | import java.util.Set;
15 | import java.util.concurrent.ConcurrentSkipListSet;
16 |
17 | public class UserMarkerFactory {
18 |
19 | private final Set userIdSet = new ConcurrentSkipListSet<>();
20 |
21 | private final ContextDecider decider =
22 | context ->
23 | userIdSet.contains(context.currentUserId()) ? FilterReply.ACCEPT : FilterReply.NEUTRAL;
24 |
25 | public void addUserId(String userId) {
26 | userIdSet.add(userId);
27 | }
28 |
29 | public void clear() {
30 | userIdSet.clear();
31 | }
32 |
33 | public UserMarker create(ApplicationContext applicationContext) {
34 | return new UserMarker("userMarker", applicationContext, decider);
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/logback-bytebuddy/src/main/java/com/tersesystems/logback/bytebuddy/impl/DeclaringTypeLoggerResolver.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: CC0-1.0
3 | *
4 | * Copyright 2018-2020 Will Sargent.
5 | *
6 | * Licensed under the CC0 Public Domain Dedication;
7 | * You may obtain a copy of the License at
8 | *
9 | * http://creativecommons.org/publicdomain/zero/1.0/
10 | */
11 | package com.tersesystems.logback.bytebuddy.impl;
12 |
13 | import java.util.Objects;
14 | import java.util.function.Supplier;
15 | import org.slf4j.ILoggerFactory;
16 | import org.slf4j.Logger;
17 |
18 | /** Returns the logger with the class that was instrumented. */
19 | public class DeclaringTypeLoggerResolver implements LoggerResolver {
20 |
21 | private final Supplier loggerFactory;
22 |
23 | public DeclaringTypeLoggerResolver(Supplier loggerFactory) {
24 | this.loggerFactory = Objects.requireNonNull(loggerFactory);
25 | }
26 |
27 | @Override
28 | public Logger resolve(String origin) {
29 | int firstPipe = origin.indexOf('|');
30 | String declaringType = origin.substring(0, firstPipe);
31 | return loggerFactory.get().getLogger(declaringType);
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/logback-turbomarker/logback-turbomarker.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: CC0-1.0
3 | *
4 | * Copyright 2018-2020 Will Sargent.
5 | *
6 | * Licensed under the CC0 Public Domain Dedication;
7 | * You may obtain a copy of the License at
8 | *
9 | * http://creativecommons.org/publicdomain/zero/1.0/
10 | */
11 | dependencies {
12 | implementation project(':logback-classic')
13 | implementation "ch.qos.logback:logback-classic:$logbackVersion"
14 |
15 | // https://mvnrepository.com/artifact/org.mockito/mockito-core
16 | testImplementation group: 'org.mockito', name: 'mockito-core', version: '3.0.0'
17 | testImplementation "com.launchdarkly:launchdarkly-java-server-sdk:4.6.6"
18 | testImplementation "net.logstash.logback:logstash-logback-encoder:$logstashVersion"
19 | testImplementation "com.typesafe:config:$configVersion"
20 | //testImplementation "com.fasterxml.jackson.module:jackson-datatype-jdk8"
21 | //testImplementation "com.fasterxml.jackson.module:jackson-datatype-jsr310"
22 | testImplementation 'org.apiguardian:apiguardian-api:1.1.0'
23 | testImplementation group: 'com.fasterxml.jackson.core', name: 'jackson-annotations', version: '2.9.9'
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/logback-classic/src/main/java/com/tersesystems/logback/classic/sift/DiscriminatingMarker.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: CC0-1.0
3 | *
4 | * Copyright 2018-2020 Will Sargent.
5 | *
6 | * Licensed under the CC0 Public Domain Dedication;
7 | * You may obtain a copy of the License at
8 | *
9 | * http://creativecommons.org/publicdomain/zero/1.0/
10 | */
11 | package com.tersesystems.logback.classic.sift;
12 |
13 | import ch.qos.logback.classic.spi.ILoggingEvent;
14 | import com.tersesystems.logback.classic.TerseBasicMarker;
15 | import java.util.function.Function;
16 |
17 | public class DiscriminatingMarker extends TerseBasicMarker implements DiscriminatingValue {
18 |
19 | private static final String TS_DISCRIMINATING_MARKER = "TS_DESCRIMINATING_MARKER";
20 | private final Function discriminatingFunction;
21 |
22 | public DiscriminatingMarker(Function discriminatingFunction) {
23 | super(TS_DISCRIMINATING_MARKER);
24 | this.discriminatingFunction = discriminatingFunction;
25 | }
26 |
27 | @Override
28 | public String getDiscriminatingValue(ILoggingEvent loggingEvent) {
29 | return discriminatingFunction.apply(loggingEvent);
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/logback-classic/src/main/java/com/tersesystems/logback/classic/functional/RootLoggerSupplier.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: CC0-1.0
3 | *
4 | * Copyright 2018-2020 Will Sargent.
5 | *
6 | * Licensed under the CC0 Public Domain Dedication;
7 | * You may obtain a copy of the License at
8 | *
9 | * http://creativecommons.org/publicdomain/zero/1.0/
10 | */
11 | package com.tersesystems.logback.classic.functional;
12 |
13 | import ch.qos.logback.classic.Logger;
14 | import ch.qos.logback.classic.LoggerContext;
15 | import com.tersesystems.logback.classic.Utils;
16 | import java.util.function.Supplier;
17 |
18 | public class RootLoggerSupplier implements Supplier {
19 |
20 | private final LoggerContext loggerContext;
21 |
22 | public RootLoggerSupplier(LoggerContext loggerContext) {
23 | this.loggerContext = loggerContext;
24 | }
25 |
26 | public Logger get() {
27 | return loggerContext.getLogger(Logger.ROOT_LOGGER_NAME);
28 | }
29 |
30 | public static RootLoggerSupplier create(LoggerContext loggerContext) {
31 | return new RootLoggerSupplier(loggerContext);
32 | }
33 |
34 | public static RootLoggerSupplier create() {
35 | return create(Utils.defaultContext());
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/logback-budget/src/test/resources/logback-budget.xml:
--------------------------------------------------------------------------------
1 |
11 |
12 |
13 |
14 |
15 |
16 |
17 | INFO
18 | 5
19 | 1
20 | second
21 |
22 |
23 | DENY
24 | NEUTRAL
25 |
26 |
27 |
28 | %-5relative %-5level %logger{35} - %msg%n
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/logback-typesafe-config/src/main/java/com/tersesystems/logback/typesafeconfig/ConfigConstants.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: CC0-1.0
3 | *
4 | * Copyright 2018-2020 Will Sargent.
5 | *
6 | * Licensed under the CC0 Public Domain Dedication;
7 | * You may obtain a copy of the License at
8 | *
9 | * http://creativecommons.org/publicdomain/zero/1.0/
10 | */
11 | package com.tersesystems.logback.typesafeconfig;
12 |
13 | /** Constants having to do with typesafe config. */
14 | public final class ConfigConstants {
15 |
16 | public static final String TYPESAFE_CONFIG_CTX_KEY = "typesafeConfig";
17 |
18 | public static final String LEVELS_KEY = "levels";
19 |
20 | public static final String LOGBACK = "logback";
21 |
22 | public static final String LOGBACK_TEST = "logback-test";
23 |
24 | public static final String LOGBACK_REFERENCE_CONF = "logback-reference.conf";
25 |
26 | public static final String CONFIG_FILE_PROPERTY = "terse.logback.configurationFile";
27 |
28 | public static final String CONTEXT_SCOPE = "context";
29 |
30 | public static final String LOCAL_SCOPE = "local";
31 |
32 | public static final String PATH_ATTRIBUTE = "path";
33 |
34 | public static final String DEBUG_ATTRIBUTE = "debug";
35 | }
36 |
--------------------------------------------------------------------------------
/logback-classic/src/main/java/com/tersesystems/logback/classic/encoder/PatternLayoutEncoder.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: CC0-1.0
3 | *
4 | * Copyright 2018-2020 Will Sargent.
5 | *
6 | * Licensed under the CC0 Public Domain Dedication;
7 | * You may obtain a copy of the License at
8 | *
9 | * http://creativecommons.org/publicdomain/zero/1.0/
10 | */
11 |
12 | package com.tersesystems.logback.classic.encoder;
13 |
14 | import ch.qos.logback.classic.PatternLayout;
15 | import ch.qos.logback.classic.spi.ILoggingEvent;
16 | import com.tersesystems.logback.core.pattern.PatternLayoutEncoderBase;
17 |
18 | /**
19 | * Create a pattern layout encoder that doesn't require that the parent is an appender.
20 | *
21 | *
This allows for encoders that can take encoders and so on.
22 | */
23 | public class PatternLayoutEncoder extends PatternLayoutEncoderBase {
24 |
25 | @Override
26 | public void start() {
27 | PatternLayout patternLayout = new PatternLayout();
28 | patternLayout.setContext(context);
29 | patternLayout.setPattern(getPattern());
30 | patternLayout.setOutputPatternAsHeader(outputPatternAsHeader);
31 | patternLayout.start();
32 | this.layout = patternLayout;
33 | super.start();
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/logback-correlationid/src/main/java/com/tersesystems/logback/correlationid/CorrelationIdDecider.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: CC0-1.0
3 | *
4 | * Copyright 2018-2020 Will Sargent.
5 | *
6 | * Licensed under the CC0 Public Domain Dedication;
7 | * You may obtain a copy of the License at
8 | *
9 | * http://creativecommons.org/publicdomain/zero/1.0/
10 | */
11 |
12 | package com.tersesystems.logback.correlationid;
13 |
14 | import ch.qos.logback.classic.Level;
15 | import ch.qos.logback.classic.Logger;
16 | import ch.qos.logback.core.spi.FilterReply;
17 | import com.tersesystems.logback.classic.TurboFilterDecider;
18 | import java.util.Optional;
19 | import org.slf4j.Marker;
20 |
21 | public class CorrelationIdDecider implements TurboFilterDecider {
22 | protected final CorrelationIdUtils utils;
23 |
24 | public CorrelationIdDecider(CorrelationIdUtils utils) {
25 | this.utils = utils;
26 | }
27 |
28 | @Override
29 | public FilterReply decide(
30 | Marker marker, Logger logger, Level level, String format, Object[] params, Throwable t) {
31 | Optional maybeCorrelationId = utils.get(utils.getMDCPropertyMap(), marker);
32 | return maybeCorrelationId.isPresent() ? FilterReply.ACCEPT : FilterReply.NEUTRAL;
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/logback-censor/src/test/java/com/tersesystems/logback/censor/RegexCensorTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: CC0-1.0
3 | *
4 | * Copyright 2018-2020 Will Sargent.
5 | *
6 | * Licensed under the CC0 Public Domain Dedication;
7 | * You may obtain a copy of the License at
8 | *
9 | * http://creativecommons.org/publicdomain/zero/1.0/
10 | */
11 | package com.tersesystems.logback.censor;
12 |
13 | import static org.assertj.core.api.Assertions.assertThat;
14 |
15 | import org.junit.Test;
16 |
17 | public class RegexCensorTest {
18 |
19 | @Test
20 | public void testCensor() throws Exception {
21 | String replacementText = "*******";
22 |
23 | RegexCensor censor = new RegexCensor();
24 | censor.setReplacementText(replacementText);
25 | censor.setRegex("hunter2");
26 | censor.start();
27 |
28 | assertThat(censor.censorText("hunter2")).isEqualTo("*******");
29 | }
30 |
31 | @Test
32 | public void testCensorWithNoMatch() throws Exception {
33 | String replacementText = "*******";
34 |
35 | RegexCensor censor = new RegexCensor();
36 | censor.setReplacementText(replacementText);
37 | censor.setRegex("hunter2");
38 | censor.start();
39 |
40 | assertThat(censor.censorText("password1")).isEqualTo("password1");
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/logback-classic/src/main/java/com/tersesystems/logback/classic/NanoTimeComponentAppender.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: CC0-1.0
3 | *
4 | * Copyright 2018-2020 Will Sargent.
5 | *
6 | * Licensed under the CC0 Public Domain Dedication;
7 | * You may obtain a copy of the License at
8 | *
9 | * http://creativecommons.org/publicdomain/zero/1.0/
10 | */
11 |
12 | package com.tersesystems.logback.classic;
13 |
14 | import ch.qos.logback.classic.spi.ILoggingEvent;
15 | import com.tersesystems.logback.core.DecoratingAppender;
16 |
17 | /** This appender adds a relative nanotime component to the logging event. */
18 | public class NanoTimeComponentAppender
19 | extends DecoratingAppender {
20 | @Override
21 | protected IContainerLoggingEvent decorateEvent(ILoggingEvent eventObject) {
22 | IContainerLoggingEvent containerEvent;
23 | if (eventObject instanceof IContainerLoggingEvent) {
24 | containerEvent = (IContainerLoggingEvent) eventObject;
25 | } else {
26 | containerEvent = new ContainerProxyLoggingEvent(eventObject);
27 | }
28 | long nanoTime = System.nanoTime() - NanoTime.start;
29 | containerEvent.putComponent(NanoTimeSupplier.class, () -> nanoTime);
30 | return containerEvent;
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/logback-classic/src/test/resources/logback-tapfilter-correlation.xml:
--------------------------------------------------------------------------------
1 |
11 |
12 |
13 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 | correlationId
23 |
24 |
25 |
26 |
27 |
28 |
29 | %-5relative %-5level %logger{35} - %msg%n
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/logback-audio/src/main/java/com/tersesystems/logback/audio/AudioMarkerAppender.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: CC0-1.0
3 | *
4 | * Copyright 2018-2020 Will Sargent.
5 | *
6 | * Licensed under the CC0 Public Domain Dedication;
7 | * You may obtain a copy of the License at
8 | *
9 | * http://creativecommons.org/publicdomain/zero/1.0/
10 | */
11 | package com.tersesystems.logback.audio;
12 |
13 | import ch.qos.logback.classic.spi.ILoggingEvent;
14 | import ch.qos.logback.core.AppenderBase;
15 | import java.util.Iterator;
16 | import org.slf4j.Marker;
17 |
18 | public class AudioMarkerAppender extends AppenderBase {
19 |
20 | @Override
21 | protected void append(ILoggingEvent eventObject) {
22 | writePlayerMarkerIfNecessary(eventObject.getMarker());
23 | }
24 |
25 | private void writePlayerMarkerIfNecessary(Marker marker) {
26 | if (marker != null) {
27 | if (isPlayerMarker(marker)) {
28 | ((Player) marker).play();
29 | }
30 |
31 | if (marker.hasReferences()) {
32 | for (Iterator i = marker.iterator(); i.hasNext(); ) {
33 | writePlayerMarkerIfNecessary(i.next());
34 | }
35 | }
36 | }
37 | }
38 |
39 | private static boolean isPlayerMarker(Marker marker) {
40 | return marker instanceof Player;
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/logback-audio/src/main/java/com/tersesystems/logback/audio/AudioMarker.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: CC0-1.0
3 | *
4 | * Copyright 2018-2020 Will Sargent.
5 | *
6 | * Licensed under the CC0 Public Domain Dedication;
7 | * You may obtain a copy of the License at
8 | *
9 | * http://creativecommons.org/publicdomain/zero/1.0/
10 | */
11 | package com.tersesystems.logback.audio;
12 |
13 | import com.tersesystems.logback.classic.TerseBasicMarker;
14 | import java.io.InputStream;
15 | import java.net.URL;
16 | import java.nio.file.Path;
17 |
18 | public class AudioMarker extends TerseBasicMarker implements Player {
19 |
20 | private static final String MARKER_NAME = "TS_AUDIO_MARKER";
21 |
22 | private final Player player;
23 |
24 | public AudioMarker(URL url) {
25 | super(MARKER_NAME);
26 | player = SimplePlayer.fromURL(url);
27 | }
28 |
29 | public AudioMarker(Path path) {
30 | super(MARKER_NAME);
31 | player = SimplePlayer.fromPath(path);
32 | }
33 |
34 | public AudioMarker(InputStream inputStream) {
35 | super(MARKER_NAME);
36 | player = SimplePlayer.fromInputStream(inputStream);
37 | }
38 |
39 | public AudioMarker(Player player) {
40 | super(MARKER_NAME);
41 | this.player = player;
42 | }
43 |
44 | public void play() {
45 | player.play();
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/logback-classic/src/main/java/com/tersesystems/logback/classic/ContainerProxyLoggingEvent.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: CC0-1.0
3 | *
4 | * Copyright 2018-2020 Will Sargent.
5 | *
6 | * Licensed under the CC0 Public Domain Dedication;
7 | * You may obtain a copy of the License at
8 | *
9 | * http://creativecommons.org/publicdomain/zero/1.0/
10 | */
11 |
12 | package com.tersesystems.logback.classic;
13 |
14 | import ch.qos.logback.classic.spi.ILoggingEvent;
15 | import java.util.HashMap;
16 | import java.util.Map;
17 | import java.util.Objects;
18 |
19 | /** A logging event that implements a container and proxies another logging event. */
20 | public class ContainerProxyLoggingEvent extends ProxyLoggingEvent
21 | implements IContainerLoggingEvent {
22 | private Map, Object> components = new HashMap<>();
23 |
24 | public ContainerProxyLoggingEvent(ILoggingEvent delegate) {
25 | super(delegate);
26 | }
27 |
28 | public void putComponent(Class type, T instance) {
29 | components.put(Objects.requireNonNull(type), instance);
30 | }
31 |
32 | public T getComponent(Class type) {
33 | return type.cast(components.get(type));
34 | }
35 |
36 | @Override
37 | public boolean hasComponent(Class type) {
38 | return components.containsKey(type);
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/logback-audio/src/main/java/com/tersesystems/logback/audio/PlayerConverter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: CC0-1.0
3 | *
4 | * Copyright 2018-2020 Will Sargent.
5 | *
6 | * Licensed under the CC0 Public Domain Dedication;
7 | * You may obtain a copy of the License at
8 | *
9 | * http://creativecommons.org/publicdomain/zero/1.0/
10 | */
11 | package com.tersesystems.logback.audio;
12 |
13 | import ch.qos.logback.classic.pattern.ClassicConverter;
14 | import ch.qos.logback.classic.spi.ILoggingEvent;
15 | import java.util.Iterator;
16 | import org.slf4j.Marker;
17 |
18 | public class PlayerConverter extends ClassicConverter {
19 |
20 | @Override
21 | public String convert(ILoggingEvent event) {
22 | writePlayerMarkerIfNecessary(event.getMarker());
23 | return null;
24 | }
25 |
26 | private void writePlayerMarkerIfNecessary(Marker marker) {
27 | if (marker != null) {
28 | if (isPlayerMarker(marker)) {
29 | ((Player) marker).play();
30 | }
31 |
32 | if (marker.hasReferences()) {
33 | for (Iterator i = marker.iterator(); i.hasNext(); ) {
34 | writePlayerMarkerIfNecessary(i.next());
35 | }
36 | }
37 | }
38 | }
39 |
40 | private static boolean isPlayerMarker(Marker marker) {
41 | return marker instanceof Player;
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/logback-budget/src/test/java/com.tersesystems.logback.budget/BudgetEvaluatorTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: CC0-1.0
3 | *
4 | * Copyright 2018-2020 Will Sargent.
5 | *
6 | * Licensed under the CC0 Public Domain Dedication;
7 | * You may obtain a copy of the License at
8 | *
9 | * http://creativecommons.org/publicdomain/zero/1.0/
10 | */
11 | package com.tersesystems.logback.budget;
12 |
13 | import ch.qos.logback.classic.Logger;
14 | import ch.qos.logback.classic.LoggerContext;
15 | import ch.qos.logback.classic.joran.JoranConfigurator;
16 | import ch.qos.logback.core.joran.spi.JoranException;
17 | import java.net.URL;
18 | import org.junit.Test;
19 |
20 | public class BudgetEvaluatorTest {
21 |
22 | @Test
23 | public void testBudget() throws JoranException, InterruptedException {
24 | LoggerContext context = new LoggerContext();
25 |
26 | URL resource = getClass().getResource("/logback-budget.xml");
27 | JoranConfigurator configurator = new JoranConfigurator();
28 | configurator.setContext(context);
29 | configurator.doConfigure(resource);
30 |
31 | Logger logger = context.getLogger("some.random.Logger");
32 |
33 | for (int i = 0; i < 10; i++) {
34 | logger.info("Hello world");
35 | }
36 | Thread.sleep(1000);
37 |
38 | logger.info("Hello world");
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/logback-exception-mapping/src/test/resources/logback-test.xml:
--------------------------------------------------------------------------------
1 |
11 |
12 |
13 |
15 |
16 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 | %-5relative %-5level %logger{35} - %msg%richex{1, 10, exception=[}%n
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/logback-tracing/src/main/java/com/tersesystems/logback/tracing/EventInfo.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: CC0-1.0
3 | *
4 | * Copyright 2018-2020 Will Sargent.
5 | *
6 | * Licensed under the CC0 Public Domain Dedication;
7 | * You may obtain a copy of the License at
8 | *
9 | * http://creativecommons.org/publicdomain/zero/1.0/
10 | */
11 |
12 | package com.tersesystems.logback.tracing;
13 |
14 | import com.google.auto.value.AutoValue;
15 |
16 | /**
17 | * An event info is a span without a duration. It cannot be used as a parent.
18 | *
19 | *