Skip to content
This repository
Newer
Older
100644 163 lines (120 sloc) 4.435 kb
bc966e55 » dhrrgn
2014-03-18 A few more README tweaks.
1 # KLogger: Simple Logging for PHP
066d429f »
2010-06-22 Checking in the original version of KLogger, found at: http://codefur…
2
bc966e55 » dhrrgn
2014-03-18 A few more README tweaks.
3 A project written by [Kenny Katzgrau](http://twitter.com/katzgrau) and [Dan Horrigan](http://twitter.com/dhrrgn).
066d429f »
2010-06-22 Checking in the original version of KLogger, found at: http://codefur…
4
f6fe86a3 »
2010-06-23 Updated README to include project background and goals
5 ## About
066d429f »
2010-06-22 Checking in the original version of KLogger, found at: http://codefur…
6
eb58bab9 » dhrrgn
2014-03-18 Updating README.
7 KLogger is an easy-to-use [PSR-3](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md)
8 compliant logging class for PHP. It isn't naive about
f6fe86a3 »
2010-06-23 Updated README to include project background and goals
9 file permissions (which is expected). It was meant to be a class that you could
10 quickly include into a project and have working right away.
11
eb58bab9 » dhrrgn
2014-03-18 Updating README.
12 ## Installation
f6fe86a3 »
2010-06-23 Updated README to include project background and goals
13
eb58bab9 » dhrrgn
2014-03-18 Updating README.
14 ### Composer
15
16 From the Command Line:
17
18 ```
19 composer require katzgrau/klogger:1.0.*
20 ```
21
22 In your `composer.json`:
23
24 ``` json
25 {
26 "require": {
27 "katzgrau/klogger": "1.0.*"
28 }
29 }
30 ```
f6fe86a3 »
2010-06-23 Updated README to include project background and goals
31
997cf5de »
2010-12-11 Fixed a minor undef-array-index bug, updated readme
32 ## Basic Usage
33
eb58bab9 » dhrrgn
2014-03-18 Updating README.
34 ``` php
35 <?php
d112b9f5 » dhrrgn
2014-03-18 Better example.
36
37 require 'vendor/autoload.php';
38
39 $users = [
40 [
41 'name' => 'Kenny Katzgrau',
42 'username' => 'katzgrau',
43 ],
44 [
45 'name' => 'Dan Horrigan',
46 'username' => 'dhrrgn',
47 ],
48 ];
49
50 $logger = new Katzgrau\KLogger\Logger(__DIR__.'/logs');
eb58bab9 » dhrrgn
2014-03-18 Updating README.
51 $logger->info('Returned a million search results');
52 $logger->error('Oh dear.');
53 $logger->debug('Got these users from the Database.', $users);
54 ```
55
d112b9f5 » dhrrgn
2014-03-18 Better example.
56 ### Output
57
58 ```
46cdd92a » dhrrgn
2014-03-19 Fixing a formatting bug, and the README
59 [2014-03-20 3:35:43.762437] [INFO] Returned a million search results
60 [2014-03-20 3:35:43.762578] [ERROR] Oh dear.
61 [2014-03-20 3:35:43.762795] [DEBUG] Got these users from the Database.
62 0: array(
63 'name' => 'Kenny Katzgrau',
64 'username' => 'katzgrau',
65 )
66 1: array(
67 'name' => 'Dan Horrigan',
68 'username' => 'dhrrgn',
d112b9f5 » dhrrgn
2014-03-18 Better example.
69 )
70 ```
71
eb58bab9 » dhrrgn
2014-03-18 Updating README.
72 ## PSR-3 Compliant
73
74 KLogger is [PSR-3](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md)
75 compliant. This means it implements the `Psr\Log\LoggerInterface`.
76
77 [See Here for the interface definition.](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md#3-psrlogloggerinterface)
78
79 ## Setting the Log Level Threshold
80
81 You can use the `Psr\Log\LogLevel` constants to set Log Level Threshold, so that
82 any messages below that level, will not be logged.
83
84 ### Default Level
85
86 The default level is `DEBUG`, which means everything will be logged.
87
88 ### Available Levels
89
90 ``` php
91 <?php
92 use Psr\Log\LogLevel;
93
94 // These are in order of highest priority to lowest.
95 LogLevel::EMERGENCY;
96 LogLevel::ALERT;
97 LogLevel::CRITICAL;
98 LogLevel::ERROR;
99 LogLevel::WARNING;
100 LogLevel::NOTICE;
101 LogLevel::INFO;
102 LogLevel::DEBUG;
103 ```
997cf5de »
2010-12-11 Fixed a minor undef-array-index bug, updated readme
104
eb58bab9 » dhrrgn
2014-03-18 Updating README.
105 ### Example
f6fe86a3 »
2010-06-23 Updated README to include project background and goals
106
eb58bab9 » dhrrgn
2014-03-18 Updating README.
107 ``` php
108 <?php
109 // The
110 $logger = new Katzgrau\KLogger\Logger('/var/log/', Psr\Log\LogLevel::WARNING);
111 $logger->error('Uh Oh!'); // Will be logged
112 $logger->info('Something Happened Here'); // Will be NOT logged
113 ```
f6fe86a3 »
2010-06-23 Updated README to include project background and goals
114
115 ## Why use KLogger?
116
117 Why not? Just drop it in and go. If it saves you time and does what you need,
118 go for it! Take a line from the book of our C-code fathers: "`build` upon the
119 work of others".
120
121 ## Who uses KLogger?
122
123 Klogger has been used in projects at:
124
125 * The University of Iowa
126 * The University of Laverne
127 * The New Jersey Institute of Technology
128 * Middlesex Hospital in NJ
129
130 Additionally, it's been used in numerous projects, both commercial and personal.
131
2d4835e4 »
2010-10-09 Added special thnks section to readme
132 ## Special Thanks
133
eb58bab9 » dhrrgn
2014-03-18 Updating README.
134 Special thanks to all contributors:
2d4835e4 »
2010-10-09 Added special thnks section to readme
135
bc966e55 » dhrrgn
2014-03-18 A few more README tweaks.
136 * [Dan Horrigan](http://twitter.com/dhrrgn)
137 * [Tim Kinnane](http://twitter.com/etherealtim)
138 * [Brian Fenton](http://github.com/fentie)
139 * [Cameron Will](https://github.com/cwill747)
2d4835e4 »
2010-10-09 Added special thnks section to readme
140
f6fe86a3 »
2010-06-23 Updated README to include project background and goals
141 ## License
142
a74818bb »
2010-06-24 * Normalized casing of members and methods
143 The MIT License
144
eb58bab9 » dhrrgn
2014-03-18 Updating README.
145 Copyright (c) 2008-2014 Kenny Katzgrau <katzgrau@gmail.com>
f6fe86a3 »
2010-06-23 Updated README to include project background and goals
146
147 Permission is hereby granted, free of charge, to any person obtaining a copy
148 of this software and associated documentation files (the "Software"), to deal
149 in the Software without restriction, including without limitation the rights
150 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
151 copies of the Software, and to permit persons to whom the Software is
152 furnished to do so, subject to the following conditions:
153
154 The above copyright notice and this permission notice shall be included in
155 all copies or substantial portions of the Software.
156
157 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
158 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
159 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
160 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
161 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
162 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2d4835e4 »
2010-10-09 Added special thnks section to readme
163 THE SOFTWARE.
Something went wrong with that request. Please try again.