CakePHP
  • Documentation
    • Book
    • API
    • Videos
    • Reporting Security Issues
    • Privacy Policy
    • Logos & Trademarks
  • Business Solutions
  • Swag
  • Road Trip
  • Team
  • Community
    • Community
    • Get Involved
    • Issues (GitHub)
    • Bakery
    • Featured Resources
    • Training
    • Meetups
    • My CakePHP
    • CakeFest
    • Newsletter
    • Linkedin
    • YouTube
    • Facebook
    • Twitter
    • Mastodon
    • Help & Support
    • Forum
    • Stack Overflow
    • Slack
    • Paid Support
CakePHP

C CakePHP 2.1 API

  • Overview
  • Tree
  • Deprecated
  • Version:
    • 2.1
      • 4.2
      • 4.1
      • 4.0
      • 3.9
      • 3.8
      • 3.7
      • 3.6
      • 3.5
      • 3.4
      • 3.3
      • 3.2
      • 3.1
      • 3.0
      • 2.10
      • 2.9
      • 2.8
      • 2.7
      • 2.6
      • 2.5
      • 2.4
      • 2.3
      • 2.2
      • 2.1
      • 2.0
      • 1.3
      • 1.2

Packages

  • Cake
    • Cache
      • Engine
    • Configure
    • Console
      • Command
        • Task
    • Controller
      • Component
        • Acl
        • Auth
    • Core
    • Error
    • Event
    • I18n
    • Log
      • Engine
    • Model
      • Behavior
      • Datasource
        • Database
        • Session
    • Network
      • Email
      • Http
    • Routing
      • Route
    • TestSuite
      • Coverage
      • Fixture
      • Reporter
    • Utility
    • View
      • Helper

Classes

  • FileLog
 1: <?php
 2: /**
 3:  * File Storage stream for Logging
 4:  *
 5:  * PHP 5
 6:  *
 7:  * CakePHP(tm) :  Rapid Development Framework (http://cakephp.org)
 8:  * Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
 9:  *
10:  * Licensed under The MIT License
11:  * Redistributions of files must retain the above copyright notice.
12:  *
13:  * @copyright     Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
14:  * @link          http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
15:  * @package       Cake.Log.Engine
16:  * @since         CakePHP(tm) v 1.3
17:  * @license       MIT License (http://www.opensource.org/licenses/mit-license.php)
18:  */
19: 
20: App::uses('CakeLogInterface', 'Log');
21: 
22: /**
23:  * File Storage stream for Logging.  Writes logs to different files
24:  * based on the type of log it is.
25:  *
26:  * @package       Cake.Log.Engine
27:  */
28: class FileLog implements CakeLogInterface {
29: 
30: /**
31:  * Path to save log files on.
32:  *
33:  * @var string
34:  */
35:     protected $_path = null;
36: 
37: /**
38:  * Constructs a new File Logger.
39:  *
40:  * Options
41:  *
42:  * - `path` the path to save logs on.
43:  *
44:  * @param array $options Options for the FileLog, see above.
45:  */
46:     public function __construct($options = array()) {
47:         $options += array('path' => LOGS);
48:         $this->_path = $options['path'];
49:     }
50: 
51: /**
52:  * Implements writing to log files.
53:  *
54:  * @param string $type The type of log you are making.
55:  * @param string $message The message you want to log.
56:  * @return boolean success of write.
57:  */
58:     public function write($type, $message) {
59:         $debugTypes = array('notice', 'info', 'debug');
60: 
61:         if ($type == 'error' || $type == 'warning') {
62:             $filename = $this->_path . 'error.log';
63:         } elseif (in_array($type, $debugTypes)) {
64:             $filename = $this->_path . 'debug.log';
65:         } else {
66:             $filename = $this->_path . $type . '.log';
67:         }
68:         $output = date('Y-m-d H:i:s') . ' ' . ucfirst($type) . ': ' . $message . "\n";
69:         return file_put_contents($filename, $output, FILE_APPEND);
70:     }
71: 
72: }
73: 
OpenHub
Rackspace
Rackspace
  • Business Solutions
  • Showcase
  • Documentation
  • Book
  • API
  • Videos
  • Reporting Security Issues
  • Privacy Policy
  • Logos & Trademarks
  • Community
  • Get Involved
  • Issues (GitHub)
  • Bakery
  • Featured Resources
  • Training
  • Meetups
  • My CakePHP
  • CakeFest
  • Newsletter
  • Linkedin
  • YouTube
  • Facebook
  • Twitter
  • Mastodon
  • Help & Support
  • Forum
  • Stack Overflow
  • Slack
  • Paid Support

Generated using CakePHP API Docs