Comments (4)
Hello, @nicutor
Based on my codereading, I think what you have to do is just to redirect stderr
to file you want.
so,
$ ./your-script.sh 2>log-file.txt
Because all log
methods(defined in lib/util/logs.sh
) seems to cat all messages to stderr
my test success(test.sh
is example code at README.md, Using Basic Logging, Colors and Powerline Emoji):
<X_X>:bash-oo-framework$ ./test.sh
I'm blue...
[DEBUG] [test.sh:19] Play me some Jazz, will ya? 🎷
Something bad happened.
This will be printed to STDERR, no matter what.
0is0[feature/japanese-docs]
<X_X>:bash-oo-framework$ ./test.sh 2>log.txt
I'm blue...
0is0[feature/japanese-docs]
<X_X>:bash-oo-framework$ cat log.txt
[DEBUG] [test.sh:19] Play me some Jazz, will ya? 🎷
Something bad happened.
This will be printed to STDERR, no matter what.
++ I'm not a member of maintainer, not good at this framework, so this might be wrong.
Please remember this is just my opinion...
I'm happy if this helps you.
from bash-oo-framework.
@Cj-bc Thank you for your help, but I am trying to avoid that way.
Based on documentation, I've already find a way, but, if there is any better example of how to log to file, syslog or email, please let me know.
#!/usr/bin/env bash
source "$( cd "${BASH_SOURCE[0]%/*}" && pwd )/lib/oo-bootstrap.sh"
import util/log
namespace myApp
myLoggingDelegate() {
echo "$(date +'%F %T %Z') [${subject}]: $*"
echo "$(date +'%F %T %Z') [${subject}]: $*" >> test.log
}
Log::RegisterLogger MYLOGGER myLoggingDelegate
Log::AddOutput myApp MYLOGGER
subject="WARNING" Log "Something"
from bash-oo-framework.
@nicutor oh, I see.
I think the way you showed(declaring Logger) is only the way to do that.
If I find any solution, I'll let you know.
from bash-oo-framework.
@nicutor's answer is correct. In the current version logging is a bit over-engineered. I'd like to simplify it in the next version that we're brainstorming in #45, feel free to join.
from bash-oo-framework.
Related Issues (20)
- Is the project dead? HOT 3
- Sorry, a bit cheeky/impolite... HOT 2
- Unbound variables cause a crash when running examples with 'set -u' HOT 3
- [bug?] `throw` is said to be 'undefined command' when `import` fail HOT 5
- Catch exception from Classes doesn't work HOT 7
- Inconsistent array assignments HOT 3
- Translating README into Japanese
- for people who want to use Bpkg to install this framework HOT 1
- example/trycatch.sh doesn't work as expected
- Make wiki page
- [Question] Does value of '__primitive_extension_fingerprint' have special meaning?
- update readme instructions for namedParameters
- util/exception.sh shows stack trace as expected but don't exit on Ctrl+C HOT 2
- False boolean not working HOT 1
- Referring this in Human example class doesn't work as described HOT 1
- Exception messages are invisible in light theme mode in Shell console.
- [Question] Is this project still alive? HOT 6
- [Discussion] Log API
- Using a variable for an Object name
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bash-oo-framework.