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);
41 /** Logger class that wraps the Log4Vala logger */
42 public class MoonshotLogger : Object {
43 static bool logger_is_initialized = false;
45 private Log4Vala.Logger logger;
47 public MoonshotLogger(string name) {
48 if (!logger_is_initialized) {
49 //!! TODO: Don't hard-code the pathname.
50 Log4Vala.init("/home/dbreslau/log4vala.conf");
51 logger_is_initialized = true;
54 logger = Log4Vala.Logger.get_logger(name);
58 * Log a trace message.
59 * @param message log message
60 * @param e optional Error to be logged
62 public void trace(string message, Error? e = null) {
63 logger.trace(message, e);
68 * Log a debug message.
69 * @param message log message
70 * @param e optional Error to be logged
72 public void debug(string message, Error? e = null) {
73 logger.debug(message, e);
78 * Log an info message.
79 * @param e optional Error to be logged
81 public void info(string message, Error? e = null) {
82 logger.info(message, e);
86 * Log a warning message.
87 * @param message log message
88 * @param e optional Error to be logged
90 public void warn(string message, Error? e = null) {
91 logger.warn(message, e);
95 * Log an error message.
96 * @param message log message
97 * @param e optional Error to be logged
99 public void error(string message, Error? e = null) {
100 logger.error(message, e);
104 * Log a fatal message.
105 * @param message log message
106 * @param e optional Error to be logged
108 public void fatal(string message, Error? e = null) {
109 logger.fatal(message, e);
116 /** Logger that currently does nothing, but may eventually write to stdout or a file if enabled */
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) {