Hi Burkhard
Thanks for the tip. After tinkering around with REPL I finally got it working
with
this,
The page logging:
<p data-sly-use.logError="${'logic.js' @ text='One two three'}"
data-sly-unwrap>${logError.logMe}</p>
The logic.js containing the method:
use(function () {
var text = this.text || ' Not Found';
return {
logMe: function() {
log.error(text);
}
};
});
Here with a single parameter:
<p data-sly-use.logError="${'logic.js' @ text='One two three: {}',
parameter1=resource.path}" data-sly-unwrap>${logError.logMe}</p>
use(function () {
var text = this.text || ' Not Found';
var param1 = this.parameter1;
return {
message: 'hello world',
logMe: function() {
log.error(text, param1);
}
};
});
Not quite user-friendly but it gets the job done.
Thanks - Andy
> On Mar 30, 2017, at 12:07 AM, Burkhard Pauli <[email protected]> wrote:
>
> Hi Andy,
>
> The access to the global logger is added via the SlingBindings.
>
> You can get it within the Java Use-API [0] with:
> Logger logger = get(SlingBindings.LOG, Logger.class);
> (But it's more common to define your own logger inside of your Java Use
> Object.)
>
> or in the JavaScript Use-API[1] just with the global variable 'log'.
>
> Cheers,
> Burkhard
>
> [0] https://docs.adobe.com/docs/en/htl/docs/use-api/java.html
> [1] https://docs.adobe.com/docs/en/htl/docs/use-api/javascript.html
>
> On Wed, Mar 29, 2017 at 8:57 PM, Andreas Schaefer Sr. <[email protected]>
> wrote:
>
>> Hi
>>
>> In the HTL documentation I saw that there is a global
>> HTL object log for the SLF4J logger.
>>
>> How would I use that logger?
>>
>> Cheers - Andy
>>
>
>
>
> --
> ––––––––––––––––––––––––––––––––––––––––––
> Burkhard Pauli
> Bötzowstr. 13 | 10407 Berlin
> Fon 030. 648 315 73 | Mobil 0151 407 033 89
> –––––––––––––––––––––––––––––––––––––––––-