12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- <!doctype html>
- <html lang="en">
- <head>
- <meta charset="utf-8">
- <meta http-equiv="X-UA-Compatible" content="IE=edge">
- <meta name="viewport" content="width=device-width, initial-scale=1">
- <meta name="description" content="">
- <title>glog | Casey DeLorme's Portfolio / caseydelorme.com</title>
- <link rel="icon" type="image/x-icon" href="https://d2xxklvztqk0jd.cloudfront.net/favicon.ico" />
- <link rel="stylesheet" type="text/css" href="/css/main.css#9eb699d">
- </head>
- <body>
- <header class="group">
- <h1><a href='/'>Casey DeLorme</a></h1>
- <nav>
- <ul>
- <li><a href="/projects">Projects</a></li>
- <li><a href="/resume.html">Resume</a></li>
- </ul>
- </nav>
- </header>
- <div class="content group">
- <h3><a href="https://github.com/cdelorme/glog">glog</a></h3>
- <p>I wrote this some time ago when I realized that the default <a href="https://golang.org/pkg/log/">log</a> package forced the software to exit when you called the Error functions. <em>It also does not include any context; the package, file, or line number which are immensely helpful when troubleshooting.</em></p>
- <p>While there are other packages that provide the functionality I would want, some mirror the default package’s behavior, and most are relatively large or have additional dependencies.</p>
- <p>So I decided to write my own, which was so simple I was amazed how big some of the other packages are.</p>
- <p>Instead of the myriad of conflicting behaviors that a developer could embed into their application for configuration (eg. <code>-s</code> or <code>--silent</code>, <code>-q</code> or <code>--quiet</code>, literally every full or partial log level name, or a log level with severity as a value, I’ve seen it all). <strong>Developers can ignore all that now, just let the user set <code>LOG_LEVEL</code> environment variable.</strong></p>
- <p>It provides standardized severities which defaults to “Error”. <em>I generally only use around 3~4 of them, but all of them are included.</em></p>
- <p>It can determine color support in the terminal and will log in color (disabled if output is redirected).</p>
- <p>It offers context, so you can easily debug code by tracking down the file and line number the error occurred.</p>
- <p>All output goes to stderr, <em>which is the optimal sane default to avoid messing with expected application output.</em></p>
- <p>It is concurrently safe, using a package level mutex.</p>
- <p>It comes with comprehensive tests, and benchmarks.</p>
- <p><strong>I highly recommend <a href="https://github.com/cdelorme/glog">trying it out</a>.</strong></p>
- <p><strong><em>written on 2017-04-13</em></strong></p>
- </div>
- <footer class="group">
- <a href='https://www.facebook.com/CaseyRDeLorme' class='link facebook'></a>
- <a href='https://www.linkedin.com/in/cdelorme' class='link linkedin'></a>
- <a href='https://www.youtube.com/user/LordOfElm' class='link youtube'></a>
- <a href='https://github.com/cdelorme' class='link github'></a>
- <a href='skype:casey.delorme?chat' class='link skype'></a>
- <div class="scripts">
- <script type="text/javascript" src="/js/main.js#9eb699d" async></script>
- </div>
- </footer>
- </body>
- </html>
|