Skip to main content

Formatter

Creates messages from Record objects for use in Handlers.

The format string passed to the constructor may contain any of the following:

Format Description
%(asctime) Current time rendered as %Y-%m-%d %I:%M:%S
%(name) Full name of logger
%(message) Record message
%(level) Record level as name
%(levelno) Record level as number

Properties

fmt

since 0.1.0
</>
Formatter.fmt: string

Determines how the message should be format.

Functions

new

since 0.1.0
</>
Formatter.new(fmtstring) → Formatter

Create a new formatter which uses the given format string.

setFormat

since 0.1.0
</>
Formatter:setFormat(fmtstring) → ()

Sets the message format used by this formatter.

format

since 0.1.0
</>
Formatter:format(recordRecord) → ()

Format the Formatter.fmt string using details from the given Record

Show raw api
{
    "functions": [
        {
            "name": "new",
            "desc": "Create a new formatter which uses the given format string.",
            "params": [
                {
                    "name": "fmt",
                    "desc": "",
                    "lua_type": "string"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Formatter"
                }
            ],
            "function_type": "static",
            "since": "0.1.0",
            "source": {
                "line": 39,
                "path": "Logging/Formatter.lua"
            }
        },
        {
            "name": "setFormat",
            "desc": "Sets the message format used by this formatter.",
            "params": [
                {
                    "name": "fmt",
                    "desc": "",
                    "lua_type": "string"
                }
            ],
            "returns": [],
            "function_type": "method",
            "since": "0.1.0",
            "source": {
                "line": 51,
                "path": "Logging/Formatter.lua"
            }
        },
        {
            "name": "format",
            "desc": "Format the [Formatter.fmt] string using details from the given [Record]",
            "params": [
                {
                    "name": "record",
                    "desc": "",
                    "lua_type": "Record"
                }
            ],
            "returns": [],
            "function_type": "method",
            "since": "0.1.0",
            "source": {
                "line": 61,
                "path": "Logging/Formatter.lua"
            }
        }
    ],
    "properties": [
        {
            "name": "fmt",
            "desc": "Determines how the message should be format.",
            "lua_type": "string",
            "since": "0.1.0",
            "source": {
                "line": 32,
                "path": "Logging/Formatter.lua"
            }
        }
    ],
    "types": [],
    "name": "Formatter",
    "desc": "Creates messages from [Record] objects for use in [Handler]s.\n\nThe format string passed to the constructor may contain any of the following:\n\n| Format       | Description                                  |\n|--------------|----------------------------------------------|\n| `%(asctime)` | Current time rendered as `%Y-%m-%d %I:%M:%S` |\n| `%(name)`    | Full name of logger                          |\n| `%(message)` | Record message                               |\n| `%(level)`   | Record level as name                         |\n| `%(levelno)` | Record level as number                       |",
    "source": {
        "line": 17,
        "path": "Logging/Formatter.lua"
    }
}