Repository
Current version released
3 years ago
Versions
Analogger
This is a simple Deno library to consume access logs generated by nginx/apache and generate reports about visits, sessions, etc.
It’s divided in two scopes:
- Transformers: to parse, transform and enrich the data from log files.
- Reporters: to generate reports of this data.
Example
import {
read,
show,
reports,
transform,
transformers as t
} from "https://deno.land/x/analogger/mod.ts";
// Step 1: Read the log file.
const logs = read("./access.log");
// Step 2: Parse and transform the logs:
const result = await transform(
logs,
t.parse(), // Parse the data.
t.filterByExtensions([".html", ""]), // Filter by .html extensions or not extension at all.
t.filter((log) => log.status === 200), // Get only requests generating a 200 status code response.
t.isBot(), // Add the `isBot` property indicating if the request is from a bot (ex: Google).
t.filter((log) => !log.isBot), // Discard request from bots
t.parseUserAgent(), // Parse the user-agent info
t.sessionId(), // Add the `sessionId` property with an autogenerated session id
t.searchEngine(), // Add the `searchEngine` property (google, bing, yahoo...)
t.socialNetwork(), // Add the `socialNetwork` property (facebook, twitter, instagram...)
);
// Step 3: Generate reports with this data.
// For example, the number of sessions by month:
const report = reports.sessions(result, "monthly");
// Step 3: See the report in your browser
await show(report);