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

Method print

CodenameOne/src/com/codename1/io/Log.java:442–480  ·  view source on GitHub ↗
(String text, int level)

Source from the content-addressed store, hash-verified

440 ///
441 /// - `level`: one of DEBUG, INFO, WARNING, ERROR
442 protected void print(String text, int level) {
443 if (!initialized) {
444 initialized = true;
445 try {
446 InputStream is = null; //NOPMD CloseResource
447 try {
448 is = Display.getInstance().getResourceAsStream(getClass(), "/cn1-version-numbers");
449 if (is != null) {
450 print("Codename One revisions: " + Util.readToString(is), INFO);
451 }
452 } finally {
453 Util.cleanup(is);
454 }
455 } catch (IOException err) {
456 // shouldn't happen...
457 err.printStackTrace();
458 }
459 }
460 if (this.level > level) {
461 return;
462 }
463 logDirty = true;
464 text = getThreadAndTimeStamp() + " - " + text;
465 CodenameOneImplementation impl = Util.getImplementation();
466 if (impl != null) {
467 impl.systemOut(text);
468 } else {
469 System.out.println(text);
470 }
471 try {
472 synchronized (this) {
473 Writer w = getWriter(); //NOPMD CloseResource - shared writer managed by Log
474 w.write(text + "\n");
475 w.flush();
476 }
477 } catch (Throwable err) {
478 err.printStackTrace();
479 }
480 }
481
482 /// Default method for creating the output writer into which we write, this method
483 /// creates a simple log file using the file connector

Callers 1

logThrowableMethod · 0.95

Calls 13

getInstanceMethod · 0.95
readToStringMethod · 0.95
cleanupMethod · 0.95
getThreadAndTimeStampMethod · 0.95
getImplementationMethod · 0.95
systemOutMethod · 0.95
getWriterMethod · 0.95
writeMethod · 0.95
flushMethod · 0.95
printlnMethod · 0.65
getResourceAsStreamMethod · 0.45
getClassMethod · 0.45

Tested by

no test coverage detected