elos is Erlang Log Server
$ clone https://github.com/vkatsuba/elos.git
$ cd elos
$ rebar3 compile
$ rebar3 as prod tar
$ rebar3 as prod release
$ _build/prod/rel/elos/bin/elos console
$ rebar3 xref
$ rebar3 dialyzer
For case if application provide error:
===> Failed to boot elos for reason {{shutdown,
{failed_to_start_child,elos,
eaddrinuse}},
{elos_app,start,[normal,[]]}}
See IPs by List Of Opened Files:
$ lsof -i -n -P
Kill signal:
$ kill -9 Pid
Pid of elos
:
1> whereis('127.0.0.1:8181').
Config1 = #{
name => '127.0.0.1:8282',
ip => {127, 0, 0, 1},
port => 8282,
file => "log/127.0.0.1:8282.log",
level => error,
recbuf => 8192
},
{ok, Pid} = elos:start_instance(Config1).
whereis('127.0.0.1:8282').
whereis('127.0.0.1:8282').
elos:stop_instance('127.0.0.1:8282').
whereis('127.0.0.1:8282').
Create send_log.py
:
$ touch send_log.py
Copy & Paste:
#!/usr/bin/env python3
import socket
UDP_IP = "127.0.0.1"
UDP_PORT = 8181
LOG_LEVEL = chr(1)
MESSAGE = (LOG_LEVEL + 'This message was sended from Python client').encode('ascii')
print("UDP target IP: %s" % UDP_IP)
print("UDP target port: %s" % UDP_PORT)
print("message: %s" % MESSAGE)
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.sendto(MESSAGE, (UDP_IP, UDP_PORT))
data, addr = sock.recvfrom(1024) # buffer size is 1024 bytes
print("received message: %s" % data)
Run:
$ chmod 777 send_log.py
$ ./send_log.py
UDP target IP: 127.0.0.1
UDP target port: 8181
message: b'\x01This message was sended from Python client'
received message: b'\x01'
1> {ok, Socket} = gen_udp:open(8081, [{ip, {127,0,0,1}}, {active, true}, binary, {reuseaddr, true}]).
{ok,#Port<0.6>}
2> gen_udp:send(Socket, "127.0.0.1", 8181, <<1:8/integer, "This message was sended from Erlang client">>).
ok
3> {udp, Socket, {127, 0, 0, 1}, 8181, Res} = receive R -> R end.
{udp,#Port<0.6>,{127,0,0,1},8181,<<1>>}
4> Res.
<<1>>