Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # logDaBandaRestart plugin by imikelance/marcelofoxes/KeplerBR
- # Acknowledgments: EternalHarvest
- #
- #
- # 23:20 sexta-feira, 8 de junho de 2012
- # - Make name file of logs
- # - In the logs show the origin of the message
- # - Fix bug of time and edited colors
- #
- # 23:42 segunda-feira, 6 de fevereiro de 2012
- # - released !
- #
- # This source code is licensed under the
- # GNU General Public License, Version 2.
- # See http://www.gnu.org/licenses/gpl.html
- package logDaBandaRestart;
- use strict;
- use Plugins;
- use Commands;
- use Log qw( warning message error );
- use Settings;
- use Globals;
- use Misc;
- use constant {
- PLUGINNAME => "logDaBandaRestart",
- };
- #-----------------
- # Plugin: settings
- #-----------------
- Plugins::register(PLUGINNAME, "check your logs folder !", \&unload);
- # Log hook
- my $logHook = Log::addHook(\&on_Log, PLUGINNAME);
- #-----------------------------
- # File: Make name file of logs
- #-----------------------------
- my $arqui;
- if ($config{'NoRestartFile'}) {
- $arqui = 'console.html';
- } else {
- my $DataLocal = localtime(time());
- my @Data = split(/ +/,$DataLocal);
- $arqui = 'console ' . $Data[2] . ' ' . $Data[1] . ' ' . $Data[4] . ".html";
- }
- #---------------
- # Plugin: unload
- #---------------
- sub unload {
- Log::delHook($logHook);
- undef $logHook;
- }
- #-------------
- # Log: handler
- #-------------
- sub on_Log {
- my ($type, $domain, $level, $globalVerbosity, $message, $user_data) = @_;
- if ($level <= $globalVerbosity) {
- my $msgColor;
- if (defined $consoleColors{$type}{$domain}) {
- $msgColor = $consoleColors{$type}{$domain};
- } elsif ($type eq "warning") {
- $msgColor = $consoleColors{warning}{default};
- } elsif ($type eq "error") {
- $msgColor = $consoleColors{error}{default};
- } elsif ($type eq "debug") {
- $msgColor = $consoleColors{debug}{default};
- } else {
- $msgColor = 'grey';
- }
- $message =~ s/(\r\n|\n|\r)+/<\/br>/g;
- my $hor = localtime();
- my $message2 ="<span class=\"".$msgColor."\">[" . $domain . "][" . $hor . "] ".$message."</span>";
- open(F, ">>:utf8", "$Settings::logs_folder/" . $arqui);
- if(-z "$Settings::logs_folder/". $arqui) {
- print F q(
- <head><style type="text/css">
- body {
- background-color: black;
- font-family: "Lucida Console";
- font-weight: bold;
- font-size: 12px;
- }
- .grey {
- color: #c0c0c0;
- }
- .yellow {
- color: #ffff00;
- }
- .darkgreen {
- color: #008000;
- }
- .green {
- color: #00FF00;
- }
- .white {
- color: #FFFFFF;
- }
- .red {
- color: #FF0000;
- }
- .cyan {
- color: #00FFFF;
- }
- .darkmagenta {
- color: #800080;
- }
- .magenta {
- color: #ff00ff;
- }
- .blue {
- color: #0000ff;
- }
- .darkcyan {
- color: #008080;
- }
- .brown {
- color: #808000;
- }
- </style>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- </head>
- );
- }
- print F $message2."\n";
- close(F);
- }
- }
- 1;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement