All Projects → waza-ari → Monolog Mysql

waza-ari / Monolog Mysql

Licence: mit
MySQL Handler for Monolog, which allows to store log messages to a MySQL Table

Projects that are alternatives of or similar to Monolog Mysql

Imgbot
An Azure Function solution to crawl through all of your image files in GitHub and losslessly compress them. This will make the file size go down, but leave the dimensions and quality untouched. Once it's done, ImgBot will open a pull request for you to review and merge. [email protected]
Stars: ✭ 732 (+467.44%)
Mutual labels:  help-wanted
Junit Schema
XSD for Apache Ant's JUnit output
Stars: ✭ 64 (-50.39%)
Mutual labels:  help-wanted
Colmena
Colmena is a starter kit for an API with an Admin interface that can be easily extended and built upon.
Stars: ✭ 1,420 (+1000.78%)
Mutual labels:  help-wanted
Openprocure
An open list of government procurement thresholds
Stars: ✭ 22 (-82.95%)
Mutual labels:  help-wanted
Ascii Combat
A simple CLI text adventure game, created for learning purposes, feel free to contribute.
Stars: ✭ 49 (-62.02%)
Mutual labels:  help-wanted
Chakracore
ChakraCore is an open source Javascript engine with a C API.
Stars: ✭ 8,600 (+6566.67%)
Mutual labels:  help-wanted
Plots2
a collaborative knowledge-exchange platform in Rails; we welcome first-time contributors! 🎈
Stars: ✭ 666 (+416.28%)
Mutual labels:  help-wanted
Boltbrowser
boltBrowser is a GUI web-based explorer and editor for boltDB
Stars: ✭ 116 (-10.08%)
Mutual labels:  help-wanted
Gophergameserver
🏆 Feature packed, easy-to-use game server API for Go back-ends and Javascript clients. Tutorials and examples included!
Stars: ✭ 61 (-52.71%)
Mutual labels:  help-wanted
Itsagramlive
It's A Gram Live is a Python script that create a Instagram Live and provide you a rtmp server and stream key to streaming using sofwares like OBS-Studio.
Stars: ✭ 107 (-17.05%)
Mutual labels:  help-wanted
Koa Typeorm Starter
Starter project for using koa with TS and TypeORM
Stars: ✭ 23 (-82.17%)
Mutual labels:  help-wanted
Hacktoberfest2k19
Hacktoberfest is here! Raise the PR and earn goodies.
Stars: ✭ 34 (-73.64%)
Mutual labels:  help-wanted
Scala Cheatsheet
The Biggest Scala Cheat-Sheet.
Stars: ✭ 81 (-37.21%)
Mutual labels:  help-wanted
Verticalcardswiper
A marriage between the Shazam Discover UI and Tinder, built with UICollectionView in Swift.
Stars: ✭ 830 (+543.41%)
Mutual labels:  help-wanted
Daily Dozen Ios
Keep track of the foods that Dr. Greger recommends in his NYT's best-selling book, How Not to Die with this iOS app
Stars: ✭ 109 (-15.5%)
Mutual labels:  help-wanted
Barinsta
Open-source alternative Instagram client on Android.
Stars: ✭ 717 (+455.81%)
Mutual labels:  help-wanted
One Line Wonders
OneLineWondersCode | 1000+ Commits | 278/300 One Liners | 200+ Forks | Actively maintained open-source collection of "one-line" programs performing various tasks in different languages
Stars: ✭ 65 (-49.61%)
Mutual labels:  help-wanted
Leetcode Solutions
This repository consists of solutions to the problem from LeetCode platform. Subscribe to our Channel for more updates
Stars: ✭ 128 (-0.78%)
Mutual labels:  help-wanted
Ventas
Clojure ecommerce platform
Stars: ✭ 114 (-11.63%)
Mutual labels:  help-wanted
Doesangue Core
Online platform that connects people interested in blood donation
Stars: ✭ 91 (-29.46%)
Mutual labels:  help-wanted

monolog-mysql

MySQL Handler for Monolog, which allows to store log messages in a MySQL Table. It can log text messages to a specific table, and creates the table automatically if it does not exist. The class further allows to dynamically add extra attributes, which are stored in a separate database field, and can be used for later analyzing and sorting.

HELP WANTED

As I do not use this project myself anymore and I do not find the time to maintain this project as it deserves I would be happy to find someone taking it over. Please contact me at [email protected] if you'd be interesting to take over that project. Thanks!

Installation

monolog-mysql is available via composer. Just add the following line to your required section in composer.json and do a php composer.phar update.

"wazaari/monolog-mysql": ">1.0.0"

Usage

Just use it as any other Monolog Handler, push it to the stack of your Monolog Logger instance. The Handler however needs some parameters:

  • $pdo PDO Instance of your database. Pass along the PDO instantiation of your database connection with your database selected.
  • $table The table name where the logs should be stored
  • $additionalFields simple array of additional database fields, which should be stored in the database. The columns are created automatically, and the fields can later be used in the extra context section of a record. See examples below. Defaults to an empty array()
  • $level can be any of the standard Monolog logging levels. Use Monologs statically defined contexts. Defaults to Logger::DEBUG
  • $bubble Defaults to true
  • $skipDatabaseModifications Defines whether we should skip any attempts to sync current database state with what's requested by the code (includes creating the table and adding / dropping fields). Defaults to false

If $skipDatabaseModifications is set to true, please use the following query as a template to create the log table (with additional fields, if necessary)

CREATE TABLE `log` (
    id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, channel VARCHAR(255), level INTEGER, message LONGTEXT, time INTEGER UNSIGNED, INDEX(channel) USING HASH, INDEX(level) USING HASH, INDEX(time) USING BTREE
)

Examples

Given that $pdo is your database instance, you could use the class as follows:

//Import class
use MySQLHandler\MySQLHandler;

//Create MysqlHandler
$mySQLHandler = new MySQLHandler($pdo, "log", array('username', 'userid'), \Monolog\Logger::DEBUG);

//Create logger
$logger = new \Monolog\Logger($context);
$logger->pushHandler($mySQLHandler);

//Now you can use the logger, and further attach additional information
$logger->addWarning("This is a great message, woohoo!", array('username'  => 'John Doe', 'userid'  => 245));

License

This tool is free software and is distributed under the MIT license. Please have a look at the LICENSE file for further information.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].