Skip to content

Instantly share code, notes, and snippets.

@danveloper
Last active December 15, 2015 06:09
Show Gist options
  • Save danveloper/5214002 to your computer and use it in GitHub Desktop.
Save danveloper/5214002 to your computer and use it in GitHub Desktop.
LoggingService.log - Real Time Logging Project
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