Comments (12)
你在你使用log4z的项目的 windows下vs的工程属性(不是log4z的工程)中 C/C++ ==> 命令行 ==> 添加命令 /FC 来开启.
log4z的该实现用的是__FILE__ 在VS下会受到该参数的影响.
from log4z.
那意思说,Linux下不管Debug还是Release都是绝对路径咯?
from log4z.
上面的回答只针对VS情况, 具体情况要看编译器对__FILE__的支持情况, linux下也有多个编译器.
from log4z.
Ubuntu 14.04 LTS, g++ 4.8,我自己单独测试一下
from log4z.
linux g++ 都是全路径, mac下记得也是 但现在暂连不上mac机器无法确认, __FILE__在VS下的表现受/FC控制并且debug和release不同主要原因在于, DEBUG下的调试格式/ZI选项默认会包含/FC 而release下默认的调试格式是没有的.
下面是截取的MSDN上描述:
/FC is also needed if you want to see the full path of a file name when using the FILE macro.
The /FC option is implied by /ZI. For more information about /ZI, see /Z7, /Zi, /ZI (Debug Information Format).
地址在这里:http://msdn.microsoft.com/en-us/library/027c4t2s.aspx
from log4z.
你在Linux下测试一下这里的代码,看输出结果是多少呢?我这边Debug/Release都是相对路径哦。
http://blog.csdn.net/xiaopohaibebo/article/details/8140232
from log4z.
如果是gcc main.c 输出的是main.c
如果是gcc /root/main.c 输出的是 /root/main.c
from log4z.
我的项目基本上用的都是cmake的自动搜索源文件, 而这些搜索结果都是全路径的, 所以在我看来所有日志在linux下也都成了全路径的了.
from log4z.
对,__FILE__看编译时传递的路径。我也是cmake,囧。
from log4z.
这个方法不错,可以考虑一下。
#define FILE (strrchr(__ FILE__, '/') ? strrchr(__ FILE__, '/') + 1 : __ FILE__)
via: http://stackoverflow.com/questions/8487986/file-macro-shows-full-path
from log4z.
这个宏写的很漂亮, 不过对我来说 是否全路径基本上不影响, 而且可以选的话 更喜欢全路径. 所以库的实现还是用默认的__FILE__更好一些 想DIY的话就自己fork一份直接改. 我倾向这么做.
from log4z.
好的,谢谢你的回复!
from log4z.
Related Issues (20)
- 建议封装成动态库 HOT 2
- 怎么输出进程线程ID啊?还有就是输出的顺序有点问题? HOT 1
- 进程长时间不写(跨天),重新新建log文件写入的问题 HOT 1
- 是否支持中文路径? HOT 1
- android compile err.error: 'gcvt' was not declared in this scope. HOT 3
- Thread_local is not supported for iOS 8.4 or earlier. It will cause a compile error in Xcode HOT 1
- 'isnan' was not declared in this scope if (isnan(t)) ;这样的问题怎么解决? HOT 1
- DynamicCreateLogger 接口缺失 HOT 2
- 在VS下断点调试时,并不能立即输出 HOT 2
- API reference is missed HOT 2
- 如何限制日志的大小呢? HOT 1
- error C3861: 'isnan': identifier not found HOT 1
- 日志自动清除 HOT 2
- 可以指定文件名格式和文件夹格式吗
- Log4zFileHandler::open不支持单个2GB以上的文件
- Mismatch (malloc vs operator delete)
- 这个是不是多线写日志文件 自旋锁导致的问题 程序崩溃?
- log4z thread mutex bug? HOT 1
- 请问单条日志容量如何设定?
- Does log4z clear old logs in the logfolder? HOT 1
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 log4z.