forked from elastic/elasticsearch
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1ac9108
commit eeb43ec
Showing
720 changed files
with
2,766 additions
and
3,785 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
apply plugin: 'elasticsearch.publish' | ||
|
||
dependencies { | ||
moduleCompileOnly project(':libs:elasticsearch-x-content') // TODO: for JsonStringEncoder | ||
moduleCompileOnly project(':libs:elasticsearch-cli') // TODO: prob remove this, if just for exception types | ||
moduleCompileOnly "org.apache.logging.log4j:log4j-api:${versions.log4j}" | ||
moduleCompileOnly "org.apache.logging.log4j:log4j-core:${versions.log4j}" | ||
|
||
moduleCompileOnly "co.elastic.logging:log4j2-ecs-layout:${versions.ecsLogging}" | ||
moduleCompileOnly "co.elastic.logging:ecs-logging-core:${versions.ecsLogging}" | ||
|
||
testImplementation "com.carrotsearch.randomizedtesting:randomizedtesting-runner:${versions.randomizedrunner}" | ||
testImplementation "junit:junit:${versions.junit}" | ||
testImplementation "org.hamcrest:hamcrest:${versions.hamcrest}" | ||
|
||
testImplementation(project(":test:framework")) { | ||
exclude group: 'org.elasticsearch', module: 'elasticsearch-logging' | ||
} | ||
} | ||
|
||
//tasks.named('forbiddenApisMain').configure { | ||
// // :libs:elasticsearch-core does not depend on server | ||
// // TODO: Need to decide how we want to handle for forbidden signatures with the changes to server | ||
// replaceSignatureFiles 'jdk-signatures' | ||
//} | ||
// | ||
tasks.named("compileJava").configure { | ||
options.compilerArgs.add("-Xlint:-requires-automatic") | ||
options.compilerArgs.add("-Xlint:-module") // qualified exports | ||
options.compilerArgs.add("-Xlint:-exports") // implements Message!! | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
module org.elasticsearch.logging { | ||
requires org.elasticsearch.cli; | ||
requires org.elasticsearch.xcontent; | ||
requires log4j2.ecs.layout; | ||
requires ecs.logging.core; | ||
requires org.apache.logging.log4j; | ||
requires org.apache.logging.log4j.core; | ||
|
||
exports org.elasticsearch.logging; | ||
exports org.elasticsearch.logging.internal to org.elasticsearch.server; | ||
exports org.elasticsearch.logging.internal.spi to org.elasticsearch.server; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
libs/logging/src/main/java/org/elasticsearch/logging/ESLogMessage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
package org.elasticsearch.logging; | ||
|
||
import org.elasticsearch.logging.internal.ESLogMessageImpl; | ||
|
||
import java.util.Map; | ||
import java.util.stream.Collectors; | ||
import java.util.stream.Stream; | ||
|
||
/** | ||
* Custom logger messages. Carries additional fields which will populate JSON fields in logs. | ||
*/ | ||
public final class ESLogMessage implements Message { | ||
|
||
private final ESLogMessageImpl impl; | ||
|
||
public ESLogMessage() { | ||
impl = new ESLogMessageImpl(); | ||
} | ||
|
||
public ESLogMessage(String messagePattern, Object... args) { | ||
impl = new ESLogMessageImpl(messagePattern, args); | ||
|
||
} | ||
|
||
public ESLogMessage argAndField(String key, Object value) { | ||
return this.argAndField(key, value); | ||
} | ||
|
||
public ESLogMessage withFields(Map<String, Object> jsonFields) { | ||
return this.withFields(jsonFields); | ||
} | ||
|
||
public ESLogMessage field(String key, Object value) { | ||
return this.field(key, value); | ||
} | ||
|
||
public String get(String key) { | ||
return impl.get(key); | ||
} | ||
|
||
@Override | ||
public String getFormattedMessage() { | ||
return impl.getFormattedMessage(); | ||
} | ||
|
||
@Override | ||
public String getFormat() { | ||
return impl.getFormat(); | ||
} | ||
|
||
@Override | ||
public Object[] getParameters() { | ||
return impl.getParameters(); | ||
} | ||
|
||
@Override | ||
public Throwable getThrowable() { | ||
return impl.getThrowable(); | ||
} | ||
|
||
public static String asJsonArray(Stream<String> stream) { | ||
return "[" + stream.map(ESLogMessageImpl::inQuotes).collect(Collectors.joining(", ")) + "]"; | ||
} | ||
|
||
// static ESLogMessage of() { | ||
// return new ESLogMessageImpl(); | ||
// } | ||
// | ||
// static ESLogMessage of(String messagePattern, Object... args) { | ||
// return new ESLogMessageImpl(messagePattern, args); | ||
// } | ||
} |
81 changes: 81 additions & 0 deletions
81
libs/logging/src/main/java/org/elasticsearch/logging/Level.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
package org.elasticsearch.logging; | ||
|
||
import org.elasticsearch.logging.internal.StandardLevels; | ||
|
||
import java.util.Locale; | ||
import java.util.Objects; | ||
import java.util.concurrent.ConcurrentHashMap; | ||
import java.util.concurrent.ConcurrentMap; | ||
|
||
public final class Level { | ||
|
||
public static final Level OFF = new Level("OFF", StandardLevels.OFF); | ||
|
||
public static final Level FATAL = new Level("FATAL", StandardLevels.FATAL); | ||
|
||
public static final Level ERROR = new Level("ERROR", StandardLevels.ERROR); | ||
|
||
public static final Level WARN = new Level("WARN", StandardLevels.WARN); | ||
|
||
public static final Level INFO = new Level("INFO", StandardLevels.INFO); | ||
|
||
public static final Level DEBUG = new Level("DEBUG", StandardLevels.DEBUG); | ||
|
||
public static final Level TRACE = new Level("TRACE", StandardLevels.TRACE); | ||
|
||
public static final Level ALL = new Level("ALL", StandardLevels.ALL); | ||
|
||
private static final ConcurrentMap<String, Level> LEVELS = new ConcurrentHashMap<>(); | ||
|
||
private final String name; | ||
|
||
private final int severity; | ||
|
||
/*package*/ static Level of(String name, int severity) { | ||
var level = new Level(name, severity); | ||
if (LEVELS.putIfAbsent(name, level) != null) { | ||
throw new IllegalStateException("Level " + name + " is already been defined."); | ||
} | ||
return level; | ||
} | ||
|
||
private Level(String name, int severity) { | ||
this.name = name; | ||
this.severity = severity; | ||
} | ||
|
||
/** | ||
* Returns the name of this level. | ||
*/ | ||
public String name() { | ||
return name; | ||
} | ||
|
||
public int getSeverity() { | ||
return severity; | ||
} | ||
|
||
/** Return the Level associated with the name. */ | ||
public static Level valueOf(final String name) { | ||
Objects.requireNonNull(name); | ||
final String levelName = name.trim().toUpperCase(Locale.ROOT); | ||
final Level level = LEVELS.get(levelName); | ||
if (level != null) { | ||
return level; | ||
} | ||
throw new IllegalArgumentException("Unknown level constant [" + levelName + "]."); | ||
} | ||
|
||
public boolean isMoreSpecificThan(Level level) { | ||
return this.severity <= level.severity; | ||
} | ||
|
||
} |
23 changes: 23 additions & 0 deletions
23
libs/logging/src/main/java/org/elasticsearch/logging/LogManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
package org.elasticsearch.logging; | ||
|
||
public class LogManager { | ||
|
||
public static Logger getLogger(final String name) { | ||
return null; | ||
} | ||
|
||
public static Logger getLogger(final Class<?> clazz) { | ||
return null; | ||
} | ||
|
||
private LogManager() {} | ||
|
||
} |
Oops, something went wrong.