Wrapper for old log_message

@param string $strMessage
@param string $strLogg
352683
public static function logMessage($strMessage, $strLog=null)
    {
        if ($strLog === null)
        {
            $strLog = 'prod-' . date('Y-m-d') . '.log';
        }
        else 
        {
            $strLog = 'prod-' . date('Y-m-d') . '-' . $strLog . '.log';
        }
        
        $strLogsDir = null;
        
        if (($container = \System::getContainer()) !== null)
        {
            $strLogsDir = $container->getParameter('kernel.logs_dir');
        }
        
        if (!$strLogsDir)
        {
            $strLogsDir = TL_ROOT . '/var/logs';
        }
        
        error_log(sprintf("[%s] %s\n", date('d-M-Y H:i:s'), $strMessage), 3, $strLogsDir . '/' . $strLog);
    }
85390
public function logIPNResponse($sLevel, $sMessage, $oIpnMessage = null)
    {
        if ((bool)$this->getConfig()->getConfigParam('blAmazonLogging') !== true) {
            return;
        }

        $aContext = ($oIpnMessage !== null) ? array('ipnMessage' => $oIpnMessage) : array();
        $this->_getLogger()->log($sLevel, $sMessage, $aContext);
    }
40549
static function write( $message, $logName = 'common.log', $dir = 'var/log' )
    {
        $fileName = $dir . '/' . $logName;
        $oldumask = @umask( 0 );

        $fileExisted = file_exists( $fileName );
        if ( $fileExisted and
             filesize( $fileName ) > eZLog::maxLogSize() )
        {
            if ( eZLog::rotateLog( $fileName ) )
                $fileExisted = false;
        }
        else if ( !$fileExisted and !file_exists( $dir ) )
        {
            eZDir::mkdir( $dir, false, true );
        }

        $logFile = @fopen( $fileName, "a" );
        if ( $logFile )
        {
            $time = strftime( "%b %d %Y %H:%M:%S", strtotime( "now" ) );
            $logMessage = "[ " . $time . " ] $message\n";
            @fwrite( $logFile, $logMessage );
            @fclose( $logFile );
            if ( !$fileExisted )
            {
                $ini = eZINI::instance();
                $permissions = octdec( $ini->variable( 'FileSettings', 'LogFilePermissions' ) );
                @chmod( $fileName, $permissions );
            }
            @umask( $oldumask );
        }
        else
        {
            eZDebug::writeError( 'Couldn\'t create the log file "' . $fileName . '"', __METHOD__ );
        }
    }
180284
static function log($msg,$path = "") {
    if(empty($path)){
      $path = MF_FILES_DIR;
    }

    if(!is_string($msg)){
      $msg = print_r($msg,true);
    }

    $fp = fopen($path.'magic_fields.log', 'a+');
    $date = gmdate( 'Y-m-d H:i:s' );
    fwrite($fp, "$date - $msg\n");
    fclose($fp);
   }
721396
function _append_log($protocol_flags, $message)
    {
        switch (NET_SSH1_LOGGING) {
            // useful for benchmarks
            case self::LOG_SIMPLE:
                $this->protocol_flags_log[] = $protocol_flags;
                break;
            // the most useful log for SSH1
            case self::LOG_COMPLEX:
                $this->protocol_flags_log[] = $protocol_flags;
                $this->_string_shift($message);
                $this->log_size+= strlen($message);
                $this->message_log[] = $message;
                while ($this->log_size > self::LOG_MAX_SIZE) {
                    $this->log_size-= strlen(array_shift($this->message_log));
                    array_shift($this->protocol_flags_log);
                }
                break;
            // dump the output out realtime; packets may be interspersed with non packets,
            // passwords won't be filtered out and select other packets may not be correctly
            // identified
            case self::LOG_REALTIME:
                echo "<pre>\r\n" . $this->_format_log(array($message), array($protocol_flags)) . "\r\n</pre>\r\n";
                @flush();
                @ob_flush();
                break;
            // basically the same thing as self::LOG_REALTIME with the caveat that self::LOG_REALTIME_FILE
            // needs to be defined and that the resultant log file will be capped out at self::LOG_MAX_SIZE.
            // the earliest part of the log file is denoted by the first <<< START >>> and is not going to necessarily
            // at the beginning of the file
            case self::LOG_REALTIME_FILE:
                if (!isset($this->realtime_log_file)) {
                    // PHP doesn't seem to like using constants in fopen()
                    $filename = self::LOG_REALTIME_FILE;
                    $fp = fopen($filename, 'w');
                    $this->realtime_log_file = $fp;
                }
                if (!is_resource($this->realtime_log_file)) {
                    break;
                }
                $entry = $this->_format_log(array($message), array($protocol_flags));
                if ($this->realtime_log_wrap) {
                    $temp = "<<< START >>>\r\n";
                    $entry.= $temp;
                    fseek($this->realtime_log_file, ftell($this->realtime_log_file) - strlen($temp));
                }
                $this->realtime_log_size+= strlen($entry);
                if ($this->realtime_log_size > self::LOG_MAX_SIZE) {
                    fseek($this->realtime_log_file, 0);
                    $this->realtime_log_size = strlen($entry);
                    $this->realtime_log_wrap = true;
                }
                fputs($this->realtime_log_file, $entry);
        }
    }
195510
protected void log(final String message) {
        if (stringLogger == null) {
            stringLogger = new StringPluginLogger("TASKS");
        }
        stringLogger.log(message);
    }
1234610
private function log($message)
    {
        if (!is_null($this->logger)) {
            $this->logger->log(
                LogLevel::DEBUG,
                sprintf("[%s] - %s", date('Y-m-d H:i:s'), $message)
            );
        }
    }
892805
public function log($message)
    {
        $formattedMessage = $this->formatMessage($message);
        if (!empty($formattedMessage)) {
            $this->logger->info($formattedMessage);
        }
    }
264283
private function logQuery($strQuery, $dblQueryTime)
    {
        if ($this->blnEnableProfiling) {
            // Dereference-ize Backtrace Information
            $objDebugBacktrace = debug_backtrace();

            // get rid of unnecessary backtrace info in case of:
            // query
            if ((count($objDebugBacktrace) > 3) &&
                (array_key_exists('function', $objDebugBacktrace[2])) &&
                (($objDebugBacktrace[2]['function'] == 'QueryArray') ||
                    ($objDebugBacktrace[2]['function'] == 'QuerySingle') ||
                    ($objDebugBacktrace[2]['function'] == 'QueryCount'))
            ) {
                $objBacktrace = $objDebugBacktrace[3];
            } else {
                if (isset($objDebugBacktrace[2])) // non query
                {
                    $objBacktrace = $objDebugBacktrace[2];
                } else // ad hoc query
                {
                    $objBacktrace = $objDebugBacktrace[1];
                }
            }

            // get rid of reference to current object in backtrace array
            if (isset($objBacktrace['object'])) {
                $objBacktrace['object'] = null;
            }

            for ($intIndex = 0, $intMax = count($objBacktrace['args']); $intIndex < $intMax; $intIndex++) {
                $obj = $objBacktrace['args'][$intIndex];

                if (is_null($obj)) {
                    $obj = 'null';
                } else {
                    if (gettype($obj) == 'integer') {
                    } else {
                        if (gettype($obj) == 'object') {
                            $obj = 'Object: ' . get_class($obj);
                            if (method_exists($obj, '__toString')) {
                                $obj .= '- ' . $obj;
                            }
                        } else {
                            if (is_array($obj)) {
                                $obj = 'Array';
                            } else {
                                $obj = sprintf("'%s'", $obj);
                            }
                        }
                    }
                }
                $objBacktrace['args'][$intIndex] = $obj;
            }

            // Push it onto the profiling information array
            $arrProfile = array(
                'objBacktrace' => $objBacktrace,
                'strQuery' => $strQuery,
                'dblTimeInfo' => $dblQueryTime
            );

            array_push($this->strProfileArray, $arrProfile);
        }
    }
185971
public final function log ($msg, $title = null)
    {
        if (is_null($title)) {
            $log = '  '.pack('c',0x1B)."[1m". $msg.pack('c',0x1B)."[0m".PHP_EOL;

        } else {
            $log = '  '.pack('c',0x1B)."[1;32m". $title.':'. pack('c',0x1B)."[0m".'  '.
                pack('c',0x1B)."[1m". $msg. pack('c',0x1B)."[0m".PHP_EOL;
        }

        echo $log;
    }
1234016
protected function log($message)
    {
        if ($this->log_handle == null) {
            $this->log_handle = fopen($this->config['logfile'], 'a');
        }
        fwrite($this->log_handle, $message);
    }
1094530
public function log($msg)
    {
        $agi = $this->getAgi();
        $this->logger->debug($msg);
        $agi->consoleLog($msg);
    }
579067
public function consoleLog(
        $msg,
        $enableTS = true,
        $fgColor = null,
        $returnLine = true,
        $padLength = false
    )
    {
        if ($enableTS) {
            $msg = '[' . date('Y-m-d H:i:s') . '] ' . $msg;
        }
        if ($padLength) {
            $msg = str_pad($msg, $padLength, '.', STR_PAD_RIGHT);
        }
        if ($returnLine) {
            $msg .= PHP_EOL;
        }
        $this->stdout($msg, $fgColor);
    }
276354
public static void log (String message, Object... args)
    {
        StringBuilder sb = new StringBuilder();
        sb.append(message);
        if (args.length > 1) {
            sb.append(" [");
            for (int ii = 0, ll = args.length/2; ii < ll; ii++) {
                if (ii > 0) {
                    sb.append(", ");
                }
                sb.append(args[2*ii]).append("=").append(args[2*ii+1]);
            }
            sb.append("]");
        }
        Object error = (args.length % 2 == 1) ? args[args.length-1] : null;
        if (GWT.isScript()) {
            if (error != null) {
                sb.append(": ").append(error);
            }
            firebugLog(sb.toString(), error);
        } else {
            GWT.log(sb.toString(), (Throwable)error);
        }
    }
978655
public static void log (@Nonnull final Logger aLogger,
                          @Nonnull final IHasErrorLevel aErrorLevelProvider,
                          @Nonnull final String sMsg)
  {
    log (aLogger, aErrorLevelProvider.getErrorLevel (), sMsg, null);
  }
714757
def my_log_message(verbose, prio, msg):
    
    syslog.syslog(prio, msg)
    if verbose or prio == syslog.LOG_ERR:
        sys.stderr.write("%s\n" % (msg))
656235
public String logMessage(String strTrxIDIn, BaseMessage trxMessage, String strMessageInfoType, String strMessageProcessType, String strMessageStatus, String strMessageDescription, String strMessageMimeType)
    {
        String strTrxID = strTrxIDIn;
        int iUserID = -1;
        String strContactType = null;
        String strContact = null;
        int iMessageReferenceID = -1;

        Task taskParent = this.getTask();
        Record recMessageLog = this.getRecord(MessageLog.MESSAGE_LOG_FILE);
        if (recMessageLog == null)
            recMessageLog = Record.makeRecordFromClassName(MessageLogModel.THICK_CLASS, this);
        try {
            if (strTrxID != null)
            {
                recMessageLog.getField(MessageLogModel.ID).setString(strTrxID);
                recMessageLog.setKeyArea(MessageLogModel.ID);
                if (recMessageLog.seek(null))
                {
                    recMessageLog.edit();
                }
                else
                    strTrxID = null;
            }
            if (strTrxID == null)
                recMessageLog.addNew();
            ReferenceField fldReference = (ReferenceField)recMessageLog.getField(MessageLogModel.MESSAGE_INFO_TYPE_ID);
            int iMessageInfoTypeID = fldReference.getIDFromCode(strMessageInfoType);
            fldReference.setValue(iMessageInfoTypeID);  // Message type
            fldReference = (ReferenceField)recMessageLog.getField(MessageLogModel.MESSAGE_TYPE_ID);
            int iMessageProcessTypeID = fldReference.getIDFromCode(strMessageProcessType);
            fldReference.setValue(iMessageProcessTypeID);  // Message type
            
            fldReference = (ReferenceField)recMessageLog.getField(MessageLogModel.MESSAGE_STATUS_ID);
            String objNativeMessage = null;
            if (objNativeMessage == null)
                if (trxMessage != null)
                    if (trxMessage.getExternalMessage() != null)
                        if (!MessageStatusModel.ERROR.equals(strMessageStatus))
                            objNativeMessage = trxMessage.getExternalMessage().toString();
            if (objNativeMessage == null)
                if (strMessageStatus == null)
                    strMessageStatus = MessageStatusModel.TRX_ID_HOLD;
            if (strMessageStatus == null)
                strMessageStatus = MessageStatusModel.UNKNOWN;
            int iMessageTimeout = 0;
            if (trxMessage != null)
                if (MessageStatusModel.SENT.equalsIgnoreCase(strMessageStatus))
                {
                    if ((trxMessage.getMessageHeader().get(TrxMessageHeader.MESSAGE_RESPONSE_ID) == null)
                        && (trxMessage.getMessageHeader().get(TrxMessageHeader.MESSAGE_RESPONSE_CODE) == null)
                        && (trxMessage.getMessageHeader().get(TrxMessageHeader.MESSAGE_RESPONSE_CLASS) == null))
                            strMessageStatus = MessageStatusModel.SENTOK;    // If I'm not expecting a response, status is sent okay.
                    else
                        if (trxMessage.getMessageHeader().get(TrxMessageHeader.MESSAGE_TIMEOUT) != null)
                        {
                            try {
                                iMessageTimeout = Integer.parseInt((String)trxMessage.getMessageHeader().get(TrxMessageHeader.MESSAGE_TIMEOUT));
                            } catch (NumberFormatException ex) {
                                iMessageTimeout = 0;
                            }
                        }
                }
            recMessageLog.getField(MessageLogModel.TIMEOUT_SECONDS).setValue(iMessageTimeout);
            if ((fldReference.isNull()) || (!MessageStatusModel.ERROR.equalsIgnoreCase(fldReference.getReference().getField(MessageStatusModel.CODE).toString())))
            {   // Can't change error status to something else
                int iMessageStatusID = fldReference.getIDFromCode(strMessageStatus);
                fldReference.setValue(iMessageStatusID);  // Message type
            }
            
            String strMessageTransport = this.getMessageTransportType();
            fldReference = (ReferenceField)recMessageLog.getField(MessageLogModel.MESSAGE_TRANSPORT_ID);
            int iMessageTransportID = fldReference.getIDFromCode(strMessageTransport);
            fldReference.setValue(iMessageTransportID);  // Message type
            
            String strReferenceType = null;
            int iMessageProcessInfoID = -1;

            if (!MessageStatusModel.ERROR.equals(strMessageStatus))
                if ((trxMessage != null) && (trxMessage.getMessageHeader() != null))
            {
                TrxMessageHeader trxMessageHeader = (TrxMessageHeader)trxMessage.getMessageHeader();
                if (strMessageDescription == null)
                    strMessageDescription = Utility.convertObjectToString(trxMessageHeader.get(TrxMessageHeader.DESCRIPTION));
                strContactType = Utility.convertObjectToString(trxMessageHeader.get(TrxMessageHeader.CONTACT_TYPE));
                if (strContactType != null)
                    if (strContactType.length() > 0)
                        if (!Utility.isNumeric(strContactType))
                {       // Convert the contact type from the record name to the ID.
                    Record recContactType = ((ReferenceField)recMessageLog.getField(MessageLogModel.CONTACT_TYPE_ID)).getReferenceRecord();
                    recContactType.setKeyArea(ContactTypeModel.CODE_KEY);
                    recContactType.getField(ContactTypeModel.CODE).setString(strContactType);
                    try {
                        if (recContactType.seek(null))
                        {   // Success
                            strContactType = recContactType.getField(ContactTypeModel.ID).toString();
                        }
                    } catch (DBException ex)    {
                        ex.printStackTrace();
                    }
                }
                strContact = Utility.convertObjectToString(trxMessageHeader.get(TrxMessageHeader.CONTACT_ID));
                Object objUserID = trxMessageHeader.get(DBParams.USER_ID);
                if (objUserID == null)
                    objUserID = trxMessageHeader.get(DBParams.USER_NAME);
                if (objUserID instanceof Integer)
                    iUserID = ((Integer)objUserID).intValue();
                else if (objUserID instanceof String)
                {
                    if (Utility.isNumeric((String)objUserID))
                        iUserID = Integer.parseInt((String)objUserID);
                    else
                    {
                        Record recUserInfo = Record.makeRecordFromClassName(UserInfoModel.THICK_CLASS, this);
                        if (((UserInfoModel)recUserInfo).getUserInfo((String)objUserID, false))
                            iUserID = (int)recUserInfo.getField(UserInfoModel.ID).getValue();
                        recUserInfo.free();
                    }
                }
                Object objMessageReferenceID = trxMessageHeader.get(TrxMessageHeader.REFERENCE_ID);
                if (objMessageReferenceID == null)
                	objMessageReferenceID = trxMessage.get(TrxMessageHeader.REFERENCE_ID);
                if (objMessageReferenceID instanceof Integer)
                    iMessageReferenceID = ((Integer)objMessageReferenceID).intValue();
                else if (objMessageReferenceID instanceof String)
                {
                    if (Utility.isNumeric((String)objMessageReferenceID))
                        iMessageReferenceID = Integer.parseInt((String)objMessageReferenceID);
                }
                if (trxMessageHeader.get(TrxMessageHeader.REFERENCE_TYPE) != null)
                	strReferenceType = (String)trxMessageHeader.get(TrxMessageHeader.REFERENCE_TYPE);
                if (strReferenceType == null)
                		strReferenceType = (String)trxMessage.get(TrxMessageHeader.REFERENCE_TYPE);
                if (trxMessageHeader.get(TrxMessageHeader.MESSAGE_PROCESS_INFO_ID) != null)
                {
                    Object objMessageProcessInfoID = trxMessageHeader.get(TrxMessageHeader.MESSAGE_PROCESS_INFO_ID);
                    if (objMessageProcessInfoID instanceof Integer)
                    	iMessageProcessInfoID = ((Integer)objMessageProcessInfoID).intValue();
                    else if (objMessageProcessInfoID instanceof String)
                    {
                        if (Utility.isNumeric((String)objMessageProcessInfoID))
                        	iMessageProcessInfoID = Integer.parseInt((String)objMessageProcessInfoID);
                    }
                }
            }

            if (iUserID != -1)
                recMessageLog.getField(MessageLogModel.USER_ID).setValue(iUserID);
            else if (taskParent != null)
                recMessageLog.getField(MessageLogModel.USER_ID).setString(((BaseApplication)taskParent.getApplication()).getUserID());

            if (strContactType != null)
                recMessageLog.getField(MessageLogModel.CONTACT_TYPE_ID).setString(strContactType);
            if (strContact != null)
                recMessageLog.getField(MessageLogModel.CONTACT_ID).setString(strContact);
            if (strMessageDescription != null)
                recMessageLog.getField(MessageLogModel.DESCRIPTION).setString(strMessageDescription);
            recMessageLog.getField(MessageLogModel.MESSAGE_TIME).setValue(DateTimeField.currentTime());
            if (iMessageProcessInfoID != -1)
                recMessageLog.getField(MessageLogModel.MESSAGE_PROCESS_INFO_ID).setValue(iMessageProcessInfoID);
            if (strReferenceType != null)
            	recMessageLog.getField(MessageLogModel.REFERENCE_TYPE).setString(strReferenceType);
            if (iMessageReferenceID != -1)
                recMessageLog.getField(MessageLogModel.REFERENCE_ID).setValue(iMessageReferenceID);
            if (strMessageInfoType != null)
                recMessageLog.getField(MessageLogModel.MESSAGE_DATA_TYPE).setString(strMessageInfoType);

            if (!MessageStatusModel.ERROR.equals(strMessageStatus))
                if (trxMessage != null)
            {
                recMessageLog.getField(MessageLogModel.MESSAGE_CLASS_NAME).setString(trxMessage.getClass().getName());
                if (trxMessage.getMessageHeader() != null)
                {
                    recMessageLog.getField(MessageLogModel.MESSAGE_HEADER_CLASS_NAME).setString(trxMessage.getMessageHeader().getClass().getName());
                    recMessageLog.getField(MessageLogModel.MESSAGE_QUEUE_NAME).setString(trxMessage.getMessageHeader().getQueueName());
                    recMessageLog.getField(MessageLogModel.MESSAGE_QUEUE_TYPE).setString(trxMessage.getMessageHeader().getQueueType());
                    Map<String,Object> propHeaderInfo = ((TrxMessageHeader)trxMessage.getMessageHeader()).getMessageInfoMap();
                    if (propHeaderInfo != null)
                        ((PropertiesField)recMessageLog.getField(MessageLogModel.MESSAGE_INFO_PROPERTIES)).setProperties(propHeaderInfo);
                    Map<String,Object> propMessageHeader = ((TrxMessageHeader)trxMessage.getMessageHeader()).getMessageHeaderMap();
                    if (propMessageHeader != null)
                        ((PropertiesField)recMessageLog.getField(MessageLogModel.MESSAGE_HEADER_PROPERTIES)).setProperties(propMessageHeader);
                    Map<String,Object> propHeaderTransport = ((TrxMessageHeader)trxMessage.getMessageHeader()).getMessageTransportMap();
                    if (propHeaderTransport != null)
                        ((PropertiesField)recMessageLog.getField(MessageLogModel.MESSAGE_TRANSPORT_PROPERTIES)).setProperties(propHeaderTransport);
                }
                String strMessage = trxMessage.getXML(false);
                recMessageLog.getField(MessageLogModel.XML_MESSAGE_DATA).setString(strMessage);
                if (trxMessage.getMessageDataDesc(null) != null)
                    recMessageLog.getField(MessageLogModel.MESSAGE_DATA_CLASS_NAME).setString(trxMessage.getMessageDataDesc(null).getClass().getName());
                if (trxMessage.getExternalMessage() != null)
                    recMessageLog.getField(MessageLogModel.EXTERNAL_MESSAGE_CLASS_NAME).setString(trxMessage.getExternalMessage().getClass().getName());
            }
            if (objNativeMessage != null)
                recMessageLog.getField(MessageLogModel.MESSAGE_DATA).setString(objNativeMessage.toString());

            if (MessageStatusModel.ERROR.equals(strMessageStatus))
                recMessageLog.getField(MessageLogModel.ERROR_TEXT).setString(strMessageDescription);

            if (strTrxID == null)
            {
                recMessageLog.add();
                strTrxID = recMessageLog.getLastModified(DBConstants.BOOKMARK_HANDLE).toString();
            }
            else
                recMessageLog.set();
            
        } catch (DBException ex)    {
            ex.printStackTrace();
            strTrxID = null;
        } finally {
            // No, leave it here!
            // recMessageLog.free();
        }
        
        if ((MessageStatusModel.TRX_ID_HOLD.equals(strMessageStatus)) || (strTrxIDIn == null))
            if (trxMessage != null)
                if (trxMessage.getMessageHeader() instanceof TrxMessageHeader)
                    ((TrxMessageHeader)trxMessage.getMessageHeader()).put(TrxMessageHeader.LOG_TRX_ID, strTrxID);

        return strTrxID;
    }