Module syslog_lib

A library module providing syslog specific utility functions.

Description

A library module providing syslog specific utility functions.

Function Index

ensure_error_logger/0 Start the error_logger process if not running and block the calling process until the error_logger is started and registered by name.
format_rfc3164_date/1 Formats a (UTC) timestamp according to RFC3164.
format_rfc5424_date/1 Formats a (UTC) timestamp according to RFC5424.
get_hostname/1 Returns the hostname of the running node.
get_name/0 Returns the name reported in the APP-NAME field.
get_pid/1 Returns a string representation for a process.
get_property/2 Returns the value for a specific key from the application environment.
get_property/3 Similar to get_property/2.
get_utc_datetime/1 Returns a syslog datetime object (UTC) with microsecond resolution.
get_utc_offset/2 Returns the offset of a local datetime from the given UTC datetime.
to_type/2 Convert variables from one type to another.
truncate/2 Returns a truncated string with at most Len characters/bytes.

Function Details

ensure_error_logger/0

ensure_error_logger() -> ok | {error, term()}

Start the error_logger process if not running and block the calling process until the error_logger is started and registered by name.

format_rfc3164_date/1

format_rfc3164_date(X1::syslog:datetime()) -> iodata()

Formats a (UTC) timestamp according to RFC3164. The returned timestamp will be in local time.

format_rfc5424_date/1

format_rfc5424_date(X1::syslog:datetime()) -> iodata()

Formats a (UTC) timestamp according to RFC5424. The returned timestamp will be in local time with UTC offset (if available).

get_hostname/1

get_hostname(Transform::none | short | long) -> string()

Returns the hostname of the running node. This may include the fully qualified domain name. The hostname will usually be the host part of the node name, except for the cases when the node is not alive or some strange host part was set, e.g. something related to the loopback interface. In this case the hostname will be what inet:gethostname/0 returns, optionally with the domain removed.

get_name/0

get_name() -> binary()

Returns the name reported in the APP-NAME field. If no name is configured using the application environment, name part of the running node is returned. If the node is not running in distributed mode (no nodename configured) the string "beam" will be returned.

get_pid/1

get_pid(P::pid() | atom() | string()) -> binary()

Returns a string representation for a process. This will either be the (locally) registered name of the process or its process id.

get_property/2

get_property(Property::atom(), Default::term()) -> term()

Returns the value for a specific key from the application environment. If no value is configured or the application environment can not be read the provided default value is returned.

get_property/3

get_property(Property::atom(), Default::term(), Type::binary | integer | ip_addr) -> term()

Similar to get_property/2. Additionally, this function allows to specifiy the desired target type. The configured value will be converted to the desired type. If this is not possible, the function crashes.

get_utc_datetime/1

get_utc_datetime(X1::erlang:timestamp()) -> syslog:datetime()

Returns a syslog datetime object (UTC) with microsecond resolution.

get_utc_offset/2

get_utc_offset(Utc::calendar:datetime(), Local::calendar:datetime()) -> {43 | 45, 0..23, 0..59}

Returns the offset of a local datetime from the given UTC datetime.

to_type/2

to_type(Type, V) -> any()

Convert variables from one type to another

truncate/2

truncate(Len::pos_integer(), Str::string() | binary()) -> string() | binary()

Returns a truncated string with at most Len characters/bytes.


Generated by EDoc