Skip to content

Logalicious is a Java library that can be used to log messages generated by your app, and have them stored in an encrypted database for later retrieval and / or automatically send them via email at a specified interval and by severity level.

Notifications You must be signed in to change notification settings

eodeluga/Logalicious

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

Logalicious

Logalicious is a Java library that can be used to log messages generated by your app, and have them stored in an encrypted database for later retrieval and / or automatically send them via email at a specified interval and by severity level.

Features

  • Encrypted log database
  • Emailing of log entries at customisable frequency and severity level
  • Supports TLS encryption or plaintext for emailing log entries

Usage
Import the logalicious-1.0.jar module into your project as a library and use as follows

import com.eo.LogSender;
import com.eo.LogWriter;
import com.eo.LogReader;

class Example {
    public static void main(String[] args) {

        // Log using supported severity levels
        LogWriter.writeLog(LogWriter.INFO, "Just a bit of info");
        LogWriter.writeLog(LogWriter.WARNING, "This is a warning");
        LogWriter.writeLog(LogWriter.SEVERE, "This is serious");

        // If using the log sending service, then the following parameters are mandatory.
        // A Null pointer exception is thrown if any are left unset
        //
        // Configure TLS email service
        LogSender.host = "smtp.gmail.com";
        LogSender.username = "[email protected]";    // Mandatory only when using TLS
        LogSender.password = "$habbA!"; // Mandatory only when using TLS
        LogSender.subject = "Dropping logs";
        LogSender.from = "[email protected]";
        LogSender.to = "[email protected]";

	// The parameters below are optional.
        //
        // Used to change port number for mail server (default is 587)
        // LogSender.port = 465;
        //
        // Set to use plaintext email instead of TLS
        // LogSender.useTLS = false;
        //
        // The minimum level of logged messages to send (default is WARNING)
        LogSender.severity = LogWriter.INFO;

        // How often (in seconds) that messages are sent (default is 60)
        LogSender.interval = 30;

        // Run the optional log sending service in the background
        LogSender.startService();

        /*
         * Wait a minute
         */
        try { Thread.sleep(60000L); } catch (InterruptedException e) {/**/}


        // Stop the log sending service
        LogSender.stopService();

        // Read unsent log entries from the database with a minimum
        // severity of INFO
        System.out.println(LogReader.readLog(LogWriter.INFO, false));

        // As above but also include entries that have already been sent
        System.out.println(LogReader.readLog(LogWriter.INFO, true));
    }
}

About

Logalicious is a Java library that can be used to log messages generated by your app, and have them stored in an encrypted database for later retrieval and / or automatically send them via email at a specified interval and by severity level.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages