apjanke / octave-slf4o Goto Github PK
View Code? Open in Web Editor NEWA simple logging framework for GNU Octave
License: GNU General Public License v3.0
A simple logging framework for GNU Octave
License: GNU General Public License v3.0
doc/
to texinfoPKG_ADD
hack to load the QHelp manualThe documentation-building scripts and Makefile can be taken from the Tablicious package.
Follows up #3.
When I try to launch the configurator GUI, Octave throws some Java errors and crashes. This happens on both Octave.app 4.4.1 and vanilla Homebrewed Octave 5.2.0 on my macOS 10.14.6 system.
When this happens, the prompt for the legacy Java 6 installer pops up.
Here's what it looks like when run from command line Octave 5.2.0:
octave:5> logger.initSLF4O
warning: function ./+logger/error.m shadows a built-in function
OpenJDK 64-Bit Server VM warning: Archived non-system classes are disabled because the java.system.class.loader property is specified (value = "org.octave.OctClassLoader"). To use archived non-system classes, this property must not be set
octave:6> logger.Log4jConfigurator.showGui
warning: function ./+logger/error.m shadows a built-in function
No Java runtime present, requesting install.
$
(That $
is me being dropped back to the shell after Octave crashed.)
I need to do this from M-code:
rootLogger.setLevel(org.apache.log4j.Level.INFO);
where org.apache.log4j.Level.INFO
is referencing the public static final
field INFO
defined on the Java class org.apache.log4j.Level
. How do I do that?
Unlike Matlab's isa()
, Octave's isa()
does not answer true if you do isa(someJavaObject, 'some.interface.it.Implements')
. This means we can't use mustBeA()
in some of our stuff.
Report this upstream to Octave.
Possibly implement our own workaround using Java instanceof
checks/reflection.
I think you should be able to build and test your distribution against the pending changes in your working copy before committing those changes. That means that the make dist
target should use the current file state, instead of doing a git archive
export from the last commit. (Maybe that git archive
version could be kept around as a make realdist
or make commitdist
target.)
The error() calls variously use the "dispstrlib:", "slf4o:", or "logger:" prefix in the error identifiers. Pick one and use it throughout.
>> pkg load slf4o
warning: load_path: /Users/janke/Library/Application Support/Octave.app/4.4.1/pkg/slf4o-0.1.0-SNAPSHOT/lib/matlab/dispstr/dispstr-1.1.1/Mcode-examples: No such file or directory
warning: load_path: /Users/janke/Library/Application Support/Octave.app/4.4.1/pkg/slf4o-0.1.0-SNAPSHOT/lib/matlab/dispstr/dispstr-1.1.1/Mcode-examples: No such file or directory
warning: called from
installed_packages at line 42 column 19
load_packages at line 27 column 22
pkg at line 457 column 7
error: package slf4o is not installed
error: called from
load_packages at line 41 column 7
pkg at line 457 column 7
>>
Hmmmmm...
We define a package-scoped function error()
inside the +logger
package. Octave mistakenly thinks that this shadows the built-in error()
function, and repeatedly issues warnings like this:
warning: function [...]/SLF4O/inst/+logger/error.m shadows a built-in function
So we're just doing warning off Octave:shadowed-function
in PKG_ADD
. That's a gross hack. See if that can be fixed.
logger.version is broken because it relies on the VERSION
file, which is outside the inst/
directory and thus not installed as part of the package.
Change its implementation to parse the DESCRIPTION file instead. (That gets installed as part of the package, right?) It should detect DESCRIPTION in its location in both source repo and installed-package cases.
I tried installing it under Octave.app, and all I got was this.
>> pkg load slf4o
warning: load_path: /Users/janke/Library/Application Support/Octave.app/4.4.1/pkg/slf4o-0.1.0-SNAPSHOT/lib/matlab/dispstr/dispstr-1.1.1/Mcode-examples: No such file or directory
warning: load_path: /Users/janke/Library/Application Support/Octave.app/4.4.1/pkg/slf4o-0.1.0-SNAPSHOT/lib/matlab/dispstr/dispstr-1.1.1/Mcode-examples: No such file or directory
warning: called from
installed_packages at line 42 column 19
load_packages at line 27 column 22
pkg at line 457 column 7
error: package slf4o is not installed
error: called from
load_packages at line 41 column 7
pkg at line 457 column 7
>> logger.initSLF4O
warning: load_path: /Users/janke/Library/Application Support/Octave.app/4.4.1/pkg/slf4o-0.1.0-SNAPSHOT/lib/matlab/dispstr/dispstr-1.1.1/Mcode-examples: No such file or directory
warning: load_path: /Users/janke/Library/Application Support/Octave.app/4.4.1/pkg/slf4o-0.1.0-SNAPSHOT/lib/matlab/dispstr/dispstr-1.1.1/Mcode-examples: No such file or directory
error: 'logger' undefined near line 1 column 1
>> logger.info('hello world!')
warning: load_path: /Users/janke/Library/Application Support/Octave.app/4.4.1/pkg/slf4o-0.1.0-SNAPSHOT/lib/matlab/dispstr/dispstr-1.1.1/Mcode-examples: No such file or directory
warning: load_path: /Users/janke/Library/Application Support/Octave.app/4.4.1/pkg/slf4o-0.1.0-SNAPSHOT/lib/matlab/dispstr/dispstr-1.1.1/Mcode-examples: No such file or directory
error: 'logger' undefined near line 1 column 1
>> path
warning: load_path: /Users/janke/Library/Application Support/Octave.app/4.4.1/pkg/slf4o-0.1.0-SNAPSHOT/lib/matlab/dispstr/dispstr-1.1.1/Mcode-examples: No such file or directory
Octave's search path contains the following directories:
.
/Users/janke/Library/Application Support/Octave.app/4.4.1/pkg/slf4o-0.1.0-SNAPSHOT/lib/matlab/dispstr/dispstr-1.1.1/Mcode-examples
/Users/janke/Documents/octave
/Applications/Octave-4.4.1.app/Contents/Resources/usr/Cellar/[email protected]/4.4.1/share/octave/site/m
/Applications/Octave-4.4.1.app/Contents/Resources/usr/Cellar/[email protected]/4.4.1/share/octave/site/m/startup
The user manual (in doc/slf4o.texi.in) could use an "Introduction" section. Add one.
Finish converting this to Octave pkg
package format:
PKG_ADD
hack to load the QHelp manualThis can be done based on the Tablicious package.
>> pkg install https://github.com/apjanke/octave-slf4o/archive/master.zip
warning: function /Users/janke/Library/Application Support/Octave.app/4.4.1/pkg/slf4o-0.1.0-SNAPSHOT/+logger/error.m shadows a built-infunction
warning: function /Users/janke/Library/Application Support/Octave.app/4.4.1/pkg/slf4o-0.1.0-SNAPSHOT/+logger/error.m shadows a built-infunction
class not found: dispstrlib.Displayable
error: called from
doc_cache_create>create_cache at line 109 column 18
gen_doc_cache_in_dir>@<anonymous> at line 143 column 16
doc_cache_create>gen_doc_cache_in_dir at line 144 column 9
doc_cache_create at line 55 column 12
install>generate_lookfor_cache at line 793 column 5
install at line 223 column 7
pkg at line 437 column 9
>>
This looks ignorable. Looks like it's because the library is not initialized at package installation time.
The sub-library loading might be too fancy for Octave. Maybe I should just merge the Dispstr stuff into the main inst/
directory and forget about the lib/matlab/dispstr/
approach.
Because of this logic for slurping up leading blank lines and copyright blocks:
my $fh = IO::File->new($mfile, "r")
or die "Error: Could not open file $mfile: $!\n";
# Skip leading blank lines
while (<$fh>) {
last if /\S/;
}
# First block may be copyright statement; skip it
if (m/\s*[%\#][\s\#%]* Copyright/) {
print "Skipping Copyright block\n";
while (<$fh>) {
last unless /^\s*[%\#]/;
}
}
[...]
while (<$fh>) {
my $line_num = $fh->input_line_number();
[...]
}
See how that attempt to skip leading blank lines will actually slurp in the "## -- texinfo --" line if it's the first line in the file, and it'll then be discarded?
It's vestigial from when dispstrlib was shipped in lib/.
Right now my source code is mostly in Matlab style. Consider converting it to GNU Octave style, as a courtesy to Octave users who are probably more used to that.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.