Skip to content

Commit 1ff8d97

Browse files
author
Damien Dallimore
committed
minified builds for specific logging frameworks
1 parent ad3dfaa commit 1ff8d97

15 files changed

+287
-141
lines changed

build/build.xml

Lines changed: 142 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<project name="SPLUNK Logging" default="build_release" basedir="..">
22
<description>
33
SPLUNK Logging Build Script
4-
</description>
4+
</description>
55

66

77
<property file="build/build.properties" />
@@ -28,7 +28,8 @@
2828

2929
<mkdir dir="${temp_build}/${classes}" />
3030

31-
<javac srcdir="${src}" destdir="${temp_build}/${classes}" target="${javaClassTarget}">
31+
<javac srcdir="${src}" destdir="${temp_build}/${classes}"
32+
target="${javaClassTarget}">
3233
<classpath refid="project.class.path" />
3334
</javac>
3435

@@ -73,11 +74,149 @@
7374
<delete dir="${temp_build}/${classes}" />
7475

7576
<tar destfile="${release}/${id}-${version}${suffix}" compression="${compressionType}">
76-
<zipfileset dir="${temp_build}" prefix="${id}" />
77+
<zipfileset dir="${temp_build}" prefix="${id}" />
7778
</tar>
7879

7980
<delete dir="${temp_build}" />
8081

8182
</target>
8283

84+
<target name="build_log4j" depends="compile"
85+
description="generate a log4j only distribution">
86+
<!-- Create the distribution directory -->
87+
88+
89+
<copy todir="${temp_build}/${lib}">
90+
<fileset dir="${lib}"
91+
includes="splunk_tlsv12.jar,log4j-1.2.16.jar,commons-lang-2.4.jar" />
92+
93+
</copy>
94+
95+
96+
97+
<copy todir="${temp_build}/${config}">
98+
<fileset dir="${config}" includes="log4j.properties" />
99+
</copy>
100+
101+
102+
<copy todir="${temp_build}/3rdparty_licenses">
103+
<fileset dir="3rdparty_licenses" />
104+
</copy>
105+
106+
107+
<copy todir="${temp_build}">
108+
<fileset file="LICENSE" />
109+
<fileset file="README.md" />
110+
</copy>
111+
112+
113+
<jar jarfile="${temp_build}/${lib}/${id}-log4j.jar">
114+
<fileset dir="${temp_build}/${classes}"
115+
includes="com/splunk/logging/*.class,com/splunk/logging/log4j/**" />
116+
117+
</jar>
118+
119+
<delete dir="${temp_build}/${classes}" />
120+
121+
<tar destfile="${release}/${id}-log4j-${version}${suffix}"
122+
compression="${compressionType}">
123+
<zipfileset dir="${temp_build}" prefix="${id}" />
124+
</tar>
125+
126+
<delete dir="${temp_build}" />
127+
128+
</target>
129+
130+
<target name="build_logback" depends="compile"
131+
description="generate a logback only distribution">
132+
<!-- Create the distribution directory -->
133+
134+
135+
<copy todir="${temp_build}/${lib}">
136+
<fileset dir="${lib}"
137+
includes="splunk_tlsv12.jar,logback*.jar,commons-lang-2.4.jar" />
138+
139+
</copy>
140+
141+
142+
143+
<copy todir="${temp_build}/${config}">
144+
<fileset dir="${config}" includes="logback.xml" />
145+
</copy>
146+
147+
148+
<copy todir="${temp_build}/3rdparty_licenses">
149+
<fileset dir="3rdparty_licenses" />
150+
</copy>
151+
152+
153+
<copy todir="${temp_build}">
154+
<fileset file="LICENSE" />
155+
<fileset file="README.md" />
156+
</copy>
157+
158+
159+
<jar jarfile="${temp_build}/${lib}/${id}-logback.jar">
160+
<fileset dir="${temp_build}/${classes}"
161+
includes="com/splunk/logging/*.class,com/splunk/logging/logback/**" />
162+
163+
</jar>
164+
165+
<delete dir="${temp_build}/${classes}" />
166+
167+
<tar destfile="${release}/${id}-logback-${version}${suffix}"
168+
compression="${compressionType}">
169+
<zipfileset dir="${temp_build}" prefix="${id}" />
170+
</tar>
171+
172+
<delete dir="${temp_build}" />
173+
174+
</target>
175+
176+
<target name="build_jdk" depends="compile"
177+
description="generate a jdk only distribution">
178+
<!-- Create the distribution directory -->
179+
180+
181+
<copy todir="${temp_build}/${lib}">
182+
<fileset dir="${lib}" includes="splunk_tlsv12.jar" />
183+
184+
</copy>
185+
186+
187+
188+
<copy todir="${temp_build}/${config}">
189+
<fileset dir="${config}" includes="jdklogging.properties" />
190+
</copy>
191+
192+
193+
<copy todir="${temp_build}/3rdparty_licenses">
194+
<fileset dir="3rdparty_licenses" />
195+
</copy>
196+
197+
198+
<copy todir="${temp_build}">
199+
<fileset file="LICENSE" />
200+
<fileset file="README.md" />
201+
</copy>
202+
203+
204+
<jar jarfile="${temp_build}/${lib}/${id}-jdk.jar">
205+
<fileset dir="${temp_build}/${classes}"
206+
includes="com/splunk/logging/*.class,com/splunk/logging/jdk/**" />
207+
208+
</jar>
209+
210+
<delete dir="${temp_build}/${classes}" />
211+
212+
<tar destfile="${release}/${id}-jdk-${version}${suffix}"
213+
compression="${compressionType}">
214+
<zipfileset dir="${temp_build}" prefix="${id}" />
215+
</tar>
216+
217+
<delete dir="${temp_build}" />
218+
219+
</target>
220+
221+
83222
</project>

releases/splunklogging-jdk-1.2.tar.gz

256 KB
Binary file not shown.
919 KB
Binary file not shown.
998 KB
Binary file not shown.

src/com/splunk/logging/SplunkInput.java

Lines changed: 72 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -4,140 +4,148 @@
44
import java.util.List;
55

66
/**
7-
* Common base class for all Splunk Input types.
8-
* Currently just has shared logic for queuing up events.
7+
* Common base class for all Splunk Input types. Currently just has shared logic
8+
* for queuing up events.
99
*
1010
* @author Damien Dallimore damien@dtdsoftware.com
11-
*
11+
*
1212
*/
1313
public abstract class SplunkInput {
1414

15-
//data size multipliers
15+
// data size multipliers
1616
private static final int KB = 1024;
17-
private static final int MB = KB*1024;
18-
private static final int GB = MB*1024;
19-
20-
//default to 500K
21-
private long maxQueueSize = 500*KB;
22-
//default. If true,queue will get emptied when it fills up to accommodate new data.
17+
private static final int MB = KB * 1024;
18+
private static final int GB = MB * 1024;
19+
20+
// default to 500K
21+
private long maxQueueSize = 500 * KB;
22+
// default. If true,queue will get emptied when it fills up to accommodate
23+
// new data.
2324
private boolean dropEventsOnQueueFull = false;
24-
25-
//Using this collection structure to implement the FIFO queue
26-
private List <String>queue = new ArrayList<String>();
27-
25+
26+
// Using this collection structure to implement the FIFO queue
27+
private List<String> queue = new ArrayList<String>();
28+
2829
private long currentQueueSizeInBytes = 0;
29-
30+
3031
/**
31-
* Add an event to the tail of the FIFO queue subject to there being capacity
32+
* Add an event to the tail of the FIFO queue subject to there being
33+
* capacity
34+
*
3235
* @param event
3336
*/
34-
protected void enqueue(String event){
35-
37+
protected void enqueue(String event) {
38+
3639
long eventSize = event.getBytes().length;
37-
38-
if(queueHasCapacity(eventSize)){
39-
queue.add(event);
40-
currentQueueSizeInBytes += eventSize;
41-
}
42-
else if(dropEventsOnQueueFull){
40+
41+
if (queueHasCapacity(eventSize)) {
42+
queue.add(event);
43+
currentQueueSizeInBytes += eventSize;
44+
} else if (dropEventsOnQueueFull) {
4345
queue.clear();
4446
queue.add(event);
4547
currentQueueSizeInBytes = eventSize;
46-
47-
}
48-
else{
49-
//bummer , queue is full up
50-
48+
49+
} else {
50+
// bummer , queue is full up
51+
5152
}
5253
}
53-
54+
5455
/**
5556
* True if the queue has capacity for adding an event of the given size
57+
*
5658
* @param eventSize
5759
* @return
5860
*/
5961
private boolean queueHasCapacity(long eventSize) {
60-
61-
return (currentQueueSizeInBytes+eventSize) <= maxQueueSize;
62+
63+
return (currentQueueSizeInBytes + eventSize) <= maxQueueSize;
6264
}
6365

6466
/**
6567
* True if there are pending events in the queue
68+
*
6669
* @return
6770
*/
68-
protected boolean queueContainsEvents(){
71+
protected boolean queueContainsEvents() {
6972
return !queue.isEmpty();
7073
}
71-
74+
7275
/**
73-
* Remove an event from the head of the FIFO queue or null if there are no items in the queue
76+
* Remove an event from the head of the FIFO queue or null if there are no
77+
* items in the queue
78+
*
7479
* @return
7580
*/
76-
protected String dequeue(){
77-
78-
if(queueContainsEvents()){
79-
String event = queue.remove(0);
80-
currentQueueSizeInBytes -= event.getBytes().length;
81-
if(currentQueueSizeInBytes < 0){
82-
currentQueueSizeInBytes = 0;
83-
}
84-
return event;
81+
protected String dequeue() {
82+
83+
if (queueContainsEvents()) {
84+
String event = queue.remove(0);
85+
currentQueueSizeInBytes -= event.getBytes().length;
86+
if (currentQueueSizeInBytes < 0) {
87+
currentQueueSizeInBytes = 0;
88+
}
89+
return event;
8590
}
8691
return null;
8792
}
88-
93+
8994
/**
90-
* Set the queue size from the configured property String value.
91-
* If parsing fails , the default of 500KB will be used.
95+
* Set the queue size from the configured property String value. If parsing
96+
* fails , the default of 500KB will be used.
9297
*
93-
* @param rawProperty in format [<integer>|<integer>[KB|MB|GB]]
98+
* @param rawProperty
99+
* in format [<integer>|<integer>[KB|MB|GB]]
94100
*/
95-
public void setMaxQueueSize(String rawProperty) {
96-
101+
public void setMaxQueueSize(String rawProperty) {
102+
97103
int multiplier;
98104
int factor;
99-
100-
if(rawProperty.endsWith("KB")){
105+
106+
if (rawProperty.endsWith("KB")) {
101107
multiplier = KB;
102-
}
103-
else if(rawProperty.endsWith("MB")){
108+
} else if (rawProperty.endsWith("MB")) {
104109
multiplier = MB;
105-
}
106-
else if(rawProperty.endsWith("GB")){
110+
} else if (rawProperty.endsWith("GB")) {
107111
multiplier = GB;
108-
}
109-
else{
112+
} else {
110113
return;
111114
}
112115
try {
113-
factor = Integer.parseInt(rawProperty.substring(0,rawProperty.length()-2));
116+
factor = Integer.parseInt(rawProperty.substring(0,
117+
rawProperty.length() - 2));
114118
} catch (NumberFormatException e) {
115119
return;
116120
}
117-
setMaxQueueSize(factor*multiplier);
118-
121+
setMaxQueueSize(factor * multiplier);
122+
119123
}
120-
124+
121125
public long getMaxQueueSize() {
122126
return maxQueueSize;
123127
}
128+
124129
/**
125130
* Max queue size in bytes
131+
*
126132
* @param maxQueueSize
127133
*/
128134
public void setMaxQueueSize(long maxQueueSize) {
129135
this.maxQueueSize = maxQueueSize;
130136
}
137+
131138
public boolean isDropEventsOnQueueFull() {
132139
return dropEventsOnQueueFull;
133140
}
141+
134142
/**
135143
* If true,queue will get emptied when it fills up to accommodate new data.
144+
*
136145
* @param dropEventsOnQueueFull
137146
*/
138147
public void setDropEventsOnQueueFull(boolean dropEventsOnQueueFull) {
139148
this.dropEventsOnQueueFull = dropEventsOnQueueFull;
140149
}
141-
142-
150+
143151
}

0 commit comments

Comments
 (0)