Last active
December 15, 2015 06:09
-
-
Save danveloper/5214002 to your computer and use it in GitHub Desktop.
LoggingService.log - Real Time Logging Project
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class LoggingService { | |
/** | |
* These two fields represent the atmosphere "config". | |
*/ | |
static final MAPPING_URI = ApplicationHolder.application.config.grails.atmosphere.mappingUri | |
static atmosphere = [mapping: MAPPING_URI] | |
/** | |
* The {@link LoggingServiceActivator} delegates its messages to this method. | |
* This method, in turn, broadcasts them to the UI via the atmosphere broadcaster. | |
* | |
* @param command | |
* @return | |
*/ | |
def log(LogMessageCommand command) { | |
registerApplicationInstance(command.ipAddress, command.hostname, command.application) | |
addMessageToLogHistory(command) | |
command.message = command.message | |
def message = command as JSON | |
// The "broadcaster" property is conveniently injected into services and controllers | |
// when using the grails-amotphere-plugin | |
broadcaster[MAPPING_URI].broadcast(message.toString()) | |
} | |
... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment