* distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * @category File * @package talkback * @author Chris Noden <*****@*****.**> * @copyright 2013 Chris Noden * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0 * @link https://github.com/chrisnoden */ require '../vendor/autoload.php'; /** * Create a Talkback collection * * A File channel outputs all events to /tmp/test.log * A Basic channel will output CRITICAL events to console * A Growl channel will show all INFO events */ $logger = \Talkback\Logger::getLogger('complex logger'); $logger->addChannel(array(\Psr\Log\LogLevel::ERROR, \Psr\Log\LogLevel::CRITICAL, \Psr\Log\LogLevel::ALERT, \Psr\Log\LogLevel::EMERGENCY, \Psr\Log\LogLevel::INFO, \Psr\Log\LogLevel::NOTICE, \Psr\Log\LogLevel::WARNING, \Psr\Log\LogLevel::DEBUG), \Talkback\Channel\ChannelFactory::File('/tmp/test.log'))->addChannel(\Psr\Log\LogLevel::CRITICAL, \Talkback\Channel\ChannelFactory::Basic())->addChannel(\Psr\Log\LogLevel::INFO, \Talkback\Channel\ChannelFactory::Growl('Bundle')); /** * Send an INFO event which will appear in the File log and on Growl */ $logger->info('My goodness this is good information'); // dump the log file to the console $file = file_get_contents('/tmp/test.log'); echo "Your file contains:" . PHP_EOL . $file; // clean up unlink('/tmp/test.log');
/** * Trying to instantiate a new File channel without a filename * or with an invalid filename should cause an Exception to be thrown */ public function testFileChannelInvalidNameException() { $this->setExpectedException('Talkback\\Exception\\InvalidArgumentException', 'filename must be an absolute filename in a writeable directory'); /** @noinspection PhpUnusedLocalVariableInspection */ $obj = ChannelFactory::File($this->_invalidFileName); }