Skip to main content

FuncHandler

An implementation of Handler which wraps a subject function and calls it when the handler is emit a Record. Logger:addHandler automatically creates one if you pass it a function.

Properties

func

since 0.1.0
</>
FuncHandler.func: (Record) → ()

The subject function to be called with Record as they are emit.

Functions

new

since 0.1.0
</>
FuncHandler.new(func(Record) → ()) → FuncHandler

Creates a new FuncHandler with the given subject function.

emit

since 0.1.0
</>
FuncHandler:emit(recordRecord) → ()

Calls the subject function with the given record.

Show raw api
{
    "functions": [
        {
            "name": "new",
            "desc": "Creates a new FuncHandler with the given subject function.",
            "params": [
                {
                    "name": "func",
                    "desc": "",
                    "lua_type": "(Record) -> ()"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "FuncHandler"
                }
            ],
            "function_type": "static",
            "since": "0.1.0",
            "source": {
                "line": 25,
                "path": "Logging/Handler/FuncHandler.lua"
            }
        },
        {
            "name": "emit",
            "desc": "Calls the subject function with the given record.",
            "params": [
                {
                    "name": "record",
                    "desc": "",
                    "lua_type": "Record"
                }
            ],
            "returns": [],
            "function_type": "method",
            "since": "0.1.0",
            "source": {
                "line": 41,
                "path": "Logging/Handler/FuncHandler.lua"
            }
        }
    ],
    "properties": [
        {
            "name": "func",
            "desc": "The subject function to be called with [Record] as they are emit.",
            "lua_type": "(Record) -> ()",
            "since": "0.1.0",
            "source": {
                "line": 18,
                "path": "Logging/Handler/FuncHandler.lua"
            }
        }
    ],
    "types": [],
    "name": "FuncHandler",
    "desc": "An implementation of [Handler] which wraps a subject function and calls it when\nthe handler is emit a [Record]. [Logger:addHandler] automatically creates one\nif you pass it a function.",
    "source": {
        "line": 7,
        "path": "Logging/Handler/FuncHandler.lua"
    }
}