Difference between revisions of "Function logf()"
Jump to navigation
Jump to search
(Založena nová stránka s textem „{{DISPLAYTITLE:function log()}} Insert a formated record into the socket's event log. Suitable for debugging purposes. <i>nil</i> logf(<u>message</u>) =…“) |
|||
Line 2: | Line 2: | ||
Insert a formated record into the socket's event log. Suitable for debugging purposes. | Insert a formated record into the socket's event log. Suitable for debugging purposes. | ||
− | <i>nil</i> logf(< | + | <i>nil</i> <b>logf</b>(<code>message</code>) |
=== Parameters === | === Parameters === | ||
− | <i>string</i> < | + | <i>string</i> <code>message</code> will be inserted into the event log. Can use tokens described below. The tokens will be replaced by following parameters (variable arguments). |
=== Tokens === | === Tokens === | ||
− | * %d is substituted by following argument as a number | + | * <code>%d</code> is substituted by following argument as a number |
− | * %s is substituted by following argument as a number | + | * <code>%s</code> is substituted by following argument as a number |
− | There is no %b token to display boolean values. To display boolean x as a number, use 'x and 1 or 0' idiom (true as 1, false as 0). | + | There is no <code>%b</code> token to display boolean values. To display boolean x as a number, use 'x and 1 or 0' idiom (true as 1, false as 0). |
=== Return value === | === Return value === | ||
Line 20: | Line 20: | ||
local b = false | local b = false | ||
local c = "Hello"; | local c = "Hello"; | ||
+ | |||
-- displays 'test: 42, 0, Hello.' | -- displays 'test: 42, 0, Hello.' | ||
log("test: %d, %d, %s.", a, b and 1 or 0, c) | log("test: %d, %d, %s.", a, b and 1 or 0, c) |
Revision as of 19:52, 18 April 2017
Insert a formated record into the socket's event log. Suitable for debugging purposes.
nil logf(message
)
Parameters
string message
will be inserted into the event log. Can use tokens described below. The tokens will be replaced by following parameters (variable arguments).
Tokens
%d
is substituted by following argument as a number%s
is substituted by following argument as a number
There is no %b
token to display boolean values. To display boolean x as a number, use 'x and 1 or 0' idiom (true as 1, false as 0).
Return value
nil
Usage
local a = 42 local b = false local c = "Hello"; -- displays 'test: 42, 0, Hello.' log("test: %d, %d, %s.", a, b and 1 or 0, c)
See also
- log() to display unformatted string and system properties