diff --git a/.gitignore b/.gitignore index 467bfdd..2f8fa27 100644 --- a/.gitignore +++ b/.gitignore @@ -9,13 +9,12 @@ discord-* # output files **nowplaying.txt +analyze.db # Usually copy this file from config.php-default config.php # Demo files -SSL/Plugins/NowPlaying/SevenDigital.key -template.html Demo # XOUP compiled files diff --git a/External/getID3/getid3.lib.php b/External/getID3/getid3.lib.php index 5ba9b16..ba7a8e6 100644 --- a/External/getID3/getid3.lib.php +++ b/External/getID3/getid3.lib.php @@ -11,6 +11,13 @@ // /// ///////////////////////////////////////////////////////////////// +if(!defined('GETID3_LIBXML_OPTIONS') && defined('LIBXML_VERSION')) { + if(LIBXML_VERSION >= 20621) { + define('GETID3_LIBXML_OPTIONS', LIBXML_NOENT | LIBXML_NONET | LIBXML_NOWARNING | LIBXML_COMPACT); + } else { + define('GETID3_LIBXML_OPTIONS', LIBXML_NOENT | LIBXML_NONET | LIBXML_NOWARNING); + } +} class getid3_lib { @@ -731,7 +738,7 @@ public static function XML2array($XMLstring) { // This function has been deprecated in PHP 8.0 because in libxml 2.9.0, external entity loading is // disabled by default, but is still needed when LIBXML_NOENT is used. $loader = @libxml_disable_entity_loader(true); - $XMLobject = simplexml_load_string($XMLstring, 'SimpleXMLElement', LIBXML_NOENT); + $XMLobject = simplexml_load_string($XMLstring, 'SimpleXMLElement', GETID3_LIBXML_OPTIONS); $return = self::SimpleXMLelement2array($XMLobject); @libxml_disable_entity_loader($loader); return $return; diff --git a/External/getID3/getid3.php b/External/getID3/getid3.php index 9bc1988..17dbdbb 100644 --- a/External/getID3/getid3.php +++ b/External/getID3/getid3.php @@ -182,7 +182,7 @@ class getID3 public $option_md5_data = false; /** - * Use MD5 of source file if availble - only FLAC and OptimFROG + * Use MD5 of source file if available - only FLAC and OptimFROG * * @var bool */ @@ -387,7 +387,7 @@ class getID3 */ protected $startup_warning = ''; - const VERSION = '1.9.21-202112151109'; + const VERSION = '1.9.21-202204141319'; const FREAD_BUFFER_SIZE = 32768; const ATTACHMENTS_NONE = false; @@ -568,7 +568,7 @@ public function openfile($filename, $filesize=null, $fp=null) { $this->info['php_memory_limit'] = (($this->memory_limit > 0) ? $this->memory_limit : false); // remote files not supported - if (preg_match('#^(ht|f)tp://#', $filename)) { + if (preg_match('#^(ht|f)tps?://#', $filename)) { throw new getid3_exception('Remote files are not supported - please copy the file locally first'); } @@ -1054,15 +1054,16 @@ public function GetFileFormatArray() { 'mime_type' => 'audio/x-monkeys-audio', ), -// has been known to produce false matches in random files (e.g. JPEGs), leave out until more precise matching available -// // MOD - audio - MODule (assorted sub-formats) -// 'mod' => array( -// 'pattern' => '^.{1080}(M\\.K\\.|M!K!|FLT4|FLT8|[5-9]CHN|[1-3][0-9]CH)', -// 'group' => 'audio', -// 'module' => 'mod', -// 'option' => 'mod', -// 'mime_type' => 'audio/mod', -// ), + + // MOD - audio - MODule (SoundTracker) + 'mod' => array( + //'pattern' => '^.{1080}(M\\.K\\.|M!K!|FLT4|FLT8|[5-9]CHN|[1-3][0-9]CH)', // has been known to produce false matches in random files (e.g. JPEGs), leave out until more precise matching available + 'pattern' => '^.{1080}(M\\.K\\.)', + 'group' => 'audio', + 'module' => 'mod', + 'option' => 'mod', + 'mime_type' => 'audio/mod', + ), // MOD - audio - MODule (Impulse Tracker) 'it' => array( diff --git a/External/getID3/module.audio.mp3.php b/External/getID3/module.audio.mp3.php index 992124f..3d8a944 100644 --- a/External/getID3/module.audio.mp3.php +++ b/External/getID3/module.audio.mp3.php @@ -315,6 +315,10 @@ public function GuessEncoderOptions() { $encoder_options .= ' -b'.$thisfile_mpeg_audio_lame['bitrate_min']; } + if (isset($thisfile_mpeg_audio['bitrate']) && $thisfile_mpeg_audio['bitrate'] === 'free') { + $encoder_options .= ' --freeformat'; + } + if (!empty($thisfile_mpeg_audio_lame['encoding_flags']['nogap_prev']) || !empty($thisfile_mpeg_audio_lame['encoding_flags']['nogap_next'])) { $encoder_options .= ' --nogap'; } @@ -750,7 +754,8 @@ public function decodeMPEGaudioHeader($offset, &$info, $recursivesearch=true, $S unset($thisfile_mpeg_audio_lame['long_version']); // It the LAME tag was only introduced in LAME v3.90 - // http://www.hydrogenaudio.org/?act=ST&f=15&t=9933 + // https://wiki.hydrogenaud.io/index.php/LAME#VBR_header_and_LAME_tag + // https://hydrogenaud.io/index.php?topic=9933 // Offsets of various bytes in http://gabriel.mp3-tech.org/mp3infotag.html // are assuming a 'Xing' identifier offset of 0x24, which is the case for @@ -786,7 +791,7 @@ public function decodeMPEGaudioHeader($offset, &$info, $recursivesearch=true, $S $thisfile_mpeg_audio_lame['lowpass_frequency'] = getid3_lib::BigEndian2Int(substr($headerstring, $LAMEtagOffsetContant + 0xA6, 1)) * 100; // bytes $A7-$AE Replay Gain - // http://privatewww.essex.ac.uk/~djmrob/replaygain/rg_data_format.html + // https://web.archive.org/web/20021015212753/http://privatewww.essex.ac.uk/~djmrob/replaygain/rg_data_format.html // bytes $A7-$AA : 32 bit floating point "Peak signal amplitude" if ($thisfile_mpeg_audio_lame['short_version'] >= 'LAME3.94b') { // LAME 3.94a16 and later - 9.23 fixed point @@ -914,7 +919,7 @@ public function decodeMPEGaudioHeader($offset, &$info, $recursivesearch=true, $S // LAME CBR - if ($thisfile_mpeg_audio_lame_raw['vbr_method'] == 1) { + if ($thisfile_mpeg_audio_lame_raw['vbr_method'] == 1 && $thisfile_mpeg_audio['bitrate'] !== 'free') { $thisfile_mpeg_audio['bitrate_mode'] = 'cbr'; $thisfile_mpeg_audio['bitrate'] = self::ClosestStandardMP3Bitrate($thisfile_mpeg_audio['bitrate']); diff --git a/SSL/Factories/TitleFilteredSSLRepo.php b/SSL/Factories/TitleFilteredSSLRepo.php index e094ab7..63bd824 100644 --- a/SSL/Factories/TitleFilteredSSLRepo.php +++ b/SSL/Factories/TitleFilteredSSLRepo.php @@ -33,4 +33,4 @@ public function newRuntimeCachingTrack($cache) { return new TitleFilteredRuntimeCachingSSLTrack($cache); } -} \ No newline at end of file +} diff --git a/SSL/HistoryAnalyzer.php b/SSL/HistoryAnalyzer.php index e7774b7..e293cff 100644 --- a/SSL/HistoryAnalyzer.php +++ b/SSL/HistoryAnalyzer.php @@ -24,44 +24,14 @@ * THE SOFTWARE. */ -class HistoryAnalyzer +class HistoryAnalyzer extends HistoryReader { - // command line switches - protected $verbosity = L::INFO; - - protected $plugins = array(); - protected $override_verbosity = array(); - - protected $appname; - protected $filename; - protected $historydir; - protected $log_file; - protected $help; - protected $db = 'analyze.db'; - + /** * @var SQLite3 */ protected $dbo; - - /** - * @var Logger - */ - protected $logger; - - /** - * Takes an array of class names => log levels. Mainly - * you can use this to shut certain classes up that are too noisy - * at a particular log level, e.g. TickSource (which normally - * sends a L::DEBUG message every 2 seconds). - * - * @param array $override - */ - public function setVerbosityOverride(array $override) - { - $this->override_verbosity = $override; - } /** * The main entry point to the application. Start here! @@ -77,7 +47,12 @@ public function main($argc, array $argv) try { + // do this now so that we can still use defailt logging during parsing options + $this->setupLogging(); + $this->parseOptions($argv); + + // do it again, as parsing options may have altered the logging setup $this->setupLogging(); // guess history file (always go for the most recently modified) @@ -92,7 +67,6 @@ public function main($argc, array $argv) $this->dbo = new SQLite3($this->db); $this->initializeDb(); - $this->analyzeDir($this->historydir); } @@ -107,46 +81,21 @@ public function main($argc, array $argv) } } - public function usage($appname, array $argv) + public function usage($appname, array $arg, $debug_help = false, $plugin_help = false) { echo "Usage: {$appname} [OPTIONS] [session file]\n"; echo "Session file is optional. If omitted, the most recent history file from {$this->historydir} will be used automatically\n"; echo " -h or --help: This message.\n"; echo "\n"; - foreach($this->plugins as $plugin) + foreach($this->cli_plugins as $plugin) { + /* @var $plugin CLIPlugin */ $plugin->usage($appname, $argv); } echo "Debugging options:\n"; echo " -v or --verbosity <0-9>: How much logging to output. (default: 0 (none))\n"; } - protected function getDefaultHistoryDir() - { - // OSX - $dir = getenv('HOME') . '/Music/ScratchLIVE/History/Sessions'; - if(is_dir($dir)) return $dir; - - $dir = getenv('HOME') . '/Music/_Serato_/History/Sessions'; - if(is_dir($dir)) return $dir; - - // Windows Vista / Windows 7 ? - $dir = getenv('USERPROFILE') . '\Music\ScratchLIVE\History\Sessions'; - if(is_dir($dir)) return $dir; - - $dir = getenv('USERPROFILE') . '\Music\_Serato_\History\Sessions'; - if(is_dir($dir)) return $dir; - - // Windows XP - $dir = getenv('USERPROFILE') . '\My Documents\My Music\ScratchLIVE\History\Sessions'; - if(is_dir($dir)) return $dir; - - $dir = getenv('USERPROFILE') . '\My Documents\My Music\_Serato_\History\Sessions'; - if(is_dir($dir)) return $dir; - - throw new RuntimeException("Could not find your ScratchLive History folder; it wasn't where I was expecting."); - } - protected function parseOptions(array $argv) { $this->appname = array_shift($argv); @@ -169,31 +118,13 @@ protected function parseOptions(array $argv) } } - protected function setupLogging() - { - if($this->verbosity == 0) - { - L::setLogger(new NullLogger()); - return; - } - - if($this->log_file) - { - $logger = new FileLogger(); - $logger->setLogFile($this->log_file); - } - else - { - $logger = new ConsoleLogger(); - } - - L::setLogger($logger); - L::setLevel($this->verbosity); - L::setOverrides($this->override_verbosity); - } - protected function analyzeDir($from_dir) { + // Use the caching version via Dependency Injection. This means that all + // new SSLTracks created using a SSLTrackFactory will get a RuntimeCachingSSLTrack + // that knows how to ask the cache about expensive lookups (such as getID3 stuff). + Inject::map('SSLTrackFactory', new SSLTrackCache()); + $newest_mtime = 0; $fps = array(); @@ -210,56 +141,78 @@ protected function analyzeDir($from_dir) natsort($fps); + $track_total = 0; foreach($fps as $fp) { $fn = basename($fp); - echo "** Parsing {$fn}...\n"; try { $parser = new SSLParser($dom); - $dom = $parser->parse($fp); + $parsed_dom = $parser->parse($fp); } catch(Exception $e) { echo "-- ignoring {$fn}.\n"; + $parser->close(); + continue; } $parser->close(); - } - echo "++ Saw " . count($dom) . " chunks\n"; - echo "** Extracting tracks...\n"; - $tracks = $dom->getTracks(); - echo "++ Saw " . count($tracks) . " tracks\n"; - echo "** Importing to db"; - foreach($tracks as $track) - { - /* @var $track SSLTrack */ - echo "."; - $query = sprintf("INSERT INTO history (row, filename, title, artist, deck, starttime, endtime, played, updatedAt, playtime, length, album, fullpath) - VALUES (%d, '%s', '%s', '%s', %d, %d, %d, %d, %d, %d, '%s', '%s', '%s')", - $track->getRow(), - sqlite_escape_string($track->getFilename()), - sqlite_escape_string($track->getTitle()), - sqlite_escape_string($track->getArtist()), - $track->getDeck(), - $track->getStartTime(), - $track->getEndTime(), - $track->getPlayed(), - $track->getUpdatedAt(), - $track->getPlayTime(), - sqlite_escape_string($track->getLength()), - sqlite_escape_string($track->getAlbum()), - sqlite_escape_string($track->getFullpath()) - ); - - if(!$this->dbo->exec($query)) + $tracks = $parsed_dom->getDedupedTracks(); + $count = count($tracks); + + echo "++ session $fn: " . count($parsed_dom) . " chunks yielded $count tracks to add to the DB\n"; + + foreach($tracks as $track) { - throw new Exception($error); + /* @var $track SSLTrack */ + $query = sprintf("INSERT INTO history (row, filename, title, artist, deck, starttime, endtime, played, updatedAt, playtime, length, album, fullpath) + VALUES (%d, '%s', '%s', '%s', %d, %d, %d, %d, %d, %d, '%s', '%s', '%s')", + $track->getRow(), + SQLite3::escapeString($track->getFilename()), + SQLite3::escapeString($track->getTitle()), + SQLite3::escapeString($track->getArtist()), + $track->getDeck(), + $track->getStartTime(), + $track->getEndTime(), + $track->getPlayed(), + $track->getUpdatedAt(), + $track->getPlayTime(), + $track->getLengthInSeconds(SSLTrack::TRY_HARD), + SQLite3::escapeString($track->getAlbum()), + SQLite3::escapeString($track->getFullpath()) + ); + + if(!$this->dbo->exec($query)) + { + echo "WARNING: '{$this->dbo->lastErrorMsg()} (code {$this->dbo->lastErrorCode()})' importing '{$track->getRow()}' - {(string)$track}\n"; + } + + $track_total++; + if($track_total % 100 == 0) { + echo "Track {$track_total}…\n"; + } } } + echo "++ Saw $track_total tracks overall.\n"; echo "done\n"; } protected function initializeDb() { - + $this->dbo->exec("DROP TABLE IF EXISTS history;"); + $this->dbo->exec("CREATE TABLE history ( + row INTEGER PRIMARY KEY, + filename VARCHAR, + title VARCHAR, + artist VARCHAR, + deck INTEGER, + starttime INTEGER, + endtime INTEGER, + played INTEGER, + updatedAt INTEGER, + playtime INTEGER, + length INTEGER, + album VARCHAR, + fullpath TEXT + );"); } } diff --git a/SSL/Logger/L.php b/SSL/Logger/L.php index 2011b9c..9b287ec 100644 --- a/SSL/Logger/L.php +++ b/SSL/Logger/L.php @@ -72,12 +72,7 @@ public static function setOverrides(array $overrides) self::$overrides = $overrides; } - public static function level($log_at_level) - { - return $log_at_level <= self::$threshold; - } - - public static function log($log_at_level, $source, $message, array $args=array()) + public static function level($log_at_level, $source) { if(isset(self::$overrides[$source])) { @@ -87,10 +82,15 @@ public static function log($log_at_level, $source, $message, array $args=array() { $threshold = self::$threshold; } - - if($log_at_level <= $threshold) + + return $log_at_level <= $threshold; + } + + public static function log($log_at_level, $source, $message, array $args=array()) + { + if(self::level($log_at_level, $source)) { self::$logger->log(time(), $log_at_level, $source, vsprintf($message, $args)); } } -} \ No newline at end of file +} diff --git a/SSL/PCNTL/ParallelRunner.php b/SSL/PCNTL/ParallelRunner.php index 1159de5..faabb51 100644 --- a/SSL/PCNTL/ParallelRunner.php +++ b/SSL/PCNTL/ParallelRunner.php @@ -30,7 +30,7 @@ public function spinOff(ParallelTask $t, $task='task') { if(function_exists('pcntl_fork') && !defined('SINGLE_THREADED')) { - L::level(L::DEBUG) && + L::level(L::DEBUG, __CLASS__) && L::log(L::DEBUG, __CLASS__, "Forking %s...", array($task)); @@ -40,7 +40,7 @@ public function spinOff(ParallelTask $t, $task='task') // parent if($pid == -1) { - L::level(L::WARNING) && + L::level(L::WARNING, __CLASS__) && L::log(L::WARNING, __CLASS__, "Fork failed! Running %s single-threaded...", array($task)); @@ -60,7 +60,7 @@ public function spinOff(ParallelTask $t, $task='task') } else { - L::level(L::DEBUG) && + L::level(L::DEBUG, __CLASS__) && L::log(L::DEBUG, __CLASS__, "PCNTL not supported. Running %s single-threaded. If %s is slow, it will block the app until it is finished.", array($task, $task)); @@ -69,4 +69,4 @@ public function spinOff(ParallelTask $t, $task='task') return false; } -} \ No newline at end of file +} diff --git a/SSL/PluginManager/PluginManager.php b/SSL/PluginManager/PluginManager.php index 6718ae1..bb2bc42 100644 --- a/SSL/PluginManager/PluginManager.php +++ b/SSL/PluginManager/PluginManager.php @@ -81,7 +81,7 @@ public function addPlugin(SSLPlugin $plugin) $this->plugin_wrapper->addPlugin($this->max_plugin_id, $plugin); - L::level(L::DEBUG) && + L::level(L::DEBUG, __CLASS__) && L::log(L::DEBUG, __CLASS__, "added %s plugin with id %d", array(get_class($plugin), $this->max_plugin_id)); @@ -126,4 +126,4 @@ public function getObservers() public function setOptions(array $options) { $this->plugin_wrapper->setOptions($options); } -} \ No newline at end of file +} diff --git a/SSL/PluginManager/PluginWrapper.php b/SSL/PluginManager/PluginWrapper.php index b930e60..91880e4 100644 --- a/SSL/PluginManager/PluginWrapper.php +++ b/SSL/PluginManager/PluginWrapper.php @@ -260,13 +260,13 @@ protected function addAllObserversFromPlugins() } } - L::level(L::INFO) && + L::level(L::INFO, __CLASS__) && L::log(L::INFO, __CLASS__, "%d: %s installed", array($id, get_class($plugin))); - L::level(L::DEBUG) && + L::level(L::DEBUG, __CLASS__) && L::log(L::DEBUG, __CLASS__, "%s brought %d observers to the table", array(get_class($plugin), $oc)); } } -} \ No newline at end of file +} diff --git a/SSL/Plugins/Analyzer/README.txt b/SSL/Plugins/Analyzer/README.txt deleted file mode 100644 index 8d5fa52..0000000 --- a/SSL/Plugins/Analyzer/README.txt +++ /dev/null @@ -1,3 +0,0 @@ -Everytime you re-run the analysis you should remove analyse.db and reinitialise it like this: - -sqlite3 analyze.db load($class); } +spl_autoload_register("___autoload"); + // set max log levels for various internal components. (The default is unlimited.) $log_levels = array( @@ -47,9 +50,9 @@ function __autoload($class) // 'SSLHistoryFileMonitor' => L::DEBUG, // 'SSLRealtimeModel' => L::DEBUG, // 'NowPlayingModel' => L::DEBUG, +// 'RuntimeCachingSSLTrack' => L::DEBUG, ); $h = new HistoryAnalyzer(); -$h->setVerbosityOverride($log_levels); -//$h->addPlugin(new JSONServerPOC()); +$h->setVerbosityOverride($log_levels, L::ERROR); $h->main($argc, $argv); diff --git a/SSL/Plugins/DB/CLIDBPlugin.php b/SSL/Plugins/DB/CLIDBPlugin.php index c9aa6fa..7d24003 100644 --- a/SSL/Plugins/DB/CLIDBPlugin.php +++ b/SSL/Plugins/DB/CLIDBPlugin.php @@ -78,7 +78,7 @@ public function addPrompts(array &$argv) public function addPluginsTo(SSLPluggable $sslpluggable) { - L::level(L::DEBUG) && + L::level(L::DEBUG, __CLASS__) && L::log(L::DEBUG, __CLASS__, "yielding %d plugins", array(count($this->plugins))); @@ -92,4 +92,4 @@ protected function newDBPlugin($config, $key) { return new DBPlugin($config, $key); } -} \ No newline at end of file +} diff --git a/SSL/Plugins/DBPlugin.php b/SSL/Plugins/DBPlugin.php index a5458f4..9013865 100644 --- a/SSL/Plugins/DBPlugin.php +++ b/SSL/Plugins/DBPlugin.php @@ -105,7 +105,7 @@ public function notifyNowPlaying(SSLTrack $track=null) $placeholders = $this->getPlaceholdersForNoTrack($this->placeholder_map); } - L::level(L::INFO) && + L::level(L::INFO, __CLASS__) && L::log(L::INFO, __CLASS__, 'Sending %s to DB', array($track ? $track->getFullTitle() : $this->config['empty_string'])); @@ -188,7 +188,7 @@ protected function executeWithRetries( array $placeholders, $retry_count=0 ) { if($retry_count > self::RETRY_LIMIT) { - L::level(L::ERROR) && + L::level(L::ERROR, __CLASS__) && L::log(L::ERROR, __CLASS__, 'Failed to execute database statement; tried %d times', array(self::RETRY_LIMIT + 1)); @@ -197,7 +197,7 @@ protected function executeWithRetries( array $placeholders, $retry_count=0 ) if($retry_count > 0) { - L::level(L::INFO) && + L::level(L::INFO, __CLASS__) && L::log(L::INFO, __CLASS__, 'Retrying database statement. Attempt number %d', array($retry_count + 1)); } @@ -211,7 +211,7 @@ protected function executeWithRetries( array $placeholders, $retry_count=0 ) { $this->close(); - L::level(L::WARNING) && + L::level(L::WARNING, __CLASS__) && L::log(L::WARNING, __CLASS__, 'Statement failed: %s', array($e->getMessage())); diff --git a/SSL/Plugins/Discord/CLIDiscordPlugin.php b/SSL/Plugins/Discord/CLIDiscordPlugin.php index aa7237a..6a31aa7 100644 --- a/SSL/Plugins/Discord/CLIDiscordPlugin.php +++ b/SSL/Plugins/Discord/CLIDiscordPlugin.php @@ -105,7 +105,7 @@ public function addPrompts(array &$argv) public function addPluginsTo(SSLPluggable $sslpluggable) { - L::level(L::DEBUG) && + L::level(L::DEBUG, __CLASS__) && L::log(L::DEBUG, __CLASS__, "yielding %d plugins", array(count($this->plugins))); @@ -119,4 +119,4 @@ protected function newDiscordPlugin($config, $sessionname) { return new DiscordPlugin($config, $sessionname); } -} \ No newline at end of file +} diff --git a/SSL/Plugins/Discord/SSLDiscordAdaptor.php b/SSL/Plugins/Discord/SSLDiscordAdaptor.php index e87d484..a238873 100644 --- a/SSL/Plugins/Discord/SSLDiscordAdaptor.php +++ b/SSL/Plugins/Discord/SSLDiscordAdaptor.php @@ -90,7 +90,7 @@ protected function sendNowPlaying() try { - L::level(L::DEBUG) && + L::level(L::DEBUG, __CLASS__) && L::log(L::DEBUG, __CLASS__, 'Sending Now Playing to Discord: %s', array( $message )); @@ -105,7 +105,7 @@ protected function sendNowPlaying() } catch(Exception $e) { - L::level(L::WARNING) && + L::level(L::WARNING, __CLASS__) && L::log(L::WARNING, __CLASS__, 'Could not send Now Playing to Discord: %s', array( $e->getMessage() )); } @@ -124,4 +124,4 @@ public function run() public function setSynchronous($synchronous) { $this->synchronous = $synchronous; } -} \ No newline at end of file +} diff --git a/SSL/Plugins/DmcaAlerter.php b/SSL/Plugins/DmcaAlerter.php index 42fa356..200a25f 100644 --- a/SSL/Plugins/DmcaAlerter.php +++ b/SSL/Plugins/DmcaAlerter.php @@ -68,7 +68,7 @@ public function notifyTrackChange(TrackChangeEventList $events) $track = $event->getTrack(); if($track) { - L::level(L::INFO) && + L::level(L::INFO, __CLASS__) && L::log(L::INFO, __CLASS__, "Checking if track would break any Mixcloud DMCA limits", array( )); @@ -82,7 +82,7 @@ public function notifyScrobble(SSLTrack $track=null) { if($track) { - L::level(L::INFO) && + L::level(L::INFO, __CLASS__) && L::log(L::INFO, __CLASS__, "Recording track as played for Mixcloud DMCA accounting", array( )); @@ -123,7 +123,7 @@ protected function recordPlayedTrack(SSLTrack $track) if(count($this->last_two_albums) > 2) array_shift($this->last_two_albums); - L::level(L::DEBUG) && + L::level(L::DEBUG, __CLASS__) && L::log(L::DEBUG, __CLASS__, "Last 3 artists: '%s'; Last 2 albums: '%s'", array( implode("', '", $this->last_three_artists), implode("', '", $this->last_two_albums) )); @@ -161,7 +161,7 @@ protected function checkLimits(SSLTrack $track) else { - L::level(L::INFO) && + L::level(L::INFO, __CLASS__) && L::log(L::INFO, __CLASS__, "Nah, we're fine!", array( )); } @@ -200,7 +200,7 @@ protected function alert($message, $offending_item) $this->notifier->notify(__CLASS__, "⚠️ Don't play it!", sprintf($message, $offending_item)); } - L::level(L::WARNING) && + L::level(L::WARNING, __CLASS__) && L::log(L::WARNING, __CLASS__, "⚠️ Don't play it! :- " . $message, array( $offending_item )); } diff --git a/SSL/Plugins/Growl/SSLEventRenderer.php b/SSL/Plugins/Growl/SSLEventRenderer.php index 6d0c683..900ae7d 100644 --- a/SSL/Plugins/Growl/SSLEventRenderer.php +++ b/SSL/Plugins/Growl/SSLEventRenderer.php @@ -45,7 +45,7 @@ public function notifyTrackChange(TrackChangeEventList $events) // Commented out as this is actually quite noisy // $this->popup_notifier->notify('alert', 'Track Change', $event); - L::level(L::INFO) && + L::level(L::INFO, __CLASS__) && L::log(L::INFO, __CLASS__, '>> Track change: >> %s', array($event)); } @@ -57,7 +57,7 @@ public function notifyNowPlaying(SSLTrack $track=null) { $this->popup_notifier->notify('alert', 'Now Playing', $track->getFullTitle()); - L::level(L::INFO) && + L::level(L::INFO, __CLASS__) && L::log(L::INFO, __CLASS__, '>> Now Playing: >> %s', array($track->getFullTitle())); } @@ -65,7 +65,7 @@ public function notifyNowPlaying(SSLTrack $track=null) { $this->popup_notifier->notify('alert', 'Now Playing', ''); - L::level(L::INFO) && + L::level(L::INFO, __CLASS__) && L::log(L::INFO, __CLASS__, '>> Now Playing: >> ', array()); } @@ -75,8 +75,8 @@ public function notifyScrobble(SSLTrack $track) { $this->popup_notifier->notify('alert', 'Scrobbling', $track->getFullTitle()); - L::level(L::INFO) && + L::level(L::INFO, __CLASS__) && L::log(L::INFO, __CLASS__, '>> Scrobbling: >> %s', array($track->getFullTitle())); } -} \ No newline at end of file +} diff --git a/SSL/Plugins/IrcCat/CLIIrcCatPlugin.php b/SSL/Plugins/IrcCat/CLIIrcCatPlugin.php index 5b09a03..fb18b2d 100644 --- a/SSL/Plugins/IrcCat/CLIIrcCatPlugin.php +++ b/SSL/Plugins/IrcCat/CLIIrcCatPlugin.php @@ -86,7 +86,7 @@ public function addPrompts(array &$argv) public function addPluginsTo(SSLPluggable $sslpluggable) { - L::level(L::DEBUG) && + L::level(L::DEBUG, __CLASS__) && L::log(L::DEBUG, __CLASS__, "yielding %d plugins", array(count($this->plugins))); @@ -100,4 +100,4 @@ protected function newIrcCatPlugin($config, $host, $port, $channel) { return new IrcCatPlugin($config, $host, $port, $channel); } -} \ No newline at end of file +} diff --git a/SSL/Plugins/IrcCatPlugin.php b/SSL/Plugins/IrcCatPlugin.php index 3855fa1..7c0e548 100644 --- a/SSL/Plugins/IrcCatPlugin.php +++ b/SSL/Plugins/IrcCatPlugin.php @@ -68,7 +68,7 @@ public function notifyNowPlaying(SSLTrack $track=null) $sock = fsockopen($this->host, $this->port, $errno, $errstr, $timeout=1); if($sock===false) { - L::level(L::ERROR) && + L::level(L::ERROR, __CLASS__) && L::log(L::ERROR, __CLASS__, "couldn't connect to IRCCat: (%d) %s", array($errno, $errstr)); @@ -77,7 +77,7 @@ public function notifyNowPlaying(SSLTrack $track=null) $message = sprintf($this->config['message'], $track->getFullTitle()); - L::level(L::INFO) && + L::level(L::INFO, __CLASS__) && L::log(L::INFO, __CLASS__, "sending '%s' -> %s:%d#%s", array($message, $this->host, $this->port, $this->channel)); diff --git a/SSL/Plugins/JsonServer/CLIJsonServerPlugin.php b/SSL/Plugins/JsonServer/CLIJsonServerPlugin.php index d88f931..1d44333 100644 --- a/SSL/Plugins/JsonServer/CLIJsonServerPlugin.php +++ b/SSL/Plugins/JsonServer/CLIJsonServerPlugin.php @@ -102,11 +102,11 @@ public function parseOption($arg, array &$argv) $this->config['template_fields'] = $matches[1]; - L::level(L::INFO) && + L::level(L::INFO, __CLASS__) && L::log(L::INFO, __CLASS__, "loaded HTML template from %s with %d templated fields", array($template_filename, $match_count)); - L::level(L::DEBUG) && + L::level(L::DEBUG, __CLASS__) && L::log(L::DEBUG, __CLASS__, "Fields in this template: %s", array(implode(', ', $matches[1]))); @@ -126,7 +126,7 @@ public function addPrompts(array &$argv) public function addPluginsTo(SSLPluggable $sslpluggable) { - L::level(L::DEBUG) && + L::level(L::DEBUG, __CLASS__) && L::log(L::DEBUG, __CLASS__, "yielding %d plugins", array(count($this->plugins))); @@ -141,4 +141,4 @@ protected function newJsonServerPlugin($config, $port) { return new JsonServerPlugin($config, $port); } -} \ No newline at end of file +} diff --git a/SSL/Plugins/JsonServerPlugin.php b/SSL/Plugins/JsonServerPlugin.php index 54206df..1ab7b68 100644 --- a/SSL/Plugins/JsonServerPlugin.php +++ b/SSL/Plugins/JsonServerPlugin.php @@ -59,11 +59,11 @@ public function onStart() socket_set_nonblock($this->socket); - L::level(L::DEBUG) && + L::level(L::DEBUG, __CLASS__) && L::log(L::DEBUG, __CLASS__, "Installed JSON / HTML listener...", array()); - if(L::level(L::INFO)) + if(L::level(L::INFO, __CLASS__)) { L::log(L::INFO, __CLASS__, "now playing info will be available at:", array()); @@ -251,7 +251,7 @@ protected function handleRequest($conn) $bytes = socket_recv($conn, $request, 16384, 0); if($bytes === false) { - L::level(L::DEBUG) && + L::level(L::DEBUG, __CLASS__) && L::log(L::DEBUG, __CLASS__, "Problem reading from socket: %s", array(socket_last_error($conn))); @@ -294,7 +294,7 @@ protected function handleRequest($conn) socket_write($conn, implode("\n", $lines)); socket_close($conn); - L::level(L::DEBUG) && + L::level(L::DEBUG, __CLASS__) && L::log(L::DEBUG, __CLASS__, "Finished handling %s request.", array($route_name)); } diff --git a/SSL/Plugins/Last.fm/CLILastfmPlugin.php b/SSL/Plugins/Last.fm/CLILastfmPlugin.php index 6276a5a..576870a 100644 --- a/SSL/Plugins/Last.fm/CLILastfmPlugin.php +++ b/SSL/Plugins/Last.fm/CLILastfmPlugin.php @@ -106,7 +106,7 @@ public function addPrompts(array &$argv) public function addPluginsTo(SSLPluggable $sslpluggable) { - L::level(L::DEBUG) && + L::level(L::DEBUG, __CLASS__) && L::log(L::DEBUG, __CLASS__, "yielding %d plugins", array(count($this->plugins))); @@ -120,4 +120,4 @@ protected function newLastfmPlugin($config, $username) { return new LastfmPlugin($config, $username); } -} \ No newline at end of file +} diff --git a/SSL/Plugins/Last.fm/SSLScrobblerAdaptor.php b/SSL/Plugins/Last.fm/SSLScrobblerAdaptor.php index d9d501c..ef43428 100644 --- a/SSL/Plugins/Last.fm/SSLScrobblerAdaptor.php +++ b/SSL/Plugins/Last.fm/SSLScrobblerAdaptor.php @@ -42,7 +42,7 @@ public function notifyNowPlaying(SSLTrack $track=null) { try { - L::level(L::DEBUG) && + L::level(L::DEBUG, __CLASS__) && L::log(L::DEBUG, __CLASS__, 'Sending Now Playing to Last.fm', array( )); @@ -55,7 +55,7 @@ public function notifyNowPlaying(SSLTrack $track=null) } catch(Exception $e) { - L::level(L::WARNING) && + L::level(L::WARNING, __CLASS__) && L::log(L::WARNING, __CLASS__, 'Could not send Now Playing to Last.fm: %s', array( $e->getMessage() )); } @@ -70,7 +70,7 @@ public function notifyScrobble(SSLTrack $track) { // Perhaps this entry was added manually. - L::level(L::WARNING) && + L::level(L::WARNING, __CLASS__) && L::log(L::WARNING, __CLASS__, 'Could not guess length. Last.fm will silently ignore the scrobble.', array( )); } @@ -85,7 +85,7 @@ public function notifyScrobble(SSLTrack $track) $track->getStartTime() ); - L::level(L::DEBUG) && + L::level(L::DEBUG, __CLASS__) && L::log(L::DEBUG, __CLASS__, 'Sending %d scrobble(s) to Last.fm', array( $this->scrobbler->getQueueSize() )); @@ -95,9 +95,9 @@ public function notifyScrobble(SSLTrack $track) } catch(Exception $e) { - L::level(L::WARNING) && + L::level(L::WARNING, __CLASS__) && L::log(L::WARNING, __CLASS__, 'Could not send %d scrobble(s) to Last.fm: %s', array( $this->scrobbler->getQueueSize(), $e->getMessage() )); } } -} \ No newline at end of file +} diff --git a/SSL/Plugins/MixcloudSuggestor.php b/SSL/Plugins/MixcloudSuggestor.php index 29d9b24..9e313a5 100644 --- a/SSL/Plugins/MixcloudSuggestor.php +++ b/SSL/Plugins/MixcloudSuggestor.php @@ -75,7 +75,7 @@ protected function printSuggestions(SSLTrack $track) 'track' => $this->getNextTrackFor($mixcloud_track_key, $cloudcast['key']) ); } catch (Exception $e) { - L::level(L::WARNING) && + L::level(L::WARNING, __CLASS__) && L::log(L::WARNING, __CLASS__, '%s', array( $e->getMessage() )); // continue @@ -97,7 +97,7 @@ protected function printSuggestions(SSLTrack $track) } } catch(Exception $e) { - L::level(L::WARNING) && + L::level(L::WARNING, __CLASS__) && L::log(L::WARNING, __CLASS__, 'No suggestions: %s', array( $e->getMessage() )); @@ -137,7 +137,7 @@ protected function getBestTrack(SSLTrack $track) ksort($potential_tracks); $best_track = array_shift($potential_tracks); - L::level(L::INFO) && + L::level(L::INFO, __CLASS__) && L::log(L::INFO, __CLASS__, 'Best track match: %s', array( $best_track )); @@ -166,7 +166,7 @@ protected function getMixesForTrack($key) $cloudcasts[] = $result; } - L::level(L::INFO) && + L::level(L::INFO, __CLASS__) && L::log(L::INFO, __CLASS__, 'Found %d mixes for track %s', array( count($cloudcasts), $key )); diff --git a/SSL/Plugins/NowPlaying/CLINowPlayingLoggerPlugin.php b/SSL/Plugins/NowPlaying/CLINowPlayingLoggerPlugin.php index ccc767f..4fd363b 100644 --- a/SSL/Plugins/NowPlaying/CLINowPlayingLoggerPlugin.php +++ b/SSL/Plugins/NowPlaying/CLINowPlayingLoggerPlugin.php @@ -96,7 +96,7 @@ public function addPrompts(array &$argv) public function addPluginsTo(SSLPluggable $sslpluggable) { - L::level(L::DEBUG) && + L::level(L::DEBUG, __CLASS__) && L::log(L::DEBUG, __CLASS__, "yielding %d plugins", array(count($this->plugins))); @@ -110,4 +110,4 @@ protected function newNowPlayingLoggerPlugin($config) { return new NowPlayingLoggerPlugin($config); } -} \ No newline at end of file +} diff --git a/SSL/Plugins/NowPlayingLoggerPlugin.php b/SSL/Plugins/NowPlayingLoggerPlugin.php index 486fb54..3cfa35b 100644 --- a/SSL/Plugins/NowPlayingLoggerPlugin.php +++ b/SSL/Plugins/NowPlayingLoggerPlugin.php @@ -48,7 +48,7 @@ public function setConfig(array $config) if(!isset($this->config['filename'])) { - L::level(L::WARNING) && + L::level(L::WARNING, __CLASS__) && L::log(L::WARNING, __CLASS__, '%s', array( 'I am configured with no filename. Defaulting to nowplaying.txt in your current dir' )); @@ -59,11 +59,11 @@ public function setConfig(array $config) { // warn people who used the old default config that they might want to make up their mind. - L::level(L::WARNING) && + L::level(L::WARNING, __CLASS__) && L::log(L::WARNING, __CLASS__, '%s', array( 'I am configured without a "transform" setting. Add "transform" => "tostring" or "transform" => "serialize" to silence this gripe.' )); - L::level(L::WARNING) && + L::level(L::WARNING, __CLASS__) && L::log(L::WARNING, __CLASS__, '%s', array( '("serialize" was the default before, but most people probably want "tostring", as that\'s the human readable one. Compare your config with config.php-default)' )); } @@ -122,4 +122,4 @@ public function notifyNowPlaying(SSLTrack $track=null) { file_put_contents($this->getFilename(), $this->transform($track)); } -} \ No newline at end of file +} diff --git a/SSL/Plugins/Twitter/CLITwitterPlugin.php b/SSL/Plugins/Twitter/CLITwitterPlugin.php index 109e697..d2a4b56 100644 --- a/SSL/Plugins/Twitter/CLITwitterPlugin.php +++ b/SSL/Plugins/Twitter/CLITwitterPlugin.php @@ -116,7 +116,7 @@ public function addPrompts(array &$argv) public function addPluginsTo(SSLPluggable $sslpluggable) { - L::level(L::DEBUG) && + L::level(L::DEBUG, __CLASS__) && L::log(L::DEBUG, __CLASS__, "yielding %d plugins", array(count($this->plugins))); @@ -130,4 +130,4 @@ protected function newTwitterPlugin($config, $sessionname) { return new TwitterPlugin($config, $sessionname); } -} \ No newline at end of file +} diff --git a/SSL/Plugins/Twitter/MessageFilters/BeatportTrackMessageFilter.php b/SSL/Plugins/Twitter/MessageFilters/BeatportTrackMessageFilter.php index b2486a9..655b239 100644 --- a/SSL/Plugins/Twitter/MessageFilters/BeatportTrackMessageFilter.php +++ b/SSL/Plugins/Twitter/MessageFilters/BeatportTrackMessageFilter.php @@ -76,7 +76,7 @@ protected function getBeatportURL(SSLTrack $track) $bp_track_string = implode(', ', $bp_artist_names) . ' - ' . $bp_track_title; $ssl_track_string = $track->getFullTitle(); - L::level(L::INFO) && + L::level(L::INFO, __CLASS__) && L::log(L::INFO, __CLASS__, "Found %s at %s", array($bp_track_string, $bp_url)); @@ -86,14 +86,14 @@ protected function getBeatportURL(SSLTrack $track) } else { - L::level(L::INFO) && + L::level(L::INFO, __CLASS__) && L::log(L::INFO, __CLASS__, "Rejected %s as a match for %s", array($bp_track_string, $ssl_track_string)); } } else { - L::level(L::INFO) && + L::level(L::INFO, __CLASS__) && L::log(L::INFO, __CLASS__, "No track found.", array()); } @@ -133,4 +133,4 @@ protected function newBeatportAPIClient() { return new BeatportAPIClient(); } -} \ No newline at end of file +} diff --git a/SSL/Plugins/Twitter/MessageFilters/URLShorteners/VgdURLShortener.php b/SSL/Plugins/Twitter/MessageFilters/URLShorteners/VgdURLShortener.php index 5af549c..4fbd100 100644 --- a/SSL/Plugins/Twitter/MessageFilters/URLShorteners/VgdURLShortener.php +++ b/SSL/Plugins/Twitter/MessageFilters/URLShorteners/VgdURLShortener.php @@ -30,7 +30,7 @@ class VgdURLShortener implements IURLShortener { public function shorten($url) { - L::level(L::INFO) && + L::level(L::INFO, __CLASS__) && L::log(L::INFO, __CLASS__, "Shortening %s", array($url)); @@ -38,14 +38,14 @@ public function shorten($url) if($result['shortURL']) { - L::level(L::INFO) && + L::level(L::INFO, __CLASS__) && L::log(L::INFO, __CLASS__, "Shortened to %s", array($result['shortURL'])); return $result['shortURL']; } - L::level(L::WARNING) && + L::level(L::WARNING, __CLASS__) && L::log(L::WARNING, __CLASS__, "Shorten failed: %s", array($result['errorMessage'])); @@ -55,4 +55,4 @@ public function shorten($url) //return $url; return ''; } -} \ No newline at end of file +} diff --git a/SSL/Plugins/Twitter/SSLTwitterAdaptor.php b/SSL/Plugins/Twitter/SSLTwitterAdaptor.php index aff39a9..fba2ff5 100644 --- a/SSL/Plugins/Twitter/SSLTwitterAdaptor.php +++ b/SSL/Plugins/Twitter/SSLTwitterAdaptor.php @@ -106,7 +106,7 @@ protected function sendNowPlaying() try { - L::level(L::DEBUG) && + L::level(L::DEBUG, __CLASS__) && L::log(L::DEBUG, __CLASS__, 'Sending Now Playing to Twitter: %s', array( $status )); @@ -117,7 +117,7 @@ protected function sendNowPlaying() } catch(Exception $e) { - L::level(L::WARNING) && + L::level(L::WARNING, __CLASS__) && L::log(L::WARNING, __CLASS__, 'Could not send Now Playing to Twitter: %s', array( $e->getMessage() )); } @@ -149,7 +149,7 @@ protected function saveReplyId($id) { protected function getReplyId() { $reply_file = 'twitter-' . $this->sessionname . '-last-reply.txt'; if (! file_exists($reply_file)) { - L::level(L::INFO) && + L::level(L::INFO, __CLASS__) && L::log(L::INFO, __CLASS__, 'No reply file - starting new Twitter thread.', array( )); return false; @@ -159,11 +159,11 @@ protected function getReplyId() { if($reply_file_age > 3600 /* 1 hour */) { unlink($reply_file); - L::level(L::INFO) && + L::level(L::INFO, __CLASS__) && L::log(L::INFO, __CLASS__, 'Reply file too old - starting new Twitter thread.', array( )); return false; } return file_get_contents($reply_file); } -} \ No newline at end of file +} diff --git a/SSL/Plugins/curlPlugin.php b/SSL/Plugins/curlPlugin.php index 4691951..d4d0722 100644 --- a/SSL/Plugins/curlPlugin.php +++ b/SSL/Plugins/curlPlugin.php @@ -65,12 +65,12 @@ public function notifyNowPlaying(SSLTrack $track=null) { if($track) { - L::level(L::INFO) && L::log(L::INFO, __CLASS__, 'Sending %s to an API via cURL.', array($track->getFullTitle())); + L::level(L::INFO, __CLASS__) && L::log(L::INFO, __CLASS__, 'Sending %s to an API via cURL.', array($track->getFullTitle())); $this->sendRequest($track); } else { - L::level(L::INFO) && L::log(L::INFO, __CLASS__, 'No track data available. Not Sending via cURL.'); + L::level(L::INFO, __CLASS__) && L::log(L::INFO, __CLASS__, 'No track data available. Not Sending via cURL.'); } } diff --git a/SSL/RTM/DiffMonitor.php b/SSL/RTM/DiffMonitor.php index 3d9ca95..e388d95 100644 --- a/SSL/RTM/DiffMonitor.php +++ b/SSL/RTM/DiffMonitor.php @@ -71,7 +71,7 @@ protected function checkForNewFilename() if($got_new_file) { $this->filename = $new_filename; - L::level(L::INFO) && + L::level(L::INFO, __CLASS__) && L::log(L::INFO, __CLASS__, "Changed to new file %s", array($this->filename)); } @@ -100,7 +100,7 @@ protected function fileIsNewer($old_filename, $new_filename) // don't spam if($new_filename != $this->last_ignored_filename) { - L::level(L::INFO) && + L::level(L::INFO, __CLASS__) && L::log(L::INFO, __CLASS__, "Ignoring update to older session file %s", array($new_filename)); @@ -142,4 +142,4 @@ protected function onDiff(SSLDom $changed) $this->diff_delegate->onDiff($changed); } -} \ No newline at end of file +} diff --git a/SSL/RTM/NowPlayingModel.php b/SSL/RTM/NowPlayingModel.php index 851cc17..98ef058 100644 --- a/SSL/RTM/NowPlayingModel.php +++ b/SSL/RTM/NowPlayingModel.php @@ -126,11 +126,11 @@ protected function stopTrack(SSLTrack $stopped_track) // reindex the queue $this->now_playing_queue = array_merge($this->now_playing_queue); - L::level(L::INFO) && + L::level(L::INFO, __CLASS__) && L::log(L::INFO, __CLASS__, 'dequeued track %s', array($stopped_track->getFullTitle()) ); - L::level(L::DEBUG) && + L::level(L::DEBUG, __CLASS__) && L::log(L::DEBUG, __CLASS__, 'queue length is now %d', array(count($this->now_playing_queue)) ); } @@ -159,11 +159,11 @@ protected function startTrack(SSLTrack $started_track) } $this->now_playing_queue[] = $scrobble_model; - L::level(L::INFO) && + L::level(L::INFO, __CLASS__) && L::log(L::INFO, __CLASS__, 'enqueued track %s', array($started_track->getFullTitle()) ); - L::level(L::DEBUG) && + L::level(L::DEBUG, __CLASS__) && L::log(L::DEBUG, __CLASS__, 'queue length is now %d', array( count($this->now_playing_queue)) ); } @@ -176,11 +176,11 @@ protected function updateTrack(SSLTrack $updated_track) $scrobble_model->update($updated_track); } - L::level(L::INFO) && + L::level(L::INFO, __CLASS__) && L::log(L::INFO, __CLASS__, 'updated track %s', array($updated_track->getFullTitle()) ); - L::level(L::DEBUG) && + L::level(L::DEBUG, __CLASS__) && L::log(L::DEBUG, __CLASS__, 'queue length is now %d', array( count($this->now_playing_queue)) ); } @@ -337,4 +337,4 @@ protected function notifyNowPlayingObservers(SSLTrack $track=null) $observer->notifyNowPlaying($track); } } -} \ No newline at end of file +} diff --git a/SSL/RTM/SSLFileReader.php b/SSL/RTM/SSLFileReader.php index 39e8c12..136c25a 100644 --- a/SSL/RTM/SSLFileReader.php +++ b/SSL/RTM/SSLFileReader.php @@ -56,20 +56,20 @@ protected function read($filename) public function dump() { - L::level(L::INFO) && + L::level(L::INFO, __CLASS__) && L::log(L::INFO, __CLASS__, 'reading structure of %s...', array($this->filename)); $tree = $this->read($this->filename); - L::level(L::INFO) && + L::level(L::INFO, __CLASS__) && L::log(L::INFO, __CLASS__, 'asking structure DOM to parse %s...', array($this->filename)); // Without this line you'll just get hexdumps, which is not very exciting. $tree->getData(); - L::level(L::INFO) && + L::level(L::INFO, __CLASS__) && L::log(L::INFO, __CLASS__, 'printing structure of %s...', array($this->filename)); @@ -83,4 +83,4 @@ public function dump() * @return SSLDom */ abstract protected function newDom(); -} \ No newline at end of file +} diff --git a/SSL/RTM/SSLHistoryFileReplayer.php b/SSL/RTM/SSLHistoryFileReplayer.php index 0f1da02..8a1c6c9 100644 --- a/SSL/RTM/SSLHistoryFileReplayer.php +++ b/SSL/RTM/SSLHistoryFileReplayer.php @@ -98,13 +98,13 @@ public function addTickObserver(TickObserver $observer) protected function notifyTickObservers($seconds) { - L::level(L::DEBUG) && + L::level(L::DEBUG, __CLASS__) && L::log(L::DEBUG, __CLASS__, 'Pseudo tick %d seconds', array($seconds)); foreach($this->tick_observers as $observer) { - L::level(L::DEBUG) && + L::level(L::DEBUG, __CLASS__) && L::log(L::DEBUG, __CLASS__, 'Sending tick to %s', array(get_class($observer))); @@ -130,7 +130,7 @@ public function notifyTick($seconds) foreach($this->payloads as $payload) { $payload_timestamp = $payload->getFirstTimestamp(); - L::level(L::DEBUG) && + L::level(L::DEBUG, __CLASS__) && L::log(L::DEBUG, __CLASS__, 'Yielding payload for timestamp %s (%s)', array( $payload_timestamp, @@ -189,7 +189,7 @@ protected function groupByTimestamp(array $tracks) $last_updated_at = 0; $group = array(); - L::level(L::DEBUG) && + L::level(L::DEBUG, __CLASS__) && L::log(L::DEBUG, __CLASS__, 'Found %d tracks in file', array(count($tracks))); @@ -204,7 +204,7 @@ protected function groupByTimestamp(array $tracks) { if(!empty($group)) { - L::level(L::DEBUG) && + L::level(L::DEBUG, __CLASS__) && L::log(L::DEBUG, __CLASS__, 'Entries found at %s', array(date('Y-m-d H:i:s', $last_updated_at))); @@ -219,14 +219,14 @@ protected function groupByTimestamp(array $tracks) if(!empty($group)) { - L::level(L::DEBUG) && + L::level(L::DEBUG, __CLASS__) && L::log(L::DEBUG, __CLASS__, 'Entries found at %s', array(date('Y-m-d H:i:s', $last_updated_at))); $this->payloads[$last_updated_at] = new SSLHistoryDiffDom($group); } - L::level(L::DEBUG) && + L::level(L::DEBUG, __CLASS__) && L::log(L::DEBUG, __CLASS__, 'Divided tracks in %d groups', array(count($this->payloads))); } @@ -250,7 +250,7 @@ protected function checkUpdatedAtIsMeaningful(array $tracks) { // which is a big clue that the history was bulk-rewritten (as // it often is when you quit Serato). if($updated_at < $last_updated_at) { - L::level(L::DEBUG) && + L::level(L::DEBUG, __CLASS__) && L::log(L::DEBUG, __CLASS__, 'UpdatedAt not meaningful: row %d updated before row %d', array($row, $last_row)); return false; @@ -265,7 +265,7 @@ protected function checkUpdatedAtIsMeaningful(array $tracks) { } if($group_count < count($tracks)/2) { - L::level(L::DEBUG) && + L::level(L::DEBUG, __CLASS__) && L::log(L::DEBUG, __CLASS__, 'UpdatedAt not meaningful: %d tracks but only %d groups', array(count($tracks), $group_count)); return false; @@ -284,4 +284,4 @@ private function timestampSort(SSLTrack $a, SSLTrack $b) if($a_ts == $b_ts) return 0; return -1; } -} \ No newline at end of file +} diff --git a/SSL/RTM/SSLRealtimeModel.php b/SSL/RTM/SSLRealtimeModel.php index ba9075e..6967146 100644 --- a/SSL/RTM/SSLRealtimeModel.php +++ b/SSL/RTM/SSLRealtimeModel.php @@ -232,7 +232,7 @@ public function notifyDiff(SSLHistoryDiffDom $diff) { $events = $this->factory->newTrackChangeEventList($events); - L::level(L::DEBUG) && + L::level(L::DEBUG, __CLASS__) && L::log(L::DEBUG, __CLASS__, "notifying %s", array($events)); diff --git a/SSL/RTM/SSLRealtimeModelDeck.php b/SSL/RTM/SSLRealtimeModelDeck.php index 6562c42..f687141 100644 --- a/SSL/RTM/SSLRealtimeModelDeck.php +++ b/SSL/RTM/SSLRealtimeModelDeck.php @@ -228,7 +228,7 @@ public function notify(SSLHistoryDiffDom $diff) { // track notification for this deck! $my_tracks[$track->getRow()] = $track; - L::level(L::DEBUG) && + L::level(L::DEBUG, __CLASS__) && L::log(L::DEBUG, __CLASS__, "Saw %s in diff (row %s @ %s)", array( $track->getTitle(), $track->getRow(), $track->getFullStartTime())); } @@ -245,7 +245,7 @@ public function notify(SSLHistoryDiffDom $diff) } catch(SSLInvalidTransitionException $e) { - L::level(L::WARNING) && + L::level(L::WARNING, __CLASS__) && L::log(L::WARNING, __CLASS__, "Invalid Transition: %s", array($e->getMessage()) ); } @@ -300,7 +300,7 @@ public function transitionTo(SSLTrack $track) $from = $this->getStatus(); $to = $track->getStatus(); - L::level(L::DEBUG) && + L::level(L::DEBUG, __CLASS__) && L::log(L::DEBUG, __CLASS__, "deck %d transitioned from %s to %s with track %s", array( $this->deck_number, $from, $to, $track->getTitle()) ); @@ -563,4 +563,4 @@ protected function transitionFromNewToSkipped(SSLTrack $track) // don't touch previous track } -} \ No newline at end of file +} diff --git a/SSL/RTM/ScrobbleModel.php b/SSL/RTM/ScrobbleModel.php index 9facd5a..a52b16a 100644 --- a/SSL/RTM/ScrobbleModel.php +++ b/SSL/RTM/ScrobbleModel.php @@ -68,11 +68,11 @@ protected function trackStopped(SSLTrack $track) $stm = $this->factory->newScrobblerTrackModel($track); if($stm->isScrobblable()) { - L::level(L::INFO) && + L::level(L::INFO, __CLASS__) && L::log(L::INFO, __CLASS__, 'I reckon it\'s time to submit a scrobble for %s!', array($track->getFullTitle())); $this->notifyScrobbleObservers($track); } } -} \ No newline at end of file +} diff --git a/SSL/RTM/ScrobblerTrackModel.php b/SSL/RTM/ScrobblerTrackModel.php index 42b1e59..c56637c 100644 --- a/SSL/RTM/ScrobblerTrackModel.php +++ b/SSL/RTM/ScrobblerTrackModel.php @@ -86,21 +86,21 @@ public function elapse($seconds) if($this->passed_now_playing_point && !$was_passed_now_playing_point) { - L::level(L::INFO) && + L::level(L::INFO, __CLASS__) && L::log(L::INFO, __CLASS__, '%s passed now playing point', array($this->track->getFullTitle())); } if($this->passed_scrobble_point && !$was_passed_scrobble_point) { - L::level(L::INFO) && + L::level(L::INFO, __CLASS__) && L::log(L::INFO, __CLASS__, '%s passed scrobble point', array($this->track->getFullTitle())); } if($this->passed_end && !$was_ended) { - L::level(L::INFO) && + L::level(L::INFO, __CLASS__) && L::log(L::INFO, __CLASS__, '%s passed end point', array($this->track->getFullTitle())); } @@ -142,4 +142,4 @@ public function getTrack() { return $this->track; } -} \ No newline at end of file +} diff --git a/SSL/RTM/TickSource.php b/SSL/RTM/TickSource.php index d62f3ba..026f936 100644 --- a/SSL/RTM/TickSource.php +++ b/SSL/RTM/TickSource.php @@ -50,7 +50,7 @@ protected function notifyTickObservers($seconds) public function startClock($interval, SignalHandler $sh = null, InputHandler $ih = null) { - L::level(L::DEBUG) && + L::level(L::DEBUG, __CLASS__) && L::log(L::DEBUG, __CLASS__, "Clock Started, interval %s", array($interval)); @@ -63,7 +63,7 @@ public function startClock($interval, SignalHandler $sh = null, InputHandler $ih // debugging option --multiply-time $elapsed *= $this->time_multiplier; - L::level(L::DEBUG) && + L::level(L::DEBUG, __CLASS__) && L::log(L::DEBUG, __CLASS__, "Tick %s seconds", array($elapsed)); @@ -73,7 +73,7 @@ public function startClock($interval, SignalHandler $sh = null, InputHandler $ih if($processing_time > $interval) { - L::level(L::WARNING) && + L::level(L::WARNING, __CLASS__) && L::log(L::WARNING, __CLASS__, "Notification took %s, which is longer than interval %s", array($processing_time, $interval)); } @@ -111,10 +111,10 @@ protected function sleep($seconds) public function notifyExit() { - L::level(L::DEBUG) && + L::level(L::DEBUG, __CLASS__) && L::log(L::DEBUG, __CLASS__, "Exit caught.", array()); $this->exit_notified = true; } -} \ No newline at end of file +} diff --git a/SSL/SSLChunkParser.php b/SSL/SSLChunkParser.php index 3ac5e43..32a77fb 100644 --- a/SSL/SSLChunkParser.php +++ b/SSL/SSLChunkParser.php @@ -95,7 +95,7 @@ protected function resync($fp) if(strlen($next_four) < 4) { - L::level(L::DEBUG) && + L::level(L::DEBUG, __CLASS__) && L::log(L::DEBUG, __CLASS__, "Reached EOF whilst resyncing; no more to read after %d bytes junk", array($junk_size)); @@ -109,7 +109,7 @@ protected function resync($fp) // rewind by the length of 'oent' fseek($fp, -4, SEEK_CUR); - L::level(L::DEBUG) && + L::level(L::DEBUG, __CLASS__) && L::log(L::DEBUG, __CLASS__, "Skipped %d bytes junk", array($junk_size)); @@ -120,7 +120,7 @@ protected function resync($fp) } while(!feof($fp)); - L::level(L::DEBUG) && + L::level(L::DEBUG, __CLASS__) && L::log(L::DEBUG, __CLASS__, "Reached EOF condition whilst resyncing; no more to read after %d bytes junk", array($junk_size)); @@ -143,7 +143,7 @@ public function parseFromFile($fp) if($length_read == 0) { - L::level(L::DEBUG) && + L::level(L::DEBUG, __CLASS__) && L::log(L::DEBUG, __CLASS__, "Reached EOF; no more to read", array()); @@ -153,7 +153,7 @@ public function parseFromFile($fp) $just_blank_bytes = (str_pad($header_bin, 8, "\0") == "\0\0\0\0\0\0\0\0"); if($just_blank_bytes) { - L::level(L::WARNING) && + L::level(L::WARNING, __CLASS__) && L::log(L::WARNING, __CLASS__, "Hit unallocated blank space in file.", array()); @@ -188,7 +188,7 @@ public function parseFromFile($fp) $body_bin = fread($fp, $chunk_size); $chunk = $this->chunk_factory->newChunk($chunk_type, $body_bin); - L::level(L::DEBUG) && + L::level(L::DEBUG, __CLASS__) && L::log(L::DEBUG, __CLASS__, "Read %s chunk from file (size: %d)", array($chunk_type, $chunk_size)); } @@ -196,7 +196,7 @@ public function parseFromFile($fp) { $chunk = ''; - L::level(L::WARNING) && + L::level(L::WARNING, __CLASS__) && L::log(L::WARNING, __CLASS__, "Read 0-byte %s chunk from file. This is unusual.", array($chunk_type)); } diff --git a/SSL/SSLChunkReader.php b/SSL/SSLChunkReader.php index 796c0ee..95697e0 100644 --- a/SSL/SSLChunkReader.php +++ b/SSL/SSLChunkReader.php @@ -53,7 +53,7 @@ public function getChunks() } while($chunk !== false); - L::level(L::DEBUG) && + L::level(L::DEBUG, __CLASS__) && L::log(L::DEBUG, __CLASS__, "Read %d chunks", array( count($chunks))); @@ -71,4 +71,4 @@ protected function readChunk() $cp = $this->factory->newChunkParser(); return $cp->parseFromFile($this->fp); } -} \ No newline at end of file +} diff --git a/SSL/SSLHistoryDom.php b/SSL/SSLHistoryDom.php index 47520f6..39785c5 100644 --- a/SSL/SSLHistoryDom.php +++ b/SSL/SSLHistoryDom.php @@ -51,7 +51,42 @@ public function getTracks() } return $tracks; } - + + /** + * @return array of SSLTrack + */ + public function getDedupedTracks() + { + $tracks = $this->getTracks(); + + // raw session files are append-only when in use, and often contain multiple entries + // for the same track written at different points in the lifecycle (e.g. deck load / + // deck eject). Newer versions of Serato clean these up when you end the session, + // but it can still happen if you crash etc. + + $seen_ids = array(); + $positions_to_filter = array(); + + $ptr = count($tracks); + while($ptr > 0) + { + // work backward through the array removing younger dupes + + $ptr--; + $row_id = $tracks[$ptr]->getRow(); + if(isset($seen_ids[$row_id])) + { + $tracks[$ptr] = null; + } + else + { + $seen_ids[$row_id] = true; + } + } + + return array_filter($tracks); + } + /** * @return array of SSLAdatChunk */ diff --git a/SSL/SSLLibraryDom.php b/SSL/SSLLibraryDom.php index 3e41728..3a194af 100644 --- a/SSL/SSLLibraryDom.php +++ b/SSL/SSLLibraryDom.php @@ -63,11 +63,11 @@ public function getData() $chunk_count++; - L::level(L::DEBUG) && !($chunk_count % 1000) && + L::level(L::DEBUG, __CLASS__) && !($chunk_count % 1000) && L::log(L::DEBUG, __CLASS__, "Parsed %d chunks...", array( $chunk_count )); } return $data; } -} \ No newline at end of file +} diff --git a/SSL/SSLTrackCache.php b/SSL/SSLTrackCache.php index b86b1da..2dee681 100644 --- a/SSL/SSLTrackCache.php +++ b/SSL/SSLTrackCache.php @@ -31,6 +31,7 @@ class SSLTrackCache extends SSLTrackFactory */ protected $factory; protected $tracks = array(); + protected $file_lengths = array(); public function __construct() { @@ -39,7 +40,22 @@ public function __construct() public function register(SSLTrack $track) { - $this->tracks[$track->getRow()] = $track; + $this->tracks[$track->getRow()] = $track; + $length = $track->getLength(); + if($length) + { + // know the length? cache it by path too + $this->setLengthByFullpath($track->getFullpath(), $length); + } + else + { + // don't know the length? check if it's cached by path + $length = $this->getLengthByFullpath($track->getFullpath()); + if($length) + { + $track->setLength($length); + } + } } public function getByRow($row) @@ -55,4 +71,17 @@ public function newTrack() { return $this->factory->newRuntimeCachingTrack($this); } -} \ No newline at end of file + + public function setLengthByFullpath($fullpath, $length) + { + $this->file_lengths[$fullpath] = $length; + } + + public function getLengthByFullpath($fullpath) + { + if(isset($this->file_lengths[$fullpath])) + { + return $this->file_lengths[$fullpath]; + } + } +} diff --git a/SSL/SignalHandler.php b/SSL/SignalHandler.php index 742e69a..e68d8d8 100644 --- a/SSL/SignalHandler.php +++ b/SSL/SignalHandler.php @@ -36,7 +36,7 @@ public function install() } else { - L::level(L::WARNING) && + L::level(L::WARNING, __CLASS__) && L::log(L::WARNING, __CLASS__, 'PCNTL extension not installed! Cannot trap Ctrl-C / SIGKILL', array()); } @@ -76,7 +76,7 @@ protected function handle($signal) switch ($signal) { case SIGINT: - L::level(L::INFO) && + L::level(L::INFO, __CLASS__) && L::log(L::INFO, __CLASS__, 'Caught SIGINT', array()); @@ -84,4 +84,4 @@ protected function handle($signal) break; } } -} \ No newline at end of file +} diff --git a/SSL/Structs/RuntimeCachingSSLTrack.php b/SSL/Structs/RuntimeCachingSSLTrack.php index 1e683ec..9ad89f1 100644 --- a/SSL/Structs/RuntimeCachingSSLTrack.php +++ b/SSL/Structs/RuntimeCachingSSLTrack.php @@ -70,15 +70,39 @@ public function setLengthIfUnknown() if($cached_track) { - $cached_length = $cached_track->getLength(); - if(isset($cached_length)) - { - $this->setLength($cached_length); - } + $length = $cached_track->getLength(); + + if($length) + L::level(L::DEBUG, __CLASS__) && + L::log(L::DEBUG, __CLASS__, "setLengthIfUnknown() got a cache hit (%s) by row (%d)", + array( $length, $this->getRow())); } - + + if(!isset($length)) + { + // either there's no cached track or it was cached without a length. + // it may also be cached by file path. + $length = $this->track_cache->getLengthByFullpath($this->getFullpath()); + + if($length) + L::level(L::DEBUG, __CLASS__) && + L::log(L::DEBUG, __CLASS__, "setLengthIfUnknown() got a cache hit (%s) by fullpath (%s)", + array( $length, $this->getFullpath())); + } + + if(isset($length)) + { + $this->setLength($length); + return; + } + + L::level(L::DEBUG, __CLASS__) && + L::log(L::DEBUG, __CLASS__, "setLengthIfUnknown() cache miss (row %d, %s)", + array( $this->getRow(), $this->getFullpath())); + // if we got here, we did not get the length from cache. parent::setLengthIfUnknown(); + // we still may not have it, but we checked the file this time. $length = $this->getLength(); // save in the cache, for next time. @@ -92,7 +116,9 @@ public function setLengthIfUnknown() { $this->track_cache->register($this); } + + $this->track_cache->setLengthByFullpath($this->getFullpath(), $length); } } } -} \ No newline at end of file +} diff --git a/SSL/Structs/SSLTrack.php b/SSL/Structs/SSLTrack.php index 01805a4..af2ac04 100644 --- a/SSL/Structs/SSLTrack.php +++ b/SSL/Structs/SSLTrack.php @@ -181,7 +181,7 @@ protected function guessLengthFromFile() if(isset($fullpath) && strlen($fullpath) == 0) { - L::level(L::WARNING) && + L::level(L::WARNING, __CLASS__) && L::log(L::WARNING, __CLASS__, 'Guessing MP3 length from file failed: full path was empty. Perhaps this entry was manually added?', array( )); @@ -190,7 +190,7 @@ protected function guessLengthFromFile() if(!$this->file_exists($fullpath)) { - L::level(L::WARNING) && + L::level(L::WARNING, __CLASS__) && L::log(L::WARNING, __CLASS__, 'Guessing MP3 length from file failed: file not found (%s)', array( $fullpath )); @@ -213,7 +213,7 @@ protected function guessLengthFromFile() $playtime = $info['playtime_seconds']; if($playtime) { - L::level(L::WARNING) && + L::level(L::WARNING, __CLASS__) && L::log(L::WARNING, __CLASS__, 'Guessed MP3 length %d seconds from file.', array( $playtime )); @@ -222,7 +222,7 @@ protected function guessLengthFromFile() return sprintf("%d:%02d", $minutes, $seconds); } - L::level(L::WARNING) && + L::level(L::WARNING, __CLASS__) && L::log(L::WARNING, __CLASS__, 'Guessing MP3 length from file failed for an unknown reason. Hmmph.', array( )); @@ -230,7 +230,7 @@ protected function guessLengthFromFile() catch(getid3_exception $e) { // MP3 couldn't be analyzed. - L::level(L::WARNING) && + L::level(L::WARNING, __CLASS__) && L::log(L::WARNING, __CLASS__, 'Guessing MP3 length from file failed: %s', array( $e->getMessage() )); } diff --git a/SSL/Unpacker.php b/SSL/Unpacker.php index 1c26080..5059c4b 100644 --- a/SSL/Unpacker.php +++ b/SSL/Unpacker.php @@ -82,7 +82,7 @@ protected function unpackuint($datum, $intmax = PHP_INT_MAX) { if($vals['upper']) { - L::level(L::WARNING) && + L::level(L::WARNING, __CLASS__) && L::log(L::WARNING, __CLASS__, "Encountered 64-bit integer > PHP_INT_MAX on a 32-bit PHP. Throwing away upper bytes. Original value was 0x%08X%08X", array(dechex($vals['upper']), dechex($vals['lower']))); } @@ -151,7 +151,7 @@ protected function unpacksint($datum, $intmax = PHP_INT_MAX) ( $vals['upper'] == 0xFFFFFFFF && $vals['lower'] & 0x80000000 == 0 ) || ( $vals['upper'] == 0 && $vals['lower'] & 0x80000000 == 0x80000000 ) ) { - L::level(L::WARNING) && + L::level(L::WARNING, __CLASS__) && L::log(L::WARNING, __CLASS__, "Encountered signed 64-bit integer > PHP_INT_MAX on a 32-bit PHP. Throwing away upper bytes. Original value was 0x%08X%08X", array(dechex($vals['upper']), dechex($vals['lower']))); } @@ -261,4 +261,4 @@ protected function unpackfloat($datum) } return $vals['val']; } -} \ No newline at end of file +} diff --git a/SSL/Unpacker/XoupCompiler.php b/SSL/Unpacker/XoupCompiler.php index 9b890e5..1a94d8a 100644 --- a/SSL/Unpacker/XoupCompiler.php +++ b/SSL/Unpacker/XoupCompiler.php @@ -56,7 +56,7 @@ public function parse($program) public function compile($filename) { - L::level(L::INFO) && + L::level(L::INFO, __CLASS__) && L::log(L::INFO, __CLASS__, 'compiling %s', array($filename)); @@ -89,7 +89,7 @@ public function compile($filename) $output .= " }\n\n"; $output .= " public function flushBuffer()\n"; $output .= " {\n"; - $output .= " L::level(L::INFO) &&\n"; + $output .= " L::level(L::INFO, __CLASS__) &&\n"; $output .= " L::log(L::INFO, __CLASS__, \$this->out_buffer,\n"; $output .= " array());\n\n"; $output .= " \$this->out_buffer = '';\n"; @@ -394,4 +394,4 @@ protected function getClassName($filename) $basename = basename($filename, '.xoup'); return 'XOUP' . $basename . 'Unpacker'; } -} \ No newline at end of file +} diff --git a/SSL/Unpacker/XoupInterpreter.php b/SSL/Unpacker/XoupInterpreter.php index 182f8be..4d88e12 100644 --- a/SSL/Unpacker/XoupInterpreter.php +++ b/SSL/Unpacker/XoupInterpreter.php @@ -372,11 +372,11 @@ protected function write($datum, array &$context, &$acc, $type, $dest) protected function flushBuffer() { - L::level(L::INFO) && + L::level(L::INFO, __CLASS__) && L::log(L::INFO, __CLASS__, $this->out_buffer, array()); $this->out_buffer = ''; } -} \ No newline at end of file +} diff --git a/SSL/Unpacker/XoupLoader.php b/SSL/Unpacker/XoupLoader.php index f2c8e50..1a981b8 100644 --- a/SSL/Unpacker/XoupLoader.php +++ b/SSL/Unpacker/XoupLoader.php @@ -66,7 +66,7 @@ public function load($filename, $load_compiled=true, $compile=true) throw new RuntimeException("Could not load {$filename}"); } - L::level(L::DEBUG) && + L::level(L::DEBUG, __CLASS__) && L::log(L::DEBUG, __CLASS__, 'selecting XOUP interpreter for %s', array($filename)); @@ -93,7 +93,7 @@ protected function loadCompiled($filename) if($compiled_ts < $source_ts) { - L::level(L::DEBUG) && + L::level(L::DEBUG, __CLASS__) && L::log(L::DEBUG, __CLASS__, 'source modified since last compilation', array()); @@ -102,7 +102,7 @@ protected function loadCompiled($filename) if($compiled_ts < $compiler_ts) { - L::level(L::DEBUG) && + L::level(L::DEBUG, __CLASS__) && L::log(L::DEBUG, __CLASS__, 'compiler modified since last compilation', array()); @@ -116,7 +116,7 @@ protected function loadCompiled($filename) throw new RuntimeException("{$class} not present in {$compiled_name}"); } - L::level(L::DEBUG) && + L::level(L::DEBUG, __CLASS__) && L::log(L::DEBUG, __CLASS__, 'loaded compiled XOUP class %s from file %s', array($class, $compiled_name)); } @@ -124,7 +124,7 @@ protected function loadCompiled($filename) { // no compiled file exists - L::level(L::DEBUG) && + L::level(L::DEBUG, __CLASS__) && L::log(L::DEBUG, __CLASS__, 'compiled XOUP file %s does not (yet) exist', array($compiled_name)); diff --git a/SSL/Unpacker/XoupParser.php b/SSL/Unpacker/XoupParser.php index 84af5ec..119f6e6 100644 --- a/SSL/Unpacker/XoupParser.php +++ b/SSL/Unpacker/XoupParser.php @@ -81,7 +81,7 @@ public function parse($program) throw new RuntimeException("Parse error: no 'main' sub found."); } - L::level(L::DEBUG) && + L::level(L::DEBUG, __CLASS__) && L::log(L::DEBUG, __CLASS__, 'parsed %d subs and %d literals', array(count($subs), count($this->data))); @@ -104,5 +104,3 @@ protected function parseData($data_text) $this->data = $data; } } - - diff --git a/historyreader.php b/historyreader.php index 3a84325..686ae01 100755 --- a/historyreader.php +++ b/historyreader.php @@ -27,7 +27,7 @@ error_reporting(E_ALL | E_STRICT); -chdir(dirname(__FILE__)); +chdir(__DIR__); require_once 'External/getID3/getid3.php'; require_once 'SSL/Autoloader.php'; @@ -74,3 +74,6 @@ function ___autoload($class) // GO! $h->main($argc, $argv); + +// N.B. if you make changes to this file be sure to reflect them in other "main" files such as +// * Plugins/Analyzer/analyzehistory.php