Skip to content

Commit a859c6b

Browse files
authored
License headers and other legal stuff (#6)
1 parent c6068fb commit a859c6b

File tree

25 files changed

+541
-92
lines changed

25 files changed

+541
-92
lines changed

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@
186186
same "printed page" as the copyright notice for easier
187187
identification within third-party archives.
188188

189-
Copyright [yyyy] [name of copyright owner]
189+
Copyright 2019 Elastic and contributors
190190

191191
Licensed under the Apache License, Version 2.0 (the "License");
192192
you may not use this file except in compliance with the License.

NOTICE

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
java-ecs-logging
2+
Copyright 2019 Elasticsearch B.V.
3+
4+
###############################################################################
5+
This product includes software licensed under the Apache License 2.0 developed at FasterXML.
6+
7+
Jackson LICENSE:
8+
-------------------------------------------------------------------------------
9+
This copy of Jackson JSON processor streaming parser/generator is licensed under the
10+
Apache (Software) License, version 2.0 ("the License").
11+
See the License for details about distribution rights, and the
12+
specific rights regarding derivate works.
13+
14+
You may obtain a copy of the License at:
15+
16+
http://www.apache.org/licenses/LICENSE-2.0
17+
-------------------------------------------------------------------------------
18+
19+
20+
Jackson NOTICE:
21+
-------------------------------------------------------------------------------
22+
# Jackson JSON processor
23+
24+
Jackson is a high-performance, Free/Open Source JSON processing library.
25+
It was originally written by Tatu Saloranta (tatu.saloranta@iki.fi), and has
26+
been in development since 2007.
27+
It is currently developed by a community of developers, as well as supported
28+
commercially by FasterXML.com.
29+
30+
## Licensing
31+
32+
Jackson core and extension components may licensed under different licenses.
33+
To find the details that apply to this artifact see the accompanying LICENSE file.
34+
For more information, including possible other licensing options, contact
35+
FasterXML.com (http://fasterxml.com).
36+
37+
## Credits
38+
39+
A list of contributors may be found from CREDITS file, which is included
40+
in some artifacts (usually source distributions); but is always available
41+
from the source code management (SCM) system project uses.
42+
-------------------------------------------------------------------------------
43+
###############################################################################

ecs-logging-core/pom.xml

+3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
<modelVersion>4.0.0</modelVersion>
1111

1212
<artifactId>ecs-logging-core</artifactId>
13+
<properties>
14+
<parent.base.dir>${project.basedir}/..</parent.base.dir>
15+
</properties>
1316

1417
<build>
1518
<plugins>

ecs-logging-core/src/main/java/co/elastic/logging/EcsJsonSerializer.java

+25-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,32 @@
1+
/*-
2+
* #%L
3+
* Java ECS logging
4+
* %%
5+
* Copyright (C) 2019 Elastic and contributors
6+
* %%
7+
* Licensed to Elasticsearch B.V. under one or more contributor
8+
* license agreements. See the NOTICE file distributed with
9+
* this work for additional information regarding copyright
10+
* ownership. Elasticsearch B.V. licenses this file to you under
11+
* the Apache License, Version 2.0 (the "License"); you may
12+
* not use this file except in compliance with the License.
13+
* You may obtain a copy of the License at
14+
*
15+
* http://www.apache.org/licenses/LICENSE-2.0
16+
*
17+
* Unless required by applicable law or agreed to in writing,
18+
* software distributed under the License is distributed on an
19+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
20+
* KIND, either express or implied. See the License for the
21+
* specific language governing permissions and limitations
22+
* under the License.
23+
* #L%
24+
*/
125
package co.elastic.logging;
226

327
import java.io.PrintWriter;
428
import java.io.StringWriter;
529
import java.util.Arrays;
6-
import java.util.Collections;
7-
import java.util.HashSet;
830
import java.util.List;
931
import java.util.Map;
1032
import java.util.Set;
@@ -115,4 +137,4 @@ private static CharSequence formatThrowable(final Throwable throwable) {
115137
pw.flush();
116138
return sw.toString();
117139
}
118-
}
140+
}
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,51 @@
1+
/*-
2+
* #%L
3+
* Java ECS logging
4+
* %%
5+
* Copyright (C) 2019 Elastic and contributors
6+
* %%
7+
* Licensed to Elasticsearch B.V. under one or more contributor
8+
* license agreements. See the NOTICE file distributed with
9+
* this work for additional information regarding copyright
10+
* ownership. Elasticsearch B.V. licenses this file to you under
11+
* the Apache License, Version 2.0 (the "License"); you may
12+
* not use this file except in compliance with the License.
13+
* You may obtain a copy of the License at
14+
*
15+
* http://www.apache.org/licenses/LICENSE-2.0
16+
*
17+
* Unless required by applicable law or agreed to in writing,
18+
* software distributed under the License is distributed on an
19+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
20+
* KIND, either express or implied. See the License for the
21+
* specific language governing permissions and limitations
22+
* under the License.
23+
* #L%
24+
*/
125
package co.elastic.logging;
226

327
/**
4-
* This class is borrowed from <a href="https://github.com/FasterXML/jackson-core">Jackson</a>.
28+
* This class is based on com.fasterxml.jackson.core.io.CharTypes,
29+
* under Apache License 2.0
530
*/
631
public final class JsonUtils {
732

8-
private static final char[] HC = "0123456789ABCDEF".toCharArray();
33+
private final static char[] HC = "0123456789ABCDEF".toCharArray();
934

1035
/**
11-
* Read-only encoding table for first 128 Unicode code points (single-byte UTF-8 characters).
12-
* Value of 0 means "no escaping"; other positive values that value is character
13-
* to use after backslash; and negative values that generic (backslash - u)
14-
* escaping is to be used.
36+
* Lookup table used for determining which output characters in
37+
* 7-bit ASCII range need to be quoted.
1538
*/
16-
private static final int[] ESC_CODES;
39+
private final static int[] sOutputEscapes128;
40+
1741
static {
18-
final int[] table = new int[128];
42+
int[] table = new int[128];
1943
// Control chars need generic escape sequence
2044
for (int i = 0; i < 32; ++i) {
2145
// 04-Mar-2011, tatu: Used to use "-(i + 1)", replaced with constant
2246
table[i] = -1;
2347
}
24-
/* Others (and some within that range too) have explicit shorter
25-
* sequences
26-
*/
48+
// Others (and some within that range too) have explicit shorter sequences
2749
table['"'] = '"';
2850
table['\\'] = '\\';
2951
// Escaping of slash is optional, so let's not add it
@@ -32,72 +54,40 @@ public final class JsonUtils {
3254
table[0x0C] = 'f';
3355
table[0x0A] = 'n';
3456
table[0x0D] = 'r';
35-
ESC_CODES = table;
36-
}
37-
38-
/**
39-
* Temporary buffer used for composing quote/escape sequences
40-
*/
41-
private final static ThreadLocal<char[]> _qbufLocal = new ThreadLocal<>();
42-
43-
private static char[] getQBuf() {
44-
char[] _qbuf = _qbufLocal.get();
45-
if (_qbuf == null) {
46-
_qbuf = new char[6];
47-
_qbuf[0] = '\\';
48-
_qbuf[2] = '0';
49-
_qbuf[3] = '0';
50-
51-
_qbufLocal.set(_qbuf);
52-
}
53-
return _qbuf;
57+
sOutputEscapes128 = table;
5458
}
5559

56-
/**
57-
* Quote text contents using JSON standard quoting, and append results to a supplied {@link StringBuilder}.
58-
*/
59-
public static void quoteAsString(final CharSequence input, final StringBuilder output) {
60-
final char[] qbuf = getQBuf();
61-
final int escCodeCount = ESC_CODES.length;
62-
int inPtr = 0;
63-
final int inputLen = input.length();
64-
65-
outer:
66-
while (inPtr < inputLen) {
67-
tight_loop:
68-
while (true) {
69-
final char c = input.charAt(inPtr);
70-
if (c < escCodeCount && ESC_CODES[c] != 0) {
71-
break tight_loop;
72-
}
73-
output.append(c);
74-
if (++inPtr >= inputLen) {
75-
break outer;
76-
}
60+
public static void quoteAsString(CharSequence content, StringBuilder sb) {
61+
final int[] escCodes = sOutputEscapes128;
62+
final int escLen = escCodes.length;
63+
for (int i = 0, len = content.length(); i < len; ++i) {
64+
char c = content.charAt(i);
65+
if (c >= escLen || escCodes[c] == 0) {
66+
sb.append(c);
67+
continue;
7768
}
78-
// something to escape; 2 or 6-char variant?
79-
final char d = input.charAt(inPtr++);
80-
final int escCode = ESC_CODES[d];
81-
final int length = (escCode < 0)
82-
? _appendNumeric(d, qbuf)
83-
: _appendNamed(escCode, qbuf);
69+
sb.append('\\');
70+
int escCode = escCodes[c];
71+
if (escCode < 0) { // generic quoting (hex value)
72+
// The only negative value sOutputEscapes128 returns
73+
// is CharacterEscapes.ESCAPE_STANDARD, which mean
74+
// appendQuotes should encode using the Unicode encoding;
75+
// not sure if this is the right way to encode for
76+
// CharacterEscapes.ESCAPE_CUSTOM or other (future)
77+
// CharacterEscapes.ESCAPE_XXX values.
8478

85-
output.append(qbuf, 0, length);
79+
// We know that it has to fit in just 2 hex chars
80+
sb.append('u');
81+
sb.append('0');
82+
sb.append('0');
83+
int value = c; // widening
84+
sb.append(HC[value >> 4]);
85+
sb.append(HC[value & 0xF]);
86+
} else { // "named", i.e. prepend with slash
87+
sb.append((char) escCode);
88+
}
8689
}
8790
}
8891

89-
private static int _appendNumeric(final int value, final char[] qbuf) {
90-
qbuf[1] = 'u';
91-
// We know it's a control char, so only the last 2 chars are non-0
92-
qbuf[4] = HC[value >> 4];
93-
qbuf[5] = HC[value & 0xF];
94-
return 6;
95-
}
96-
97-
private static int _appendNamed(final int esc, final char[] qbuf) {
98-
qbuf[1] = (char) esc;
99-
return 2;
100-
}
101-
10292
}
10393

ecs-logging-core/src/main/java/co/elastic/logging/TimestampSerializer.java

+24
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,27 @@
1+
/*-
2+
* #%L
3+
* Java ECS logging
4+
* %%
5+
* Copyright (C) 2019 Elastic and contributors
6+
* %%
7+
* Licensed to Elasticsearch B.V. under one or more contributor
8+
* license agreements. See the NOTICE file distributed with
9+
* this work for additional information regarding copyright
10+
* ownership. Elasticsearch B.V. licenses this file to you under
11+
* the Apache License, Version 2.0 (the "License"); you may
12+
* not use this file except in compliance with the License.
13+
* You may obtain a copy of the License at
14+
*
15+
* http://www.apache.org/licenses/LICENSE-2.0
16+
*
17+
* Unless required by applicable law or agreed to in writing,
18+
* software distributed under the License is distributed on an
19+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
20+
* KIND, either express or implied. See the License for the
21+
* specific language governing permissions and limitations
22+
* under the License.
23+
* #L%
24+
*/
125
package co.elastic.logging;
226

327
import java.text.SimpleDateFormat;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
java-ecs-logging
2+
Copyright 2019 Elasticsearch B.V.
3+
4+
###############################################################################
5+
This product includes software licensed under the Apache License 2.0 developed at FasterXML.
6+
- co.elastic.logging.JsonUtils
7+
8+
Jackson LICENSE:
9+
-------------------------------------------------------------------------------
10+
This copy of Jackson JSON processor streaming parser/generator is licensed under the
11+
Apache (Software) License, version 2.0 ("the License").
12+
See the License for details about distribution rights, and the
13+
specific rights regarding derivate works.
14+
15+
You may obtain a copy of the License at:
16+
17+
http://www.apache.org/licenses/LICENSE-2.0
18+
-------------------------------------------------------------------------------
19+
20+
21+
Jackson NOTICE:
22+
-------------------------------------------------------------------------------
23+
# Jackson JSON processor
24+
25+
Jackson is a high-performance, Free/Open Source JSON processing library.
26+
It was originally written by Tatu Saloranta (tatu.saloranta@iki.fi), and has
27+
been in development since 2007.
28+
It is currently developed by a community of developers, as well as supported
29+
commercially by FasterXML.com.
30+
31+
## Licensing
32+
33+
Jackson core and extension components may licensed under different licenses.
34+
To find the details that apply to this artifact see the accompanying LICENSE file.
35+
For more information, including possible other licensing options, contact
36+
FasterXML.com (http://fasterxml.com).
37+
38+
## Credits
39+
40+
A list of contributors may be found from CREDITS file, which is included
41+
in some artifacts (usually source distributions); but is always available
42+
from the source code management (SCM) system project uses.
43+
-------------------------------------------------------------------------------
44+
###############################################################################

ecs-logging-core/src/test/java/co/elastic/logging/AbstractEcsLoggingTest.java

+24
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,27 @@
1+
/*-
2+
* #%L
3+
* Java ECS logging
4+
* %%
5+
* Copyright (C) 2019 Elastic and contributors
6+
* %%
7+
* Licensed to Elasticsearch B.V. under one or more contributor
8+
* license agreements. See the NOTICE file distributed with
9+
* this work for additional information regarding copyright
10+
* ownership. Elasticsearch B.V. licenses this file to you under
11+
* the Apache License, Version 2.0 (the "License"); you may
12+
* not use this file except in compliance with the License.
13+
* You may obtain a copy of the License at
14+
*
15+
* http://www.apache.org/licenses/LICENSE-2.0
16+
*
17+
* Unless required by applicable law or agreed to in writing,
18+
* software distributed under the License is distributed on an
19+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
20+
* KIND, either express or implied. See the License for the
21+
* specific language governing permissions and limitations
22+
* under the License.
23+
* #L%
24+
*/
125
package co.elastic.logging;
226

327

0 commit comments

Comments
 (0)