/** * Prepares use of logger. * * This method may be called to switch previous name of application. It * might be called at any time as it's preventing multiple preparations * internally. * * @param string $applicationName name of application to show in logs */ public static function prepare($applicationName = null) { if (!self::$prepared || $applicationName !== null && $applicationName !== self::$prepared) { openlog($applicationName !== null ? "TXF.{$applicationName}" : 'TXF', LOG_NDELAY + LOG_PID, LOG_USER); self::$prepared = $applicationName !== null ? $applicationName : true; } }
function __construct($_sFeaturePath, $_iPort = 16816) { openlog("cuke4php", LOG_PID, LOG_DAEMON); if (is_file($_sFeaturePath)) { $_sFeaturePath = dirname($_sFeaturePath); } if ($_iPort > 0) { $this->iPort = $_iPort; } else { $this->iPort = 16816; } foreach (self::rglob("*.php", 0, $_sFeaturePath . "/support") as $sFilename) { require_once $sFilename; } set_error_handler(array('PHPUnit_Util_ErrorHandler', 'handleError'), E_ALL | E_STRICT); require_once "Cucumber.php"; foreach (self::rglob("*.php", 0, $_sFeaturePath . "/step_definitions") as $sFilename) { require_once $sFilename; } $this->aStepClasses = CucumberSteps::getSubclasses(); foreach ($this->aStepClasses as $sClass) { $oReflection = new ReflectionClass($sClass); $aMethods = $oReflection->getMethods(); foreach ($aMethods as $oMethod) { $sComment = $oMethod->getDocComment(); $aMatches = array(); $aMethod = array(); $aMethod['method'] = $oMethod->name; $aMethod['class'] = $oMethod->class; $aMethod['filename'] = $oMethod->getFileName(); $aMethod['startline'] = $oMethod->getStartLine(); if (substr($oMethod->name, 0, 4) === "step") { preg_match("/(?:Given|When|Then) (.+)\$/im", $sComment, $aMatches); $aMethod['regexp'] = $aMatches[1]; $this->aWorld['steps'][] = $aMethod; continue; } preg_match("/(@.+)/im", $sComment, $aMatches); if (array_key_exists(1, $aMatches)) { $aMethod['tags'] = explode(" ", str_replace("@", "", $aMatches[1])); } else { $aMethod['tags'] = array(); } if (substr($oMethod->name, 0, 6) === "before") { $this->aWorld['before'][] = $aMethod; continue; } if (substr($oMethod->name, 0, 5) === "after") { $this->aWorld['after'][] = $aMethod; continue; } if (substr($oMethod->name, 0, 9) == "transform") { preg_match("/(?:Transform) (.+)\$/im", $sComment, $aMatches); $aMethod['regexp'] = $aMatches[1]; $this->aWorld['transform'][] = $aMethod; continue; } } } }
function __construct(array $params = array()) { if (isset($params['application'])) { $this->_appName = $params['application']; } openlog($this->_appName, LOG_PID, LOG_USER); }
/** * Constructor. * * @param array &$options Log object options. * * @since 11.1 */ public function __construct(array &$options) { // Call the parent constructor. parent::__construct($options); // Ensure that we have an identity string for the Syslog entries. if (empty($this->options['sys_ident'])) { $this->options['sys_ident'] = 'Joomla Platform'; } // If the option to add the process id to Syslog entries is set use it, otherwise default to true. if (isset($this->options['sys_add_pid'])) { $this->options['sys_add_pid'] = (bool) $this->options['sys_add_pid']; } else { $this->options['sys_add_pid'] = true; } // If the option to also send Syslog entries to STDERR is set use it, otherwise default to false. if (isset($this->options['sys_use_stderr'])) { $this->options['sys_use_stderr'] = (bool) $this->options['sys_use_stderr']; } else { $this->options['sys_use_stderr'] = false; } // Build the Syslog options from our log object options. $sysOptions = 0; if ($this->options['sys_add_pid']) { $sysOptions = $sysOptions | LOG_PID; } if ($this->options['sys_use_stderr']) { $sysOptions = $sysOptions | LOG_PERROR; } // Open the Syslog connection. openlog((string) $this->options['sys_ident'], $sysOptions, LOG_USER); }
public function write(string $level, string $message) { $l = LOG_INFO; $message = $this->interpolate($level, $message); switch ($level) { case 'emergency': case 'alert': case 'critical': case 'error': case 'warning': $l = LOG_WARNING; break; case 'notice': $l = LOG_NOTICE; break; case 'debug': $l = LOG_DEBUG; break; default: break; } if (\openlog($this->ident, LOG_PID, LOG_USER)) { \syslog($l, $message); } }
/** * Opens a connection to the system logger, if it has not already * been opened. This is implicitly called by log(), if necessary. * @access public */ function open() { if (!$this->_opened) { $this->_opened = openlog($this->_ident, LOG_PID, $this->_name); } return $this->_opened; }
function __construct($name = 'ykval') { $this->name = $name; $this->fields = array(); $this->LOG_LEVELS = array(LOG_EMERG => 'LOG_EMERG', LOG_ALERT => 'LOG_ALERT', LOG_CRIT => 'LOG_CRIT', LOG_ERR => 'LOG_ERR', LOG_WARNING => 'LOG_WARNING', LOG_NOTICE => 'LOG_NOTICE', LOG_INFO => 'LOG_INFO', LOG_DEBUG => 'LOG_DEBUG'); openlog("ykval", LOG_PID, LOG_LOCAL0); }
/** * Write a log message to the log socket. * * @param int $priority The priority. * @param string $message The message. * @param string $ident Defaults to the ident set via setIdent() * @param int $date Timestamp for log message. Defaults to now. * * @return \YapepBase\Syslog\LegacySyslogConnection * * @throws \YapepBase\Exception\SyslogException on error * @throws \YapepBase\Exception\NotImplementedException if the date is set, because this implementation * doesn't support it. */ public function log($priority, $message, $ident = null, $date = null) { $this->validatePriority($priority); $this->validateIdent($ident); if (!\is_null($date)) { throw new NotImplementedException('PHP\'s internal syslog functions don\'t support passing the date'); } if (!is_string($ident)) { $ident = $this->ident; } if (!openlog($ident, $this->options, $this->facility)) { throw new SyslogException('openlog() failed'); } else { if (!syslog($priority, $message)) { $e = new SyslogException('syslog() failed'); } if (!closelog()) { if (isset($e)) { throw new SyslogException('syslog() and closelog() failed'); } else { throw new SyslogException('closelog() failed'); } } elseif (isset($e)) { throw $e; } } return $this; }
function processData() { $flag = false; $firstName = $_POST['firstname']; if (strlen($firstName) == 0) { $flag = true; } $lastName = $_POST['lastname']; if (strlen($lastName) == 0) { $flag = true; } $emailAddress = $_POST['emailaddress']; if (strlen($emailAddress) == 0) { $flag = true; } if ($flag == false) { openlog('php', LOG_CONS | LOG_NDELAY | LOG_PID, LOG_USER | LOG_PERROR); syslog(LOG_ERR, 'Error!'); syslog(LOG_INFO, "{$firstName} {$lastName} {$emailAddress}"); closelog(); echo "<style type='text/css'>#formContainer{display:none;}</style>"; echo "\n\t\t\t\t\t\t\t\t\t\t<h3 class='FormLabel'>SUCCESS!</h3>\n\t\t\t\t\t\t\t\t\t\tThank you for creating an account {$firstName} {$lastName}!\n\t\t\t\t\t\t\t\t\t\tA confirmation email has been sent to {$emailAddress}.\n\t\t\t\t\t\t\t\t\t\tOnce you receive this email please follow the instructions\n\t\t\t\t\t\t\t\t\t\tprovided to active your new account.\n\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t<h6>This page will refresh in 10 seconds...</h6>\n\t\t\t\t\t\t\t\t\t"; header("refresh:10;url=index.php"); } }
public static function init($ident, $facility) { if (!defined('PHP_WINDOWS_VERSION_BUILD')) { self::$facilities['local0'] = LOG_LOCAL0; self::$facilities['local1'] = LOG_LOCAL1; self::$facilities['local2'] = LOG_LOCAL2; self::$facilities['local3'] = LOG_LOCAL3; self::$facilities['local4'] = LOG_LOCAL4; self::$facilities['local5'] = LOG_LOCAL5; self::$facilities['local6'] = LOG_LOCAL6; self::$facilities['local7'] = LOG_LOCAL7; } if (array_key_exists(strtolower($facility), self::$facilities)) { $facility = self::$facilities[strtolower($facility)]; } elseif (!in_array($facility, array_values(self::$facilities), true)) { throw new \UnexpectedValueException('Unknown facility value "' . $facility . '"'); } return function ($info) use($ident, $facility) { if (!openlog($ident, LOG_PID, $facility)) { throw new \LogicException('Can\'t open syslog for ident "' . $ident . '" and facility "' . $facility . '"'); } syslog(Syslog::$levels[$info['level']], vsprintf('%1$s: %4$s', $info)); closelog(); }; }
function logMessage($type, $level, $message) { global $debug; global $use_syslog; if ($use_syslog) { define_syslog_variables(); if ($debug) { } if ($level == 0) { $s_level = LOG_ERR; } else { if ($level == 1) { $s_level = LOG_WARNING; } else { if ($level == 2) { $s_level = LOG_INFO; } else { if ($level == 3) { $s_level = LOG_DEBUG; } else { $s_level = LOG_ERR; } } } } $s_message = $type . " " . $message; openlog("restbot", LOG_PID, LOG_DAEMON); syslog($s_level, $s_message); closelog(); } }
function _log($text) { _trace($text); openlog("alarm", LOG_PID | LOG_PERROR, LOG_LOCAL0); syslog(LOG_DEBUG, var_export($text)); closelog(); }
/** * class constructor opens syslog with passed log ident and options * * @error 12101 * @param string $ident expects log identifier * @param int $facility expects optional bitmasked values * @throws Xapp_Log_Writer_Exception */ public function __construct($ident = 'Xapp', $facility = LOG_USER) { $this->_ident = trim((string) $ident); if (!openlog($this->_ident, LOG_CONS, $facility)) { throw new Xapp_Log_Writer_Exception(_("unable to open sys log with passed parameters"), 1210101); } }
public function __construct() { $this->config = \Jelix\Core\App::config()->syslogLogger; $this->catSyslog = array('error' => LOG_ERR, 'warning' => LOG_WARNING, 'notice' => LOG_NOTICE, 'deprecated' => LOG_NOTICE, 'strict' => LOG_NOTICE, 'debug' => LOG_DEBUG); $ident = strtr($this->config['ident'], array('%sapi%' => php_sapi_name(), '%domain%' => \Jelix\Core\App::config()->domainName, '%pid%' => getmypid())); openlog($ident, LOG_ODELAY | LOG_PERROR, $this->config['facility']); }
public function writeLog($message = null, $code = null) { if (empty($this->message) && empty($message)) { return; } else { $this->message = $message; } if (empty($this->code) && empty($code)) { $this->code = 0; } else { $this->code = $code; } if (openlog(LoggingConfig::LOG_IDENT, LOG_PID | LOG_CONS, LoggingConfig::LOG_FACILITY) === true) { $entries = explode("\n", $this->message); foreach ($entries as $entry) { syslog(LOG_INFO, sprintf("(%s) [%s] %s %s %s - %s", $this->ip, $this->user, strtoupper($this->method), $this->code, $this->uri, $entry)); } if (LoggingConfig::LOG_DEBUG == true && !empty($this->input) && $this->input != "null") { syslog(LOG_DEBUG, sprintf("(%s) [%s] Input: %s", $this->ip, $this->user, $this->input)); } if (LoggingConfig::LOG_DEBUG == true && !empty($this->output) && $this->output != "null") { syslog(LOG_DEBUG, sprintf("(%s) [%s] Output: %s", $this->ip, $this->user, $this->output)); } closelog(); } else { trigger_error("Could not open syslog facility", E_USER_ERROR); } }
public function log() { $argsNum = func_num_args(); if ($argsNum < 2) { return false; } $args = func_get_args(); $priority = $args[0]; $message = $args[1]; if ($priority > $this->allowPriority) { return false; } $priorityName = $this->getLevelName($priority); $strLog = ''; if ($priorityName) { $strLog = "[{$priorityName}]"; } $strLog .= "{$message}"; for ($i = 2; $i < $argsNum; $i++) { $strLog .= $args[$i]; } openlog('SPF', LOG_PID, LOG_USER); syslog($priority, $strLog); closelog(); }
/** * {@inheritdoc} */ protected function write(array $record) { if (!openlog($this->ident, $this->logopts, $this->facility)) { throw new \LogicException('Can\'t open syslog for ident "' . $this->ident . '" and facility "' . $this->facility . '"'); } syslog($this->logLevels[$record['level']], (string) $record['formatted']); }
public static function write($stack) { if (self::$isOpen === false) { $default = array('ident' => 'PhotonApp', 'facility' => LOG_USER, 'option' => LOG_CONS | LOG_NDELAY | LOG_PID); $conf = Conf::f('log_syslog', $default); $conf = array_merge($default, $conf); // Windows can log only in LOG_USER if (substr(PHP_OS, 0, 3) === 'WIN') { $conf['facility'] = LOG_USER; } $rc = openlog($conf['ident'], $conf['option'], $conf['facility']); if ($rc === true) { self::$isOpen = true; } } foreach ($stack as $elt) { $level = self::$photon2syslog[$elt[1]]; if (is_array($elt[2]) || is_object($elt[2])) { $msg = json_encode($elt[2]); } else { $msg = $elt[2]; } syslog($level, $msg); } return false; }
/** * @see \Components\Log_Appender_Abstract::initialize() initialize */ public function initialize() { if (false === $this->m_initialized) { parent::initialize(); openlog($this->name, $this->options, $this->facility); } }
function LogInfo($msg) { global $argv; openlog($argv[0], LOG_PID, LOG_USER); syslog(LOG_INFO, $msg); closelog(); }
public function __construct($passthru = false, $ajax = false) { date_default_timezone_set('EST'); if ($ajax) { $this->ajax = true; } $this->passthru = $passthru; error_reporting(E_ERROR | E_WARNING | E_PARSE); openlog(config::APP_NAMESPACE, 0, LOG_LOCAL0); $this->logFile = fopen(config::LOG_FILE, "a+"); $this->initDB(); // Bring up the database connection $this->initMemcache(); $this->validateSession(); // Session startup and login validator $this->escapeVars(); // Sanitation $this->htmlData = base::init(); if (!$passthru) { $this->buildUserObject(); } // Build User Object if ($this->getSetting('stripe_private')) { Stripe::setApiKey($this->getSetting('stripe_private')); } }
/** * Opens a connection to the system logger, if it has not already * been opened. This is implicitly called by log(), if necessary. * @access public */ function open() { if (!$this->_opened) { openlog($this->_ident, LOG_PID, $this->_name); $this->_opened = true; } }
/** * Constructs a new syslog writer with the identity $ident, options $option * and the facility $facility. * * The identity will be prepended to each log message in the syslog. * * The $option argument is used to indicate what logging options will be used * when generating a log message. See * {@link syslog() syslog} for more information on valid values for $option. * The default options are LOG_PID and LOG_ODELAY. * * The $facility argument is used to specify what type of program is logging * the message. This allows you to specify (in your machine's syslog configuration) * how messages coming from different facilities will be handled. See * {@link syslog() syslog} for more information on valid values for $facility. * * @param string $ident * @param int $option * @param int $facility */ public function __construct($ident, $option = null, $facility = LOG_USER) { if ($option == null) { $option = LOG_PID | LOG_ODELAY; } openlog($ident, $option, $facility); }
/** * Creates a new syslog logger. * * @see http://us2.php.net/openlog * * @param string syslog identifier * @param int facility to log to * @return void */ public function __construct($ident = 'KohanaPHP', $facility = LOG_USER) { $this->_ident = $ident; // Open the connection to syslog openlog($this->_ident, LOG_CONS, $facility); }
/** * @param string $ident * @param mixed $facility * @param integer $level The minimum logging level at which this handler will be triggered * @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not */ public function __construct($ident, $facility = LOG_USER, $level = Logger::DEBUG, $bubble = true) { parent::__construct($level, $bubble); if (false === strpos(PHP_OS, 'WIN')) { $this->facilities['local0'] = LOG_LOCAL0; $this->facilities['local1'] = LOG_LOCAL1; $this->facilities['local2'] = LOG_LOCAL2; $this->facilities['local3'] = LOG_LOCAL3; $this->facilities['local4'] = LOG_LOCAL4; $this->facilities['local5'] = LOG_LOCAL5; $this->facilities['local6'] = LOG_LOCAL6; $this->facilities['local7'] = LOG_LOCAL7; } // convert textual description of facility to syslog constant if (array_key_exists(strtolower($facility), $this->facilities)) { $facility = $this->facilities[strtolower($facility)]; } else { if (!in_array($facility, array_values($this->facilities), true)) { throw new \UnexpectedValueException('Unknown facility value "' . $facility . '" given'); } } if (!openlog($ident, LOG_PID, $facility)) { throw new \LogicException('Can\'t open syslog for ident "' . $ident . '" and facility "' . $facility . '"'); } }
function Debuglogs($text = null, $function = null, $line = null) { if (!$GLOBALS["DEBUG"]) { return; } if ($text == null) { return; } $linetext = null; if ($function == null) { if (function_exists("debug_backtrace")) { $trace = @debug_backtrace(); } if (is_array($trace)) { $filename = basename($trace[1]["file"]); $function = $trace[1]["function"]; $line = $trace[1]["line"]; } } $linetext = $text; if ($function != null) { $linetext = "{$function}/{$line} {$linetext}"; } else { if ($line != null) { $linetext = "{$line} {$linetext}"; } } if (function_exists("syslog")) { $LOG_SEV = LOG_INFO; openlog("error_page", LOG_PID, LOG_SYSLOG); syslog($LOG_SEV, $linetext); closelog(); } }
/** * Constructor * * @access public */ function OCS_Log() { // adapted from CI's Log.php $config =& get_config(); if (is_numeric($config['log_threshold'])) { $this->_threshold = $config['log_threshold']; } if ($config['log_date_format'] != '') { $this->_date_fmt = $config['log_date_format']; } if (isset($config['log_backtrace_func'])) { $this->_backtrace_func = $config['log_backtrace_func']; } if (isset($config['log_backtrace_line'])) { $this->_backtrace_line = $config['log_backtrace_line']; } if (isset($config['log_use_syslog'])) { $this->_use_syslog = $config['log_use_syslog']; } if (isset($config['log_syslog_facility'])) { $this->_syslog_facility = $config['log_syslog_facility']; } if ($this->_use_syslog === TRUE) { if (!openlog("ocs", LOG_PID, $this->_syslog_facility)) { $this->_enable = FALSE; } } else { $this->log_path = $config['log_path'] != '' ? $config['log_path'] : BASEPATH . 'logs/'; if (!is_dir($this->log_path) or !is_really_writable($this->log_path)) { $this->_enabled = FALSE; } } }
/** * Open log file for append, and flush out buffered messages to the file. */ public function open() { $this->fileHandle = openlog($this->signature, LOG_ODELAY | LOG_PID, LOG_LOCAL0); if ($this->fileHandle !== false && count($this->stack)) { $this->stackFlush(); } }
public function write($uuid, $appName, $timestamp, $arguments) { openlog('WebSessionProfiler', LOG_PID, $this->_facility); $msg = array('wspid' => $uuid, 'appName' => $appName, 'timestamp' => $timestamp, 'message' => json_encode($arguments)); $msg = json_encode($msg); syslog($this->_priority, $msg); }
/** * $this->_write( int $level ) * @param int $level - log level * @return void * @access public */ public function write($level) { openlog($this->ident, $this->openlog_opt, $this->facility) or die(ERROR_CANT_OPEN_SYSLOG); $this->to_string(&$this->last_log); syslog(self::$id2syslog[$level], $this->last_log) or die(ERROR_CANT_WRITE_SYSLOG); closelog() or die(ERROR_CANT_CLOSE_SYSLOG); }