Giter Club home page Giter Club logo

Comments (7)

vinoski avatar vinoski commented on September 27, 2024

In general, Yaws logging needs work, as it's never been converted over to logger. With the recent Yaws 2.1.0 release, the oldest Erlang/OTP release we now support is 21.0, which is when logger was introduced, so Yaws should now just drop older logging support and convert fully to logger.

from yaws.

seriyps avatar seriyps commented on September 27, 2024

Thanks.
I can try to have a look and maybe send some pull-request to migrate to OTP logger.

What degree of backwards-compatibility should we have? May you point me if there is some documentation describing public logging-related APIs which we should not break?

from yaws.

seriyps avatar seriyps commented on September 27, 2024

I guess might be nice to keep yaws_logger behaviour, but that may require a special logger_handler for "virtual servers" which requested a custom logger_mod.

Maybe install individual logger handler for each enabled auth_log and access_log.

Some docs I found:

yaws/doc/yaws.tex

Lines 2005 to 2023 in 866714d

We have the following log files:
\begin{itemize}
\item The access log. Access logging is turned on or off per server in
the \textit{yaws.conf} file. If access\_log is turned on for a
server, \Yaws\ will produce a log in Common Access Log Format called
\textit{HostName:PortNumber.access}
\item The auth log. Auth logging is turned on or off per server in the
\textit{yaws.conf} file. If auth\_log is turned on for a server,
\Yaws\ will produce a log called \textit{HostName:PortNumber.auth}
which contains all HTTP auth-related messages.
\item \textit{report.log} This file contains all error and crash
messages for all virtual servers in the same file.
\item Trace files. The two command line flags \verb+-t+ and \verb+-T+ tells
\Yaws\ to trace all traffic or just all HTTP messages and write them to files.
\end{itemize}

http://yaws.hyber.org/logger_mod.yaws

yaws/doc/yaws.tex

Lines 2801 to 2873 in 866714d

\item \verb+auth_log = true | false+ ---
Enable or disable the auth log for this virtual server.
Default is true.
\item \verb+access_log = true | false+ ---
Setting this directive to false turns off
traffic logging for this virtual server. The
default value is true.
\item \verb+logger_mod = Module+ ---
It is possible to set a special module that handles access and
auth logging. The default is to log all web server traffic to
\verb+<Host>.access+ and \verb+<Host>.auth+ files in the
configured or default \verb+logdir+.
This module must implement the behaviour
\verb+yaws_logger+. Default value is \verb+yaws_log+.
The following functions should be exported:
\begin{itemize}
\item \verb+Module:open_log(ServerName, Type, LogDir)+ --- When
\Yaws\ is started, this function is called for this virtual
server. If the initialization is successful, the function must
return \verb+{true, State}+ and if an error occurred, it must
return \verb+false+.
\item \verb+Module:close_log(ServerName, Type, State)+ -- This
function is called for this virtual server when
\Yaws\ is stopped.
\item \verb+Module:wrap_log(ServerName, Type, State, LogWrapSize)+
--- This function is used to rotate log files. It is regularly
called by \Yaws\ and must return the possibly updated internal
\verb+NewState+.
\item \verb+Module:write_log(ServerName, Type, State, Infos)+ --
When it needs to log a message, \Yaws\ will call this
function. The parameter \verb+Infos+ is
\verb+{Ip, Req, InHdrs, OutHdrs, Time}+ for an access log and
\verb+{Ip, Path, Item}+ for an auth log, where:
\begin{itemize}
\item \verb+Ip+ --- IP address of the accessing client (as
a tuple).
\item \verb+Req+ --- The HTTP method, URI path, and HTTP
version of the request (as an\\ \verb+#http_request{}+
record).
\item \verb+InHdrs+ --- The HTTP headers which were sent
from the WWW client (as a \verb+#headers{}+ record).
\item \verb+OutHdrs+ --- The HTTP headers sent to the WWW
client (as a \verb+#outh{}+ record).
\item \verb+Path+ --- The URI path of the request (as a
string).
\item \verb+Item+ -- The result of an authentication
request. May be \verb+{ok, User}+, \verb+403+ or\\
\verb+{401, Realm}+.
\item \verb+Time+ --- The time taken to serve the request,
in microseconds.
\end{itemize}
For all of these callbacks, \verb+ServerName+ is the virtual
server's name, \verb+Type+ is the atom \verb+access+ or
\verb+auth+ and \verb+State+ is the internal state of the logger.
\end{itemize}

from yaws.

seriyps avatar seriyps commented on September 27, 2024

Actually, it seems the better plan would be:

  • keep the yaws_logger as is
  • update the yaws_log (default implementation of yaws_logger behaviour) to be a tiny wrapper over logger:add_handler logger:remove_handler logger:log with logger_std_h with custom formatter.
  • remove yaws_log_file_h

from yaws.

vinoski avatar vinoski commented on September 27, 2024

Yep, that sounds right.

from yaws.

seriyps avatar seriyps commented on September 27, 2024

Ok, pushed a bit different implementation from what I planned, see #443.
Still, fully backwards-compatible.

from yaws.

seriyps avatar seriyps commented on September 27, 2024

Fixed by #445

from yaws.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.