2929import com .stackify .api .common .collect .SynchronizedEvictingQueue ;
3030import com .stackify .api .common .http .HttpException ;
3131import com .stackify .api .common .util .Preconditions ;
32+ import lombok .NonNull ;
3233
3334/**
3435 * LogCollector
@@ -41,11 +42,18 @@ public class LogCollector {
4142 */
4243 private static final int MAX_BATCH = 100 ;
4344
45+ private static final String DEFAULT_PLATFORM = "java" ;
46+
4447 /**
4548 * The logger (project) name
4649 */
4750 private final String logger ;
4851
52+ /**
53+ * The logger platform (log type)
54+ */
55+ private final String platform ;
56+
4957 /**
5058 * Environment details
5159 */
@@ -60,22 +68,36 @@ public class LogCollector {
6068 * The queue of objects to be transmitted
6169 */
6270 private final Queue <LogMsg > queue = new SynchronizedEvictingQueue <LogMsg >(10000 );
63-
71+
6472 /**
6573 * Constructor
66- * @param logger The logger (project) name
74+ *
75+ * @param platform Logger platform (log type)
76+ * @param logger The logger (project) name
6777 * @param envDetail Environment details
6878 */
69- public LogCollector (final String logger , final EnvironmentDetail envDetail , final AppIdentityService appIdentityService ) {
70- Preconditions . checkNotNull ( logger );
71- Preconditions . checkNotNull ( envDetail );
72- Preconditions . checkNotNull ( appIdentityService );
73-
79+ public LogCollector (@ NonNull final String platform ,
80+ @ NonNull final String logger ,
81+ @ NonNull final EnvironmentDetail envDetail ,
82+ @ NonNull final AppIdentityService appIdentityService ) {
83+ this . platform = platform ;
7484 this .logger = logger ;
7585 this .envDetail = envDetail ;
7686 this .appIdentityService = appIdentityService ;
7787 }
7888
89+ /**
90+ * Constructor
91+ *
92+ * @param logger The logger (project) name
93+ * @param envDetail Environment details
94+ */
95+ public LogCollector (final String logger ,
96+ final EnvironmentDetail envDetail ,
97+ final AppIdentityService appIdentityService ) {
98+ this (DEFAULT_PLATFORM , logger , envDetail , appIdentityService );
99+ }
100+
79101 /**
80102 * Queues logMsg to be sent
81103 * @param logMsg The log message
@@ -112,7 +134,7 @@ public int flush(final LogSender sender) throws IOException, HttpException {
112134 }
113135
114136 // build the log message group
115- LogMsgGroup group = createLogMessageGroup (batch , logger , envDetail , appIdentity );
137+ LogMsgGroup group = createLogMessageGroup (batch , platform , logger , envDetail , appIdentity );
116138
117139 // send the batch to Stackify
118140 int httpStatus = sender .send (group );
@@ -133,32 +155,35 @@ public int flush(final LogSender sender) throws IOException, HttpException {
133155 /**
134156 *
135157 * @param batch - a bunch of messages that should be sent over the wire
158+ * @param platform - platform (log type)
136159 * @param logger - logger (project) name
137160 * @param envDetail - environment details
138161 * @param appIdentity - application identity
139162 * @return LogMessage group object with
140163 */
141- private LogMsgGroup createLogMessageGroup (
142- final List <LogMsg > batch , final String logger , final EnvironmentDetail envDetail , final AppIdentity appIdentity
143- ) {
164+ private LogMsgGroup createLogMessageGroup (final List <LogMsg > batch ,
165+ final String platform ,
166+ final String logger ,
167+ final EnvironmentDetail envDetail ,
168+ final AppIdentity appIdentity ) {
144169 final LogMsgGroup .Builder groupBuilder = LogMsgGroup .newBuilder ();
145170
146171 groupBuilder
147- .platform ("java" )
148- .logger (logger )
149- .serverName (envDetail .getDeviceName ())
150- .env (envDetail .getConfiguredEnvironmentName ())
151- .appName (envDetail .getConfiguredAppName ())
152- .appLoc (envDetail .getAppLocation ());
172+ .platform (platform )
173+ .logger (logger )
174+ .serverName (envDetail .getDeviceName ())
175+ .env (envDetail .getConfiguredEnvironmentName ())
176+ .appName (envDetail .getConfiguredAppName ())
177+ .appLoc (envDetail .getAppLocation ());
153178
154179 if (appIdentity != null ) {
155180 groupBuilder
156- .cdId (appIdentity .getDeviceId ())
157- .cdAppId (appIdentity .getDeviceAppId ())
158- .appNameId (appIdentity .getAppNameId ())
159- .appEnvId (appIdentity .getAppEnvId ())
160- .envId (appIdentity .getEnvId ())
161- .env (appIdentity .getEnv ());
181+ .cdId (appIdentity .getDeviceId ())
182+ .cdAppId (appIdentity .getDeviceAppId ())
183+ .appNameId (appIdentity .getAppNameId ())
184+ .appEnvId (appIdentity .getAppEnvId ())
185+ .envId (appIdentity .getEnvId ())
186+ .env (appIdentity .getEnv ());
162187
163188 if ((appIdentity .getAppName () != null ) && (0 < appIdentity .getAppName ().length ())) {
164189 groupBuilder .appName (appIdentity .getAppName ());
0 commit comments