Skip to content

Commit

Permalink
[TASK] Merge code variants from different projects, set TYPO3 8 as re…
Browse files Browse the repository at this point in the history
…quirement, clean up code
  • Loading branch information
fsuter committed Aug 28, 2019
1 parent dc3c840 commit ff5bbbb
Show file tree
Hide file tree
Showing 8 changed files with 103 additions and 81 deletions.
59 changes: 35 additions & 24 deletions Classes/Log/Logger.php
Original file line number Diff line number Diff line change
@@ -1,18 +1,29 @@
<?php
namespace Cobweb\LogEntries\Log;

/**
* This file is part of the TYPO3 CMS project.
/***************************************************************
* Copyright notice
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
* (c) 2013 Julien Henchoz <[email protected]>
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
* All rights reserved
*
* The TYPO3 project - inspiring people to share!
*/
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/

use TYPO3\CMS\Core\Log\LogManager;
use TYPO3\CMS\Core\Utility\GeneralUtility;
Expand All @@ -30,7 +41,7 @@ class Logger
* @param string $message
* @return string
*/
static public function emergency($process, $message)
public static function emergency($process, $message)
{
/** @var \TYPO3\CMS\Core\Log\Logger $logger */
$logger = GeneralUtility::makeInstance(LogManager::class)->getLogger(__CLASS__);
Expand All @@ -42,98 +53,98 @@ static public function emergency($process, $message)

/**
* Sends a critical log to logentries
* @param string $process Process related to this log
* @param string $message
* @return string
*/
static public function critical($process, $message)
public static function critical($process, $message)
{
/** @var \TYPO3\CMS\Core\Log\Logger $logger */
$logger = GeneralUtility::makeInstance(LogManager::class)->getLogger(__CLASS__);
// Write to Log
$logger->critical($process . ' - ' . $message);
return $message;
}

/**
* Sends an alert log to logentries
* @param string $process Process related to this log
* @param string $message
* @return string
*/
static public function alert($process, $message)
public static function alert($process, $message)
{
/** @var \TYPO3\CMS\Core\Log\Logger $logger */
$logger = GeneralUtility::makeInstance(LogManager::class)->getLogger(__CLASS__);
// Write to Log
$logger->alert($process . ' - ' . $message);
return $message;
}

/**
* Sends an error log to logentries
* @param string $process Process related to this log
* @param string $message
* @return string
*/
static public function error($process, $message)
public static function error($process, $message)
{
/** @var \TYPO3\CMS\Core\Log\Logger $logger */
$logger = GeneralUtility::makeInstance(LogManager::class)->getLogger(__CLASS__);
// Write to Log
$logger->error($process . ' - ' . $message);
return $message;
}

/**
* Sends a warning log to logentries
* @param string $process Process related to this log
* @param string $message
* @return string
*/
static public function warning($process, $message)
public static function warning($process, $message)
{
/** @var \TYPO3\CMS\Core\Log\Logger $logger */
$logger = GeneralUtility::makeInstance(LogManager::class)->getLogger(__CLASS__);
// Write to Log
$logger->warning($process . ' - ' . $message);
return $message;
}

/**
* Sends a notice log to logentries
* @param string $process Process related to this log
* @param string $message
* @return string
*/
static public function notice($process, $message)
public static function notice($process, $message)
{
/** @var \TYPO3\CMS\Core\Log\Logger $logger */
$logger = GeneralUtility::makeInstance(LogManager::class)->getLogger(__CLASS__);
// Write to Log
$logger->notice($process . ' - ' . $message);
return $message;
}

/**
* Sends an info log to logentries
* @param string $process Process related to this log
* @param string $message
* @return string
*/
static public function info($process, $message)
public static function info($process, $message)
{
/** @var \TYPO3\CMS\Core\Log\Logger $logger */
$logger = GeneralUtility::makeInstance(LogManager::class)->getLogger(__CLASS__);
// Write to Log
$logger->info($process . ' - ' . $message);
return $message;
}

/**
* Sends a debug log to logentries
* @param string $process Process related to this log
* @param string $message
* @return string
*/
static public function debug($process, $message)
public static function debug($process, $message)
{
/** @var \TYPO3\CMS\Core\Log\Logger $logger */
$logger = GeneralUtility::makeInstance(LogManager::class)->getLogger(__CLASS__);
// Write to Log
$logger->debug($process . ' - ' . $message);
return $message;
}
Expand Down
31 changes: 22 additions & 9 deletions Classes/Log/Writer/LogEntries.php
Original file line number Diff line number Diff line change
@@ -1,25 +1,38 @@
<?php

namespace Cobweb\LogEntries\Log\Writer;

/**
* This file is part of the TYPO3 CMS project.
/***************************************************************
* Copyright notice
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
* (c) 2013 Julien Henchoz <[email protected]>
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
* All rights reserved
*
* The TYPO3 project - inspiring people to share!
*/
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/

use TYPO3\CMS\Core\Log\LogRecord;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;

/**
* Sends log messages to Logentries.com
*
*/
class LogEntries extends \TYPO3\CMS\Core\Log\Writer\AbstractWriter
{
Expand Down
15 changes: 7 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,13 @@ makes it possible to use it with the TYPO3 logging framework.
Example:

```
$GLOBALS['TYPO3_CONF_VARS']['LOG']['Cobweb']['LogEntries']['Log']['Logger'] = array(
'writerConfiguration' => array(
\TYPO3\CMS\Core\Log\LogLevel::DEBUG => array(
'Cobweb\\LogEntries\\Log\\Writer\\LogEntries' => array(
)
),
)
);
$GLOBALS['TYPO3_CONF_VARS']['LOG']['Cobweb']['LogEntries']['Log']['Logger'] = [
'writerConfiguration' => [
\TYPO3\CMS\Core\Log\LogLevel::DEBUG => [
'Cobweb\\LogEntries\\Log\\Writer\\LogEntries' => []
],
]
];
```
The extension also provides some static methods for quickly writing to
Logentries:
Expand Down
File renamed without changes
Binary file removed Resources/Public/Icons/relation.gif
Binary file not shown.
58 changes: 28 additions & 30 deletions ext_emconf.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,33 +10,31 @@
* "version" and "dependencies" must not be touched!
***************************************************************/

$EM_CONF[$_EXTKEY] = array(
'title' => 'LogEntries logger',
'description' => 'Provides a logger that sends data to LogEntries.com',
'category' => 'services',
'author' => 'Julien Henchoz',
'author_email' => '[email protected]',
'author_company' => 'Cobweb Development SARL',
'shy' => '',
'priority' => '',
'module' => '',
'state' => 'stable',
'internal' => '',
'uploadfolder' => '0',
'createDirs' => '',
'modify_tables' => '',
'clearCacheOnLoad' => 0,
'lockType' => '',
'version' => '1.1.0',
'constraints' => array(
'depends' => array(
'typo3' => '7.6.0-7.6.99',
),
'conflicts' => array(
),
'suggests' => array(
),
),
);

?>
$EM_CONF[$_EXTKEY] = [
'title' => 'LogEntries logger',
'description' => 'Provides a logger that sends data to LogEntries.com',
'category' => 'services',
'author' => 'Julien Henchoz',
'author_email' => '[email protected]',
'author_company' => 'Idéative',
'shy' => '',
'priority' => '',
'module' => '',
'state' => 'stable',
'internal' => '',
'uploadfolder' => '0',
'createDirs' => '',
'modify_tables' => '',
'clearCacheOnLoad' => 0,
'lockType' => '',
'version' => '1.1.0',
'constraints' => [
'depends' => [
'typo3' => '8.7.0-8.7.99',
],
'conflicts' => [
],
'suggests' => [
],
],
];
Binary file removed ext_icon.png
Binary file not shown.
21 changes: 11 additions & 10 deletions ext_localconf.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
<?php
if (!defined('TYPO3_MODE')) {
die ('Access denied.');
}

require_once(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('logentries') . '/Classes/Log/Logger.php');
require_once(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('logentries') . '/Classes/Log/Writer/LogEntries.php');

/**
* Define which logWriter to use for our logging class
*/
$GLOBALS['TYPO3_CONF_VARS']['LOG']['Cobweb']['LogEntries']['Log']['Logger'] = array(
'writerConfiguration' => array(
\TYPO3\CMS\Core\Log\LogLevel::DEBUG => array(
\Cobweb\LogEntries\Log\Writer\LogEntries::class => array()
),
)
);
$GLOBALS['TYPO3_CONF_VARS']['LOG']['Cobweb']['LogEntries']['Log']['Logger'] = [
'writerConfiguration' => [
\TYPO3\CMS\Core\Log\LogLevel::DEBUG => [
\Cobweb\LogEntries\Log\Writer\LogEntries::class => [
]
],
]
];

0 comments on commit ff5bbbb

Please sign in to comment.