Log support through boost::log
This commit is contained in:
parent
e67e37c772
commit
0d20a81354
5 changed files with 64 additions and 1 deletions
|
@ -18,6 +18,8 @@ sub debugf {
|
||||||
printf @_ if $debug;
|
printf @_ if $debug;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
our $loglevel = 0;
|
||||||
|
|
||||||
# load threads before Moo as required by it
|
# load threads before Moo as required by it
|
||||||
our $have_threads;
|
our $have_threads;
|
||||||
BEGIN {
|
BEGIN {
|
||||||
|
@ -104,6 +106,10 @@ my $pause_sema = Thread::Semaphore->new;
|
||||||
my $parallel_sema;
|
my $parallel_sema;
|
||||||
my $paused = 0;
|
my $paused = 0;
|
||||||
|
|
||||||
|
# Set the logging level at the Slic3r XS module.
|
||||||
|
$Slic3r::loglevel = (defined($ENV{'SLIC3R_LOGLEVEL'}) && $ENV{'SLIC3R_LOGLEVEL'} =~ /^[1-9]/) ? $ENV{'SLIC3R_LOGLEVEL'} : 0;
|
||||||
|
set_logging_level($Slic3r::loglevel);
|
||||||
|
|
||||||
sub spawn_thread {
|
sub spawn_thread {
|
||||||
my ($cb) = @_;
|
my ($cb) = @_;
|
||||||
|
|
||||||
|
|
|
@ -117,7 +117,7 @@ if (defined $ENV{BOOST_LIBRARYDIR}) {
|
||||||
|
|
||||||
# In order to generate the -l switches we need to know how Boost libraries are named
|
# In order to generate the -l switches we need to know how Boost libraries are named
|
||||||
my $have_boost = 0;
|
my $have_boost = 0;
|
||||||
my @boost_libraries = qw(system thread); # we need these
|
my @boost_libraries = qw(system thread log); # we need these
|
||||||
|
|
||||||
# check without explicit lib path (works on Linux)
|
# check without explicit lib path (works on Linux)
|
||||||
if (! $mswin) {
|
if (! $mswin) {
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <boost/log/trivial.hpp>
|
||||||
|
|
||||||
// #define SLIC3R_DEBUG
|
// #define SLIC3R_DEBUG
|
||||||
|
|
||||||
|
@ -197,6 +198,8 @@ struct MyLayersPtrCompare
|
||||||
|
|
||||||
void PrintObjectSupportMaterial::generate(PrintObject &object)
|
void PrintObjectSupportMaterial::generate(PrintObject &object)
|
||||||
{
|
{
|
||||||
|
BOOST_LOG_TRIVIAL(info) << "Support generator - Start";
|
||||||
|
|
||||||
coordf_t max_object_layer_height = 0.;
|
coordf_t max_object_layer_height = 0.;
|
||||||
for (size_t i = 0; i < object.layer_count(); ++ i)
|
for (size_t i = 0; i < object.layer_count(); ++ i)
|
||||||
max_object_layer_height = std::max(max_object_layer_height, object.get_layer(i)->height);
|
max_object_layer_height = std::max(max_object_layer_height, object.get_layer(i)->height);
|
||||||
|
@ -210,6 +213,8 @@ void PrintObjectSupportMaterial::generate(PrintObject &object)
|
||||||
// The layers will be referenced by various LayersPtr (of type std::vector<Layer*>)
|
// The layers will be referenced by various LayersPtr (of type std::vector<Layer*>)
|
||||||
MyLayerStorage layer_storage;
|
MyLayerStorage layer_storage;
|
||||||
|
|
||||||
|
BOOST_LOG_TRIVIAL(info) << "Support generator - Creating top contacts";
|
||||||
|
|
||||||
// Determine the top contact surfaces of the support, defined as:
|
// Determine the top contact surfaces of the support, defined as:
|
||||||
// contact = overhangs - clearance + margin
|
// contact = overhangs - clearance + margin
|
||||||
// This method is responsible for identifying what contact surfaces
|
// This method is responsible for identifying what contact surfaces
|
||||||
|
@ -232,6 +237,8 @@ void PrintObjectSupportMaterial::generate(PrintObject &object)
|
||||||
}
|
}
|
||||||
#endif /* SLIC3R_DEBUG */
|
#endif /* SLIC3R_DEBUG */
|
||||||
|
|
||||||
|
BOOST_LOG_TRIVIAL(info) << "Support generator - Creating bottom contacts";
|
||||||
|
|
||||||
// Determine the bottom contact surfaces of the supports over the top surfaces of the object.
|
// Determine the bottom contact surfaces of the supports over the top surfaces of the object.
|
||||||
// Depending on whether the support is soluble or not, the contact layer thickness is decided.
|
// Depending on whether the support is soluble or not, the contact layer thickness is decided.
|
||||||
MyLayersPtr bottom_contacts = this->bottom_contact_layers(object, top_contacts, layer_storage);
|
MyLayersPtr bottom_contacts = this->bottom_contact_layers(object, top_contacts, layer_storage);
|
||||||
|
@ -245,11 +252,15 @@ void PrintObjectSupportMaterial::generate(PrintObject &object)
|
||||||
}
|
}
|
||||||
#endif /* SLIC3R_DEBUG */
|
#endif /* SLIC3R_DEBUG */
|
||||||
|
|
||||||
|
BOOST_LOG_TRIVIAL(info) << "Support generator - Trimming top contacts by bottom contacts";
|
||||||
|
|
||||||
// Because the top and bottom contacts are thick slabs, they may overlap causing over extrusion
|
// Because the top and bottom contacts are thick slabs, they may overlap causing over extrusion
|
||||||
// and unwanted strong bonds to the object.
|
// and unwanted strong bonds to the object.
|
||||||
// Rather trim the top contacts by their overlapping bottom contacts to leave a gap instead of over extruding.
|
// Rather trim the top contacts by their overlapping bottom contacts to leave a gap instead of over extruding.
|
||||||
this->trim_top_contacts_by_bottom_contacts(object, bottom_contacts, top_contacts);
|
this->trim_top_contacts_by_bottom_contacts(object, bottom_contacts, top_contacts);
|
||||||
|
|
||||||
|
BOOST_LOG_TRIVIAL(info) << "Support generator - Creating intermediate layers - indices";
|
||||||
|
|
||||||
// Generate empty intermediate layers between the top / bottom support contact layers,
|
// Generate empty intermediate layers between the top / bottom support contact layers,
|
||||||
// The layers may or may not be synchronized with the object layers, depending on the configuration.
|
// The layers may or may not be synchronized with the object layers, depending on the configuration.
|
||||||
// For example, a single nozzle multi material printing will need to generate a waste tower, which in turn
|
// For example, a single nozzle multi material printing will need to generate a waste tower, which in turn
|
||||||
|
@ -257,6 +268,8 @@ void PrintObjectSupportMaterial::generate(PrintObject &object)
|
||||||
MyLayersPtr intermediate_layers = this->raft_and_intermediate_support_layers(
|
MyLayersPtr intermediate_layers = this->raft_and_intermediate_support_layers(
|
||||||
object, bottom_contacts, top_contacts, layer_storage, max_object_layer_height);
|
object, bottom_contacts, top_contacts, layer_storage, max_object_layer_height);
|
||||||
|
|
||||||
|
BOOST_LOG_TRIVIAL(info) << "Support generator - Creating base layers";
|
||||||
|
|
||||||
// Fill in intermediate layers between the top / bottom support contact layers, trimmed by the object.
|
// Fill in intermediate layers between the top / bottom support contact layers, trimmed by the object.
|
||||||
this->generate_base_layers(object, bottom_contacts, top_contacts, intermediate_layers);
|
this->generate_base_layers(object, bottom_contacts, top_contacts, intermediate_layers);
|
||||||
|
|
||||||
|
@ -269,6 +282,8 @@ void PrintObjectSupportMaterial::generate(PrintObject &object)
|
||||||
}
|
}
|
||||||
#endif /* SLIC3R_DEBUG */
|
#endif /* SLIC3R_DEBUG */
|
||||||
|
|
||||||
|
BOOST_LOG_TRIVIAL(info) << "Support generator - Creating raft";
|
||||||
|
|
||||||
// If raft is to be generated, the 1st top_contact layer will contain the 1st object layer silhouette without holes.
|
// If raft is to be generated, the 1st top_contact layer will contain the 1st object layer silhouette without holes.
|
||||||
// Add the bottom contacts to the raft, inflate the support bases.
|
// Add the bottom contacts to the raft, inflate the support bases.
|
||||||
// There is a contact layer below the 1st object layer in the bottom contacts.
|
// There is a contact layer below the 1st object layer in the bottom contacts.
|
||||||
|
@ -284,6 +299,8 @@ void PrintObjectSupportMaterial::generate(PrintObject &object)
|
||||||
shape = this->generate_pillars_shape(contact, support_z);
|
shape = this->generate_pillars_shape(contact, support_z);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
BOOST_LOG_TRIVIAL(info) << "Support generator - Creating interfaces";
|
||||||
|
|
||||||
// Propagate top / bottom contact layers to generate interface layers.
|
// Propagate top / bottom contact layers to generate interface layers.
|
||||||
MyLayersPtr interface_layers = this->generate_interface_layers(
|
MyLayersPtr interface_layers = this->generate_interface_layers(
|
||||||
object, bottom_contacts, top_contacts, intermediate_layers, layer_storage);
|
object, bottom_contacts, top_contacts, intermediate_layers, layer_storage);
|
||||||
|
@ -305,6 +322,8 @@ void PrintObjectSupportMaterial::generate(PrintObject &object)
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
BOOST_LOG_TRIVIAL(info) << "Support generator - Creating layers";
|
||||||
|
|
||||||
// Install support layers into the object.
|
// Install support layers into the object.
|
||||||
MyLayersPtr layers_sorted;
|
MyLayersPtr layers_sorted;
|
||||||
layers_sorted.reserve(bottom_contacts.size() + top_contacts.size() + intermediate_layers.size() + interface_layers.size());
|
layers_sorted.reserve(bottom_contacts.size() + top_contacts.size() + intermediate_layers.size() + interface_layers.size());
|
||||||
|
@ -332,8 +351,12 @@ void PrintObjectSupportMaterial::generate(PrintObject &object)
|
||||||
++ layer_id;
|
++ layer_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOST_LOG_TRIVIAL(info) << "Support generator - Generating tool paths";
|
||||||
|
|
||||||
// Generate the actual toolpaths and save them into each layer.
|
// Generate the actual toolpaths and save them into each layer.
|
||||||
this->generate_toolpaths(object, raft, bottom_contacts, top_contacts, intermediate_layers, interface_layers);
|
this->generate_toolpaths(object, raft, bottom_contacts, top_contacts, intermediate_layers, interface_layers);
|
||||||
|
|
||||||
|
BOOST_LOG_TRIVIAL(info) << "Support generator - End";
|
||||||
}
|
}
|
||||||
|
|
||||||
void collect_region_slices_by_type(const Layer &layer, SurfaceType surface_type, Polygons &out)
|
void collect_region_slices_by_type(const Layer &layer, SurfaceType surface_type, Polygons &out)
|
||||||
|
|
|
@ -66,3 +66,30 @@ confess_at(const char *file, int line, const char *func,
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <boost/log/core.hpp>
|
||||||
|
#include <boost/log/trivial.hpp>
|
||||||
|
#include <boost/log/expressions.hpp>
|
||||||
|
|
||||||
|
namespace Slic3r {
|
||||||
|
|
||||||
|
static boost::log::trivial::severity_level logSeverity = boost::log::trivial::fatal;
|
||||||
|
|
||||||
|
void set_logging_level(unsigned int level)
|
||||||
|
{
|
||||||
|
switch (level) {
|
||||||
|
case 0: logSeverity = boost::log::trivial::fatal; break;
|
||||||
|
case 1: logSeverity = boost::log::trivial::error; break;
|
||||||
|
case 2: logSeverity = boost::log::trivial::warning; break;
|
||||||
|
case 3: logSeverity = boost::log::trivial::info; break;
|
||||||
|
case 4: logSeverity = boost::log::trivial::debug; break;
|
||||||
|
default: logSeverity = boost::log::trivial::trace; break;
|
||||||
|
}
|
||||||
|
|
||||||
|
boost::log::core::get()->set_filter
|
||||||
|
(
|
||||||
|
boost::log::trivial::severity >= logSeverity
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace Slic3r
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
%package{Slic3r::XS};
|
%package{Slic3r::XS};
|
||||||
|
|
||||||
#include <xsinit.h>
|
#include <xsinit.h>
|
||||||
|
#include "Utils.hpp"
|
||||||
|
|
||||||
%{
|
%{
|
||||||
|
|
||||||
|
@ -28,6 +29,12 @@ FORK_NAME()
|
||||||
RETVAL = newSVpv(SLIC3R_FORK_NAME, 0);
|
RETVAL = newSVpv(SLIC3R_FORK_NAME, 0);
|
||||||
OUTPUT: RETVAL
|
OUTPUT: RETVAL
|
||||||
|
|
||||||
|
void
|
||||||
|
set_logging_level(level)
|
||||||
|
unsigned int level;
|
||||||
|
CODE:
|
||||||
|
Slic3r::set_logging_level(level);
|
||||||
|
|
||||||
void
|
void
|
||||||
xspp_test_croak_hangs_on_strawberry()
|
xspp_test_croak_hangs_on_strawberry()
|
||||||
CODE:
|
CODE:
|
||||||
|
|
Loading…
Reference in a new issue