Module logi_location

The location where log message issued.

Copyright © 2014-2016 Takeru Ohta <phjgt308@gmail.com>

Description

The location where log message issued

EXAMPLE

  > Location = logi_location:new(lists, filter, 10).
  > logi_location:to_map(Location).
  #{application => stdlib,
    function => filter,
    line => 10,
    module => lists,
    process => <0.91.0>}
  
guess_location/0 returns the current location.
  > Location = logi_location:guess_location(). % If logi_transform is not used, a warning will be emitted.
  =WARNING REPORT==== 19-Oct-2015::14:02:26 ===
     pid: <0.91.0>
     module: erl_eval
     function: do_apply
     line: 673
     msg: "A deprecated function 'logi_location:guess_location/0' is called. Please use the {parse_transform, logi_transform} compiler option."
 
  > logi_location:to_map(Location).
  #{application => stdlib,
    function => do_apply,
    line => 673,
    module => erl_eval,
    process => <0.91.0>}
  

Data Types

application()

application() = atom()

An application name

line()

line() = pos_integer() | 0

A line number

0 means "Unknown Line"

location()

abstract datatype: location()

A log message issued location

map_form()

map_form() = #{process => pid(), application => application(), module => module(), function => atom(), line => line()}

The map representation of a location

Function Index

from_map/1Creates a new location from Map
get_application/1Gets the application of Location
get_function/1Gets the function of Location
get_line/1Gets the line of Location
get_module/1Gets the module of Location
get_process/1Gets the PID of Location
guess_application/1Guesses the application to which Module belongs.
guess_location/0(Deprecated.) Guesses the location where the function is called (parse transformation fallback).
is_location/1Returns true if X is a location object, false otherwise.
new/3Equivalent to new(self(), guess_application(Module), Module, Function, Line).
new/5Creates a new location object.
to_map/1Converts Location into a map form.
unsafe_new/5Equivalent to new/5 except omission of the arguments validation.

Function Details

from_map/1

from_map(Map::map_form()) -> location()

Creates a new location from Map

Default Value: - process: self() - application: guess_application(maps:get(module, Map)) - module: undefined - function: undefined - line: 0

get_application/1

get_application(Location::location()) -> atom()

Gets the application of Location

get_function/1

get_function(Location::location()) -> atom()

Gets the function of Location

get_line/1

get_line(Location::location()) -> line()

Gets the line of Location

get_module/1

get_module(Location::location()) -> module()

Gets the module of Location

get_process/1

get_process(Location::location()) -> pid()

Gets the PID of Location

guess_application/1

guess_application(Module::module()) -> atom() | undefined

Guesses the application to which Module belongs

guess_location/0

guess_location() -> location()

This function is deprecated: Please use the {parse_transform, logi_transform} compiler option which replaces the function call to a more efficient code.

Guesses the location where the function is called (parse transformation fallback)

This function is too slow and provided for debugging/testing purposes only.

is_location/1

is_location(X::location() | term()) -> boolean()

Returns true if X is a location object, false otherwise.

new/3

new(Module::module(), Function::atom(), Line::line()) -> location()

Equivalent to new(self(), guess_application(Module), Module, Function, Line).

new/5

new(Pid::pid(), Application::application(), Module::module(), Function::atom(), Line::line()) -> location()

Creates a new location object

to_map/1

to_map(Location::location()) -> map_form()

Converts Location into a map form

unsafe_new/5

unsafe_new(Pid::pid(), Application::application(), Module::module(), Function::atom(), Line::line()) -> location()

Equivalent to new/5 except omission of the arguments validation


Generated by EDoc