GlueGen: src/java/com/jogamp/common/util/TSPrinter.java Source File

GlueGen v2.6.0 GlueGen, Native Binding Generator for Java™ (public API).

TSPrinter.java
Go to the documentation of this file.
1/**
2 * Author: Sven Gothel <sgothel@jausoft.com>
3 * Copyright (c) 2022-2023 Gothel Software e.K.
4 * Copyright (c) 2022-2023 JogAmp Community.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining
7 * a copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sublicense, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be
15 * included in all copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 */
25package com.jogamp.common.util;
26
27import java.io.PrintStream;
28
29import com.jogamp.common.os.Clock;
30
31/** A simple millisecond timestamp prepending `print*()` wrapper for a {@link PrintStream}. */
32 public class TSPrinter {
33 private static TSPrinter err;
34 private static TSPrinter out;
35
36 public static synchronized TSPrinter stderr() {
37 if( null == err ) {
38 err = new TSPrinter(System.err);
39 }
40 return err;
41 }
42 public static synchronized TSPrinter stdout() {
43 if( null == out ) {
44 out = new TSPrinter(System.out);
45 }
46 return out;
47 }
48
49 private final PrintStream parent;
50
51 public TSPrinter(final PrintStream parent) {
52 this.parent = parent;
53 }
54
55 public static void printf(final PrintStream out, final long millis, final String format, final Object ... args) {
56 out.printf("[%,9d] ", millis);
57 out.printf(format, args);
58 }
59 public static void printf(final PrintStream out, final String format, final Object ... args) {
60 printf(out, Clock.currentMillis(), format, args);
61 }
62 public void printf(final long millis, final String format, final Object ... args) {
63 printf(parent, millis, format, args);
64 }
65 public void printf(final String format, final Object ... args) {
66 printf(parent, Clock.currentMillis(), format, args);
67 }
68
69 public static void print(final PrintStream out, final long millis, final String msg) {
70 out.printf("[%,9d] %s", millis, msg);
71 }
72 public static void print(final PrintStream out, final String msg) {
73 print(out, Clock.currentMillis(), msg);
74 }
75 public void print(final long millis, final String msg) {
76 print(parent, millis, msg);
77 }
78 public void print(final String msg) {
79 print(parent, Clock.currentMillis(), msg);
80 }
81
82 public static void println(final PrintStream out, final long millis, final String msg) {
83 out.printf("[%,9d] %s%n", millis, msg);
84 }
85 public static void println(final PrintStream out, final String msg) {
86 println(out, Clock.currentMillis(), msg);
87 }
88 public void println(final long millis, final String msg) {
89 println(parent, millis, msg);
90 }
91 public void println(final String msg) {
92 println(parent, Clock.currentMillis(), msg);
93 }
94
95}
com.jogamp.common.os.Clock
Definition: Clock.java:29
com.jogamp.common.os.Clock.currentMillis
static native long currentMillis()
Returns current monotonic milliseconds since start of this application.
com.jogamp.common.util.TSPrinter
A simple millisecond timestamp prepending print*() wrapper for a PrintStream.
Definition: TSPrinter.java:32
com.jogamp.common.util.TSPrinter.print
static void print(final PrintStream out, final long millis, final String msg)
Definition: TSPrinter.java:69
com.jogamp.common.util.TSPrinter.stderr
static synchronized TSPrinter stderr()
Definition: TSPrinter.java:36
com.jogamp.common.util.TSPrinter.println
void println(final String msg)
Definition: TSPrinter.java:91
com.jogamp.common.util.TSPrinter.print
void print(final String msg)
Definition: TSPrinter.java:78
com.jogamp.common.util.TSPrinter.println
static void println(final PrintStream out, final long millis, final String msg)
Definition: TSPrinter.java:82
com.jogamp.common.util.TSPrinter.TSPrinter
TSPrinter(final PrintStream parent)
Definition: TSPrinter.java:51
com.jogamp.common.util.TSPrinter.print
void print(final long millis, final String msg)
Definition: TSPrinter.java:75
com.jogamp.common.util.TSPrinter.stdout
static synchronized TSPrinter stdout()
Definition: TSPrinter.java:42
com.jogamp.common.util.TSPrinter.printf
static void printf(final PrintStream out, final String format, final Object ... args)
Definition: TSPrinter.java:59
com.jogamp.common.util.TSPrinter.printf
void printf(final long millis, final String format, final Object ... args)
Definition: TSPrinter.java:62
com.jogamp.common.util.TSPrinter.printf
void printf(final String format, final Object ... args)
Definition: TSPrinter.java:65
com.jogamp.common.util.TSPrinter.print
static void print(final PrintStream out, final String msg)
Definition: TSPrinter.java:72
com.jogamp.common.util.TSPrinter.println
static void println(final PrintStream out, final String msg)
Definition: TSPrinter.java:85
com.jogamp.common.util.TSPrinter.printf
static void printf(final PrintStream out, final long millis, final String format, final Object ... args)
Definition: TSPrinter.java:55
com.jogamp.common.util.TSPrinter.println
void println(final long millis, final String msg)
Definition: TSPrinter.java:88