---++!! !commonlib.log %TOC{title="Contents:"}% %STARTINCLUDE% ---++ advanced log function | *Title* | advanced log function | | *Author(s)* | LiXizhi | | *Date* | | | *File* | script/ide/log.lua | ---+++ Description %T% __Sample Code__ <verbatim> NPL.load("(gl)script/ide/log.lua"); commonlib.log("hello %s \n", "paraengine") commonlib.log({"anything"}) local fromPos = commonlib.log.GetLogPos() log(fromPos.." babababa...\n"); local text = commonlib.log.GetLog(fromPos, nil) log(tostring(text).." is retrieved\n") </verbatim> ---+++ Member Functions ---++++ !commonlib.log.log_long --------------------------------------------- log file class --------------------------------------------- logging with no limit to size and with formatting. support formatting: commonlib.log("hello %s \n", "paraengine") commonlib.log = setmetatable({}, {__call = function(self, input, ...) if(type(input) == "string") then local args = {...}; if(#args == 0) then commonlib.log.log_long(input) else commonlib.log.log_long(string.format(input, ...)); end elseif(type(input) == "table") then commonlib.log.log_long(commonlib.serialize(input)); else commonlib.log.log_long(tostring(input)); end end}); it support logging string longer than 1024 bytes by deviding input into multiple sections. By default: log(string) longer than 1024 is cut. Use this function if u want to log something really long * _param_ __str__ : the string to log. * _param_ __maxLength__ : if nil it is unlimited. __syntax__ <verbatim>function commonlib.log.log_long(str, maxLength)</verbatim> __parameters__ | *str* | the string to log. | | *maxLength* | | ---++++ !commonlib.log.GetLogPos get the current log file position. it is equavalent to the log file size in bytes. one can later get log text between two Log positions. __syntax__ <verbatim>function commonlib.log.GetLogPos()</verbatim> ---++++ !commonlib.log.GetLog get log text between two Log positions. * _param_ __fromPos__ : position in bytes. if nil, it defaults to 0 * _param_ __nCount__ : count in bytes. if nil, it defaults to end of log file. * _return_ __string__ : returned. __syntax__ <verbatim>function commonlib.log.GetLog(fromPos, nCount)</verbatim> __parameters__ | *fromPos* | position in bytes. if nil, it defaults to 0 | | *nCount* | | | *return* | returned. | %STOPINCLUDE%
E
dit
|
A
ttach
|
P
rint version
|
H
istory
: r1
|
B
acklinks
|
V
iew topic
|
Ra
w
edit
|
M
ore topic actions
Topic revision: r1 - 2008-02-29
-
LiXizhi
Home
Site map
CCWeb web
HaqiTeen web
Main web
ParaEngine web
TWiki web
Main Web
Users
Groups
Index
Search
Changes
Notifications
RSS Feed
Statistics
导航页WebTopMenu
Preferences
开发指南
Getting Started
ParacraftSDK
NPL
MCML
NPL Reference Manual
美术Mod
Account
Log In
English
简体中文
簡體中文
E
dit
A
ttach
Copyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki?
Send feedback