Apache log file functions
Funciones
Set ApaBetween2Tag(Set linSet, Text tagIni, Text tagEnd)Set ApaBetween2TagFile(Text logPth, Text tagIni, Text tagEnd)Set ApaLineSet(Text logPth)Set ApaUrl(Set linSet)Set ApaUrlFile(Text logPth)Real ApaSplitFile(Text logPth, Text outPth, Text prefix, Text filErr)//////////////////////////////////////////////////////////////////////////////
Set ApaBetween2Tag(Set linSet, // Set of log lines,
Text tagIni, // Initial tag
Text tagEnd) // End tag
//////////////////////////////////////////////////////////////////////////////
{
Set set = EvalSet(linSet, Text(Text lin)
{ TxtBetween2Tag(lin, tagIni, tagEnd, TRUE) });
SetTxtCount(set, TRUE)
};
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Returns a table with different text that appear between 2 tags.
For each text there are a line [[ text, number of ocurrences (Real)]].",
ApaBetween2Tag);
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
Set ApaBetween2TagFile(Text logPth, // Input file path
Text tagIni, // Initial tag
Text tagEnd) // End tag
//////////////////////////////////////////////////////////////////////////////
{
Set linSet = ApaLineSet(logPth); // Read log file
ApaBetween2Tag(linSet, tagIni, tagEnd)
};
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Returns a table with different text that appear between 2 tags inside a log
file.
For each text there are a line [[ text, number of ocurrences (Real)]].",
ApaBetween2TagFile);
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
Set ApaLineSet(Text logPth) // Input file path
//////////////////////////////////////////////////////////////////////////////
{
If(Not(FileExist(logPth)), Empty,
{
Text logTxt = ReadFile(logPth);
Set linSet = Tokenizer(logTxt,"\n");
Select(linSet, Real(Text lin) { lin != "" })
})
};
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Returns a set with all lines of a log file.
The empty lines are removed.",
ApaLineSet);
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
Set ApaUrl(Set linSet) // Set of log lines
//////////////////////////////////////////////////////////////////////////////
{
Set urlSet = EvalSet(linSet, Text(Text lin)
{ Compact(Sub(lin,1,TextFind(lin," - - ["))) });
SetTxtCount(urlSet, TRUE) // Count different urls that aren't null
};
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Returns a table with different urls of a set of log lines.
For each url there are a line [[ url (Text), number of ocurrences (Real)]].",
ApaUrl);
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
Set ApaUrlFile(Text logPth) // Input file path
//////////////////////////////////////////////////////////////////////////////
{
Set linSet = ApaLineSet(logPth); // Read log file
ApaUrl(linSet)
};
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Returns a table with different urls of a log file.
For each url there are a line [[ url (Text), number of ocurrences (Real)]].",
ApaUrlFile);
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
Real ApaSplitFile(Text logPth, // Input file path
Text outPth, // Output path
Text prefix, // File prefix
Text filErr) // Error file
//////////////////////////////////////////////////////////////////////////////
{
FilSplit(logPth, TRUE, Text(Text lin)
{
Text dteTxt = TxtBetween2Tag(lin, "[", "]", TRUE);
If(dteTxt=="", filErr,
{
Date dte = Txt2Dte(dteTxt, "dd/mmm/yyyy");
If(dte==UnknownDate, filErr,
outPth+"/"+prefix+FormatDate(dte,"%c%Y%m%d")+".log")
})
})
};
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Split an Apache log file (logPth) y several files by date and returns the
number lines processed.
Each output file has the name: <outPth> + / + <prefix> + YYYYMMDD + .log
The error line are stored at filErr.",
ApaUrlFile);
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
// FILE : apa.tol
// AUTHOR : http://www.asolver.com
// PURPOSE : Apache log file functions
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
// FUNCTIONS
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
Set ApaBetween2Tag(Set linSet, // Set of log lines,
Text tagIni, // Initial tag
Text tagEnd) // End tag
//////////////////////////////////////////////////////////////////////////////
{
Set set = EvalSet(linSet, Text(Text lin)
{ TxtBetween2Tag(lin, tagIni, tagEnd, TRUE) });
SetTxtCount(set, TRUE)
};
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Returns a table with different text that appear between 2 tags.
For each text there are a line [[ text, number of ocurrences (Real)]].",
ApaBetween2Tag);
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
Set ApaBetween2TagFile(Text logPth, // Input file path
Text tagIni, // Initial tag
Text tagEnd) // End tag
//////////////////////////////////////////////////////////////////////////////
{
Set linSet = ApaLineSet(logPth); // Read log file
ApaBetween2Tag(linSet, tagIni, tagEnd)
};
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Returns a table with different text that appear between 2 tags inside a log
file.
For each text there are a line [[ text, number of ocurrences (Real)]].",
ApaBetween2TagFile);
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
Set ApaLineSet(Text logPth) // Input file path
//////////////////////////////////////////////////////////////////////////////
{
If(Not(FileExist(logPth)), Empty,
{
Text logTxt = ReadFile(logPth);
Set linSet = Tokenizer(logTxt,"\n");
Select(linSet, Real(Text lin) { lin != "" })
})
};
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Returns a set with all lines of a log file.
The empty lines are removed.",
ApaLineSet);
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
Set ApaUrl(Set linSet) // Set of log lines
//////////////////////////////////////////////////////////////////////////////
{
Set urlSet = EvalSet(linSet, Text(Text lin)
{ Compact(Sub(lin,1,TextFind(lin," - - ["))) });
SetTxtCount(urlSet, TRUE) // Count different urls that aren't null
};
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Returns a table with different urls of a set of log lines.
For each url there are a line [[ url (Text), number of ocurrences (Real)]].",
ApaUrl);
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
Set ApaUrlFile(Text logPth) // Input file path
//////////////////////////////////////////////////////////////////////////////
{
Set linSet = ApaLineSet(logPth); // Read log file
ApaUrl(linSet)
};
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Returns a table with different urls of a log file.
For each url there are a line [[ url (Text), number of ocurrences (Real)]].",
ApaUrlFile);
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
Real ApaSplitFile(Text logPth, // Input file path
Text outPth, // Output path
Text prefix, // File prefix
Text filErr) // Error file
//////////////////////////////////////////////////////////////////////////////
{
FilSplit(logPth, TRUE, Text(Text lin)
{
Text dteTxt = TxtBetween2Tag(lin, "[", "]", TRUE);
If(dteTxt=="", filErr,
{
Date dte = Txt2Dte(dteTxt, "dd/mmm/yyyy");
If(dte==UnknownDate, filErr,
outPth+"/"+prefix+FormatDate(dte,"%c%Y%m%d")+".log")
})
})
};
//////////////////////////////////////////////////////////////////////////////
PutDescription(
"Split an Apache log file (logPth) y several files by date and returns the
number lines processed.
Each output file has the name: <outPth> + / + <prefix> + YYYYMMDD + .log
The error line are stored at filErr.",
ApaUrlFile);
//////////////////////////////////////////////////////////////////////////////
Ink.Watercolor construye las páginas del sitio web inkwatercolor.com
2015 asolver.com | Aviso legal | XHTML | Δ Θ Ξ | Creative Commons | Mapa y funciones del sitio