Difference between revisions of "WebFund 2016W: Assignment 4"

From Soma-notes
Jump to navigation Jump to search
Line 29: Line 29:
* 2 for functionality with missing arguments
* 2 for functionality with missing arguments
Total: 10 points
Total: 10 points
Note that if your code exits with an error you may get 0 points.  Make sure you test your code with log files other than the one supplied (look at /var/log/syslog for more entries!).
In order to query anything you'll need a working version of storeLogs.js from [[WebFund 2016W: Tutorial 5|Tutorial 5]].  be sure to store the logs in the logs collection in the log-demo database, just as storeLogLine.js does.

Revision as of 12:53, 29 February 2016

In this assignment you will create queryLogs.js, a program that will query the logs collection in the log-demo database for matching log entries. Please submit your answers as a single JavaScript source file called "<username>-queryLogs.js" (where username is your MyCarletonOne username). Please do not submit a zip file (i.e., no need for a node_modules directory). Note that this means your code should not use any modules beyond standard node modules and mongodb.

In total, there are 10 points. The questions below will be automatically graded, so please follow the directions carefully.

This assignment is due March 2, 2016.

Syntax

queryLogs.js should be called as follows:

 node queryLogs.js [--results=<output file>] [--maxcount=<max number of documents to return>]  [--service="service query"]
     [--message="message query"]

Here is an example of a query that includes all the options:

 node queryLogs.js --results=out.txt --maxcount=10 --service="systemd" --message="[Ss]tarted" 

The above would return at most 10 matching log messages and output them to out.txt. The log lines should be outputted as lines, not as objects (i.e., they should appear as they were before being stored in the database). The service and message queries should both be regular expressions and should be combined with a logical and if both are present.

Note that all arguments are optional. If neither --service or --message are specified, all stored log messages should be returned (up to --maxcount, if specified). If no --maxcount is specified, all matching records should be output. If no --results is specified, the output should go to standard out. Thus, node queryLogs.js can be called with no arguments and should just dump all of the log messages (albeit potentially in an arbitrary order).

Scoring

Points will be awarded as follows:

  • 2 for --results
  • 2 for --maxcount
  • 2 for --service
  • 2 for --message
  • 2 for functionality with missing arguments

Total: 10 points

Note that if your code exits with an error you may get 0 points. Make sure you test your code with log files other than the one supplied (look at /var/log/syslog for more entries!).

In order to query anything you'll need a working version of storeLogs.js from Tutorial 5. be sure to store the logs in the logs collection in the log-demo database, just as storeLogLine.js does.