Class Logs
- java.lang.Object
-
- com.biomatters.geneious.publicapi.utilities.Logs
-
public class Logs extends java.lang.Object
This is a convenience class for logging that is easier to use, but isn't as flexible or powerful asjava.util.logging
. Advantages of using ajava.util.logging.Logger
over using Logs:1.) The minimum severity of a log statement for it to be logged can be adjusted without changing the code and recompiling, i.e. it can even be adjusted in the distribution version.
2.) The logging level can be adjusted on a per-package (and even per-class) basis, so e.g. developer #1 can get all logs for Collaboration but nothing else on stdout, while developer #2 gets his logs printed to a file and only sees Collaboration logs if they are severe.
Advantages of Logs overjava.util.logging.Logger
:1) You don't have to put private final Logger logger = Logger.getLogger(getClass().getName()) at the top of every class you want to put a log line in.
2) Logs will automatically be recorded and appear in the Geneious Crash System (Talkback)
- Since:
- API 4.202220 (Geneious 2022.2.0)
-
-
Field Summary
Fields Modifier and Type Field Description static java.util.logging.Logger
SHARED
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static long
duration(long start, long logIfDurationGreaterThan, java.lang.String message)
Best used in conjunction withstart()
.static void
fine(java.lang.String message)
Logs a message atLevel.FINE
static void
fine(java.lang.String format, java.lang.Object... arguments)
Logs the String formatted withString.format(String, Object...)
toLevel.FINE
Logs.static void
info(java.lang.String message)
Logs a message to theLevel.INFO
log.static void
info(java.lang.String format, java.lang.Object... arguments)
Logs the String formatted withString.format(String, Object...)
toLevel.INFO
Logs.static void
infoButNotToStandardOut(java.lang.String message)
Logs a message to theLevel.INFO
log without attempting to print to standard out.static void
log(java.lang.String message, java.util.logging.Level level)
Adds a message to the history of the specified level.static void
severe(java.lang.String message)
Logs a message about something that should never happen under normal Geneious usage, and which has caused an irrecoverable crash.static void
severe(java.lang.String format, java.lang.Object... arguments)
Logs a message about something that should never happen under normal Geneious usage, and which has caused an irrecoverable crash.static long
start()
Best used in conjunction withduration(long, long, String)
.static void
warning(java.lang.String message)
Logs a message about something that shouldn't happen under normal Geneious usage, but Geneious was able to recover without crashing (e.g.static void
warning(java.lang.String format, java.lang.Object... arguments)
Logs a message about something that shouldn't happen under normal Geneious usage, but Geneious was able to recover without crashing (e.g.
-
-
-
Method Detail
-
fine
public static void fine(java.lang.String format, java.lang.Object... arguments)
Logs the String formatted withString.format(String, Object...)
toLevel.FINE
Logs. Note that logging to fine will not print the message to console by default.- Parameters:
format
- The format stringarguments
- The arguments referenced by the format specifiers in the format string.- Since:
- API 4.202220 (Geneious 2022.2.0)
- See Also:
String.format(String, Object...)
-
fine
public static void fine(java.lang.String message)
Logs a message atLevel.FINE
- Parameters:
message
- The message to log- Since:
- API 4.202220 (Geneious 2022.2.0)
-
info
public static void info(java.lang.String format, java.lang.Object... arguments)
Logs the String formatted withString.format(String, Object...)
toLevel.INFO
Logs.- Parameters:
format
- The format stringarguments
- The arguments referenced by the format specifiers in the format string.- Since:
- API 4.202220 (Geneious 2022.2.0)
- See Also:
String.format(String, Object...)
-
info
public static void info(java.lang.String message)
Logs a message to theLevel.INFO
log. This should be used to log messages which may be helpful when debugging but are not necessary in production builds.- Parameters:
message
- The message to log- Since:
- API 4.202220 (Geneious 2022.2.0)
-
infoButNotToStandardOut
public static void infoButNotToStandardOut(java.lang.String message)
Logs a message to theLevel.INFO
log without attempting to print to standard out. This should be used to log messages which may be helpful when debugging but are not necessary in production builds.- Parameters:
message
- The message to log- Since:
- API 4.202220 (Geneious 2022.2.0)
-
warning
public static void warning(java.lang.String format, java.lang.Object... arguments)
Logs a message about something that shouldn't happen under normal Geneious usage, but Geneious was able to recover without crashing (e.g. failure to load documents, failure to save a document, data that looks corrupt, user continuing to use Geneious with options they've been warned might cause Geneious to hang etc.). These messages will be printed during normal Command Line runs of Geneious.Logs the String formatted with
String.format(String, Object...)
toLevel.WARNING
Logs. Note that logging to warning will print the message to standard out by default.- Parameters:
format
- The format stringarguments
- The arguments referenced by the format specifiers in the format string.- Since:
- API 4.202220 (Geneious 2022.2.0)
- See Also:
String.format(String, Object...)
-
warning
public static void warning(java.lang.String message)
Logs a message about something that shouldn't happen under normal Geneious usage, but Geneious was able to recover without crashing (e.g. failure to load documents, failure to save a document, data that looks corrupt, user continuing to use Geneious with options they've been warned might cause Geneious to hang etc.). These messages will be printed during normal Command Line runs of Geneious.- Parameters:
message
- The message to log- Since:
- API 4.202220 (Geneious 2022.2.0)
-
severe
public static void severe(java.lang.String format, java.lang.Object... arguments)
Logs a message about something that should never happen under normal Geneious usage, and which has caused an irrecoverable crash.Logs the String formatted with
String.format(String, Object...)
toLevel.SEVERE
Logs. Note that logging to severe will print the message to standard out by default.- Parameters:
format
- The format stringarguments
- The arguments referenced by the format specifiers in the format string.- Since:
- API 4.202220 (Geneious 2022.2.0)
- See Also:
String.format(String, Object...)
-
severe
public static void severe(java.lang.String message)
Logs a message about something that should never happen under normal Geneious usage, and which has caused an irrecoverable crash.- Parameters:
message
- The message to log- Since:
- API 4.202220 (Geneious 2022.2.0)
-
log
public static void log(java.lang.String message, java.util.logging.Level level)
Adds a message to the history of the specified level. Messages will not be printed to standard out at any level.- Parameters:
message
- The message to loglevel
- The Log Level to log the message at- Since:
- API 4.202220 (Geneious 2022.2.0)
-
duration
public static long duration(long start, long logIfDurationGreaterThan, java.lang.String message)
Best used in conjunction withstart()
. This method will log a message only if the time sincestart()
was called is more thanlogIfDurationGreaterThan
milliseconds.For example:
long start = Logs.start(); // ...Do something... Logs.duration(start, 100, "Do Something took longer than 100ms");
- Parameters:
start
- time operation started is returned bystart()
logIfDurationGreaterThan
- in millisecondsmessage
- a message to be displayed- Returns:
- the duration in milliseconds
- Since:
- API 4.202220 (Geneious 2022.2.0)
-
start
public static long start()
Best used in conjunction withduration(long, long, String)
. This returns the current nano time, for use with theduration
method.For example:
long start = Logs.start(); // ...Do something... Logs.duration(start, 100, "Do Something took longer than 100ms");
- Returns:
- The current nano time
- Since:
- API 4.202220 (Geneious 2022.2.0)
- See Also:
duration(long, long, String)
-
-