siberian-fast-food / alogger Goto Github PK
View Code? Open in Web Editor NEWSimply the best logging framework for Erlang
License: Apache License 2.0
Simply the best logging framework for Erlang
License: Apache License 2.0
New function is the same as alog_if:log/8.
But check every argument for fun().
Fun should be executed.
One should have an ability to send messages to email.
For now, alog_pt makes following:
?DBG({A, B, "test ~p"}, [foobar]) → dbg(io_lib:format("A: ~p B: ~p ~s", [A, B, "test ~p"]), [foobar])
There is another way to do this with less overhead:
?DBG({A, B, "test ~p"}, [foobar]) → dbg("A: ~p B: ~p test ~p", [A, B, foobar])
One should be able to log value of a thunk
2 forms — full ?DBG("~p ~p", [Foo, Bar]) and short ?DBG({Foo, Bar})
second one can be taken as first one with automagically formed format string
every arg can be replaced with {lazy, Fun} — in this case alog_if:log_lazy is called instead of alog_if:log, or with {lazy, "Name", Fun} (in this case Name will be used as a name of resulting value in tuple expression)
new form: ?DBG(["foobar", ARBITRARY_EXPRESSION])
new macro: ?DBG_TC() that measures time of execution of list-expr and lazy funs
Possibility to add filter as list:
[{mod,[ mod1,mod2]},{tag,[ t1,t2]}]
It would be useful to have a possibility to reconfigure a log interface run time, so I propose to add reconfigure/1 function to gen_alogger behaviour to let a user do this. Also, it probably needs to add a function for restart a log interface, like restart/0, but I'll think about it more.
My application use alogger with the example configuration (tty + syslog).
On Erlang R15B3-1 all works fine.
On Erlang R16B1 and R16B2 it stops on start when alog_sup starting. No information passed to syslog, erlang console also unacceptable.
Single syslog application works fine:
1> application:start(syslog).
ok
3> {ok, S} = syslog:open("test", [cons, perror, pid], user).
{ok,#Port<0.754>}
4> syslog:log(S, 1, "qwe123").
ok
But there are some warning in syslog compillation process:
Compiling c_src/syslog_drv.c
c_src/syslog_drv.c: In function ‘syslogdrv_control’:
c_src/syslog_drv.c:187:13: warning: ‘driver_output_term’ is deprecated (declared at /home/mkrentovskiy/erlang/r16/erts-5.10.3/include/erl_driver.h:622) [-Wdeprecated-declarations]
driver_output_term(port, term, sizeof term/sizeof *term);
^
Steps to reproduce:
(alog_dev@maxubuntu)2> error_logger:error_report("some data").
2013-10-10 16:43:05.499597 =STD ERROR=======
Unknown report: "some data"
=ERROR REPORT==== 10-Oct-2013::16:43:05 ===
some data
ok
syslog:open return {ok, Pid} now, which require in syslog:log/3.
I need to write different log levels messages in different log files. What should I do?
It'ill be nice to use something like this:
[
{alog, [
{enabled_loggers,[alog_disk_log1,alog_disk_log2,alog_disk_log3]},
{install_error_logger_handler, true},
{flows, [
{{mod, ['_']}, {'=<', debug}, [alog_disk_log1]},
{{mod, ['_']}, {'=<', warning}, [alog_disk_log2]},
{{mod, [alog_examples]}, {'=<', debug}, [alog_disk_log3]}
]},
{alog_disk_log1, [
{module, alog_disk_log},
{name, alog_disk_log1},
{file, "priv/logs/alog_disk_log1.log"},
{format, external}
]},
{alog_disk_log2, [
{module, alog_disk_log},
{name, alog_disk_log2},
{file, "priv/logs/alog_disk_log2.log"},
{format, external}
]}
{alog_disk_log3, [
{module, alog_disk_log},
{name, alog_disk_log3},
{file, "priv/logs/alog_disk_log2.log"},
{format, external}
]}
]}
].
Is there way to do this with current version of alogger?
The documentation isn't up to date, so it needs to be update to reflect all the latest code changes.
Main idea of separation of logger and formatter to avoid repeat formatting for every logger.
I mean that we should format message one time and send formatted string to all needed loggers.
https://github.com/siberian-fast-food/alogger/blob/master/src/alog_if_default.erl#L50
Function alog_if_default:to_log/9 should be fixed.
One should be able to wrap their code in our macro like
Test = ?DBG({case X of ... end})
and get an expression and their value in logs, with other code unaffected.
We need some API calls to get tty messages in remote console.
For some reason our error_logger handler loses time stamps, so, the original log entry looks like this:
=ERROR REPORT==== 7-Aug-2011::22:44:50 ===
Error in process <0.65.0> on node 'alog_dev@skull' with exit value: {{badmatch,32},[{erl_eval,expr,3}]}
the log entry by our handler looks like this:
=ERROR REPORT=======
Error in process <0.65.0> on node 'alog_dev@skull' with exit value: {{badmatch,32},[{erl_eval,expr,3}]}
probably the problem is with header "formatting".
does not work as expected:
flows
id filter priority loggers enabled
2 {mod,['_']} {'=<',debug} [alog_disk_log] true
1 {mod,['_']} {'=<',debug} [alog_tty] true
This function looks missing.
It would be useful to have an ability to get logs directly into a browser.
so, basically we get badly formatted logs like:
=PROGRESS REPORT======= supervisor: {local,wpart} started: [{pid,<0.356.0>}, {name,e_socat}, {mfargs,{e_socat,start_link,[[]]}}, {restart_type,permanent}, {shutdown,2000}, {child_type,worker}]=PROGRESS REPORT======= application: e_socat started_at: erlweb@eva=PROGRESS REPORT======= exec: 1: supervisor: {local,wpart} started: [{pid,<0.358.0>}, /home/ingham/src/userver/trunk/erlangweb/rel/lib/e_socat-1.0/priv/esocat.pl: Permission denied {name,e_olup_timer}, {mfargs,{e_olup_timer,start_link,[[]]}}, {restart_type,permanent}, {shutdown,2000}, {child_type,worker}]=PROGRESS REPORT======= application: e_olup_timer started_at: erlweb@evaruntime:0:debug [<0.88.0>]->[]: "EUMSChatServer start!!!" =PROGRESS REPORT======= supervisor: {local,wpart} started: [{pid,<0.361.0>}, {name,e_umschatserver}, {mfargs,{e_umschatserver,start_link,[[]]}}, {restart_type,permanent}, {shutdown,2000}, {child_type,worker}]=PROGRESS REPORT======= application: e_umschatserver started_at: erlweb@evaruntime:0:debug [<0.88.0>]->[]: "GUID server start" runtime:0:debug [<0.358.0>]->[]: "OLUP timer job error: " {badmatch, {aborted,{no_exists,{videomail,disc_copies}}}}
it's needed to double check all the places we format a log message.
yrashk> si14: I just spent over 6 hours fighting with a problem that was sneaked in by alog :-(
yrashk> si14: I didn't know about install_error_logger_handler being true by default
yrashk> si14: so I was thinking SASL disrespects its config passed through sys.config
yrashk> si14: that was a horrible experience :-(
yrashk> si14: write about it in BIG LETTERS in the readme file
yrashk> and may be false by default
yrashk> I really spent almost a work day fighting this problem until I traced it down
yrashk> because your logs looked exactly like SASL's
yrashk> and I thought it is SASL printing them
Possible fixes (one or more should be applied):
-make this behaviour be false by default
-make SASL reports look different
-document this
Http interface would be a nice addition to alooger, so it could communicate with non-erlang processes (.NET ones for example).
In distributed environment there is a need to collect all log messages into one sink (such as bigwig, again).
I noticed a inconsistency of the macro namings all macros have written out names only debug has a abbreviation it would make more sense or at least be more constistant to name DBG also DEBUG in my eyes.
Regards,
Heinz
It would be nice to have one. We can also steal SASL formatter from lager.
?DBG("Starting pwrite"),
StartPWrt = erlang:now(),
file:pwrite(State#state.dump_file, Acc),
?DBG("Done pwrite, time: ~p", [timer:now_diff(StartPWrt, erlang:now())]),
annoying. Should invent something to make it easier.
So one can write ?INFO({foo(bar, baz)}) instead of T = foo(bar, baz), ?INFO({T}), T.
It would be nice to have an interface towards disk_log logger. For the start, it would be good to have at least the basic functionality.
To divide loggers and formatters.
2 {mod,[controller_event]} {'=<',error} [alog_disk_log] true
1 {mod,['_']} {'=<',debug} [alog_disk_log] true
In this case controlller_event with priority 'debug' will be logged by '1' rule. It will be good to have construction 'not' to avoid that.
There should be a possibility to use bigwig as a configurator for alogger
My fork of edown is now completely obsolete.
Sometimes it could be very useful to have all the log messages flatten, it means that there're no any '\n' in a log message, so, the logs are very well "grep'able".
We should take in account fact that user can try to log a very large data (big lists and binaries, for example). We should trim such messages (this trimming should be enabled by default and one should have an ability to disable it). Also http://erlang.org/pipermail/erlang-questions/2011-July/060102.html
Change library default configuration (when alog.config not found and no flows configured) so that it prints to alot_tty by default.
get rid of step 4 in:
Makes learning curve easier for new users.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.