2 * Copyright (c) 2011-2014, JANET(UK)
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
16 * 3. Neither the name of JANET(UK) nor the names of its contributors
17 * may be used to endorse or promote products derived from this software
18 * without specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 public MoonshotLogger get_logger(string name) {
35 return new MoonshotLogger(name);
40 /** Logger class that wraps the Log4Vala logger */
41 public class MoonshotLogger : Object {
42 static bool logger_is_initialized = false;
44 private Log4Vala.Logger logger;
46 public MoonshotLogger(string name) {
47 if (!logger_is_initialized) {
48 //!! TODO: Don't hard-code the pathname.
49 Log4Vala.init("/home/dbreslau/log4vala.conf");
50 logger_is_initialized = true;
53 logger = Log4Vala.Logger.get_logger(name);
57 * Log a trace message.
58 * @param message log message
59 * @param e optional Error to be logged
61 public void trace(string message, Error? e = null) {
62 logger.trace(message, e);
67 * Log a debug message.
68 * @param message log message
69 * @param e optional Error to be logged
71 public void debug(string message, Error? e = null) {
72 logger.debug(message, e);
77 * Log an info message.
78 * @param e optional Error to be logged
80 public void info(string message, Error? e = null) {
81 logger.info(message, e);
85 * Log a warning message.
86 * @param message log message
87 * @param e optional Error to be logged
89 public void warn(string message, Error? e = null) {
90 logger.warn(message, e);
94 * Log an error message.
95 * @param message log message
96 * @param e optional Error to be logged
98 public void error(string message, Error? e = null) {
99 logger.error(message, e);
103 * Log a fatal message.
104 * @param message log message
105 * @param e optional Error to be logged
107 public void fatal(string message, Error? e = null) {
108 logger.fatal(message, e);
116 /** Logger that currently does nothing, but may eventually write to stdout or a file */
117 public class MoonshotLogger : Object {
119 internal MoonshotLogger(string name) {
123 * Log a trace message.
124 * @param message log message
125 * @param e optional Error to be logged
127 public void trace(string message, Error? e = null) {
132 * Log a debug message.
133 * @param message log message
134 * @param e optional Error to be logged
136 public void debug(string message, Error? e = null) {
141 * Log an info message.
142 * @param e optional Error to be logged
144 public void info(string message, Error? e = null) {
148 * Log a warning message.
149 * @param message log message
150 * @param e optional Error to be logged
152 public void warn(string message, Error? e = null) {
156 * Log an error message.
157 * @param message log message
158 * @param e optional Error to be logged
160 public void error(string message, Error? e = null) {
164 * Log a fatal message.
165 * @param message log message
166 * @param e optional Error to be logged
168 public void fatal(string message, Error? e = null) {