-
Notifications
You must be signed in to change notification settings - Fork 35
Expand file tree
/
Copy pathLog.java
More file actions
77 lines (67 loc) · 1.72 KB
/
Copy pathLog.java
File metadata and controls
77 lines (67 loc) · 1.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
// -*- mode: java; c-basic-offset: 2; -*-
// Copyright 2009-2011 Google, All Rights reserved
// Copyright 2011-2012 MIT, All rights reserved
// Released under the MIT License https://raw.github.com/mit-cml/app-inventor/master/mitlicense.txt
package com.google.appinventor.client;
import java.util.ArrayList;
import java.util.List;
/**
* Forwards logging calls to loggers.
*
*/
// TODO(user): Use deferred binding to make sure that logging messages
// are compiled out.
public class Log {
private static final List<Logger> loggers = new ArrayList<Logger>();
private Log() {
}
/**
* Adds a logger to send logging messages to.
*/
public static void logTo(Logger logger) {
loggers.add(logger);
}
/**
* Logs an informational message.
*/
public static void info(String message) {
for (Logger l : loggers) {
l.info(message);
}
}
/**
* Logs a warning message.
*/
public static void warn(String message) {
for (Logger l : loggers) {
l.warn(message);
}
}
/**
* Logs a debugging message.
*/
public static void debug(String message) {
for (Logger l : loggers) {
l.debug(message);
}
}
/**
* Logs an error and the stack trace of the associated exception.
*
* @param message error message to log
* @param exception exception to print stack trace for
*/
public static void error(String message, Throwable exception) {
for (Logger l : loggers) {
l.error(message, exception);
}
}
/**
* Returns the result of the toString method on the object.
*/
// TODO(user): Replace this with an empty method using deferred binding
// for production code.
public static String toLogString(Object o) {
return o.toString();
}
}