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.5 API

  • Overview
  • Tree
  • Deprecated
  • Version:
    • 2.5
      • 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
      • Validator
    • Network
      • Email
      • Http
    • Routing
      • Filter
      • Route
    • TestSuite
      • Coverage
      • Fixture
      • Reporter
    • Utility
    • View
      • Helper

Classes

  • BaseLog
  • ConsoleLog
  • FileLog
  • SyslogLog
 1: <?php
 2: /**
 3:  * Console Logging
 4:  *
 5:  * CakePHP(tm) :  Rapid Development Framework (http://cakephp.org)
 6:  * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
 7:  *
 8:  * Licensed under The MIT License
 9:  * For full copyright and license information, please see the LICENSE.txt
10:  * Redistributions of files must retain the above copyright notice.
11:  *
12:  * @copyright     Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
13:  * @link          http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
14:  * @package       Cake.Log.Engine
15:  * @since         CakePHP(tm) v 2.2
16:  * @license       http://www.opensource.org/licenses/mit-license.php MIT License
17:  */
18: 
19: App::uses('BaseLog', 'Log/Engine');
20: App::uses('ConsoleOutput', 'Console');
21: 
22: /**
23:  * Console logging. Writes logs to console output.
24:  *
25:  * @package       Cake.Log.Engine
26:  */
27: class ConsoleLog extends BaseLog {
28: 
29: /**
30:  * Output stream
31:  *
32:  * @var ConsoleOutput
33:  */
34:     protected $_output = null;
35: 
36: /**
37:  * Constructs a new Console Logger.
38:  *
39:  * Config
40:  *
41:  * - `types` string or array, levels the engine is interested in
42:  * - `scopes` string or array, scopes the engine is interested in
43:  * - `stream` the path to save logs on.
44:  * - `outputAs` integer or ConsoleOutput::[RAW|PLAIN|COLOR]
45:  *
46:  * @param array $config Options for the FileLog, see above.
47:  * @throws CakeLogException
48:  */
49:     public function __construct($config = array()) {
50:         parent::__construct($config);
51:         if ((DS === '\\' && !(bool)env('ANSICON')) ||
52:             (function_exists('posix_isatty') && !posix_isatty($this->_output))
53:         ) {
54:             $outputAs = ConsoleOutput::PLAIN;
55:         } else {
56:             $outputAs = ConsoleOutput::COLOR;
57:         }
58:         $config = Hash::merge(array(
59:             'stream' => 'php://stderr',
60:             'types' => null,
61:             'scopes' => array(),
62:             'outputAs' => $outputAs,
63:             ), $this->_config);
64:         $config = $this->config($config);
65:         if ($config['stream'] instanceof ConsoleOutput) {
66:             $this->_output = $config['stream'];
67:         } elseif (is_string($config['stream'])) {
68:             $this->_output = new ConsoleOutput($config['stream']);
69:         } else {
70:             throw new CakeLogException('`stream` not a ConsoleOutput nor string');
71:         }
72:         $this->_output->outputAs($config['outputAs']);
73:     }
74: 
75: /**
76:  * Implements writing to console.
77:  *
78:  * @param string $type The type of log you are making.
79:  * @param string $message The message you want to log.
80:  * @return bool success of write.
81:  */
82:     public function write($type, $message) {
83:         $output = date('Y-m-d H:i:s') . ' ' . ucfirst($type) . ': ' . $message . "\n";
84:         return $this->_output->write(sprintf('<%s>%s</%s>', $type, $output, $type), false);
85:     }
86: 
87: }
88: 
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