MCPcopy Create free account
hub / github.com/codenameone/CodenameOne / sendLogImpl

Method sendLogImpl

CodenameOne/src/com/codename1/io/Log.java:195–233  ·  view source on GitHub ↗
(boolean sync)

Source from the content-addressed store, hash-verified

193
194 /// Sends the current log to the cloud regardless of the reporting level
195 private static void sendLogImpl(boolean sync) {
196 try {
197 // this can cause a crash
198 if (!Display.isInitialized()) {
199 return;
200 }
201 if (!instance.logDirty) {
202 return;
203 }
204 instance.logDirty = false;
205 String devId = getUniqueDeviceKey();
206 if (devId == null) {
207 if (Display.getInstance().isSimulator()) {
208 Dialog.show("Send Log Error", "Device Not Registered: Sending a log from an unregistered device is impossible", "OK", null);
209 } else {
210 Log.p("Device Not Registered: Sending a log from an unregistered device is impossible");
211 }
212 return;
213 }
214 ConnectionRequest r = new ConnectionRequest();
215 r.setPost(false);
216 MultipartRequest m = new MultipartRequest();
217 m.setUrl("https://crashreport.codenameone.com/CrashReporterEmail/sendCrashReport");
218 byte[] read = Util.readInputStream(Storage.getInstance().createInputStream("CN1Log__$"));
219 m.addArgument("i", devId);
220 m.addArgument("u", Display.getInstance().getProperty("built_by_user", ""));
221 m.addArgument("p", Display.getInstance().getProperty("package_name", ""));
222 m.addArgument("v", Display.getInstance().getProperty("AppVersion", "0.1"));
223 m.addData("log", read, "text/plain");
224 m.setFailSilently(true);
225 if (sync) {
226 NetworkManager.getInstance().addToQueueAndWait(m);
227 } else {
228 NetworkManager.getInstance().addToQueue(m);
229 }
230 } catch (Throwable ex) {
231 ex.printStackTrace();
232 }
233 }
234
235 /// Installs a log subclass that can replace the logging destination/behavior
236 ///

Callers 2

sendLogMethod · 0.95
sendLogAsyncMethod · 0.95

Calls 15

isInitializedMethod · 0.95
getUniqueDeviceKeyMethod · 0.95
getInstanceMethod · 0.95
showMethod · 0.95
pMethod · 0.95
setPostMethod · 0.95
readInputStreamMethod · 0.95
getInstanceMethod · 0.95
addArgumentMethod · 0.95
addDataMethod · 0.95
getInstanceMethod · 0.95
createInputStreamMethod · 0.80

Tested by

no test coverage detected