Skip to content

lib-log 库参考 ​

原文: https://finproducts.atlassian.net/wiki/spaces/JIDD3/pages/34793390342/FIN+5.3.1+lib-log 中文整理基于 FIN 5.3.1

导读: 向日志子系统提交日志记录:

以下为 API 参考,保留英文以便对照源码;目录已列出(英文标题便于检索);概述已尽量中译。


目录(导读) ​

  • lib
  • meta
  • funcs
  • def
  • log(level, tags, msg, err: null)
  • logDebug(tags, msg, err: null)
  • logErr(tags, msg, err: null)
  • logInfo(tags, msg, err: null)
  • logRead(span: Span.today(), filter: null, opts: null)
  • logWarn(tags, msg, err: null)

概述(中译) ​

记录引擎


API 正文(英文) ​

funcs ​

logSubmit a log record to the logging subsystem
logDebugLog at the "debug" level - see log()
logErrLog at the "err" level - see log()
logInfoLog at the "info" level - see log()
logReadRead log records for given span
logWarnLog at the "warn" level - see log()


def ​

func:log ​

log(level, tags, msg, err: null) ​

Submit a log record to the logging subsystem:

  • level: must be "err", "warn", "info", "debug" (same as LogLevel).
  • tags: Dict for LogMod.create or Str which is assumed to be {name:<str>}
  • msg: short single line summary of message to log
  • err: exception from catch block that includes errTrace tag

Best practice is to pass a SysMod/Ext name for the tags parameter, in which case the SysMod/Ext log is used. This allows you to manage the logging level via the Debug|Log view. If you pass an unknown library name or a Dict for tags then a temporary log instance is created, which cannot have its logging level configured.

Also see logErr(), logWarn(), logInfo(), and logDebug() .

Examples:

// use the host system module logger and current log level
log("info", "host", "something happened")

// convenience for previous
logInfo("host", "something happened")

// use the point extension logger and current log level
logErr("point", "something happened")

// log to my custom log - log level not configurable
logWarn("myOwnLog", "something happened")

// log to custom log name with additional tags
logWarn({name:"myOwnLog", user:"alice"}, "something happened")

/// example of logging with a stack trace
try throw "bad!" catch (e) logErr("task", "Failed", e)

meta ​

deffunc:log
isfunc
liblib:log
namelog

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function


def ​

func:logDebug ​

logDebug(tags, msg, err: null) ​

Log at the "debug" level - see log().


meta ​

deffunc:logDebug
isfunc
liblib:log
namelogDebug

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function


def ​

func:logErr ​

logErr(tags, msg, err: null) ​

Log at the "err" level - see log().


meta ​

deffunc:logErr
isfunc
liblib:log
namelogErr

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function


def ​

func:logInfo ​

logInfo(tags, msg, err: null) ​

Log at the "info" level - see log().


meta ​

deffunc:logInfo
isfunc
liblib:log
namelogInfo

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function


def ​

func:logRead ​

logRead(span: Span.today(), filter: null, opts: null) ​

Read log records for given span. A non-null filter will be applied to the log records. Opts:

  • limit: max number of recs to return (default 10,000) NOTE: log reads for today cannot increase the limit past what is configured in Settings|Log for bufMax.

meta ​

deffunc:logRead
isfunc
liblib:log
namelogRead
su✓

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function


def ​

func:logWarn ​

logWarn(tags, msg, err: null) ​

Log at the "warn" level - see log().


meta ​

deffunc:logWarn
isfunc
liblib:log
namelogWarn

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function