-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
276 additions
and
206 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
doc/code_snippets/snippets/config/instances.enabled/audit_log/myapp.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
-- myapp.lua -- | ||
local audit = require('audit') | ||
|
||
-- Log message string | ||
audit.log('Hello, Alice!') | ||
-- Log format string and arguments | ||
audit.log('Hello, %s!', 'Bob') | ||
-- Log table with audit log field values | ||
audit.log({type = 'custom_hello', description = 'Hello, World!'}) | ||
audit.log({type = 'custom_farewell', user = 'eve', module = 'custom', description = 'Farewell, Eve!'}) | ||
-- Create a new log module | ||
local my_audit = audit.new({type = 'custom_hello', module = 'my_module'}) | ||
my_audit:log('Hello, Alice!') | ||
my_audit:log({tag = 'admin', description = 'Hello, Bob!'}) | ||
-- Log 'Hello!' message with the VERBOSE severity level | ||
audit.log({severity = 'VERBOSE', description = 'Hello!'}) | ||
|
||
-- Log 'Hello!' message with a shortcut helper function | ||
audit.verbose('Hello!') | ||
|
||
-- Like audit.log(), a shortcut helper function accepts a table of options | ||
audit.verbose({description = 'Hello!'}) | ||
|
||
-- Severity levels are available for custom loggers | ||
local my_logger = audit.new({module = 'my_module'}) | ||
my_logger:log({severity = 'ALARM', description = 'Alarm'}) | ||
my_logger:alarm('Alarm') | ||
|
||
-- Overwrite session_type and remote fields | ||
audit.log({type = 'custom_hello', description = 'Hello!', | ||
session_type = 'my_session', remote = 'my_remote'}) |
Oops, something went wrong.