Skip to content

Log Uniformization #1480

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 10, 2017
Merged

Log Uniformization #1480

merged 2 commits into from
Nov 10, 2017

Conversation

dasantiago
Copy link

This change will remove the ServerStartup, which is only used for log
configuration. The FakeApp was extended to support the ServerStartup
functionality.

t/config.t Outdated
@@ -95,7 +95,7 @@ subtest 'Test configuration default modes' => sub {
# Test configuration generation with an unknown mode (should fallback to default)
$app = Mojolicious->new();
$app->mode("foo_bar");
OpenQA::ServerStartup::read_config($app);
OpenQA::FakeApp::read_config($app);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we not spread the name FakeApp then?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...what about an OpenQA Base class then? :)

@codecov
Copy link

codecov bot commented Oct 18, 2017

Codecov Report

Merging #1480 into master will increase coverage by 0.02%.
The diff coverage is 90.43%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1480      +/-   ##
==========================================
+ Coverage   88.44%   88.47%   +0.02%     
==========================================
  Files         107      106       -1     
  Lines        8074     8075       +1     
==========================================
+ Hits         7141     7144       +3     
+ Misses        933      931       -2
Impacted Files Coverage Δ
lib/OpenQA/ResourceAllocator.pm 79.26% <100%> (-0.25%) ⬇️
lib/OpenQA/Worker/Commands.pm 81.25% <100%> (+0.39%) ⬆️
lib/OpenQA/Worker/Engines/isotovideo.pm 82.09% <100%> (-0.22%) ⬇️
lib/OpenQA/Scheduler.pm 100% <100%> (ø) ⬆️
lib/OpenQA/WebSockets/Server.pm 90.74% <100%> (ø) ⬆️
lib/OpenQA/WebAPI.pm 92.03% <100%> (-0.32%) ⬇️
lib/OpenQA/Worker.pm 96.55% <100%> (-0.06%) ⬇️
lib/OpenQA/Worker/Jobs.pm 82.96% <55.55%> (+0.59%) ⬆️
lib/OpenQA/Worker/Cache.pm 86.11% <72.72%> (-0.07%) ⬇️
lib/OpenQA/Setup.pm 95.77% <92.1%> (ø)
... and 4 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9575846...4f54690. Read the comment docs.

@dasantiago dasantiago changed the title Log Uniformization [WIP]: Log Uniformization Oct 18, 2017
# is already sanitized. Otherwise we need to check
my $logfile
= catfile($self->log_dir, hostname() . (defined $self->instance ? "-${\$self->instance}" : '') . ".log");
my ($logfile, $logdir, $level, $log) = ('', '', '', undef, '');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think this is not necessary

Copy link
Author

@dasantiago dasantiago Oct 18, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those are the default values.
For example the logdir variable. If the object isn't of type FakeApp, then the object doesn't have a logdir function. Since i'm setting that value in the if only for the objects FakeApp:

if ($self->isa('OpenQA::FakeApp')) {
$logdir = $self->log_dir;
$level = $self->level;
}
else {
$log = $self->log;
OpenQA::FakeApp::read_config($self);
$level = $self->config->{logging}->{level} || 'debug';
}

then i can use it later like:

if ($logfile && $logdir) {
my $logfile = catfile($logdir, $logfile);
$log = Mojo::Log->new(handle => *STDOUT, level => $self->level);
}

Or did i understood wrongly your comment?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's ok to use different variables - but defaults values looks really weird :)
Why can't just be:

my ($logfile, $logdir, $level, $log);

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got your point :-)

@dasantiago dasantiago force-pushed the 25958 branch 8 times, most recently from d4690ad to 39ecf01 Compare October 18, 2017 15:07
}
else {
$log = $self->log;
OpenQA::FakeApp::read_config($self);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need the full qualified name inside same class

@dasantiago dasantiago force-pushed the 25958 branch 8 times, most recently from d62f56c to 1b9b39c Compare October 20, 2017 14:02
else {
$log = Mojo::Log->new(handle => \*STDOUT, level => $level);
}
$log->format(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When logging to STDOUT/STDERR, output format should not contain time, see the portion you removed: 1b9b39c#diff-5289bf936364851cb95d4833773bce49L132 - Also see https://progress.opensuse.org/issues/13866

@dasantiago dasantiago force-pushed the 25958 branch 6 times, most recently from b4db9fe to 699d922 Compare October 23, 2017 09:32
@dasantiago dasantiago force-pushed the 25958 branch 11 times, most recently from ec87f0f to c8a1aca Compare November 9, 2017 14:25
Sometimes it's required that we are able to log text to multiple
files. Currently the default OpenQA::Setup::app only logs to the
destination specified in the config files.

With these changes if the developer wants or needs to log to
another file/destination, just needs to call the normal logging
functions with an extra parameter, which is the name of the
"channel". Example:

> log_debug($message, 'this is name of channel');

This will work as long as the "channel" already exists. Otherwise,
it will use the default logging mechanism.

To create a new "channel" just invoke add_log_channel with the
**id** as first parameter. The rest of the parameters are the
same as the ones required for Mojo::Log. Example:

> add_log_channel('channel name', path=>'test.log', level=>'debug')
> unless get_channel_handle('autoinst');

This will create a Mojo::Log object that will be associated with
the name 'channel name'
@dasantiago dasantiago changed the title [WIP] Log Uniformization Log Uniformization Nov 9, 2017
Copy link
Member

@foursixnine foursixnine left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we're ready to merge this too

@os-autoinst os-autoinst deleted a comment from codecov bot Nov 10, 2017
@coolo
Copy link
Contributor

coolo commented Nov 10, 2017

@coolo coolo merged commit 31ec90c into os-autoinst:master Nov 10, 2017
coolo pushed a commit that referenced this pull request Nov 10, 2017
commit 31ec90c
Merge: 9575846 4f54690
Author:     Stephan Kulow <[email protected]>
AuthorDate: Fri Nov 10 10:15:42 2017 +0100
Commit:     GitHub <[email protected]>
CommitDate: Fri Nov 10 10:15:42 2017 +0100

    Merge pull request #1480 from dasantiago/25958

    Log Uniformization
coolo pushed a commit that referenced this pull request Nov 11, 2017
commit 31ec90c
Merge: 9575846 4f54690
Author:     Stephan Kulow <[email protected]>
AuthorDate: Fri Nov 10 10:15:42 2017 +0100
Commit:     GitHub <[email protected]>
CommitDate: Fri Nov 10 10:15:42 2017 +0100

    Merge pull request #1480 from dasantiago/25958

    Log Uniformization
coolo pushed a commit that referenced this pull request Nov 13, 2017
commit 31ec90c
Merge: 9575846 4f54690
Author:     Stephan Kulow <[email protected]>
AuthorDate: Fri Nov 10 10:15:42 2017 +0100
Commit:     GitHub <[email protected]>
CommitDate: Fri Nov 10 10:15:42 2017 +0100

    Merge pull request #1480 from dasantiago/25958

    Log Uniformization
coolo pushed a commit that referenced this pull request Nov 14, 2017
commit 31ec90c
Merge: 9575846 4f54690
Author:     Stephan Kulow <[email protected]>
AuthorDate: Fri Nov 10 10:15:42 2017 +0100
Commit:     GitHub <[email protected]>
CommitDate: Fri Nov 10 10:15:42 2017 +0100

    Merge pull request #1480 from dasantiago/25958

    Log Uniformization
coolo pushed a commit that referenced this pull request Nov 16, 2017
commit 31ec90c
Merge: 9575846 4f54690
Author:     Stephan Kulow <[email protected]>
AuthorDate: Fri Nov 10 10:15:42 2017 +0100
Commit:     GitHub <[email protected]>
CommitDate: Fri Nov 10 10:15:42 2017 +0100

    Merge pull request #1480 from dasantiago/25958

    Log Uniformization
@coolo
Copy link
Contributor

coolo commented Nov 17, 2017

why do I keep referencing this one? :)

@coolo
Copy link
Contributor

coolo commented Nov 17, 2017

could this be the cron builds of travis?

@foursixnine
Copy link
Member

Yup, it's the cron from travis... Since the line at the end of the documents keep changing, there's a new update :P

@coolo
Copy link
Contributor

coolo commented Nov 17, 2017

can we get rid of this timestamp?

@foursixnine
Copy link
Member

foursixnine commented Nov 17, 2017

@coolo Yes, we can

@okurz
Copy link
Member

okurz commented Dec 9, 2017

Is this PR the one that also changed the timestamp format of os-autoinst? It seems we have more text in one line but which is not useful for debugging a test, e.g. [:] but OTOH are missing the subsecond precision output in the timestamp which is crucial to understand some test issues. Could you please take care to bring that back?

@coolo
Copy link
Contributor

coolo commented Dec 10, 2017

no, but you found the proper one in os-autoinst yourself

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants