UNPKG

kaffee

Version:

Kaffee is a software project management tool similar to Maven and is written in Coffeescript. Kaffee allows you to compile, test, minify and many other tasks to make building your application simple and fun again.

179 lines (127 loc) 3.77 kB
/* A {@link LogEvent} instance represents a Kaffee log message. @author Fabian M. <mail.fabianm@gmail.com> */ (function() { var LogEvent; LogEvent = (function() { /* Constructs a new {@link LogEvent}. @since 0.3.0 @param manager The {@link EventManager} of this {@link LogEvent}. @param level The level of this {@link LogEvent}. @param message The message of this {@link LogEvent}. @param stack The stacktrace. @param callee The arguments.callee variable to provide more accurate stacktraces. */ function LogEvent(manager, level, message, stack, callee) { var err; this.manager = manager; this.level = level; this.message = message != null ? message : ""; this.stack = stack != null ? stack : ""; if (callee == null) { callee = null; } if (message instanceof Error) { this.message = message.message; } if (message) { this.stack || (this.stack = message.stack); } if (!this.stack) { err = new Error(this.message); err.name = ""; Error.captureStackTrace(err, callee || arguments.callee); this.stack = err.stack; } this.time = Date.now(); } /* Returns the {@link EventManager} of this {@link LogEvent}. @since 0.3.0 @return The {@link EventManager} of this {@link LogEvent}. */ LogEvent.prototype.getEventManager = function() { return this.manager; }; /* Returns the message of this {@link LogEvent}. @since 0.3.0 @return The message of this {@link LogEvent}. */ LogEvent.prototype.getMessage = function() { return this.message; }; /* Sets the message of this {@link LogEvent}. @since 0.3.0 @param message The message to set. */ LogEvent.prototype.setMessage = function(message) { this.message = message; return this; }; /* Returns the level of this {@link LogEvent}. @since 0.3.0 @return The level of this {@link LogEvent}. */ LogEvent.prototype.getLevel = function() { return this.level; }; /* Sets the level of this {@link LogEvent}. @since 0.3.0 @param level The level to set. */ LogEvent.prototype.setLevel = function(level) { this.level = level; return this; }; /* Returns the time in milliseconds of this {@link LogEvent}. @since 0.3.0 @return The time in milliseconds. */ LogEvent.prototype.getTime = function() { return this.time; }; /* Sets the time in milliseconds of this {@link LogEvent}. @since 0.3.0 @param time The time to set. */ LogEvent.prototype.setTime = function(time) { this.time = time; return this.time = time; }; /* Determines if this {@link LogEvent} has a stack or not. @since 0.3.0 @return <code>true</code> if this {@link LogEvent} has a stack, <code>false</code> otherwise. */ LogEvent.prototype.hasStack = function() { return this.stack.length > 0; }; /* Returns the stack of this {@link LogEvent}. @since 0.3.0 @return The stack of this {@link LogEvent}. */ LogEvent.prototype.getStack = function() { return this.stack; }; /* Sets the stack of this {@link LogEvent}. @since 0.3.0 @param stack The stack to set. */ LogEvent.prototype.setStack = function(stack) { this.stack = stack; return this; }; return LogEvent; })(); module.exports = LogEvent; }).call(this);