Giter Club home page Giter Club logo

logger's Introduction

Logger

Small logger class which lets you log data in a text file.


INTRODUCTION

Logger is a small class which you can use for logging data in a TXT file.


SETUP INFORMATION

Use your CLI and enter the following to clone:
git clone https://github.com/thielicious/Logger.git


USAGE

Create an object :

$log = new Logger("log.txt");
$log->setTimestamp("D M d 'y h.i A");

For example, when a user logs in, use it like this to store:

if (isset($_POST["logged_in"])) {
    $log->putLog("Successful Login: ".$_SESSION["user_name"]);
}
if (isset($_GET["logout"])) {
    $log->putLog("Logout: ".$_SESSION["user_name"]);
}

If you want to see the log, use this:

$log->getLog();

It will render like this:

Sun Jul 02 '17 05.45 PM » Successful Login: JohnDoe
Sun Jul 02 '17 05.46 PM » Logout: JohnDoe

METHODS

Logger::__construct(string $filename)

  • Choose a filename to store the log.

Logger::setTimestamp(string $format)

  • Use a format for the timestamp eg. d-m-y h:i:s.

Logger::putLog(string $content)

  • This will store the log in the file.

Logger::getLog()

  • To display the content of a log file, simply use this method.

Logger::clear()

  • Deletes the log file.


If you encounter any bugs, feel free to open up an issue, thank you.

thielicious.github.io

logger's People

Contributors

thedefinitionist avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

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.