当前位置: 首页>>代码示例>>PHP>>正文


PHP SS_Log::add_writer方法代码示例

本文整理汇总了PHP中SS_Log::add_writer方法的典型用法代码示例。如果您正苦于以下问题:PHP SS_Log::add_writer方法的具体用法?PHP SS_Log::add_writer怎么用?PHP SS_Log::add_writer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SS_Log的用法示例。


在下文中一共展示了SS_Log::add_writer方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: run

 /**
  * Implement this method in the task subclass to
  * execute via the TaskRunner
  */
 public function run($request)
 {
     if (!($adminEmail = $this->config()->get('administrator_email'))) {
         $contenders = $this->extend('feedMeAdminEmail') ?: [];
         $adminEmail = reset($contenders);
     }
     if ($adminEmail) {
         SS_Log::add_writer(new SS_LogEmailWriter($adminEmail, SS_Log::INFO));
     }
     // anything like a warning or above
     SS_Log::add_writer(new SS_LogEmailWriter(Security::findAnAdministrator()->Email), SS_Log::WARN);
     $excludedFeedClasses = $this->config()->get('excluded_feed_class_names');
     // for each implementor of the FeedMeFeedInterface check if it's not excluded then for each
     // instance of that model call feedMeImport on it.
     $implementors = ClassInfo::implementorsOf('FeedMeFeedModelInterface');
     foreach ($implementors as $className) {
         // chance to disable a feed by setting config.excluded_feed_class_names
         if (!in_array($className, $excludedFeedClasses)) {
             /** @var FeedMeFeedModelExtension $feedModel */
             foreach ($className::get() as $feedModel) {
                 $feedModel->feedMeImport();
             }
         }
     }
 }
开发者ID:CrackerjackDigital,项目名称:silverstripe-feedme,代码行数:29,代码来源:FeedSyncTask.php

示例2: testLogsError

 public function testLogsError()
 {
     $logger = new TestWorkableLogger();
     SS_Log::add_writer($logger);
     $result = Workable::create()->getJobs(['state' => 'fail']);
     $this->assertNotNull($logger->event);
     SS_Log::remove_writer($logger);
 }
开发者ID:silverstripe-labs,项目名称:workable,代码行数:8,代码来源:WorkableTest.php

示例3: setUp

 function setUp()
 {
     parent::setUp();
     SS_Log::clear_writers();
     // this test will break if existing writers are available!
     $this->testEmailWriter = new SS_LogEmailWriter('sean@silverstripe.com');
     $this->testFileWriter = new SS_LogFileWriter('../test.log');
     SS_Log::add_writer($this->testEmailWriter, SS_Log::ERR);
     SS_Log::add_writer($this->testFileWriter, SS_Log::WARN);
 }
开发者ID:SustainableCoastlines,项目名称:loveyourwater,代码行数:10,代码来源:LogTest.php

示例4: testEmailWriter

 function testEmailWriter()
 {
     $testEmailWriter = new SS_LogEmailWriter('test@test.com');
     SS_Log::add_writer($testEmailWriter, SS_Log::ERR);
     SS_Log::log('Email test', SS_LOG::ERR, array('my-string' => 'test', 'my-array' => array('one' => 1)));
     $this->assertEmailSent('test@test.com');
     $email = $this->findEmail('test@test.com');
     $parser = new CSSContentParser($email['htmlContent']);
     $extras = $parser->getBySelector('table.extras');
     $extraRows = $extras[0]->tr;
     $this->assertContains('my-string', $extraRows[count($extraRows) - 2]->td[0]->asXML(), 'Contains extra data key');
     $this->assertContains('test', $extraRows[count($extraRows) - 2]->td[1]->asXML(), 'Contains extra data value');
     $this->assertContains('my-array', $extraRows[count($extraRows) - 1]->td[0]->asXML(), 'Contains extra data key');
     $this->assertContains("array('one'=>1,)", str_replace(array("\r", "\n", " "), '', $extraRows[count($extraRows) - 1]->td[1]->asXML()), 'Serializes arrays correctly');
 }
开发者ID:nomidi,项目名称:sapphire,代码行数:15,代码来源:LogTest.php

示例5: defined

<?php

$raygunAPIKey = Config::inst()->get('RaygunLogWriter', 'api_key');
if (empty($raygunAPIKey) && defined('SS_RAYGUN_APP_KEY')) {
    $raygunAPIKey = SS_RAYGUN_APP_KEY;
}
if (!empty($raygunAPIKey)) {
    $raygun = Injector::inst()->create('RaygunLogWriter', $raygunAPIKey);
    $levelConfig = Config::inst()->get('RaygunLogWriter', 'level');
    $level = defined($levelConfig) ? constant($levelConfig) : SS_Log::WARN;
    SS_Log::add_writer($raygun, $level, '<=');
    register_shutdown_function(array($raygun, 'shutdown_function'));
} else {
    if (Director::isLive()) {
        user_error("SilverStripe RayGun module installed, but SS_RAYGUN_APP_KEY not defined in _ss_environment.php", E_USER_WARNING);
    }
}
开发者ID:helpfulrobot,项目名称:silverstripe-raygun,代码行数:17,代码来源:_config.php

示例6: ini_set

<?php

global $project;
$project = 'mysite';
global $database;
$database = 'bitnami_silverstripe';
ini_set('mysqli.default_socket', '/opt/bitnami/mysql/tmp/mysql.sock');
//Use _ss_environment.php file for configuration
require_once "conf/ConfigureFromEnv.php";
//Security::setDefaultAdmin('admin','password');
//SSL disabled because Chrome does not like unsigned cert
//Director::forceSSL(array('/^registration/', '/^Security/','/^admin/'));
SS_Log::add_writer(new SS_LogFileWriter('/home/scarola_gmail_com/logs/silverstripe/ss-notice.log'), SS_Log::NOTICE);
SS_Log::add_writer(new SS_LogFileWriter('/home/scarola_gmail_com/logs/silverstripe/ss-error.log'), SS_Log::ERR);
开发者ID:bscarola,项目名称:solslippers,代码行数:14,代码来源:_config.php

示例7: SS_LogSlackWriter

<?php

if (!Director::isDev()) {
    SS_Log::add_writer(new SS_LogSlackWriter(), SS_Log::WARN, '<=');
}
开发者ID:helpfulrobot,项目名称:plumpss-slacklogging,代码行数:5,代码来源:_config.php

示例8: SS_LogFileWriter

<?php

global $project;
$project = 'mysite';
global $database;
$database = 'nexthit';
require_once 'conf/ConfigureFromEnv.php';
// Set the site locale
i18n::set_locale('en_US');
// log errors and warnings
SS_Log::add_writer(new SS_LogFileWriter('../../' + $database + '-silverstripe-errors-warnings.log'), SS_Log::WARN, '<=');
// or just errors
SS_Log::add_writer(new SS_LogFileWriter('../../' + $database + '-silverstripe-errors.log'), SS_Log::ERR);
// or notices (e.g. for Deprecation Notifications)
SS_Log::add_writer(new SS_LogFileWriter('../../' + $database + '-silverstripe-errors-notices.log'), SS_Log::NOTICE);
开发者ID:swilsonalfa,项目名称:NextHitio,代码行数:15,代码来源:_config.php

示例9: run

 /**
  * Run the task, and do the business
  *
  * @param SS_HTTPRequest $httpRequest 
  */
 function run($httpRequest)
 {
     require_once 'Zend/Log/Writer/Stream.php';
     SS_Log::add_writer(new Zend_Log_Writer_Stream('php://output'), SS_Log::NOTICE);
     $db = DB::getConn();
     if (method_exists($db, 'supportsLocks') && $db->supportsLocks() && !$db->getLock('ScheduledPublishing')) {
         $this->log('Publication has already been triggered by a different process');
         return;
     }
     Cookie::$report_errors = false;
     if (class_exists('Subsite')) {
         Subsite::$disable_subsite_filter = true;
     }
     if (class_exists('Subsite')) {
         Subsite::$disable_subsite_filter = true;
     }
     $this->log('Looking for changes that need to be published');
     $bt = defined('DB::USE_ANSI_SQL') ? "\"" : "`";
     $wfRequests = DataObject::get('WorkflowRequest', "{$bt}Status{$bt} = 'Scheduled' AND {$bt}EmbargoDate{$bt} <= '" . SS_Datetime::now()->getValue() . "'");
     $this->log(sprintf('Found %d pages', $wfRequests ? count($wfRequests) : 0));
     $admin = Security::findAnAdministrator();
     $admin->logIn();
     if (count($wfRequests)) {
         foreach ($wfRequests as $request) {
             // Use a try block to prevent one bad request
             // taking down the whole queue
             try {
                 $page = $request->Page();
                 $this->log(sprintf("Attempting to publish '%s' (URL: %s)", $page->Title, $page->AbsoluteLink()));
                 // We remove the embargo date and republish to trigger this.
                 $request->EmbargoDate = null;
                 $result = $request->publish('Page was embargoed. Automatically published.', WorkflowSystemMember::get(), false);
                 $this->log(sprintf("Published '%s' (URL: %s)", $page->Title, $page->AbsoluteLink()));
             } catch (Exception $e) {
                 // Log it?
                 $this->log(sprintf("Failed to publish '%s (URL: %s)", $page->Title, $page->AbsoluteLink()));
                 user_error("Error publishing change to Page ID " . $request->PageID . " - " . $request->Page()->Title . " Error: " . $e->getMessage(), E_USER_WARNING);
                 continue;
             }
         }
     }
     $this->log('Looking for live pages that need to be expired');
     $pagesToExpire = Versioned::get_by_stage('SiteTree', 'Live', "\"ExpiryDate\" <= '" . SS_Datetime::now()->getValue() . "'");
     $this->log(sprintf('Found %d pages', $pagesToExpire ? count($pagesToExpire) : 0));
     if (count($pagesToExpire)) {
         foreach ($pagesToExpire as $page) {
             // Use a try block to prevent one bad request
             // taking down the whole queue
             try {
                 $this->log(sprintf("Attempting to unpublish '%s' (URL: %s)", $page->Title, $page->AbsoluteLink()));
                 // Close any existing workflows
                 if ($wf = $page->openWorkflowRequest()) {
                     $this->log(sprintf("Closing '%s' workflow request for '%s'", $wf->Status, $page->Title));
                     $wf->deny('Page automatically expired. Removing from Live site.', $admin);
                 }
                 $page->ExpiryDate = null;
                 $page->write();
                 $page->doUnpublish();
                 $this->log(sprintf("Unpublished '%s' (URL: %s)", $page->Title, $page->AbsoluteLink()));
             } catch (Exception $e) {
                 $this->log(sprintf("Failed to unpublish '%s' (URL: %s)", $page->Title, $page->AbsoluteLink()));
                 user_error("Error unpublishing Page ID " . $page->ID . " - " . $page->Title . " Error: " . $e->getMessage(), E_USER_WARNING);
                 continue;
             }
         }
     }
     // We don't need to clear the lock on every potential exception,
     // as the closing of the DB connection will do that for us.
     if (method_exists($db, 'supportsLocks') && $db->supportsLocks()) {
         $db->releaseLock('ScheduledPublishing');
     }
 }
开发者ID:helpfulrobot,项目名称:silverstripe-cmsworkflow,代码行数:77,代码来源:ScheduledPublishing.php

示例10: log_error_if_necessary

 /**
  * Log the given error, if self::$log_errors is set.
  * Uses the native error_log() funtion in PHP.
  * 
  * Format: [d-M-Y h:i:s] <type> at <file> line <line>: <errormessage> <url>
  * 
  * @todo Detect script path for CLI errors
  * @todo Log detailed errors to full file
  * @deprecated 2.5 See SS_Log on setting up error file logging
  */
 protected static function log_error_if_necessary($errno, $errstr, $errfile, $errline, $errcontext, $errtype)
 {
     Deprecation::notice('2.5', 'Use SS_Log instead. See the class documentation in SS_Log.php for more information.');
     $priority = $errtype == 'Error' ? SS_Log::ERR : SS_Log::WARN;
     $writer = new SS_LogFileWriter('../' . self::$log_errors_to);
     SS_Log::add_writer($writer, $priority);
     SS_Log::log(array('errno' => $errno, 'errstr' => $errstr, 'errfile' => $errfile, 'errline' => $errline, 'errcontext' => $errcontext), $priority);
     SS_Log::remove_writer($writer);
 }
开发者ID:nomidi,项目名称:sapphire,代码行数:19,代码来源:Debug.php

示例11: date_default_timezone_set

<?php

global $project;
$project = 'mysite';
global $database;
$database = 'silverstripe_webdevelopment_com';
require_once "conf/ConfigureFromEnv.php";
date_default_timezone_set('Pacific/Auckland');
//set cache to 72 hours
SS_Cache::set_cache_lifetime('any', 60 * 60 * 72);
if (Director::isLive()) {
    SS_Log::add_writer(new SS_LogEmailWriter('ssuerrors@gmail.com'), SS_Log::ERR);
} else {
    //BasicAuth::protect_entire_site(); see config.yml
}
HtmlEditorConfig::get('cms')->setOption('valid_styles', array('*' => 'color,font-weight,font-style,text-decoration'));
HtmlEditorConfig::get('cms')->setOption('paste_as_text', true);
HtmlEditorConfig::get('cms')->setOption('paste_text_sticky', true);
HtmlEditorConfig::get('cms')->setOption('paste_text_sticky_default', true);
开发者ID:sunnysideup,项目名称:mysite_ssu_flava,代码行数:19,代码来源:_config.php

示例12: define

<?php

// Get YML comfiguration settings
$config = Config::inst();
// use database name from config.yml unless defined in environment
if (!defined('SS_DATABASE_NAME')) {
    define('SS_DATABASE_NAME', $config->get('Database', 'name'));
}
// include configuration set in _ss_environment.php
require_once 'conf/ConfigureFromEnv.php';
FulltextSearchable::enable(array('SiteTree'));
if (Director::isDev()) {
    // Turn on all errors
    ini_set('display_errors', 1);
    ini_set("log_errors", 1);
    // error_reporting(E_ERROR | E_PARSE);
    // error_reporting(E_ALL && ~E_DEPRECATED);
    error_reporting(E_ALL | E_STRICT);
    SS_Log::add_writer(new SS_LogFileWriter(dirname(__FILE__) . '/errors.log'));
    // SSViewer::flush_template_cache();
    // Email::send_all_emails_to('?@platocreative.co.nz');
}
开发者ID:helpfulrobot,项目名称:plato-creative-plato-silverstripe-installer,代码行数:22,代码来源:_config.php

示例13: SS_LogFileWriter

<?php

require_once 'conf/ConfigureFromEnv.php';
// Set the site locale
i18n::set_locale('en_US');
// Extensions
DataObject::add_extension('SiteConfig', 'SiteConfigExtension');
// specify log files
$path = BASE_PATH . '/../logs';
SS_Log::add_writer(new SS_LogFileWriter($path . '/info.log'), SS_Log::WARN, '<=');
SS_Log::add_writer(new SS_LogFileWriter($path . '/errors.log'), SS_Log::ERR);
开发者ID:plasticstudio,项目名称:skeletor,代码行数:11,代码来源:_config.php

示例14: date_default_timezone_set

<?php

global $project;
$project = 'mysite';
global $database;
$database = 'somepainter';
require_once 'conf/ConfigureFromEnv.php';
// Set timezone
date_default_timezone_set('Australia/Melbourne');
// Set the site locale
i18n::set_locale('en_AU');
//Log notices
if (defined('MY_SS_ERROR_LOG')) {
    SS_Log::add_writer(new SS_LogFileWriter(MY_SS_ERROR_LOG), SS_Log::NOTICE, '<=');
}
// Configure Admin
CMSMenu::remove_menu_item('ReportAdmin');
CMSMenu::remove_menu_item('CMSPagesController');
CMSMenu::remove_menu_item('AssetAdmin');
CMSMenu::remove_menu_item('SecurityAdmin');
CMSMenu::remove_menu_item('CMSSettingsController');
// Configure cache
$liveCacheLife = 60 * 60;
// 60 minutes
$devCacheLife = -1;
// disabled
$cacheLife = Director::isDev() ? $devCacheLife : $liveCacheLife;
SS_Cache::set_cache_lifetime(EventsController::EVENTS_CACHE_NAME, $cacheLife, 100);
SS_Cache::set_cache_lifetime(EventsController::CONFIG_CACHE_NAME, $cacheLife, 100);
开发者ID:ehyland,项目名称:some-painter-cms,代码行数:29,代码来源:_config.php

示例15: define

<?php

define('SS_NR_BASE', basename(dirname(__FILE__)));
Config::inst()->update('NewRelicPerformanceReport', 'menu_icon', SS_NR_BASE . '/images/new-relic.png');
//Configure new relic monitoring
if (extension_loaded('newrelic')) {
    //Bind to the controller class
    Controller::add_extension('NewRelicControllerHook');
    //If we have an application name constant ensure New Relic knows what the name is
    if (defined('SS_NR_APPLICATION_NAME')) {
        newrelic_set_appname(SS_NR_APPLICATION_NAME);
    }
    //If we're in cli make sure New Relic is aware that we are
    if (Director::is_cli()) {
        newrelic_background_job(true);
    }
    //New Relic error binders
    if (Director::isLive() || defined('SS_NR_FORCE_ENABLE_LOGGING')) {
        SS_Log::add_writer(new NewRelicErrorLogger(), SS_Log::NOTICE);
        SS_Log::add_writer(new NewRelicErrorLogger(), SS_Log::WARN);
        SS_Log::add_writer(new NewRelicErrorLogger(), SS_Log::ERR);
    }
}
开发者ID:webbuilders-group,项目名称:silverstripe-new-relic,代码行数:23,代码来源:_config.php


注:本文中的SS_Log::add_writer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。