Reputation: 13342
I'v followed this tutorial
to make Scala Plaframework application work with depending module that has 'println' message in it.
So, myApp depends on myModule, in myMyModule' controller I have:
object MyLogger {
def log(message: String) {
Console.println("something" + message)
}
}
In myApp I have:
object Application extends Controller {
def index = Action {
MyLogger.log("Here's my log message");
Ok(views.html.index("Your new application is ready."))
}
}
I go to localhost:9000, and I'm expecting 'Here's my log message' to be in my output, but there is no any, except:
[info] play - Listening for HTTP on port 9000...
(Server started, use Ctrl+D to stop and go back to the console...)
I' have checked:
--
After some investigation I found that until I delete dependency to myDev, this message 'this is an info' in MyApp index controller was not showed as well. And then, when I delete that dependency, the application stars reacting to my changes again:
def index = Action {
play.api.Logger.info("this is an info")
Ok(views.html.index("Your new application is ready!"))
}
So, maybe I defined my module using wrong way. Should I change the structure of the myModule? or it is possible to leave it like a default project structure? I will check it later. I guess the reason is with 'routes' file wich I leave in my MyModule.
Upvotes: 1
Views: 3332
Reputation: 13342
The reason why I had this problem, is because myModule was an application, but not a module. I had to:
delete 'routes' file
clean up 'application.conf' file
delete 'views' folder
Then I can call this a module, but not application.
I guess it woud be better If play has something like this: play newModule. Maybe it has?
(So, I just missed this part about 'routes', that actually was described in the tutorial above. Too lazy to read.. :(. Play framework 1.x works similar to that, regarding the modules. )
Upvotes: 0
Reputation: 55798
Why won't you use play.api.Logger ?
It allows you to log to the different levels - depending on your application.conf
and app mode settings:
def index = Action {
play.api.Logger.info("this is an info")
play.api.Logger.debug("and debug is also possible")
play.api.Logger.error("...and error")
play.api.Logger.warn("or even warn")
Ok(views.html.index("Your new application is ready."))
}
dev
mode displays all levels by default and life
will avoid displaying the debug
Upvotes: 2