Catching and customizing Apexpages Messages in Apex

As we know, apex:pageMessages tag can be used to display all messages that were generated for all components on the current page, presented using the Salesforce styling, as the following source code we use:

Controller Class(CommunitiesSelfRegController)


Visualforce Page(CommunitiesSelfReg)


But how do we customizing the styling of messages, if those were generated from Salesforce Standard components, such as making user login with Site class?
Actually we can get that from Apexpages class, as the following source code :

Controller Class(LoginController)

Visualforce Page



Enjoy it!